Lots of work on the AcessNative kernel
[tpg/acess2.git] / AcessNative / acesskernel_src / threads.c
index 5f29f76..7b66624 100644 (file)
@@ -44,8 +44,12 @@ typedef struct sThread
 }      tThread;
 
 // === GLOBALS ===
-tThread        *gpThreads;
-__thread tThread       *gpCurrentThread;
+tThread        gThread_Zero = {
+       State: 1,
+       ThreadName: "ThreadZero"
+};
+tThread        *gpThreads = &gThread_Zero;
+__thread tThread       *gpCurrentThread = &gThread_Zero;
 
 // === CODE ===
 tThread        *Threads_GetThread(int TID)
@@ -66,6 +70,10 @@ tPID Threads_GetPID() { return gpCurrentThread->PID; }
 
 Uint *Threads_GetCfgPtr(int Index)
 {
+       if( Index < 0 || Index >= NUM_CFG_ENTRIES )
+               return NULL;
+       if( !gpCurrentThread )
+               return NULL;
        return &gpCurrentThread->Config[Index];
 }
 

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