Merge branch 'master' of git://github.com/thepowersgang/acess2
[tpg/acess2.git] / Tools / nativelib / include / acess.h
index da1693f..f133788 100644 (file)
@@ -13,8 +13,6 @@
 #define STR(x) #x
 #define EXPAND_STR(x) STR(x)
 
-#define ASSERT(x)      do{}while(0)
-
 extern char    __buildnum[];
 #define BUILD_NUM      ((int)(Uint)&__buildnum)
 extern const char gsGitHash[];
@@ -25,6 +23,7 @@ extern const char gsBuildInfo[];
 #define BITS   32
 #define NULL   ((void*)0)
 #include <stdint.h>
+#include <stdbool.h>
 
 typedef uintptr_t      Uint;
 //typedef unsigned int size_t;
@@ -49,9 +48,7 @@ typedef uint32_t      tPAddr;
 typedef uint32_t       tUID;
 typedef uint32_t       tGID;
 typedef uint32_t       tTID;
-
-// NOTE: Since this is single-threaded (for now) mutexes can be implimented as simple locks
-typedef char   tShortSpinlock;
+typedef uint32_t       tPGID;
 
 typedef int64_t        tTime;
 extern tTime   now(void);
@@ -59,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)
@@ -70,11 +68,33 @@ extern void *malloc(size_t bytes);
 extern void    *calloc(size_t nmemb, size_t size);
 extern void    *realloc(void *oldptr, size_t bytes);
 extern void    free(void *buffer);
+extern char    *strdup(const char *str);
 
 #include <errno.h>
-#include <acess_logging.h>
+//#include <acess_logging.h>
+#include <logdebug.h>
+
+extern void    Debug_TraceEnter(const char *Function, const char *Format, ...);
+extern void    Debug_TraceLog(const char *Function, const char *Format, ...);
+extern void    Debug_TraceLeave(const char *Function, char Type, ...);
+#undef ENTER
+#undef LOG
+#undef LEAVE
+#undef LEAVE_RET
+#if DEBUG
+# define ENTER(str, v...)      Debug_TraceEnter(__func__, str, ##v)
+# define LOG(fmt, v...)        Debug_TraceLog(__func__, fmt, ##v)
+# define LEAVE(t, v...)        Debug_TraceLeave(__func__, t, ##v)
+# define LEAVE_RET(t,v)        do{LEAVE('-');return v;}while(0)
+#else
+# define ENTER(...)    do{}while(0)
+# define LOG(...)      do{}while(0)
+# define LEAVE(...)    do{}while(0)
+# define LEAVE_RET(t,v)        do{return v;}while(0)
+#endif
 
 // Threads
+extern void    **Threads_GetHandlesPtr(void);
 extern int     *Threads_GetErrno(void);
 //extern tPGID Threads_GetPGID(void);
 //extern tPID  Threads_GetPID(void);
@@ -145,16 +165,7 @@ extern uint64_t    DivMod64U(uint64_t Num, uint64_t Den, uint64_t *Rem);
 static inline int MIN(int a, int b) { return a < b ? a : b; }
 static inline int MAX(int a, int b) { return a > b ? a : b; }
 
-#if USE_MULTITHREADING
-#error "TODO: Impliment multithreaded SHORTLOCK"
-#else
-static inline void SHORTLOCK(tShortSpinlock *Lock) {
-       if(*Lock)       Log_KernelPanic("---", "Double short lock");
-       *Lock = 1;
-}
-static inline void SHORTREL(tShortSpinlock *m) { *m = 0; }
-static inline int  CPU_HAS_LOCK(tShortSpinlock *m) { return *m; }
-#endif
+#include <shortlock.h>
 
 static inline intptr_t MM_GetPhysAddr(void *Ptr) { return 1; }
 static inline int      MM_IsUser(const void *Ptr) { return 1; }

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