Skip to content

Commit e10bf8b

Browse files
committed
v.h: Remove stdbool.h dependency on Windows
It was used in the windows portion of the rwlock abstraction, and nowhere else. So just replace bool with char, and true/false with 1/0.
1 parent 03df5ee commit e10bf8b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

include/v.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ int v_rwlock_unlock(v_rwlock *);
194194

195195
// --- decl v_thread (Threading abstraction, pthreads & win32)
196196
#if defined(WINDOWS)
197-
#include <stdbool.h>
198197
#include <Windows.h>
199198
#else
200199
#include <pthread.h>
@@ -598,15 +597,15 @@ int v_cond_broadcast(v_cond *c) {
598597
#if defined(WINDOWS)
599598
struct v_rwlock {
600599
SRWLOCK lock;
601-
bool exclusive;
600+
char exclusive;
602601
};
603602
#endif
604603

605604
v_rwlock *v_rwlock_create(void) {
606605
#if defined(WINDOWS)
607606
v_rwlock *l = malloc(sizeof(*l));
608607
InitializeSRWLock(&l->lock);
609-
l->exclusive = false;
608+
l->exclusive = 0;
610609
return l;
611610
#else
612611
pthread_rwlock_t *l = malloc(sizeof(*l));
@@ -646,7 +645,7 @@ int v_rwlock_write_lock(v_rwlock *l) {
646645
return -1;
647646
#if defined(WINDOWS)
648647
AcquireSRWLockExclusive(&l->lock);
649-
l->exclusive = true;
648+
l->exclusive = 1;
650649
return 0;
651650
#else
652651
return pthread_rwlock_wrlock((pthread_rwlock_t *)l);
@@ -658,7 +657,7 @@ int v_rwlock_unlock(v_rwlock *l) {
658657
return -1;
659658
#if defined(WINDOWS)
660659
if (l->exclusive) {
661-
l->exclusive = false;
660+
l->exclusive = 0;
662661
ReleaseSRWLockExclusive(&l->lock);
663662
} else {
664663
ReleaseSRWLockShared(&l->lock);
@@ -881,7 +880,7 @@ void v_threadpool_destroy(v_threadpool *pool) {
881880
head = next;
882881
}
883882
/* Signal worker threads to stop */
884-
pool->stop_flag = true;
883+
pool->stop_flag = 1;
885884
v_cond_broadcast(pool->work_available);
886885
v_mutex_release(pool->mutex);
887886

0 commit comments

Comments
 (0)