Andreas Ericsson | 833e3df | 2008-02-22 20:11:56 -0600 | [diff] [blame] | 1 | #ifndef THREAD_COMPAT_H |
| 2 | #define THREAD_COMPAT_H |
| 3 | |
Junio C Hamano | b361888 | 2010-12-10 10:32:12 -0800 | [diff] [blame] | 4 | #ifndef NO_PTHREADS |
| 5 | #include <pthread.h> |
| 6 | |
Nguyễn Thái Ngọc Duy | 0ec7935 | 2018-10-27 19:29:59 +0200 | [diff] [blame] | 7 | #define HAVE_THREADS 1 |
Andreas Ericsson | 833e3df | 2008-02-22 20:11:56 -0600 | [diff] [blame] | 8 | |
Junio C Hamano | 0c45d25 | 2014-10-13 12:46:14 -0700 | [diff] [blame] | 9 | #else |
| 10 | |
Nguyễn Thái Ngọc Duy | 0ec7935 | 2018-10-27 19:29:59 +0200 | [diff] [blame] | 11 | #define HAVE_THREADS 0 |
| 12 | |
| 13 | /* |
| 14 | * macros instead of typedefs because pthread definitions may have |
| 15 | * been pulled in by some system dependencies even though the user |
| 16 | * wants to disable pthread. |
| 17 | */ |
| 18 | #define pthread_t int |
| 19 | #define pthread_mutex_t int |
| 20 | #define pthread_cond_t int |
| 21 | #define pthread_key_t int |
| 22 | |
| 23 | #define pthread_mutex_init(mutex, attr) dummy_pthread_init(mutex) |
| 24 | #define pthread_mutex_lock(mutex) |
| 25 | #define pthread_mutex_unlock(mutex) |
| 26 | #define pthread_mutex_destroy(mutex) |
| 27 | |
| 28 | #define pthread_cond_init(cond, attr) dummy_pthread_init(cond) |
| 29 | #define pthread_cond_wait(cond, mutex) |
| 30 | #define pthread_cond_signal(cond) |
| 31 | #define pthread_cond_broadcast(cond) |
| 32 | #define pthread_cond_destroy(cond) |
| 33 | |
| 34 | #define pthread_key_create(key, attr) dummy_pthread_init(key) |
| 35 | #define pthread_key_delete(key) |
| 36 | |
| 37 | #define pthread_create(thread, attr, fn, data) \ |
| 38 | dummy_pthread_create(thread, attr, fn, data) |
| 39 | #define pthread_join(thread, retval) \ |
| 40 | dummy_pthread_join(thread, retval) |
| 41 | |
| 42 | #define pthread_setspecific(key, data) |
| 43 | #define pthread_getspecific(key) NULL |
| 44 | |
| 45 | int dummy_pthread_create(pthread_t *pthread, const void *attr, |
| 46 | void *(*fn)(void *), void *data); |
| 47 | int dummy_pthread_join(pthread_t pthread, void **retval); |
| 48 | |
| 49 | int dummy_pthread_init(void *); |
Junio C Hamano | 0c45d25 | 2014-10-13 12:46:14 -0700 | [diff] [blame] | 50 | |
Junio C Hamano | b361888 | 2010-12-10 10:32:12 -0800 | [diff] [blame] | 51 | #endif |
Nguyễn Thái Ngọc Duy | 0ec7935 | 2018-10-27 19:29:59 +0200 | [diff] [blame] | 52 | |
| 53 | int online_cpus(void); |
| 54 | int init_recursive_mutex(pthread_mutex_t*); |
| 55 | |
| 56 | |
Andreas Ericsson | 833e3df | 2008-02-22 20:11:56 -0600 | [diff] [blame] | 57 | #endif /* THREAD_COMPAT_H */ |