From 5a66c3a4a2019a7ddea8931c8476bb64f4d29079 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 28 Oct 2013 18:49:36 +0800 Subject: [PATCH] AcessNative - Fix some compilation issues --- AcessNative/acesskernel_src/Makefile | 11 +-- AcessNative/acesskernel_src/threads.c | 12 +++ AcessNative/acesskernel_src/threads_glue.c | 1 + AcessNative/acesskernel_src/ui_sdl.c | 87 ++++++++++---------- AcessNative/ld-acess_src/exports.c | 22 ++++- AcessNative/ld-acess_src/main.c | 5 ++ AcessNative/ld-acess_src/syscalls.c | 5 +- AcessNative/libacess-native.so_src/exports.c | 5 ++ AcessNative/syscalls.h | 2 +- Tools/nativelib/include/acess.h | 1 + 10 files changed, 94 insertions(+), 57 deletions(-) diff --git a/AcessNative/acesskernel_src/Makefile b/AcessNative/acesskernel_src/Makefile index 19484d5e..ad47c25a 100644 --- a/AcessNative/acesskernel_src/Makefile +++ b/AcessNative/acesskernel_src/Makefile @@ -38,7 +38,7 @@ K_OBJ := $(addprefix $(KERNEL_SRC)obj-native-$(PLATFORM)/,$(KERNEL_OBJ)) DEPFILES = $(filter %.o,$(OBJ) $(N_OBJ) $(K_OBJ)) DEPFILES := $(DEPFILES:%=%.dep) -KCPPFLAGS = -I include/ -I $(KERNEL_SRC)include/ -I$(LDACESS_SRC)include_exp/ +KCPPFLAGS = -I include/ -I $(KERNEL_SRC)include/ -I$(LDACESS_SRC)include_exp/ -D KERNEL_VERSION=${ACESS_VERSION} CFLAGS += -Wall -g -std=gnu99 CPPFLAGS += $(shell sdl-config --cflags) -I /usr/include/ LDFLAGS += $(shell sdl-config --libs) -g -Wl,--defsym,__buildnum=$(BUILD_NUM) @@ -68,21 +68,18 @@ $(BIN): $(OBJ) $(N_OBJ) $(K_OBJ) $(BUILDINFO_OBJ) $(OBJ): obj-$(PLATFORM)/%.o: %.c @mkdir -p $(dir $@) @echo [CC] -o $@ - @$(CC) -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) - @$(CC) -M $(CPPFLAGS) $(KCPPFLAGS) -MT $@ -o $@.dep $< + @$(CC) -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) -MMD -MP -MF $@.dep $(K_OBJ): $(KERNEL_SRC)obj-native-$(PLATFORM)/%.o: $(KERNEL_SRC)%.c @mkdir -p $(dir $@) @echo [CC] -o $@ - @$(CC) -ffreestanding -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) - @$(CC) -ffreestanding -M $(KCPPFLAGS) $(CPPFLAGS) -MT $@ -o $@.dep $< + @$(CC) -ffreestanding -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) -MMD -MP -MF $@.dep $(N_OBJ): obj-$(PLATFORM)/%.o: %.c @mkdir -p $(dir $@) @echo [CC] -o $@ - @$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) - @$(CC) -M -MT $@ -o $@.dep $< + @$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) -MMD -MP -MF $@.dep $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) Makefile @echo "" > $@ diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index 7296a58e..de61ef47 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -372,3 +372,15 @@ void Threads_ClearEvent(Uint32 EventMask) gpCurrentThread->EventState &= ~EventMask; } +// -------------------------------------------------------------------- +// Signals +// -------------------------------------------------------------------- +void Threads_PostSignal(int SigNum) +{ + Log_Error("Threads", "TODO: %s", __func__); +} +void Threads_SignalGroup(tPGID PGID, int SignalNum) +{ + Log_Error("Threads", "TODO: %s", __func__); +} + diff --git a/AcessNative/acesskernel_src/threads_glue.c b/AcessNative/acesskernel_src/threads_glue.c index ba407b81..d400b27b 100644 --- a/AcessNative/acesskernel_src/threads_glue.c +++ b/AcessNative/acesskernel_src/threads_glue.c @@ -20,6 +20,7 @@ typedef void **tShortSpinlock; #include #include +#define NORETURN __attribute__((noreturn)) #include // Kernel land, but uses standards // === CODE === diff --git a/AcessNative/acesskernel_src/ui_sdl.c b/AcessNative/acesskernel_src/ui_sdl.c index 7e97cbe7..bc6efc94 100644 --- a/AcessNative/acesskernel_src/ui_sdl.c +++ b/AcessNative/acesskernel_src/ui_sdl.c @@ -130,56 +130,53 @@ void UI_MainLoop(void) SDL_Event event; Uint32 acess_sym; - for( ;; ) + while( SDL_WaitEvent(&event) ) { - while(SDL_PollEvent(&event)) + switch(event.type) { - switch(event.type) - { - case SDL_QUIT: - AcessNative_Exit(); - return ; - - case SDL_KEYDOWN: - acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym); - // Enter key on acess returns \n, but SDL returns \r - if(event.key.keysym.sym == SDLK_RETURN) - event.key.keysym.unicode = '\n'; - - if( gUI_KeyboardCallback ) { - gUI_KeyboardCallback(KEY_ACTION_RAWSYM|acess_sym); - gUI_KeyboardCallback(KEY_ACTION_PRESS|event.key.keysym.unicode); - } - break; + case SDL_QUIT: + AcessNative_Exit(); + return ; - case SDL_KEYUP: - acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym); - - if( gUI_KeyboardCallback ) { - gUI_KeyboardCallback(KEY_ACTION_RAWSYM|acess_sym); - gUI_KeyboardCallback(KEY_ACTION_RELEASE|0); - } - break; - - case SDL_USEREVENT: - SDL_UpdateRect(gScreen, 0, 0, giUI_Width, giUI_Height); - SDL_Flip(gScreen); - break; + case SDL_KEYDOWN: + acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym); + // Enter key on acess returns \n, but SDL returns \r + if(event.key.keysym.sym == SDLK_RETURN) + event.key.keysym.unicode = '\n'; + + if( gUI_KeyboardCallback ) { + gUI_KeyboardCallback(KEY_ACTION_RAWSYM|acess_sym); + gUI_KeyboardCallback(KEY_ACTION_PRESS|event.key.keysym.unicode); + } + break; + + case SDL_KEYUP: + acess_sym = UI_GetAcessKeyFromSDL(event.key.keysym.sym); - case SDL_MOUSEMOTION: { - int abs[] = {event.motion.x, event.motion.y}; - int delta[] = {event.motion.xrel, event.motion.yrel}; - Mouse_HandleEvent(UI_GetButtonBits(SDL_GetMouseState(NULL, NULL)), delta, abs); - break; } - case SDL_MOUSEBUTTONUP: - case SDL_MOUSEBUTTONDOWN: { - int abs[] = {event.button.x, event.button.y}; - Mouse_HandleEvent(UI_GetButtonBits(SDL_GetMouseState(NULL, NULL)), NULL, abs); - break; } - - default: - break; + if( gUI_KeyboardCallback ) { + gUI_KeyboardCallback(KEY_ACTION_RAWSYM|acess_sym); + gUI_KeyboardCallback(KEY_ACTION_RELEASE|0); } + break; + + case SDL_USEREVENT: + SDL_UpdateRect(gScreen, 0, 0, giUI_Width, giUI_Height); + SDL_Flip(gScreen); + break; + + case SDL_MOUSEMOTION: { + int abs[] = {event.motion.x, event.motion.y}; + int delta[] = {event.motion.xrel, event.motion.yrel}; + Mouse_HandleEvent(UI_GetButtonBits(SDL_GetMouseState(NULL, NULL)), delta, abs); + break; } + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: { + int abs[] = {event.button.x, event.button.y}; + Mouse_HandleEvent(UI_GetButtonBits(SDL_GetMouseState(NULL, NULL)), NULL, abs); + break; } + + default: + break; } } } diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 3f5f295c..6ee25381 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -11,8 +11,7 @@ #include #include -#define DEBUG(v...) Debug(v) -//#define DEBUG(v...) do{}while(0)//Debug(v) +#define DEBUG(v...) do{if(gbSyscallDebugEnabled)Debug(v);}while(0) #define PAGE_SIZE 4096 #define TODO() Warning("TODO: %s", __func__) @@ -40,6 +39,7 @@ extern int AllocateMemory(uintptr_t VirtAddr, size_t ByteCount); // === GLOBALS === int acess__errno; + int gbSyscallDebugEnabled = 0; char *gsExecutablePath = "./ld-acess"; // === CODE === @@ -121,7 +121,6 @@ int acess__SysIOCtl(int fd, int id, void *data) { return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, len, data); } int acess__SysFInfo(int fd, t_sysFInfo *info, int maxacls) { -// DEBUG("offsetof(size, t_sysFInfo) = %i", offsetof(t_sysFInfo, size)); SYSTRACE("_SysFInfo(%i, %p, %i)", fd, info, maxacls); return _Syscall(SYS_FINFO, ">i i", fd, @@ -215,6 +214,13 @@ int acess__SysUnloadBin(void *base) return -1; } +// --- System --- +int acess__SysLoadModule(const char *Path) +{ + TODO(); + return -1; +} + // --- Timekeeping --- int64_t acess__SysTimestamp(void) { @@ -366,6 +372,15 @@ int acess__SysSpawn(const char *binary, const char **argv, const char **envp, in // _Syscall(SYS_SLEEP, ""); //} +void acess__SysTimedSleep(int64_t Delay) +{ + DEBUG("%s(%lli)", __func__, Delay); + // Not accurate, but fuck it + //if( Delay > 1000 ) sleep(Delay / 1000); + //if( Delay % 1000 ) usleep( (Delay % 1000) * 1000 ); + //_Syscall(SYS_TIMEDSLEEP, ">I", Delay); +} + int acess__SysWaitTID(int TID, int *ExitStatus) { DEBUG("%s(%i, %p)", __func__, TID, ExitStatus); @@ -377,6 +392,7 @@ int acess_setgid(int ID) { return _Syscall(SYS_SETGID, ">i", ID); } int acess_gettid(void) { return _Syscall(SYS_GETTID, ""); } int acess__SysGetPID(void) { return _Syscall(SYS_GETPID, ""); } int acess__SysGetUID(void) { return _Syscall(SYS_GETUID, ""); } +int acess__SysGetGID(void) { return _Syscall(SYS_GETGID, ""); } int acess_getgid(void) { return _Syscall(SYS_GETGID, ""); } int acess__SysSendMessage(int DestTID, int Length, void *Data) diff --git a/AcessNative/ld-acess_src/main.c b/AcessNative/ld-acess_src/main.c index a03e9634..8f24db8a 100644 --- a/AcessNative/ld-acess_src/main.c +++ b/AcessNative/ld-acess_src/main.c @@ -9,6 +9,7 @@ // === IMPORTS === extern int gSocket; extern int giSyscall_ClientID; +extern int gbSyscallDebugEnabled; extern void acess__exit(int Status); extern void Request_Preinit(void); @@ -59,6 +60,10 @@ int main(int argc, char *argv[], char **envp) } continue ; } + if( strcmp(argv[i], "--trace") == 0 ) { + gbSyscallDebugEnabled = 1; + continue ; + } if( argv[i][0] != '-' ) break; } diff --git a/AcessNative/ld-acess_src/syscalls.c b/AcessNative/ld-acess_src/syscalls.c index 34132c62..43dfe26e 100644 --- a/AcessNative/ld-acess_src/syscalls.c +++ b/AcessNative/ld-acess_src/syscalls.c @@ -26,6 +26,7 @@ // === Types === // === IMPORTS === +extern int gbSyscallDebugEnabled; // === GLOBALS === FILE *gaSyscall_LocalFPs[MAX_FPS]; @@ -280,7 +281,9 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...) free( req ); free( retPtrs ); - SYSTRACE(": %i 0x%llx", SyscallID, retValue); + if( gbSyscallDebugEnabled ) { + SYSTRACE(": %i 0x%llx", SyscallID, retValue); + } return retValue; } diff --git a/AcessNative/libacess-native.so_src/exports.c b/AcessNative/libacess-native.so_src/exports.c index 17ee9974..70c7d774 100644 --- a/AcessNative/libacess-native.so_src/exports.c +++ b/AcessNative/libacess-native.so_src/exports.c @@ -36,3 +36,8 @@ int acess__SysSpawn(const char *binary, const char **argv, const char **envp, in return 0; } +void ldacess_DumpLoadedLibraries(void) +{ + Debug("ldacess_DumpLoadedLibraries"); +} + diff --git a/AcessNative/syscalls.h b/AcessNative/syscalls.h index d2e8e91e..a9768c41 100644 --- a/AcessNative/syscalls.h +++ b/AcessNative/syscalls.h @@ -8,7 +8,7 @@ #define SYSCALL_TRACE 1 #if SYSCALL_TRACE -#define SYSTRACE(str, x...) Debug(str, x) +#define SYSTRACE(str, x...) do{ if(gbSyscallDebugEnabled)Debug(str, x); }while(0) #else #define SYSTRACE(...) do{}while(0) #endif diff --git a/Tools/nativelib/include/acess.h b/Tools/nativelib/include/acess.h index b83b9773..b8bd4df2 100644 --- a/Tools/nativelib/include/acess.h +++ b/Tools/nativelib/include/acess.h @@ -56,6 +56,7 @@ extern int64_t timestamp(int sec, int min, int hr, int day, int month, int year) extern void format_date(tTime TS, int *year, int *month, int *day, int *hrs, int *mins, int *sec, int *ms); #define PACKED __attribute__((packed)) +#define NORETURN __attribute__((noreturn)) #define DEPRECATED #define EXPORT(s) #define EXPORTV(s) -- 2.20.1