1 /* This is the file to support single-threading.
2 * We initialize the global data structure and the global access variable.
7 int __regina_tsd_initialized
= 0;
8 tsd_t __regina_tsd
= {0,}; /* Be sure the var is initialized here */
10 /* Lowest level memory allocation function for normal circumstances. */
11 static void *MTMalloc(const tsd_t
*TSD
,size_t size
)
13 TSD
= TSD
; /* keep compiler happy */
17 /* Lowest level memory deallocation function for normal circumstances. */
18 static void MTFree(const tsd_t
*TSD
,void *chunk
)
20 TSD
= TSD
; /* keep compiler happy */
24 /* Lowest level exit handler. Use this indirection to prevent errors. */
25 static void MTExit(int code
)
30 tsd_t
*ReginaInitializeProcess(void)
34 if (__regina_tsd_initialized
)
35 return(&__regina_tsd
);
36 __regina_tsd_initialized
= 1;
38 /* Set up the current (single) tsd_t:*/
39 /* Default all values to zero */
40 memset(&__regina_tsd
,0,sizeof(__regina_tsd
));
41 __regina_tsd
.MTMalloc
= MTMalloc
;
42 __regina_tsd
.MTFree
= MTFree
;
43 __regina_tsd
.MTExit
= MTExit
;
45 OK
= init_memory(&__regina_tsd
); /* Initialize the memory module FIRST*/
47 /* Without the initial memory we don't have ANY chance! */
51 OK
|= init_vars(&__regina_tsd
); /* Initialize the variable module */
52 OK
|= init_stacks(&__regina_tsd
); /* Initialize the stack module */
53 OK
|= init_filetable(&__regina_tsd
); /* Initialize the files module */
54 OK
|= init_math(&__regina_tsd
); /* Initialize the math module */
55 OK
|= init_spec_vars(&__regina_tsd
); /* Initialize the interprt module */
56 OK
|= init_tracing(&__regina_tsd
); /* Initialize the tracing module */
57 OK
|= init_builtin(&__regina_tsd
); /* Initialize the builtin module */
58 OK
|= init_client(&__regina_tsd
); /* Initialize the client module */
59 OK
|= init_library(&__regina_tsd
); /* Initialize the library module */
60 OK
|= init_rexxsaa(&__regina_tsd
); /* Initialize the rexxsaa module */
61 OK
|= init_shell(&__regina_tsd
); /* Initialize the shell module */
62 OK
|= init_envir(&__regina_tsd
); /* Initialize the envir module */
63 OK
|= init_expr(&__regina_tsd
); /* Initialize the expr module */
64 OK
|= init_error(&__regina_tsd
); /* Initialize the error module */
66 OK
|= init_vms(&__regina_tsd
); /* Initialize the vmscmd module */
67 OK
|= init_vmf(&__regina_tsd
); /* Initialize the vmsfuncs module */
69 OK
|= init_arexxf(&__regina_tsd
); /* Initialize the arexxfuncs modules */
70 #if defined(_AMIGA) || defined(__AROS__)
71 OK
|= init_amigaf(&__regina_tsd
);
73 __regina_tsd
.loopcnt
= 1; /* stupid r2perl-module */
74 __regina_tsd
.traceparse
= -1;
75 __regina_tsd
.thread_id
= 1;
78 exiterror( ERR_STORAGE_EXHAUSTED
, 0 ) ;
80 return(&__regina_tsd
);
84 #ifdef TRACK_TSD_USAGE
85 /* We may want to check the counts of calls to __regina_get_tsd() which may do
86 * MUCH work on different platforms. We do some not optimizable work here.
87 * If you really wanna track down all calls to figure out WHERE to
88 * optimize try under a GNU friendly system:
89 * 1) In Makefile: Add "-pg -a" to the variable called "CFLAGS".
90 * 2) "make rexx" (Other targets might not work)
91 * 3) "./rexx whatyoulike.rexx"
92 * 4) "gprof rexx >usage.lst"
93 * 5) look at usage.lst for occurances of "WorkHeavy".
96 volatile int __regina_Calls
= 300; /* factor to get a "feel" for multithreading */
97 volatile int __regina_Point
= 1;
99 void __regina_Nop(void)
104 /* WorkHeavy does some work and returns the correct thread-specific data. */
105 tsd_t
*__regina_WorkHeavy(void)
107 int todo
= __regina_Calls
;
110 return(&__regina_tsd
);