]>
git.proxmox.com Git - libgit2.git/blob - src/win32/pthread.c
2 * Copyright (C) 2009-2012 the libgit2 contributors
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.
10 int pthread_create(pthread_t
*GIT_RESTRICT thread
,
11 const pthread_attr_t
*GIT_RESTRICT
GIT_UNUSED(attr
),
12 void *(*start_routine
)(void*), void *GIT_RESTRICT arg
)
15 *thread
= (pthread_t
) CreateThread(NULL
, 0, (LPTHREAD_START_ROUTINE
)start_routine
, arg
, 0, NULL
);
16 return *thread
? GIT_SUCCESS
: git__throw(GIT_EOSERR
, "Failed to create pthread");
19 int pthread_join(pthread_t thread
, void **value_ptr
)
22 ret
= WaitForSingleObject(thread
, INFINITE
);
24 GetExitCodeThread(thread
, (void*) value_ptr
);
28 int pthread_mutex_init(pthread_mutex_t
*GIT_RESTRICT mutex
,
29 const pthread_mutexattr_t
*GIT_RESTRICT
GIT_UNUSED(mutexattr
))
31 GIT_UNUSED_ARG(mutexattr
);
32 InitializeCriticalSection(mutex
);
36 int pthread_mutex_destroy(pthread_mutex_t
*mutex
)
38 DeleteCriticalSection(mutex
);
42 int pthread_mutex_lock(pthread_mutex_t
*mutex
)
44 EnterCriticalSection(mutex
);
48 int pthread_mutex_unlock(pthread_mutex_t
*mutex
)
50 LeaveCriticalSection(mutex
);
54 int pthread_num_processors_np(void)
59 if (GetProcessAffinityMask(GetCurrentProcess(), &p
, &s
))