diff options
| author | Brent Cook <busterb@gmail.com> | 2019-04-11 07:28:49 -0500 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2019-04-11 07:29:45 -0500 |
| commit | a67ba9f4ad8524c2d0bdd4cae6901ec415332829 (patch) | |
| tree | 41c9b435e09bdb5c5021e78b618189f9c5a2f231 /include/compat/pthread.h | |
| parent | 41f58606c0b5b1d6e3dcf9281af9982f0b5ac5b0 (diff) | |
| download | portable-a67ba9f4ad8524c2d0bdd4cae6901ec415332829.tar.gz portable-a67ba9f4ad8524c2d0bdd4cae6901ec415332829.tar.bz2 portable-a67ba9f4ad8524c2d0bdd4cae6901ec415332829.zip | |
add pthread_mutex* windows compat for libtls
Diffstat (limited to 'include/compat/pthread.h')
| -rw-r--r-- | include/compat/pthread.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/compat/pthread.h b/include/compat/pthread.h index 861c8e1..8b8c3c6 100644 --- a/include/compat/pthread.h +++ b/include/compat/pthread.h | |||
| @@ -3,6 +3,9 @@ | |||
| 3 | * pthread.h compatibility shim | 3 | * pthread.h compatibility shim |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #ifndef LIBCRYPTOCOMPAT_PTHREAD_H | ||
| 7 | #define LIBCRYPTOCOMPAT_PTHREAD_H | ||
| 8 | |||
| 6 | #ifdef _WIN32 | 9 | #ifdef _WIN32 |
| 7 | 10 | ||
| 8 | #include <windows.h> | 11 | #include <windows.h> |
| @@ -52,6 +55,32 @@ pthread_equal(pthread_t t1, pthread_t t2) | |||
| 52 | return t1 == t2; | 55 | return t1 == t2; |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 58 | typedef CRITICAL_SECTION pthread_mutex_t; | ||
| 59 | typedef void pthread_mutexattr_t; | ||
| 60 | |||
| 61 | static inline int | ||
| 62 | pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) | ||
| 63 | { | ||
| 64 | InitializeCriticalSection(mutex); | ||
| 65 | return 0; | ||
| 66 | } | ||
| 67 | |||
| 68 | static inline int | ||
| 69 | pthread_mutex_lock(pthread_mutex_t *mutex) | ||
| 70 | { | ||
| 71 | EnterCriticalSection(mutex); | ||
| 72 | return 0; | ||
| 73 | } | ||
| 74 | |||
| 75 | static inline int | ||
| 76 | pthread_mutex_unlock(pthread_mutex_t *mutex) | ||
| 77 | { | ||
| 78 | LeaveCriticalSection(mutex); | ||
| 79 | return 0; | ||
| 80 | } | ||
| 81 | |||
| 55 | #else | 82 | #else |
| 56 | #include_next <pthread.h> | 83 | #include_next <pthread.h> |
| 57 | #endif | 84 | #endif |
| 85 | |||
| 86 | #endif | ||
