revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-unix / exec / exec_platform.h
blobac26a7fd51df013186ef5d2526732b58caf5f8c7
1 #ifndef __EXEC_PLATFORM_H
2 #define __EXEC_PLATFORM_H
4 #define SCHEDQUANTUM_VALUE 4
6 #ifdef HOST_OS_android
7 /* Android is not a true Linux ;-) */
8 #undef HOST_OS_linux
10 #else
12 #ifndef _XOPEN_SOURCE
13 /* On Darwin this definition is required by ucontext.h (which is marked as deprecated)
14 * At least on Debian 8, _XOPEN_SOURCE is already defined in /usr/include/features.h
16 #define _XOPEN_SOURCE
17 #endif
18 #include <ucontext.h>
20 #endif
22 #ifdef HOST_OS_linux
23 #define LIBC_NAME "libc.so.6"
24 #endif
26 #ifdef HOST_OS_darwin
27 #define LIBC_NAME "libSystem.dylib"
28 #endif
30 #ifndef LIBC_NAME
31 #define LIBC_NAME "libc.so"
32 #endif
34 struct LibCInterface
36 void (*exit)(int status);
37 #ifdef HAVE_SWAPCONTEXT
38 int (*getcontext)(ucontext_t *ucp);
39 void (*makecontext)(ucontext_t *ucp, void *func(), int argc, ...);
40 int (*swapcontext)(ucontext_t *oucp, ucontext_t *ucp);
41 #endif
44 struct Exec_PlatformData
46 APTR HostLibBase;
47 struct LibCInterface *SysIFace;
50 #ifndef __AROS_KERNEL__
51 #define HostLibBase PD(SysBase).HostLibBase
52 #endif
54 #ifdef AROS_NO_ATOMIC_OPERATIONS
55 #define IDNESTCOUNT_INC SysBase->IDNestCnt++
56 #define IDNESTCOUNT_DEC SysBase->IDNestCnt--
57 #define TDNESTCOUNT_INC SysBase->TDNestCnt++
58 #define TDNESTCOUNT_DEC SysBase->TDNestCnt--
59 #define FLAG_SCHEDQUANTUM_CLEAR SysBase->SysFlags &= ~SFF_QuantumOver
60 #define FLAG_SCHEDQUANTUM_SET SysBase->SysFlags |= SFF_QuantumOver
61 #define FLAG_SCHEDSWITCH_CLEAR SysBase->AttnResched &= ~ARF_AttnSwitch
62 #define FLAG_SCHEDSWITCH_SET SysBase->AttnResched |= ARF_AttnSwitch
63 #define FLAG_SCHEDDISPATCH_CLEAR SysBase->AttnResched &= ~ARF_AttnDispatch
64 #define FLAG_SCHEDDISPATCH_SET SysBase->AttnResched |= ARF_AttnDispatch
65 #else
66 #define IDNESTCOUNT_INC AROS_ATOMIC_INC(SysBase->IDNestCnt)
67 #define IDNESTCOUNT_DEC AROS_ATOMIC_DEC(SysBase->IDNestCnt)
68 #define TDNESTCOUNT_INC AROS_ATOMIC_INC(SysBase->TDNestCnt)
69 #define TDNESTCOUNT_DEC AROS_ATOMIC_DEC(SysBase->TDNestCnt)
70 #define FLAG_SCHEDQUANTUM_CLEAR AROS_ATOMIC_AND(SysBase->SysFlags, ~SFF_QuantumOver)
71 #define FLAG_SCHEDQUANTUM_SET AROS_ATOMIC_OR(SysBase->SysFlags, SFF_QuantumOver)
72 #define FLAG_SCHEDSWITCH_CLEAR AROS_ATOMIC_AND(SysBase->AttnResched, ~ARF_AttnSwitch)
73 #define FLAG_SCHEDSWITCH_SET AROS_ATOMIC_OR(SysBase->AttnResched, ARF_AttnSwitch)
74 #define FLAG_SCHEDDISPATCH_CLEAR AROS_ATOMIC_AND(SysBase->AttnResched, ~ARF_AttnDispatch)
75 #define FLAG_SCHEDDISPATCH_SET AROS_ATOMIC_OR(SysBase->AttnResched, ARF_AttnDispatch)
76 #endif
77 #define SCHEDQUANTUM_SET(val) (SysBase->Quantum=(val))
78 #define SCHEDQUANTUM_GET (SysBase->Quantum)
79 #define SCHEDELAPSED_SET(val) (SysBase->Elapsed=(val))
80 #define SCHEDELAPSED_GET (SysBase->Elapsed)
81 #define IDNESTCOUNT_GET (SysBase->IDNestCnt)
82 #define IDNESTCOUNT_SET(val) (SysBase->IDNestCnt=(val))
83 #define TDNESTCOUNT_GET (SysBase->TDNestCnt)
84 #define TDNESTCOUNT_SET(val) (SysBase->TDNestCnt=(val))
85 #define FLAG_SCHEDQUANTUM_ISSET (SysBase->SysFlags & SFF_QuantumOver)
86 #define FLAG_SCHEDSWITCH_ISSET (SysBase->AttnResched & ARF_AttnSwitch)
87 #define FLAG_SCHEDDISPATCH_ISSET (SysBase->AttnResched & ARF_AttnDispatch)
89 #define GET_THIS_TASK (SysBase->ThisTask)
90 #define SET_THIS_TASK(x) (SysBase->ThisTask=(x))
92 #endif /* __EXEC_PLATFORM_H */