Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static uint32_t thread_wrap_up(struct pthreadpool* threadpool,
return curr_active_threads;
}

static void* thread_main(void* arg);
static pthreadpool_thread_return_t thread_main(void* arg);

static void ensure_num_threads(struct pthreadpool* threadpool,
uint32_t thread_id) {
Expand Down Expand Up @@ -476,7 +476,7 @@ static void ensure_num_threads(struct pthreadpool* threadpool,
}
}

static void* thread_main(void* arg) {
static pthreadpool_thread_return_t thread_main(void* arg) {
// Unpack the argument, i.e. extract the pointer to the `pthreadpool` from the
// provided pointer to this thread's `thread_info`.
struct thread_info* thread = (struct thread_info*)arg;
Expand Down Expand Up @@ -558,7 +558,7 @@ static void* thread_main(void* arg) {
// Release our hold on the threadpool.
pthreadpool_release(threadpool);

return NULL;
return 0;
}

static size_t get_num_cpus() {
Expand Down
22 changes: 13 additions & 9 deletions src/threadpool-atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
typedef pthread_t pthreadpool_thread_t;
typedef pthread_mutex_t pthreadpool_mutex_t;
typedef pthread_cond_t pthreadpool_cond_t;
typedef void* pthreadpool_thread_return_t;
static inline void pthreadpool_mutex_init(pthreadpool_mutex_t* mutex) {
pthread_mutex_init(mutex, NULL);
}
Expand Down Expand Up @@ -84,18 +85,20 @@ static inline void pthreadpool_cond_signal(pthreadpool_cond_t* cond) {
static inline void pthreadpool_cond_broadcast(pthreadpool_cond_t* cond) {
pthread_cond_broadcast(cond);
}
static inline void pthreadpool_thread_create(pthreadpool_thread_t* thread,
void*(fun)(void*), void* arg) {
static inline void pthreadpool_thread_create(
pthreadpool_thread_t* thread, pthreadpool_thread_return_t(fun)(void*),
void* arg) {
pthread_create(thread, NULL, fun, arg);
}
static inline void pthreadpool_thread_join(pthreadpool_thread_t thread,
void* return_value) {
pthread_join(thread, (void**)return_value);
static inline void pthreadpool_thread_join(
pthreadpool_thread_t thread, pthreadpool_thread_return_t* return_value) {
pthread_join(thread, return_value);
}
#else
typedef thrd_t pthreadpool_thread_t;
typedef mtx_t pthreadpool_mutex_t;
typedef cnd_t pthreadpool_cond_t;
typedef int pthreadpool_thread_return_t;
static inline void pthreadpool_mutex_init(pthreadpool_mutex_t* mutex) {
mtx_init(mutex, mtx_plain);
}
Expand Down Expand Up @@ -124,12 +127,13 @@ static inline void pthreadpool_cond_signal(pthreadpool_cond_t* cond) {
static inline void pthreadpool_cond_broadcast(pthreadpool_cond_t* cond) {
cnd_broadcast(cond);
}
static inline void pthreadpool_thread_create(pthreadpool_thread_t* thread,
void*(fun)(void*), void* arg) {
static inline void pthreadpool_thread_create(
pthreadpool_thread_t* thread, pthreadpool_thread_return_t(fun)(void*),
void* arg) {
thrd_create(thread, fun, arg);
}
static inline void pthreadpool_thread_join(pthreadpool_thread_t thread,
void* return_value) {
static inline void pthreadpool_thread_join(
pthreadpool_thread_t thread, pthreadpool_thread_return_t* return_value) {
thrd_join(thread, return_value);
}
#endif // PTHREADPOOL_USE_PTHREADS
Expand Down
Loading