diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-04-01 19:50:49 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-01 13:50:49 +0200 |
| commit | c2a77fca277a96a49e45788601a4afc9570b1eb2 (patch) | |
| tree | 7f2737d4882c03a401f86ba91a79e6b2633492dc /src | |
| parent | 670876112e3ab4a36205223a6f0c4290a527c4a9 (diff) | |
| download | box64-c2a77fca277a96a49e45788601a4afc9570b1eb2.tar.gz box64-c2a77fca277a96a49e45788601a4afc9570b1eb2.zip | |
Added os.h for future usage (#2488)
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 1 | ||||
| -rw-r--r-- | src/dynarec/dynablock.c | 1 | ||||
| -rw-r--r-- | src/dynarec/dynarec.c | 1 | ||||
| -rw-r--r-- | src/dynarec/dynarec_native.c | 1 | ||||
| -rw-r--r-- | src/emu/x64emu.c | 1 | ||||
| -rw-r--r-- | src/emu/x64int3.c | 7 | ||||
| -rw-r--r-- | src/emu/x64run.c | 1 | ||||
| -rw-r--r-- | src/emu/x64syscall.c | 1 | ||||
| -rwxr-xr-x | src/emu/x86int3.c | 1 | ||||
| -rw-r--r-- | src/emu/x86syscall_32.c | 3 | ||||
| -rw-r--r-- | src/include/box64context.h | 1 | ||||
| -rw-r--r-- | src/include/os.h | 6 | ||||
| -rw-r--r-- | src/include/x64run.h | 2 | ||||
| -rw-r--r-- | src/libtools/signal32.c | 1 | ||||
| -rw-r--r-- | src/libtools/signals.c | 1 | ||||
| -rw-r--r-- | src/libtools/threads.c | 1 | ||||
| -rwxr-xr-x | src/libtools/threads32.c | 1 | ||||
| -rw-r--r-- | src/os/os_linux.c | 7 |
18 files changed, 28 insertions, 10 deletions
diff --git a/src/core.c b/src/core.c index 5c4dcac5..11f714d7 100644 --- a/src/core.c +++ b/src/core.c @@ -23,6 +23,7 @@ #include <fcntl.h> #endif +#include "os.h" #include "build_info.h" #include "debug.h" #include "fileutils.h" diff --git a/src/dynarec/dynablock.c b/src/dynarec/dynablock.c index 004d7a2b..109edf5c 100644 --- a/src/dynarec/dynablock.c +++ b/src/dynarec/dynablock.c @@ -4,6 +4,7 @@ #include <setjmp.h> #include <sys/mman.h> +#include "os.h" #include "debug.h" #include "box64context.h" #include "dynarec.h" diff --git a/src/dynarec/dynarec.c b/src/dynarec/dynarec.c index 1dca02a4..0bcf9451 100644 --- a/src/dynarec/dynarec.c +++ b/src/dynarec/dynarec.c @@ -3,6 +3,7 @@ #include <errno.h> #include <setjmp.h> +#include "os.h" #include "debug.h" #include "box64context.h" #include "dynarec.h" diff --git a/src/dynarec/dynarec_native.c b/src/dynarec/dynarec_native.c index e8406cce..0a32b0e5 100644 --- a/src/dynarec/dynarec_native.c +++ b/src/dynarec/dynarec_native.c @@ -5,6 +5,7 @@ #include <string.h> #include <assert.h> +#include "os.h" #include "debug.h" #include "box64context.h" #include "custommem.h" diff --git a/src/emu/x64emu.c b/src/emu/x64emu.c index 65aefa6f..05ff1393 100644 --- a/src/emu/x64emu.c +++ b/src/emu/x64emu.c @@ -7,6 +7,7 @@ #include <sys/time.h> #include <sys/mman.h> +#include "os.h" #include "debug.h" #include "box64stack.h" #include "x64emu.h" diff --git a/src/emu/x64int3.c b/src/emu/x64int3.c index e6de68fa..6c1d5d92 100644 --- a/src/emu/x64int3.c +++ b/src/emu/x64int3.c @@ -6,7 +6,6 @@ #include <string.h> #include <errno.h> #include <unistd.h> -#include <sys/syscall.h> #include <sys/types.h> #include <pthread.h> #include <signal.h> @@ -14,6 +13,7 @@ #include <sys/wait.h> #include <elf.h> +#include "os.h" #include "debug.h" #include "box64stack.h" #include "x64emu.h" @@ -401,11 +401,6 @@ void x64Int3(x64emu_t* emu, uintptr_t* addr) //emu->quit = 1; } -int GetTID() -{ - return syscall(SYS_gettid); -} - void print_rolling_log(int loglevel) { if(BOX64ENV(rolling_log)) { printf_log(loglevel, "Last calls\n"); diff --git a/src/emu/x64run.c b/src/emu/x64run.c index 0fd35d2d..ad1db962 100644 --- a/src/emu/x64run.c +++ b/src/emu/x64run.c @@ -8,6 +8,7 @@ #include <sys/types.h> #include <unistd.h> +#include "os.h" #include "debug.h" #include "box64stack.h" #include "x64emu.h" diff --git a/src/emu/x64syscall.c b/src/emu/x64syscall.c index 2b9212ed..f3d80b03 100644 --- a/src/emu/x64syscall.c +++ b/src/emu/x64syscall.c @@ -22,6 +22,7 @@ #include <poll.h> #include <sys/epoll.h> +#include "os.h" #include "debug.h" #include "box64stack.h" #include "x64emu.h" diff --git a/src/emu/x86int3.c b/src/emu/x86int3.c index 65b13902..24887f37 100755 --- a/src/emu/x86int3.c +++ b/src/emu/x86int3.c @@ -11,6 +11,7 @@ #include <pthread.h> #include <signal.h> +#include "os.h" #include "debug.h" #include "box64stack.h" #include "x64emu.h" diff --git a/src/emu/x86syscall_32.c b/src/emu/x86syscall_32.c index 31f07aad..b8c4e1cb 100644 --- a/src/emu/x86syscall_32.c +++ b/src/emu/x86syscall_32.c @@ -22,8 +22,9 @@ #endif #include <sys/resource.h> #include <poll.h> -#include <linux/futex.h> +#include <linux/futex.h> +#include "os.h" #include "debug.h" #include "box64stack.h" #include "x64emu.h" diff --git a/src/include/box64context.h b/src/include/box64context.h index d2c1d23a..2d554703 100644 --- a/src/include/box64context.h +++ b/src/include/box64context.h @@ -245,7 +245,6 @@ typedef struct box64context_s { #define mutex_trylock(A) pthread_mutex_trylock(A) #define mutex_unlock(A) pthread_mutex_unlock(A) #else -int GetTID(void); #define mutex_lock(A) {uint32_t tid = (uint32_t)GetTID(); while(native_lock_storeifnull_d(A, tid)) sched_yield();} #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()) diff --git a/src/include/os.h b/src/include/os.h new file mode 100644 index 00000000..1387255b --- /dev/null +++ b/src/include/os.h @@ -0,0 +1,6 @@ +#ifndef __OS_H_ +#define __OS_H_ + +int GetTID(void); + +#endif //__OS_H_ diff --git a/src/include/x64run.h b/src/include/x64run.h index 823a990c..c89e0786 100644 --- a/src/include/x64run.h +++ b/src/include/x64run.h @@ -8,6 +8,4 @@ int Run(x64emu_t *emu, int step); // 0 if run was successfull, 1 if error in x86 int RunTest(x64test_t *test); void DynaRun(x64emu_t *emu); -int GetTID(void); - #endif //__X64RUN_H_ diff --git a/src/libtools/signal32.c b/src/libtools/signal32.c index 8a4f103a..9a47263a 100644 --- a/src/libtools/signal32.c +++ b/src/libtools/signal32.c @@ -17,6 +17,7 @@ #include <execinfo.h> #endif +#include "os.h" #include "box32context.h" #include "debug.h" #include "x64emu.h" diff --git a/src/libtools/signals.c b/src/libtools/signals.c index dd2ad7cc..f2ed092f 100644 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -17,6 +17,7 @@ #include <execinfo.h> #endif +#include "os.h" #include "box64context.h" #include "debug.h" #include "x64emu.h" diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 046365d2..40ec2c62 100644 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -10,6 +10,7 @@ #include <sys/mman.h> #include <dlfcn.h> +#include "os.h" #include "debug.h" #include "box64context.h" #include "threads.h" diff --git a/src/libtools/threads32.c b/src/libtools/threads32.c index 9ad288e9..f1db7a35 100755 --- a/src/libtools/threads32.c +++ b/src/libtools/threads32.c @@ -10,6 +10,7 @@ #include <sys/mman.h> #include <dlfcn.h> +#include "os.h" #include "debug.h" #include "box32context.h" #include "threads.h" diff --git a/src/os/os_linux.c b/src/os/os_linux.c new file mode 100644 index 00000000..bfa6d6c4 --- /dev/null +++ b/src/os/os_linux.c @@ -0,0 +1,7 @@ +#include <sys/syscall.h> +#include <unistd.h> + +int GetTID() +{ + return syscall(SYS_gettid); +} |