RetroArch
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <pspkerror.h>
#include "pte_osal.h"
#include "../../pthread.h"
#include "../helper/tls-helper.h"
Classes | |
struct | pspThreadData |
Macros | |
#define | MAX_PSP_UID 2048 /* SWAG */ |
#define | DEFAULT_STACK_SIZE_BYTES 4096 |
#define | PSP_MAX_TLS 32 |
#define | PSP_DEBUG(x) printf(x) |
Typedefs | |
typedef struct pspThreadData | pspThreadData |
Variables | |
static unsigned int | threadDataKey |
static void * | globalTls |
#define DEFAULT_STACK_SIZE_BYTES 4096 |
#define MAX_PSP_UID 2048 /* SWAG */ |
#define PSP_MAX_TLS 32 |
typedef struct pspThreadData pspThreadData |
int ftime | ( | struct timeb * | tb | ) |
|
static |
int pspStubThreadEntry | ( | unsigned int | argc, |
void * | argv | ||
) |
int pte_osAtomicCompareExchange | ( | int * | pdest, |
int | exchange, | ||
int | comp | ||
) |
Performs an atomic compare-and-exchange oepration on the specified value. That is:
pdest | Pointer to the destination value. |
exchange | Exchange value (value to set destination to if destination == comparand) |
comp | The value to compare to destination. |
int pte_osAtomicDecrement | ( | int * | pdest | ) |
Decrements the destination.
pdest | Destination value to decrement |
int pte_osAtomicExchange | ( | int * | pTarg, |
int | val | ||
) |
int pte_osAtomicExchangeAdd | ( | int volatile * | pdest, |
int | value | ||
) |
int pte_osAtomicIncrement | ( | int * | pdest | ) |
pte_osResult pte_osInit | ( | void | ) |
Provides a hook for the OSAL to implement any OS specific initialization. This is guaranteed to be called before any other OSAL function.
pte_osResult pte_osMutexCreate | ( | pte_osMutexHandle * | pHandle | ) |
Creates a mutex
pHandle | Set to the handle of the newly created mutex. |
pte_osResult pte_osMutexDelete | ( | pte_osMutexHandle | handle | ) |
Deletes a mutex and frees any associated resources.
handle | Handle of mutex to delete. |
pte_osResult pte_osMutexLock | ( | pte_osMutexHandle | handle | ) |
Locks the mutex
handle | Handle of mutex to lock. |
pte_osResult pte_osMutexTimedLock | ( | pte_osMutexHandle | handle, |
unsigned int | timeoutMsecs | ||
) |
Locks the mutex, returning after timeoutMsecs
if the resources is not available. Can be used for polling mutex by using timeoutMsecs
of zero.
handle | Handle of mutex to lock. |
timeoutMsecs | Number of milliseconds to wait for resource before returning. |
pte_osResult pte_osMutexUnlock | ( | pte_osMutexHandle | handle | ) |
Unlocks the mutex
handle | Handle of mutex to unlock |
pte_osResult pte_osSemaphoreCancellablePend | ( | pte_osSemaphoreHandle | handle, |
unsigned int * | pTimeout | ||
) |
Acquire a semaphore, returning after timeoutMsecs
if the semaphore is not available. Can be used for polling a semaphore by using timeoutMsecs
of zero. Call must return immediately if pte_osThreadCancel() is called on the thread waiting for the semaphore.
handle | Handle of semaphore to acquire. |
pTimeout | Pointer to the number of milliseconds to wait to acquire the semaphore before returning. If set to NULL, wait forever. |
pte_osResult pte_osSemaphoreCreate | ( | int | initialValue, |
pte_osSemaphoreHandle * | pHandle | ||
) |
Creates a semaphore
initialValue | Initial value of the semaphore |
pHandle | Set to the handle of the newly created semaphore. |
pte_osResult pte_osSemaphoreDelete | ( | pte_osSemaphoreHandle | handle | ) |
Deletes a semaphore and frees any associated resources.
handle | Handle of semaphore to delete. |
pte_osResult pte_osSemaphorePend | ( | pte_osSemaphoreHandle | handle, |
unsigned int * | pTimeout | ||
) |
Acquire a semaphore, returning after timeoutMsecs
if the semaphore is not available. Can be used for polling a semaphore by using timeoutMsecs
of zero.
handle | Handle of semaphore to acquire. |
pTimeout | Pointer to the number of milliseconds to wait to acquire the semaphore before returning. If set to NULL, wait forever. |
pte_osResult pte_osSemaphorePost | ( | pte_osSemaphoreHandle | handle, |
int | count | ||
) |
Posts to the semaphore
handle | Semaphore to release |
count | Amount to increment the semaphore by. |
pte_osResult pte_osThreadCancel | ( | pte_osThreadHandle | threadHandle | ) |
Cancels the specified thread. This should cause pte_osSemaphoreCancellablePend() and for pte_osThreadCheckCancel() to return PTE_OS_INTERRUPTED
.
threadHandle | handle to the thread to cancel. |
pte_osResult pte_osThreadCheckCancel | ( | pte_osThreadHandle | threadHandle | ) |
Check if pte_osThreadCancel() has been called on the specified thread.
threadHandle | handle of thread to check the state of. |
pte_osResult pte_osThreadCreate | ( | pte_osThreadEntryPoint | entryPoint, |
int | stackSize, | ||
int | initialPriority, | ||
void * | argv, | ||
pte_osThreadHandle * | ppte_osThreadHandle | ||
) |
Creates a new thread. The thread must be started in a suspended state - it will be explicitly started when pte_osThreadStart() is called.
entryPoint | Entry point to the new thread. |
stackSize | The initial stack size, in bytes. Note that this can be considered a minimum - for instance if the OS requires a larger stack space than what the caller specified. |
initialPriority | The priority that the new thread should be initially set to. |
argv | Parameter to pass to the new thread. |
ppte_osThreadHandle | set to the handle of the new thread. |
pte_osResult pte_osThreadDelete | ( | pte_osThreadHandle | handle | ) |
Frees resources associated with the specified thread. This is called after the thread has terminated and is no longer needed (e.g. after pthread_join returns). This call will always be made from a different context than that of the target thread.
void pte_osThreadExit | ( | ) |
Causes the current thread to stop executing.
pte_osResult pte_osThreadExitAndDelete | ( | pte_osThreadHandle | handle | ) |
Frees resources associated with the specified thread and then causes the thread to exit. This is called after the thread has terminated and is no longer needed (e.g. after pthread_join returns). This call will always be made from the context of the target thread.
int pte_osThreadGetDefaultPriority | ( | ) |
Returns the priority that should be used if the caller to pthread_create doesn't explicitly set one.
pte_osThreadHandle pte_osThreadGetHandle | ( | void | ) |
Returns the handle of the currently executing thread.
int pte_osThreadGetMaxPriority | ( | ) |
Returns the maximum allowable priority
int pte_osThreadGetMinPriority | ( | ) |
Returns the minimum allowable priority
int pte_osThreadGetPriority | ( | pte_osThreadHandle | threadHandle | ) |
Returns the priority of the specified thread.
pte_osResult pte_osThreadSetPriority | ( | pte_osThreadHandle | threadHandle, |
int | newPriority | ||
) |
Sets the priority of the specified thread.
void pte_osThreadSleep | ( | unsigned int | msecs | ) |
Causes the current thread to sleep for the specified number of milliseconds.
pte_osResult pte_osThreadStart | ( | pte_osThreadHandle | osThreadHandle | ) |
Starts executing the specified thread.
osThreadHandle | handle of the thread to start. |
pte_osResult pte_osThreadWaitForEnd | ( | pte_osThreadHandle | threadHandle | ) |
Waits for the specified thread to end. If the thread has already terminated, this returns immediately.
threadHandle | Handle fo thread to wait for. |
pte_osResult pte_osTlsAlloc | ( | unsigned int * | pKey | ) |
Allocates a new TLS key.
pKey | On success will be set to the newly allocated key. |
pte_osResult pte_osTlsFree | ( | unsigned int | key | ) |
Frees the specified TLS key.
index | TLS key to free |
void* pte_osTlsGetValue | ( | unsigned int | key | ) |
Retrieves the thread specific value for the specified key for the currently executing thread. If a value has not been set for this key, NULL should be returned (i.e. TLS values default to NULL).
index | The TLS key for the value. |
key
for the current thread. pte_osResult pte_osTlsSetValue | ( | unsigned int | key, |
void * | value | ||
) |
Sets the thread specific value for the specified key for the currently executing thread.
index | The TLS key for the value. |
value | The value to save |
|
static |
|
static |