fixes for semaphore/conditions
#include <hl.h>
+typedef struct _hl_semaphore hl_semaphore;
+typedef struct _hl_condition hl_condition;
+
#if !defined(HL_THREADS)
struct _hl_mutex {
@@ -191,7 +194,7 @@ DEFINE_PRIM(_VOID, mutex_free, _MUTEX);
HL_PRIM hl_semaphore *hl_semaphore_alloc(int value) {
# if !defined(HL_THREADS)
static struct _hl_semaphore null_semaphore = {0};
- return (hl_condition *)&null_semaphore;
+ return (hl_semaphore *)&null_semaphore;
# elif defined(HL_WIN)
hl_semaphore *sem =
(hl_semaphore *)hl_gc_alloc_finalizer(sizeof(hl_semaphore));
@@ -226,6 +229,7 @@ HL_PRIM void hl_semaphore_acquire(hl_semaphore *sem) {
HL_PRIM bool hl_semaphore_try_acquire(hl_semaphore *sem, vdynamic *timeout) {
# if !defined(HL_THREADS)
+ return true;
# elif defined(HL_WIN)
return WaitForSingleObject(sem->sem,
timeout ? (DWORD)((FLOAT)timeout->v.d * 1000.0)
@@ -335,6 +339,7 @@ HL_PRIM void hl_condition_acquire(hl_condition *cond) {
HL_PRIM bool hl_condition_try_acquire(hl_condition *cond) {
# if !defined(HL_THREADS)
+ return true;
# elif defined(HL_WIN)
return (bool)TryEnterCriticalSection(&cond->cs);
# else
@@ -361,9 +366,11 @@ HL_PRIM void hl_condition_wait(hl_condition *cond) {
HL_PRIM bool hl_condition_timed_wait(hl_condition *cond, double timeout) {
# if !defined(HL_THREADS)
+ return true;
# elif defined(HL_WIN)
SleepConditionVariableCS(&cond->cond, &cond->cs,
(DWORD)((FLOAT)timeout * 1000.0));
+ return true;
# else
struct timeval tv;
struct timespec t;
