X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2Fnativelib%2Flogging.c;h=16e6f70e43669eb33b9f9d98781cce9766f8fcce;hb=071e393d22b502d75fa1a9292623cb9356c558d8;hp=0cb3ed32a8e98485b6f6ea9baadcf71080eaa343;hpb=d4b0e2edda3080715434db09cf2e25ea52d4340f;p=tpg%2Facess2.git diff --git a/Tools/nativelib/logging.c b/Tools/nativelib/logging.c index 0cb3ed32..16e6f70e 100644 --- a/Tools/nativelib/logging.c +++ b/Tools/nativelib/logging.c @@ -1,5 +1,9 @@ /* - * + * Acess2 libnative (Kernel Simulation Library) + * - By John Hodge (thePowersGang) + * + * logging.c + * - Logging functions */ #include #include @@ -8,22 +12,33 @@ #include #include #include +#include -#define LOGHDR(col,type) fprintf(stderr, "\e["col"m[%-8.8s]"type" ", Ident) +extern int Threads_GetTID(); + +#define LOGHDR(col,type) fprintf(stderr, "\e["col"m[%-8.8s]"type"%2i ", Ident, Threads_GetTID()) #define LOGTAIL() fprintf(stderr, "\e[0m\n") #define PUTERR(col,type) {\ + if(!gbThreadInLog) SHORTLOCK(&glDebugLock); \ + gbThreadInLog ++; \ LOGHDR(col,type);\ va_list args; va_start(args, Message);\ vfprintf(stderr, Message, args);\ va_end(args);\ LOGTAIL();\ + gbThreadInLog --; \ + if(!gbThreadInLog) SHORTREL(&glDebugLock); \ } +// === GLOBALS === +int __thread gbThreadInLog; +tShortSpinlock glDebugLock; + // === CODE === void Log_KernelPanic(const char *Ident, const char *Message, ...) { PUTERR("35", "k") - abort(); + exit(-1); } void Log_Panic(const char *Ident, const char *Message, ...) PUTERR("34", "p") @@ -38,6 +53,11 @@ void Log_Log(const char *Ident, const char *Message, ...) void Log_Debug(const char *Ident, const char *Message, ...) PUTERR("37", "d") +void Panic(const char *Message, ...) { + const char *Ident = ""; + PUTERR("35", "k") + exit(-1); +} void Warning(const char *Message, ...) { const char *Ident = ""; PUTERR("33", "W")