(psp pthreads) Buildfixes
This commit is contained in:
parent
a57df7d43f
commit
c4f06f2ef2
|
@ -29,9 +29,9 @@
|
||||||
#ifndef _TLS_HELPER_H_
|
#ifndef _TLS_HELPER_H_
|
||||||
#define _TLS_HELPER_H_
|
#define _TLS_HELPER_H_
|
||||||
|
|
||||||
#include "pte_osal.h"
|
#include "../../pte_osal.h"
|
||||||
|
|
||||||
/// @todo document..
|
/* @todo document.. */
|
||||||
|
|
||||||
pte_osResult pteTlsGlobalInit(int maxEntries);
|
pte_osResult pteTlsGlobalInit(int maxEntries);
|
||||||
void * pteTlsThreadInit(void);
|
void * pteTlsThreadInit(void);
|
||||||
|
|
|
@ -30,17 +30,19 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pspkerror.h>
|
|
||||||
#include "pte_osal.h"
|
|
||||||
#include "pthread.h"
|
|
||||||
#include "../helper/tls-helper.h"
|
|
||||||
|
|
||||||
/* For ftime */
|
/* For ftime */
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
|
|
||||||
#define MAX_PSP_UID 2048 // SWAG
|
#include <pspkerror.h>
|
||||||
|
|
||||||
|
#include "../../pte_osal.h"
|
||||||
|
#include "../../pthread.h"
|
||||||
|
#include "../helper/tls-helper.h"
|
||||||
|
|
||||||
|
#define MAX_PSP_UID 2048 /* SWAG */
|
||||||
|
|
||||||
#define DEFAULT_STACK_SIZE_BYTES 4096
|
#define DEFAULT_STACK_SIZE_BYTES 4096
|
||||||
|
|
||||||
|
@ -181,15 +183,11 @@ pte_osResult pte_osThreadCreate(pte_osThreadEntryPoint entryPoint,
|
||||||
pspThreadData *pThreadData;
|
pspThreadData *pThreadData;
|
||||||
|
|
||||||
if (threadNum++ > MAX_PSP_UID)
|
if (threadNum++ > MAX_PSP_UID)
|
||||||
{
|
|
||||||
threadNum = 0;
|
threadNum = 0;
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure that the stack we're going to allocate is big enough */
|
/* Make sure that the stack we're going to allocate is big enough */
|
||||||
if (stackSize < DEFAULT_STACK_SIZE_BYTES)
|
if (stackSize < DEFAULT_STACK_SIZE_BYTES)
|
||||||
{
|
|
||||||
stackSize = DEFAULT_STACK_SIZE_BYTES;
|
stackSize = DEFAULT_STACK_SIZE_BYTES;
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate TLS structure for this thread. */
|
/* Allocate TLS structure for this thread. */
|
||||||
pTls = pteTlsThreadInit();
|
pTls = pteTlsThreadInit();
|
||||||
|
@ -240,7 +238,9 @@ pte_osResult pte_osThreadCreate(pte_osThreadEntryPoint entryPoint,
|
||||||
|
|
||||||
pspAttr = 0;
|
pspAttr = 0;
|
||||||
|
|
||||||
// printf("%s %p %d %d %d\n",threadName, pspStubThreadEntry, initialPriority, stackSize, pspAttr);
|
#if 0
|
||||||
|
printf("%s %p %d %d %d\n",threadName, pspStubThreadEntry, initialPriority, stackSize, pspAttr);
|
||||||
|
#endif
|
||||||
threadId = sceKernelCreateThread(threadName,
|
threadId = sceKernelCreateThread(threadName,
|
||||||
pspStubThreadEntry,
|
pspStubThreadEntry,
|
||||||
initialPriority,
|
initialPriority,
|
||||||
|
@ -274,7 +274,6 @@ FAIL0:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pte_osResult pte_osThreadStart(pte_osThreadHandle osThreadHandle)
|
pte_osResult pte_osThreadStart(pte_osThreadHandle osThreadHandle)
|
||||||
{
|
{
|
||||||
sceKernelStartThread(osThreadHandle, 0, NULL);
|
sceKernelStartThread(osThreadHandle, 0, NULL);
|
||||||
|
@ -285,12 +284,8 @@ pte_osResult pte_osThreadStart(pte_osThreadHandle osThreadHandle)
|
||||||
|
|
||||||
pte_osResult pte_osThreadDelete(pte_osThreadHandle handle)
|
pte_osResult pte_osThreadDelete(pte_osThreadHandle handle)
|
||||||
{
|
{
|
||||||
pspThreadData *pThreadData;
|
void *pTls = getTlsStructFromThread(handle);
|
||||||
void *pTls;
|
pspThreadData *pThreadData = getThreadData(handle);
|
||||||
|
|
||||||
pTls = getTlsStructFromThread(handle);
|
|
||||||
|
|
||||||
pThreadData = getThreadData(handle);
|
|
||||||
|
|
||||||
sceKernelDeleteSema(pThreadData->cancelSem);
|
sceKernelDeleteSema(pThreadData->cancelSem);
|
||||||
|
|
||||||
|
@ -312,7 +307,7 @@ pte_osResult pte_osThreadExitAndDelete(pte_osThreadHandle handle)
|
||||||
return PTE_OS_OK;
|
return PTE_OS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pte_osThreadExit()
|
void pte_osThreadExit(void)
|
||||||
{
|
{
|
||||||
sceKernelExitThread(0);
|
sceKernelExitThread(0);
|
||||||
}
|
}
|
||||||
|
@ -324,9 +319,7 @@ void pte_osThreadExit()
|
||||||
pte_osResult pte_osThreadWaitForEnd(pte_osThreadHandle threadHandle)
|
pte_osResult pte_osThreadWaitForEnd(pte_osThreadHandle threadHandle)
|
||||||
{
|
{
|
||||||
pte_osResult result;
|
pte_osResult result;
|
||||||
pspThreadData *pThreadData;
|
pspThreadData *pThreadData = getThreadData(sceKernelGetThreadId());
|
||||||
|
|
||||||
pThreadData = getThreadData(sceKernelGetThreadId());
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -360,14 +353,12 @@ pte_osResult pte_osThreadWaitForEnd(pte_osThreadHandle threadHandle)
|
||||||
result = PTE_OS_INTERRUPTED;
|
result = PTE_OS_INTERRUPTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Nothing found and not timed out yet; let's yield so we're not
|
/* Nothing found and not timed out yet; let's yield so we're not
|
||||||
* in busy loop.
|
* in busy loop.
|
||||||
*/
|
*/
|
||||||
|
else
|
||||||
sceKernelDelayThread(POLLING_DELAY_IN_us);
|
sceKernelDelayThread(POLLING_DELAY_IN_us);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = PTE_OS_GENERAL_FAILURE;
|
result = PTE_OS_GENERAL_FAILURE;
|
||||||
|
@ -405,35 +396,22 @@ pte_osResult pte_osThreadSetPriority(pte_osThreadHandle threadHandle, int newPri
|
||||||
|
|
||||||
pte_osResult pte_osThreadCancel(pte_osThreadHandle threadHandle)
|
pte_osResult pte_osThreadCancel(pte_osThreadHandle threadHandle)
|
||||||
{
|
{
|
||||||
SceUID osResult;
|
pspThreadData *pThreadData = getThreadData(threadHandle);
|
||||||
pte_osResult result;
|
SceUID osResult = sceKernelSignalSema(pThreadData->cancelSem, 1);
|
||||||
pspThreadData *pThreadData;
|
|
||||||
|
|
||||||
pThreadData = getThreadData(threadHandle);
|
|
||||||
|
|
||||||
osResult = sceKernelSignalSema(pThreadData->cancelSem, 1);
|
|
||||||
|
|
||||||
if (osResult == SCE_KERNEL_ERROR_OK)
|
if (osResult == SCE_KERNEL_ERROR_OK)
|
||||||
{
|
return PTE_OS_OK;
|
||||||
result = PTE_OS_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = PTE_OS_GENERAL_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return PTE_OS_GENERAL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pte_osResult pte_osThreadCheckCancel(pte_osThreadHandle threadHandle)
|
pte_osResult pte_osThreadCheckCancel(pte_osThreadHandle threadHandle)
|
||||||
{
|
{
|
||||||
pspThreadData *pThreadData;
|
|
||||||
SceKernelSemaInfo semInfo;
|
SceKernelSemaInfo semInfo;
|
||||||
SceUID osResult;
|
SceUID osResult;
|
||||||
pte_osResult result;
|
pte_osResult result;
|
||||||
|
pspThreadData *pThreadData = getThreadData(threadHandle);
|
||||||
pThreadData = getThreadData(threadHandle);
|
|
||||||
|
|
||||||
if (pThreadData != NULL)
|
if (pThreadData != NULL)
|
||||||
{
|
{
|
||||||
|
@ -442,25 +420,17 @@ pte_osResult pte_osThreadCheckCancel(pte_osThreadHandle threadHandle)
|
||||||
if (osResult == SCE_KERNEL_ERROR_OK)
|
if (osResult == SCE_KERNEL_ERROR_OK)
|
||||||
{
|
{
|
||||||
if (semInfo.currentCount > 0)
|
if (semInfo.currentCount > 0)
|
||||||
{
|
|
||||||
result = PTE_OS_INTERRUPTED;
|
result = PTE_OS_INTERRUPTED;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result = PTE_OS_OK;
|
result = PTE_OS_OK;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* sceKernelReferSemaStatus returned an error */
|
/* sceKernelReferSemaStatus returned an error */
|
||||||
result = PTE_OS_GENERAL_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
/* For some reason, we couldn't get thread data */
|
|
||||||
result = PTE_OS_GENERAL_FAILURE;
|
result = PTE_OS_GENERAL_FAILURE;
|
||||||
}
|
}
|
||||||
|
/* For some reason, we couldn't get thread data */
|
||||||
|
else
|
||||||
|
result = PTE_OS_GENERAL_FAILURE;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -470,17 +440,17 @@ void pte_osThreadSleep(unsigned int msecs)
|
||||||
sceKernelDelayThread(msecs*1000);
|
sceKernelDelayThread(msecs*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pte_osThreadGetMinPriority()
|
int pte_osThreadGetMinPriority(void)
|
||||||
{
|
{
|
||||||
return 17;
|
return 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pte_osThreadGetMaxPriority()
|
int pte_osThreadGetMaxPriority(void)
|
||||||
{
|
{
|
||||||
return 30;
|
return 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pte_osThreadGetDefaultPriority()
|
int pte_osThreadGetDefaultPriority(void)
|
||||||
{
|
{
|
||||||
return 18;
|
return 18;
|
||||||
}
|
}
|
||||||
|
@ -498,9 +468,7 @@ pte_osResult pte_osMutexCreate(pte_osMutexHandle *pHandle)
|
||||||
pte_osMutexHandle handle;
|
pte_osMutexHandle handle;
|
||||||
|
|
||||||
if (mutexCtr++ > MAX_PSP_UID)
|
if (mutexCtr++ > MAX_PSP_UID)
|
||||||
{
|
|
||||||
mutexCtr = 0;
|
mutexCtr = 0;
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(mutexName,sizeof(mutexName),"mutex%d",mutexCtr);
|
snprintf(mutexName,sizeof(mutexName),"mutex%d",mutexCtr);
|
||||||
|
|
||||||
|
@ -522,8 +490,6 @@ pte_osResult pte_osMutexDelete(pte_osMutexHandle handle)
|
||||||
return PTE_OS_OK;
|
return PTE_OS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pte_osResult pte_osMutexLock(pte_osMutexHandle handle)
|
pte_osResult pte_osMutexLock(pte_osMutexHandle handle)
|
||||||
{
|
{
|
||||||
sceKernelWaitSema(handle, 1, NULL);
|
sceKernelWaitSema(handle, 1, NULL);
|
||||||
|
@ -533,22 +499,14 @@ pte_osResult pte_osMutexLock(pte_osMutexHandle handle)
|
||||||
|
|
||||||
pte_osResult pte_osMutexTimedLock(pte_osMutexHandle handle, unsigned int timeoutMsecs)
|
pte_osResult pte_osMutexTimedLock(pte_osMutexHandle handle, unsigned int timeoutMsecs)
|
||||||
{
|
{
|
||||||
pte_osResult result;
|
|
||||||
SceUInt timeoutUsecs = timeoutMsecs*1000;
|
SceUInt timeoutUsecs = timeoutMsecs*1000;
|
||||||
|
|
||||||
int status = sceKernelWaitSema(handle, 1, &timeoutUsecs);
|
int status = sceKernelWaitSema(handle, 1, &timeoutUsecs);
|
||||||
|
|
||||||
|
/* Assume that any error from sceKernelWaitSema was due to a timeout */
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
return PTE_OS_TIMEOUT;
|
||||||
// Assume that any error from sceKernelWaitSema was due to a timeout
|
|
||||||
result = PTE_OS_TIMEOUT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = PTE_OS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return PTE_OS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,9 +530,7 @@ pte_osResult pte_osSemaphoreCreate(int initialValue, pte_osSemaphoreHandle *pHan
|
||||||
char semName[32];
|
char semName[32];
|
||||||
|
|
||||||
if (semCtr++ > MAX_PSP_UID)
|
if (semCtr++ > MAX_PSP_UID)
|
||||||
{
|
|
||||||
semCtr = 0;
|
semCtr = 0;
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(semName,sizeof(semName),"pthread_sem%d",semCtr);
|
snprintf(semName,sizeof(semName),"pthread_sem%d",semCtr);
|
||||||
|
|
||||||
|
@ -612,9 +568,7 @@ pte_osResult pte_osSemaphorePend(pte_osSemaphoreHandle handle, unsigned int *pTi
|
||||||
pte_osResult osResult;
|
pte_osResult osResult;
|
||||||
|
|
||||||
if (pTimeoutMsecs == NULL)
|
if (pTimeoutMsecs == NULL)
|
||||||
{
|
|
||||||
pTimeoutUsecs = NULL;
|
pTimeoutUsecs = NULL;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeoutUsecs = *pTimeoutMsecs * 1000;
|
timeoutUsecs = *pTimeoutMsecs * 1000;
|
||||||
|
@ -624,19 +578,12 @@ pte_osResult pte_osSemaphorePend(pte_osSemaphoreHandle handle, unsigned int *pTi
|
||||||
result = sceKernelWaitSema(handle, 1, pTimeoutUsecs);
|
result = sceKernelWaitSema(handle, 1, pTimeoutUsecs);
|
||||||
|
|
||||||
if (result == SCE_KERNEL_ERROR_OK)
|
if (result == SCE_KERNEL_ERROR_OK)
|
||||||
{
|
return PTE_OS_OK;
|
||||||
osResult = PTE_OS_OK;
|
|
||||||
}
|
|
||||||
else if (result == SCE_KERNEL_ERROR_WAIT_TIMEOUT)
|
|
||||||
{
|
|
||||||
osResult = PTE_OS_TIMEOUT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osResult = PTE_OS_GENERAL_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return osResult;
|
if (result == SCE_KERNEL_ERROR_WAIT_TIMEOUT)
|
||||||
|
return PTE_OS_TIMEOUT;
|
||||||
|
|
||||||
|
return PTE_OS_GENERAL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -739,9 +686,7 @@ pte_osResult pte_osSemaphoreCancellablePend(pte_osSemaphoreHandle semHandle, uns
|
||||||
int pte_osAtomicExchange(int *ptarg, int val)
|
int pte_osAtomicExchange(int *ptarg, int val)
|
||||||
{
|
{
|
||||||
int intc = pspSdkDisableInterrupts();
|
int intc = pspSdkDisableInterrupts();
|
||||||
int origVal;
|
int origVal = *ptarg;
|
||||||
|
|
||||||
origVal = *ptarg;
|
|
||||||
|
|
||||||
*ptarg = val;
|
*ptarg = val;
|
||||||
|
|
||||||
|
@ -754,14 +699,10 @@ int pte_osAtomicExchange(int *ptarg, int val)
|
||||||
int pte_osAtomicCompareExchange(int *pdest, int exchange, int comp)
|
int pte_osAtomicCompareExchange(int *pdest, int exchange, int comp)
|
||||||
{
|
{
|
||||||
int intc = pspSdkDisableInterrupts();
|
int intc = pspSdkDisableInterrupts();
|
||||||
int origVal;
|
int origVal = *pdest;
|
||||||
|
|
||||||
origVal = *pdest;
|
|
||||||
|
|
||||||
if (*pdest == comp)
|
if (*pdest == comp)
|
||||||
{
|
|
||||||
*pdest = exchange;
|
*pdest = exchange;
|
||||||
}
|
|
||||||
|
|
||||||
pspSdkEnableInterrupts(intc);
|
pspSdkEnableInterrupts(intc);
|
||||||
|
|
||||||
|
@ -771,10 +712,8 @@ int pte_osAtomicCompareExchange(int *pdest, int exchange, int comp)
|
||||||
|
|
||||||
int pte_osAtomicExchangeAdd(int volatile* pAddend, int value)
|
int pte_osAtomicExchangeAdd(int volatile* pAddend, int value)
|
||||||
{
|
{
|
||||||
int origVal;
|
|
||||||
int intc = pspSdkDisableInterrupts();
|
int intc = pspSdkDisableInterrupts();
|
||||||
|
int origVal = *pAddend;
|
||||||
origVal = *pAddend;
|
|
||||||
|
|
||||||
*pAddend += value;
|
*pAddend += value;
|
||||||
|
|
||||||
|
@ -819,12 +758,9 @@ int pte_osAtomicIncrement(int *pdest)
|
||||||
|
|
||||||
static pspThreadData *getThreadData(SceUID threadHandle)
|
static pspThreadData *getThreadData(SceUID threadHandle)
|
||||||
{
|
{
|
||||||
pspThreadData *pThreadData;
|
void *pTls = getTlsStructFromThread(threadHandle);
|
||||||
void *pTls;
|
pspThreadData *pThreadData = (pspThreadData *)
|
||||||
|
pteTlsGetValue(pTls, threadDataKey);
|
||||||
pTls = getTlsStructFromThread(threadHandle);
|
|
||||||
|
|
||||||
pThreadData = (pspThreadData *) pteTlsGetValue(pTls, threadDataKey);
|
|
||||||
|
|
||||||
return pThreadData;
|
return pThreadData;
|
||||||
}
|
}
|
||||||
|
@ -834,10 +770,8 @@ static void *getTlsStructFromThread(SceUID thid)
|
||||||
SceKernelThreadInfo thinfo;
|
SceKernelThreadInfo thinfo;
|
||||||
unsigned int ptr;
|
unsigned int ptr;
|
||||||
unsigned int thrNum;
|
unsigned int thrNum;
|
||||||
void *pTls;
|
|
||||||
int numMatches;
|
int numMatches;
|
||||||
|
|
||||||
|
|
||||||
thinfo.size = sizeof(SceKernelThreadInfo);
|
thinfo.size = sizeof(SceKernelThreadInfo);
|
||||||
|
|
||||||
sceKernelReferThreadStatus(thid, &thinfo);
|
sceKernelReferThreadStatus(thid, &thinfo);
|
||||||
|
@ -849,15 +783,9 @@ static void *getTlsStructFromThread(SceUID thid)
|
||||||
* "global". This is a pretty bad hack, but necessary due to lack of TLS on PSP.
|
* "global". This is a pretty bad hack, but necessary due to lack of TLS on PSP.
|
||||||
*/
|
*/
|
||||||
if (numMatches == 2)
|
if (numMatches == 2)
|
||||||
{
|
return (void *) ptr;
|
||||||
pTls = (void *) ptr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pTls = globalTls;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pTls;
|
return globalTls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -868,19 +796,14 @@ static void *getTlsStructFromThread(SceUID thid)
|
||||||
|
|
||||||
pte_osResult pte_osTlsSetValue(unsigned int key, void * value)
|
pte_osResult pte_osTlsSetValue(unsigned int key, void * value)
|
||||||
{
|
{
|
||||||
void *pTls;
|
void *pTls = getTlsStructFromThread(sceKernelGetThreadId());
|
||||||
|
|
||||||
pTls = getTlsStructFromThread(sceKernelGetThreadId());
|
|
||||||
|
|
||||||
return pteTlsSetValue(pTls, key, value);
|
return pteTlsSetValue(pTls, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * pte_osTlsGetValue(unsigned int index)
|
void * pte_osTlsGetValue(unsigned int index)
|
||||||
{
|
{
|
||||||
|
void *pTls = getTlsStructFromThread(sceKernelGetThreadId());
|
||||||
void *pTls;
|
|
||||||
|
|
||||||
pTls = getTlsStructFromThread(sceKernelGetThreadId());
|
|
||||||
|
|
||||||
return (void *) pteTlsGetValue(pTls, index);
|
return (void *) pteTlsGetValue(pTls, index);
|
||||||
|
|
||||||
|
@ -889,9 +812,7 @@ void * pte_osTlsGetValue(unsigned int index)
|
||||||
|
|
||||||
pte_osResult pte_osTlsAlloc(unsigned int *pKey)
|
pte_osResult pte_osTlsAlloc(unsigned int *pKey)
|
||||||
{
|
{
|
||||||
void * pTls;
|
void *pTls = getTlsStructFromThread(sceKernelGetThreadId());
|
||||||
|
|
||||||
pTls = getTlsStructFromThread(sceKernelGetThreadId());
|
|
||||||
|
|
||||||
return pteTlsAlloc(pKey);
|
return pteTlsAlloc(pKey);
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,6 @@ typedef SceUID pte_osMutexHandle;
|
||||||
|
|
||||||
#define OS_IS_HANDLE_VALID(x) ((x) > 0)
|
#define OS_IS_HANDLE_VALID(x) ((x) > 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define OS_MAX_SIMUL_THREADS 10
|
#define OS_MAX_SIMUL_THREADS 10
|
||||||
|
|
||||||
#define OS_DEFAULT_PRIO 11
|
#define OS_DEFAULT_PRIO 11
|
||||||
|
@ -47,12 +44,12 @@ typedef SceUID pte_osMutexHandle;
|
||||||
#define OS_MIN_PRIO 17
|
#define OS_MIN_PRIO 17
|
||||||
#define OS_MAX_PRIO 32
|
#define OS_MAX_PRIO 32
|
||||||
|
|
||||||
//#define HAVE_THREAD_SAFE_ERRNO
|
#if 0
|
||||||
|
#define HAVE_THREAD_SAFE_ERRNO
|
||||||
|
#endif
|
||||||
|
|
||||||
#define POLLING_DELAY_IN_us 100
|
#define POLLING_DELAY_IN_us 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define OS_MAX_SEM_VALUE 254
|
#define OS_MAX_SEM_VALUE 254
|
||||||
|
|
||||||
int PspInterlockedExchange(int *ptarg, int val);
|
int PspInterlockedExchange(int *ptarg, int val);
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
|
|
||||||
#ifndef _OS_SUPPORT_H_
|
#ifndef _OS_SUPPORT_H_
|
||||||
#define _OS_SUPPORT_H_
|
#define _OS_SUPPORT_H_
|
||||||
|
|
||||||
// Platform specific one must be included first
|
/* Platform specific one must be included first */
|
||||||
#include "psp_osal.h"
|
#include "psp_osal.h"
|
||||||
|
|
||||||
#include "pte_generic_osal.h"
|
#include "pte_generic_osal.h"
|
||||||
|
|
||||||
|
#endif /* _OS_SUPPORT_H */
|
||||||
|
|
||||||
#endif // _OS_SUPPORT_H
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <pspsdk.h>
|
#include <pspsdk.h>
|
||||||
#include <pspctrl.h>
|
#include <pspctrl.h>
|
||||||
|
|
||||||
|
|
||||||
PSP_MODULE_INFO("Pthread Test", 0, 1, 1);
|
PSP_MODULE_INFO("Pthread Test", 0, 1, 1);
|
||||||
|
|
||||||
extern void pte_test_main();
|
extern void pte_test_main();
|
||||||
|
@ -24,10 +23,7 @@ int exit_callback(int arg1, int arg2, void *common)
|
||||||
/* Callback thread */
|
/* Callback thread */
|
||||||
int CallbackThread(SceSize args, void *argp)
|
int CallbackThread(SceSize args, void *argp)
|
||||||
{
|
{
|
||||||
|
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
||||||
int cbid;
|
|
||||||
|
|
||||||
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
|
|
||||||
sceKernelRegisterExitCallback(cbid);
|
sceKernelRegisterExitCallback(cbid);
|
||||||
|
|
||||||
sceKernelSleepThreadCB();
|
sceKernelSleepThreadCB();
|
||||||
|
@ -38,13 +34,9 @@ int CallbackThread(SceSize args, void *argp)
|
||||||
/* Sets up the callback thread and returns its thread id */
|
/* Sets up the callback thread and returns its thread id */
|
||||||
int SetupCallbacks(void)
|
int SetupCallbacks(void)
|
||||||
{
|
{
|
||||||
int thid = 0;
|
int thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
|
||||||
|
|
||||||
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
|
|
||||||
if (thid >= 0)
|
if (thid >= 0)
|
||||||
{
|
|
||||||
sceKernelStartThread(thid, 0, 0);
|
sceKernelStartThread(thid, 0, 0);
|
||||||
}
|
|
||||||
|
|
||||||
return thid;
|
return thid;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue