Made UAE buildable again.
[AROS-Contrib.git] / regina / mt_amigalib.h
blobd57ab64776399f040b1bbc6c2a79c6fbf0ba53df
1 /* This is a stub file to support single-threading.
2 * We need the following globals:
4 * 1) THREAD_PROTECT(varname)
5 * = a pseudo code NOT TERMINATED BY A SEMICOLON. After this point all
6 * code until a THREAD_UNPROTECT is executed by one thread at once.
7 * This may be done by a call to a semaphore action or something else.
8 * THREAD_PROTECT and THREAD_UNPROTECT define a C block logically.
9 * varname ist a variable created by PROTECTION_VAR()
10 * 2) THREAD_UNPROTECT(varname)
11 * = see above
12 * 3) PROTECTION_VAR(varname)
13 * = a pseudo code NOT TERMINATED BY A SEMICOLON. This define will
14 * create and initialize a local variable which may be used by
15 * THREAD_PROTECT and THREAD_UNPROTECT.
16 * Typical examples are the protection of static local variables.
17 * 4) GLOBAL_PROTECTION_VAR(varname)
18 * = a pseudo code NOT TERMINATED BY A SEMICOLON. This define will
19 * create and initialize a global variable which may be used by
20 * THREAD_PROTECT and THREAD_UNPROTECT.
21 * Typical examples are the usage of the parser or global variables
22 * like macro_serialno.
23 * 5) EXPORT_GLOBAL_PROTECTION_VAR(varname)
24 * = a pseudo code NOT TERMINATED BY A SEMICOLON. This define will
25 * export the varname in header files. There must exist one declaration
26 * of the variable done by GLOBAL_PROTECTION_VAR.
27 * 6) GLOBAL_ENTRY_POINT()
28 * = initializes the process specific data and the thread specific data.
29 * This pseudo function is only called by those functions which are
30 * external (rexxsaa.h).
31 * It should return (tsd_t *) of the current thread.
32 * 7) __regina_get_tsd()
33 * = pointer to a variable of type tsd_t.
34 * This may only exist after a GLOBAL_ENTRY_POINT()-call and must then
35 * exist.
39 #ifndef MT_H_INCLUDED
40 # error This file should included by mt.h, only.
41 #endif
43 #define THREAD_PROTECT(varname) AmigaLockSemaphore(&varname);
44 #define THREAD_UNPROTECT(varname) AmigaUnlockSemaphore(varname);
45 #define PROTECTION_VAR(varname) static struct SignalSemaphore *varname = NULL;
46 #define EXPORT_GLOBAL_PROTECTION_VAR(varname) extern struct SignalSemaphore *varname;
47 #define GLOBAL_PROTECTION_VAR(varname) struct SignalSemaphore *varname = NULL;
50 tsd_t *ReginaInitializeThread(void);
51 #include <proto/exec.h>
52 #define GLOBAL_ENTRY_POINT() (__regina_get_tsd())
53 tsd_t *__regina_get_tsd(void);
55 /* NEVER USE __regina_get_tsd() IF YOU CAN GET THE VALUE FROM SOMEWHERE ELSE.
56 * IT REDUCES THE EXECUTION SPEED SIGNIFICANTLY. TAKE THE VALUE FROM THE CALLER
57 * WHERE IT IS POSSIBLE.
60 #ifdef TRACK_TSD_USAGE
61 #error TRACK_TSD_USAGE not implemented in amiga thread support
62 #endif
64 #include <exec/semaphores.h>
66 extern APTR __regina_semaphorepool;
67 void AmigaLockSemaphore(struct SignalSemaphore **);
68 void AmigaUnlockSemaphore(struct SignalSemaphore *);
70 #include <exec/lists.h>
71 #include <exec/nodes.h>
73 typedef struct _tsd_node_t {
74 struct MinNode node;
75 struct Task *task;
76 tsd_t *TSD;
77 } tsd_node_t;
79 extern struct MinList *__regina_tsdlist;