diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-04-09 21:21:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-09 15:21:55 +0200 |
| commit | 5ea247b84c046af8894cbe27ff5596e738fd47a1 (patch) | |
| tree | 2c0674c4f9a65af832eca9b8097077aee4e2d88d /src/include | |
| parent | 8c991cb6762d3a1384cec16d6e54402ce276ea9e (diff) | |
| download | box64-5ea247b84c046af8894cbe27ff5596e738fd47a1.tar.gz box64-5ea247b84c046af8894cbe27ff5596e738fd47a1.zip | |
Made custommem OS-independent (#2517)
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/box64context.h | 15 | ||||
| -rw-r--r-- | src/include/mysignal.h | 15 | ||||
| -rw-r--r-- | src/include/os.h | 17 |
3 files changed, 32 insertions, 15 deletions
diff --git a/src/include/box64context.h b/src/include/box64context.h index 718d95b3..97c410ad 100644 --- a/src/include/box64context.h +++ b/src/include/box64context.h @@ -240,6 +240,21 @@ typedef struct box64context_s { } box64context_t; +#ifndef USE_CUSTOM_MUTEX +#define mutex_lock(A) pthread_mutex_lock(A) +#define mutex_trylock(A) pthread_mutex_trylock(A) +#define mutex_unlock(A) pthread_mutex_unlock(A) +#else +#define mutex_lock(A) \ + do { \ + uint32_t tid = (uint32_t)GetTID(); \ + while (native_lock_storeifnull_d(A, tid)) \ + sched_yield(); \ + } while (0) +#define mutex_trylock(A) native_lock_storeifnull_d(A, (uint32_t)GetTID()) +#define mutex_unlock(A) native_lock_storeifref_d(A, 0, (uint32_t)GetTID()) +#endif + extern box64context_t *my_context; // global context box64context_t *NewBox64Context(int argc); diff --git a/src/include/mysignal.h b/src/include/mysignal.h new file mode 100644 index 00000000..5eb1b782 --- /dev/null +++ b/src/include/mysignal.h @@ -0,0 +1,15 @@ +#ifndef __MYSIGNAL_H_ +#define __MYSIGNAL_H_ + +#ifndef _WIN32 +#include <signal.h> +#else +typedef struct { + int a; +} sigset_t; + +#define sigfillset(x) +#define pthread_sigmask(a, b, c) +#endif + +#endif // __MYSIGNAL_H_ \ No newline at end of file diff --git a/src/include/os.h b/src/include/os.h index d68a518b..f6e7371d 100644 --- a/src/include/os.h +++ b/src/include/os.h @@ -10,6 +10,8 @@ #else typedef __int64 ssize_t; +#define dlsym(a, b) NULL + #define PROT_READ 0x1 #define PROT_WRITE 0x2 #define PROT_EXEC 0x4 @@ -58,21 +60,6 @@ void PersonalityAddrLimit32Bit(void); #define SigSetJmp(a, b) 0 #endif -#ifndef USE_CUSTOM_MUTEX -#define mutex_lock(A) pthread_mutex_lock(A) -#define mutex_trylock(A) pthread_mutex_trylock(A) -#define mutex_unlock(A) pthread_mutex_unlock(A) -#else -#define mutex_lock(A) \ - do { \ - uint32_t tid = (uint32_t)GetTID(); \ - while (native_lock_storeifnull_d(A, tid)) \ - sched_yield(); \ - } while (0) -#define mutex_trylock(A) native_lock_storeifnull_d(A, (uint32_t)GetTID()) -#define mutex_unlock(A) native_lock_storeifref_d(A, 0, (uint32_t)GetTID()) -#endif - #ifndef _WIN32 #include <setjmp.h> #define NEW_JUMPBUFF(name) \ |