X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2Fnativelib%2Fthreads_int.c;h=324b952d8532e5b6bc36b517f1971098a5e3c147;hb=2103edc7b67600818930793851b57e3583f73954;hp=f25ab95a95991f110b964e3f0f942686c2295131;hpb=3241c317ee9f714eba6a0fa82de79cfe5f104993;p=tpg%2Facess2.git diff --git a/Tools/nativelib/threads_int.c b/Tools/nativelib/threads_int.c index f25ab95a..324b952d 100644 --- a/Tools/nativelib/threads_int.c +++ b/Tools/nativelib/threads_int.c @@ -11,9 +11,9 @@ #include #include #include +#include // === TYPES === -typedef struct sThread tThread; struct sThreadIntMutex { int lock; }; struct sThreadIntSem { int val; }; @@ -22,7 +22,6 @@ struct sThreadIntSem { int val; }; // === CODE === int Threads_int_ThreadingEnabled(void) { - Log_Debug("Threads", "pthread_create = %p", pthread_create); return !!pthread_create; } @@ -139,3 +138,38 @@ int Threads_int_CreateThread(tThread *Thread) } } +void SHORTLOCK(tShortSpinlock *Lock) +{ + if( !pthread_mutex_init ) + { + if(*Lock) Log_KernelPanic("---", "Double short lock"); + *Lock = (void*)1; + } + else + { + if( !*Lock ) { + *Lock = malloc(sizeof(pthread_mutex_t)); + pthread_mutex_init(*Lock, NULL); + } + pthread_mutex_lock(*Lock); + } +} + +void SHORTREL(tShortSpinlock *Lock) +{ + if( !pthread_mutex_init ) + { + if(!*Lock) Log_Notice("---", "Short release when not held"); + *Lock = NULL; + } + else + { + pthread_mutex_unlock(*Lock); + } +} + +int CPU_HAS_LOCK(tShortSpinlock *Lock) +{ + return 0; +} +