AcessNative - Fix some compilation issues
authorJohn Hodge <[email protected]>
Mon, 28 Oct 2013 10:49:36 +0000 (18:49 +0800)
committerJohn Hodge <[email protected]>
Mon, 28 Oct 2013 10:49:36 +0000 (18:49 +0800)
AcessNative/acesskernel_src/Makefile
AcessNative/acesskernel_src/threads.c
AcessNative/acesskernel_src/threads_glue.c
AcessNative/acesskernel_src/ui_sdl.c
AcessNative/ld-acess_src/exports.c
AcessNative/ld-acess_src/main.c
AcessNative/ld-acess_src/syscalls.c
AcessNative/libacess-native.so_src/exports.c
AcessNative/syscalls.h
Tools/nativelib/include/acess.h

index 19484d5..ad47c25 100644 (file)
@@ -38,7 +38,7 @@ K_OBJ := $(addprefix $(KERNEL_SRC)obj-native-$(PLATFORM)/,$(KERNEL_OBJ))
 DEPFILES  = $(filter %.o,$(OBJ) $(N_OBJ) $(K_OBJ))\r
 DEPFILES := $(DEPFILES:%=%.dep)\r
 \r
-KCPPFLAGS = -I include/ -I $(KERNEL_SRC)include/ -I$(LDACESS_SRC)include_exp/\r
+KCPPFLAGS = -I include/ -I $(KERNEL_SRC)include/ -I$(LDACESS_SRC)include_exp/ -D KERNEL_VERSION=${ACESS_VERSION}\r
 CFLAGS += -Wall -g -std=gnu99\r
 CPPFLAGS += $(shell sdl-config --cflags) -I /usr/include/\r
 LDFLAGS += $(shell sdl-config --libs) -g -Wl,--defsym,__buildnum=$(BUILD_NUM)\r
@@ -68,21 +68,18 @@ $(BIN): $(OBJ) $(N_OBJ) $(K_OBJ) $(BUILDINFO_OBJ)
 $(OBJ): obj-$(PLATFORM)/%.o: %.c\r
        @mkdir -p $(dir $@)\r
        @echo [CC] -o $@\r
-       @$(CC) -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS)\r
-       @$(CC) -M $(CPPFLAGS) $(KCPPFLAGS) -MT $@ -o [email protected] $<\r
+       @$(CC) -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) -MMD -MP -MF [email protected]\r
 \r
 $(K_OBJ): $(KERNEL_SRC)obj-native-$(PLATFORM)/%.o: $(KERNEL_SRC)%.c\r
        @mkdir -p $(dir $@)\r
        @echo [CC] -o $@\r
-       @$(CC) -ffreestanding -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS)\r
-       @$(CC) -ffreestanding -M $(KCPPFLAGS) $(CPPFLAGS) -MT $@ -o [email protected] $<\r
+       @$(CC) -ffreestanding -c $< -o $@ $(CFLAGS) $(KCPPFLAGS) $(CPPFLAGS) -MMD -MP -MF [email protected]\r
 \r
 \r
 $(N_OBJ): obj-$(PLATFORM)/%.o: %.c\r
        @mkdir -p $(dir $@)\r
        @echo [CC] -o $@\r
-       @$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)\r
-       @$(CC) -M -MT $@ -o [email protected] $<\r
+       @$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) -MMD -MP -MF [email protected]\r
 \r
 $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) Makefile\r
        @echo "" > $@\r
index 7296a58..de61ef4 100644 (file)
@@ -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__);
+}
+
index ba407b8..d400b27 100644 (file)
@@ -20,6 +20,7 @@ typedef void  **tShortSpinlock;
 #include <pthread.h>
 #include <assert.h>
 
+#define NORETURN       __attribute__((noreturn))
 #include <logdebug.h>  // Kernel land, but uses standards
 
 // === CODE ===
index 7e97cbe..bc6efc9 100644 (file)
@@ -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;
                }
        }
 }
index 3f5f295..6ee2538 100644 (file)
@@ -11,8 +11,7 @@
 #include <stdarg.h>
 #include <stddef.h>
 
-#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 <d >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)
index a03e963..8f24db8 100644 (file)
@@ -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;
        }
index 34132c6..43dfe26 100644 (file)
@@ -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;
 }
index 17ee997..70c7d77 100644 (file)
@@ -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");
+}
+
index d2e8e91..a9768c4 100644 (file)
@@ -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
index b83b977..b8bd4df 100644 (file)
@@ -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)

UCC git Repository :: git.ucc.asn.au