1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 8 #ifndef INCLUDE_win32_thread_h__ 9 #define INCLUDE_win32_thread_h__ 10 11 #include "common.h" 12 13 #if defined (_MSC_VER) 14 # define GIT_RESTRICT __restrict 15 #else 16 # define GIT_RESTRICT __restrict__ 17 #endif 18 19 typedef struct { 20 HANDLE thread; 21 void *(*proc)(void *); 22 void *param; 23 void *result; 24 } git_thread; 25 26 typedef CRITICAL_SECTION git_mutex; 27 typedef HANDLE git_cond; 28 29 typedef struct { void *Ptr; } GIT_SRWLOCK; 30 31 typedef struct { 32 union { 33 GIT_SRWLOCK srwl; 34 CRITICAL_SECTION csec; 35 } native; 36 } git_rwlock; 37 38 int git_threads_init(void); 39 40 int git_thread_create(git_thread *GIT_RESTRICT, 41 void *(*) (void *), 42 void *GIT_RESTRICT); 43 int git_thread_join(git_thread *, void **); 44 size_t git_thread_currentid(void); 45 void git_thread_exit(void *); 46 47 int git_mutex_init(git_mutex *GIT_RESTRICT mutex); 48 int git_mutex_free(git_mutex *); 49 int git_mutex_lock(git_mutex *); 50 int git_mutex_unlock(git_mutex *); 51 52 int git_cond_init(git_cond *); 53 int git_cond_free(git_cond *); 54 int git_cond_wait(git_cond *, git_mutex *); 55 int git_cond_signal(git_cond *); 56 57 int git_rwlock_init(git_rwlock *GIT_RESTRICT lock); 58 int git_rwlock_rdlock(git_rwlock *); 59 int git_rwlock_rdunlock(git_rwlock *); 60 int git_rwlock_wrlock(git_rwlock *); 61 int git_rwlock_wrunlock(git_rwlock *); 62 int git_rwlock_free(git_rwlock *); 63 64 #endif 65