- Create `Include/` folder for all main projects - Fix some issues here and there (found while moving things) - All includes are now in `Tactility/` subfolder and must be included with that prefix. This fixes issues with clashing POSIX headers (e.g. `<semaphore.h>` versus Tactility's `Semaphore.h`)
31 lines
778 B
C++
31 lines
778 B
C++
#include "tt_mutex.h"
|
|
#include <Tactility/Mutex.h>
|
|
|
|
extern "C" {
|
|
|
|
#define HANDLE_AS_MUTEX(handle) ((tt::Mutex*)(handle))
|
|
|
|
MutexHandle tt_mutex_alloc(enum TtMutexType type) {
|
|
switch (type) {
|
|
case TtMutexType::MUTEX_TYPE_NORMAL:
|
|
return new tt::Mutex(tt::Mutex::Type::Normal);
|
|
case TtMutexType::MUTEX_TYPE_RECURSIVE:
|
|
return new tt::Mutex(tt::Mutex::Type::Recursive);
|
|
default:
|
|
tt_crash("Type not supported");
|
|
}
|
|
}
|
|
|
|
void tt_mutex_free(MutexHandle handle) {
|
|
delete HANDLE_AS_MUTEX(handle);
|
|
}
|
|
|
|
bool tt_mutex_lock(MutexHandle handle, TickType_t timeout) {
|
|
return HANDLE_AS_MUTEX(handle)->lock((TickType_t)timeout);
|
|
}
|
|
|
|
bool tt_mutex_unlock(MutexHandle handle) {
|
|
return HANDLE_AS_MUTEX(handle)->unlock();
|
|
}
|
|
|
|
} |