struct sThreadIntMutex { int lock; };
struct sThreadIntSem { int val; };
+// === PROTOTYPES ===
+
// === CODE ===
+int Threads_int_ThreadingEnabled(void)
+{
+ Log_Debug("Threads", "pthread_create = %p", pthread_create);
+ return !!pthread_create;
+}
+
+tThreadIntMutex *Threads_int_MutexCreate(void)
+{
+ if( pthread_mutex_init )
+ {
+ tThreadIntMutex *ret = malloc(sizeof(pthread_mutex_t));
+ pthread_mutex_init( (void*)ret, NULL );
+ return ret;
+ }
+ else
+ {
+ return calloc(sizeof(tThreadIntMutex), 1);
+ }
+}
+
void Threads_int_MutexLock(tThreadIntMutex *Mutex)
{
if( !Mutex ) {
}
}
+tThreadIntSem *Threads_int_SemCreate(void)
+{
+ if( sem_init )
+ {
+ tThreadIntSem *ret = malloc(sizeof(sem_t));
+ sem_init( (void*)ret, 0, 0 );
+ return ret;
+ }
+ else
+ {
+ return calloc(sizeof(tThreadIntSem), 1);
+ }
+}
+
void Threads_int_SemSignal(tThreadIntSem *Sem)
{
if( sem_wait )
void *Threads_int_ThreadRoot(void *ThreadPtr)
{
tThread *thread = ThreadPtr;
+ lpThreads_This = thread;
+ Log_Debug("Threads", "SpawnFcn: %p, SpawnData: %p", thread->SpawnFcn, thread->SpawnData);
thread->SpawnFcn(thread->SpawnData);
return NULL;
}
{
pthread_t *pthread = malloc(sizeof(pthread_t));
Thread->ThreadHandle = pthread;
- return pthread_create(pthread, NULL, Threads_int_ThreadRoot, Thread);
+ return pthread_create(pthread, NULL, &Threads_int_ThreadRoot, Thread);
}
else
{