X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2Fnativelib%2Flogging.c;h=c2d8a76a6140719b4e9f866cff83be27aec5a3aa;hb=141a83624849c3db62522275c35c385430dfc484;hp=0cb3ed32a8e98485b6f6ea9baadcf71080eaa343;hpb=7ba570fe3cc5418f42decf5b72ac2295cce9e60f;p=tpg%2Facess2.git diff --git a/Tools/nativelib/logging.c b/Tools/nativelib/logging.c index 0cb3ed32..c2d8a76a 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")