Tactility/TactilityC/Source/tt_semaphore.cpp
Ken Van Hoeylandt c87200a80d
Project restructuring (fixes macOS builds) (#198)
- 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`)
2025-02-01 18:13:20 +01:00

29 lines
736 B
C++

#include "tt_semaphore.h"
#include <Tactility/Semaphore.h>
extern "C" {
#define HANDLE_AS_SEMAPHORE(handle) ((tt::Semaphore*)(handle))
SemaphoreHandle tt_semaphore_alloc(uint32_t maxCount, TickType_t initialCount) {
return new tt::Semaphore(maxCount, initialCount);
}
void tt_semaphore_free(SemaphoreHandle handle) {
delete HANDLE_AS_SEMAPHORE(handle);
}
bool tt_semaphore_acquire(SemaphoreHandle handle, TickType_t timeoutTicks) {
return HANDLE_AS_SEMAPHORE(handle)->acquire(timeoutTicks);
}
bool tt_semaphore_release(SemaphoreHandle handle) {
return HANDLE_AS_SEMAPHORE(handle)->release();
}
uint32_t tt_semaphore_get_count(SemaphoreHandle handle) {
return HANDLE_AS_SEMAPHORE(handle)->getAvailable();
}
}