-
-
Save t-mat/f07d0450157ea8abffad51821b0d951b to your computer and use it in GitHub Desktop.
[lz4] support <threads.h>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ #if 0 | |
# include <pthread.h> /* pthread_* */ | |
+ #else | |
+ # include <threads.h> /* thrd_*, mtx_*, cnd_* */ | |
+ # define pthread_t thrd_t | |
+ # define pthread_create thrd_create | |
+ # define pthread_join thrd_join | |
+ # define pthread_mutex_t mtx_t | |
+ # define pthread_mutex_init mtx_init | |
+ # define pthread_mutex_destroy mtx_destroy | |
+ # define pthread_mutex_lock mtx_lock | |
+ # define pthread_mutex_unlock mtx_unlock | |
+ # define pthread_cond_t cnd_t | |
+ # define pthread_cond_init cnd_init | |
+ # define pthread_cond_destroy cnd_destroy | |
+ # define pthread_cond_wait cnd_wait | |
+ # define pthread_cond_signal cnd_signal | |
+ # define pthread_cond_broadcast cnd_broadcast | |
+ #endif | |
- static void* TPOOL_thread(void* opaque); | |
+ static int TPOOL_thread(void* opaque); | |
TPOOL_ctx* TPOOL_create(int nbThreads, int queueSize) | |
{ | |
... | |
{ int error = 0; | |
- error |= pthread_mutex_init(&ctx->queueMutex, NULL); | |
- error |= pthread_cond_init(&ctx->queuePushCond, NULL); | |
- error |= pthread_cond_init(&ctx->queuePopCond, NULL); | |
+ error |= pthread_mutex_init(&ctx->queueMutex, mtx_plain); | |
+ error |= pthread_cond_init(&ctx->queuePushCond); | |
+ error |= pthread_cond_init(&ctx->queuePopCond); | |
for (i = 0; i < nbThreads; ++i) { | |
- if (pthread_create(&ctx->threads[i], NULL, &TPOOL_thread, ctx)) { | |
+ if (pthread_create(&ctx->threads[i], &TPOOL_thread, ctx)) { | |
- static void* TPOOL_thread(void* opaque) { | |
+ static int TPOOL_thread(void* opaque) { | |
- if (!ctx) { return NULL; } | |
+ if (!ctx) { return 0; } | |
- return opaque; | |
+ return 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another patch