From 1417cb897343a34a2458d1f47e71251c0de75a3e Mon Sep 17 00:00:00 2001 From: Alessandre Laguierce Date: Thu, 20 Mar 2025 16:15:39 +0100 Subject: [PATCH] fix: correctly compile with pthreads --- Makefile | 5 +++-- src/thread/thread.c | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ba70aab..6bb380e 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,9 @@ includes=$(patsubst %,-I%,${src_dirs}) CFLAGS+=-g -O0 ${includes} -fPIC LDFLAGS+= -ifdef _USE_PTHREAD +ifdef USE_PTHREAD LDFLAGS+=-lpthread +CFLAGS+=-DUSE_PTHREAD endif # Tests if the last compilation was with pthread @@ -85,7 +86,7 @@ build: ${bins_target} ${build_dir}/libthread.so ${build_dir}/libthread.a .PHONY: pthreads pthreads: - $(MAKE) _USE_PTHREAD=. ${pthread_targets} + $(MAKE) USE_PTHREAD=. ${pthread_targets} touch .lastpthread .PHONY: check diff --git a/src/thread/thread.c b/src/thread/thread.c index 496c93e..2b24486 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -1,3 +1,5 @@ +#ifndef USE_PTHREAD + #include "thread.h" #include "debug.h" #include "pthread.h" @@ -42,4 +44,4 @@ int thread_mutex_unlock(thread_mutex_t *mutex) { return pthread_mutex_unlock((pthread_mutex_t *)mutex); } - +#endif