Commit 110be1d4 authored by Ben Avison's avatar Ben Avison
Browse files

Added ARM2 support to the threadsafe dynamic memory manager.

Retagged as 'RISC_OSLib-5_47'
parent d08d7612
......@@ -14,10 +14,10 @@
Module_MajorVersion SETS "5.47"
Module_Version SETA 547
Module_MinorVersion SETS ""
Module_Date SETS "09 Oct 2003"
Module_ApplicationDate SETS "09-Oct-03"
Module_Date SETS "13 Oct 2003"
Module_ApplicationDate SETS "13-Oct-03"
Module_ComponentName SETS "RISC_OSLib"
Module_ComponentPath SETS "RiscOS/Sources/Lib/RISC_OSLib"
Module_FullVersion SETS "5.47"
Module_HelpVersion SETS "5.47 (09 Oct 2003)"
Module_HelpVersion SETS "5.47 (13 Oct 2003)"
END
......@@ -6,18 +6,18 @@
*/
#define Module_MajorVersion_CMHG 5.47
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 09 Oct 2003
#define Module_Date_CMHG 13 Oct 2003
#define Module_MajorVersion "5.47"
#define Module_Version 547
#define Module_MinorVersion ""
#define Module_Date "09 Oct 2003"
#define Module_Date "13 Oct 2003"
#define Module_ApplicationDate "09-Oct-03"
#define Module_ApplicationDate "13-Oct-03"
#define Module_ComponentName "RISC_OSLib"
#define Module_ComponentPath "RiscOS/Sources/Lib/RISC_OSLib"
#define Module_FullVersion "5.47"
#define Module_HelpVersion "5.47 (09 Oct 2003)"
#define Module_HelpVersion "5.47 (13 Oct 2003)"
#define Module_LibraryVersionInfo "5:47"
......@@ -104,6 +104,8 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h> /* for memset(...), memcpy(...) */
#include <setjmp.h>
#include <signal.h>
#include "hostsys.h"
#include "alloc.h"
......@@ -243,17 +245,47 @@ typedef struct StatsStruct {
static char sys_message[60];
/* Mutex-y things */
static int heapMutex;
static jmp_buf *swpNotAvailable = NULL; /* boolean also used to pass jmp_buf to sig handler */
static int arm2_swp(int newValue, int *location);
static inline int swp(int newValue, int *location)
{
#ifndef __APCS_32
if (swpNotAvailable) return arm2_swp(newValue, location);
#endif
int oldValue;
__asm { SWP oldValue, newValue, [location] }
return oldValue;
}
#ifdef __APCS_32
#define INITMUTEX heapMutex = 1
#else
#define INITMUTEX \
do { \
heapMutex = 1; \
jmp_buf jb; \
swpNotAvailable = &jb; \
void (*old_sig_handler)(int) = signal(SIGILL, temp_sig_handler); \
if (setjmp(jb) == 0) { \
int temp; \
__asm { SWP temp, 1, [&heapMutex] } \
swpNotAvailable = NULL; \
} \
signal(SIGILL, old_sig_handler); \
} while (0)
#endif
#define ACQUIREMUTEX \
do { \
int oldValue; \
__asm { SWP oldValue, 0, [&heapMutex] } \
while (oldValue == 0) { \
while (swp(0, &heapMutex) == 0) \
_swix(OS_UpCall, _INR(0,1), 6, &heapMutex); \
__asm { SWP oldValue, 0, [&heapMutex] } \
} \
} while (0)
#define RELEASEMUTEX { heapMutex = 1; }
#define RELEASEANDRETURN(value) {RELEASEMUTEX return (value);}
......@@ -1129,6 +1161,23 @@ extern void _init_user_alloc(void)
userHeap = totalHeap;
}
#ifndef __APCS_32
static void temp_sig_handler(int sig)
{
longjmp(*swpNotAvailable, 1);
}
static int arm2_swp(int newValue, int *location)
{
int irqs_off = _kernel_irqs_disabled();
if (!irqs_off) _swix(OS_IntOff, 0);
int oldValue = *location;
*location = newValue;
if (!irqs_off) _swix(OS_IntOn, 0);
return oldValue;
}
#endif
extern void _init_alloc(void)
{ int j;
_kernel_swi_regs r;
......
......@@ -25,7 +25,7 @@
EXPORT |CLib_data_end|
% 113*4
% 112*4
|CLib_data_end|
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment