Add initial implementation of threads/mutexes/semaphores/cvs/spinlocks

Added initial implementation (or wrapper) of the threading library.
It's rather basic, but should work for most of the tasks.

Unfortunately, spinlock implementation relies on GCC/Clang compiler
built-ins (or in-worst-case-scenario on Win32 - InterlockExchange).
In the future, I should revisit this code and fix/reimplement some stuff
(or add support for Windows XP).
This commit is contained in:
2025-03-02 23:18:23 +03:00
parent 2ca6a3e316
commit d403d41f2c
21 changed files with 1492 additions and 9 deletions

View File

@@ -0,0 +1,51 @@
#include "Thread.h"
#include <BH/Thread.h>
BH_Semaphore *BH_SemaphoreNew(int value)
{
BH_UNUSED(value);
return NULL;
}
void BH_SemaphoreFree(BH_Semaphore *semaphore)
{
BH_UNUSED(semaphore);
}
int BH_SemaphorePost(BH_Semaphore *semaphore)
{
BH_UNUSED(semaphore);
return BH_NOIMPL;
}
int BH_SemaphoreWait(BH_Semaphore *semaphore)
{
BH_UNUSED(semaphore);
return BH_NOIMPL;
}
int BH_SemaphoreWaitTry(BH_Semaphore *semaphore)
{
BH_UNUSED(semaphore);
return BH_NOIMPL;
}
int BH_SemaphoreWaitFor(BH_Semaphore *semaphore,
uint32_t timeout)
{
BH_UNUSED(semaphore);
BH_UNUSED(timeout);
return BH_NOIMPL;
}