git_mutex_init(&p[i].mutex);
git_cond_init(&p[i].cond);
- ret = git_thread_create(&p[i].thread, NULL,
+ ret = git_thread_create(&p[i].thread,
threaded_find_deltas, &p[i]);
if (ret) {
giterr_set(GITERR_THREAD, "unable to create thread");
#ifdef GIT_THREADS
#if !defined(GIT_WIN32)
-
-typedef struct {
- pthread_t thread;
-} git_thread;
-
-#define git_thread_create(git_thread_ptr, attr, start_routine, arg) \
- pthread_create(&(git_thread_ptr)->thread, attr, start_routine, arg)
-#define git_thread_join(git_thread_ptr, status) \
- pthread_join((git_thread_ptr)->thread, status)
-
+# include "unix/pthread.h"
#endif
/* Pthreads Mutex */
#else
#define git_thread unsigned int
-#define git_thread_create(thread, attr, start_routine, arg) 0
+#define git_thread_create(thread, start_routine, arg) 0
#define git_thread_join(id, status) (void)0
/* Pthreads Mutex */
--- /dev/null
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_unix_pthread_h__
+#define INCLUDE_unix_pthread_h__
+
+typedef struct {
+ pthread_t thread;
+} git_thread;
+
+#define git_thread_create(git_thread_ptr, start_routine, arg) \
+ pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
+#define git_thread_join(git_thread_ptr, status) \
+ pthread_join((git_thread_ptr)->thread, status)
+
+#endif /* INCLUDE_unix_pthread_h__ */
* void pointer. This requires the indirection. */
static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
{
- git_win32_thread *thread = lpParameter;
+ git_thread *thread = lpParameter;
thread->result = thread->proc(thread->param);
return CLEAN_THREAD_EXIT;
}
-int git_win32__thread_create(
- git_win32_thread *GIT_RESTRICT thread,
- const pthread_attr_t *GIT_RESTRICT attr,
+int git_thread_create(
+ git_thread *GIT_RESTRICT thread,
void *(*start_routine)(void*),
void *GIT_RESTRICT arg)
{
- GIT_UNUSED(attr);
-
thread->result = NULL;
thread->param = arg;
thread->proc = start_routine;
return thread->thread ? 0 : -1;
}
-int git_win32__thread_join(
- git_win32_thread *thread,
+int git_thread_join(
+ git_thread *thread,
void **value_ptr)
{
DWORD exit;
void *(*proc)(void *);
void *param;
void *result;
-} git_win32_thread;
+} git_thread;
typedef int pthread_mutexattr_t;
typedef int pthread_condattr_t;
#define PTHREAD_MUTEX_INITIALIZER {(void*)-1}
-int git_win32__thread_create(
- git_win32_thread *GIT_RESTRICT,
- const pthread_attr_t *GIT_RESTRICT,
+int git_thread_create(git_thread *GIT_RESTRICT,
void *(*) (void *),
void *GIT_RESTRICT);
-
-int git_win32__thread_join(
- git_win32_thread *,
- void **);
-
-#ifdef GIT_THREADS
-
-typedef git_win32_thread git_thread;
-
-#define git_thread_create(git_thread_ptr, attr, start_routine, arg) \
- git_win32__thread_create(git_thread_ptr, attr, start_routine, arg)
-#define git_thread_join(git_thread_ptr, status) \
- git_win32__thread_join(git_thread_ptr, status)
-
-#endif
+int git_thread_join(git_thread *, void **);
int pthread_mutex_init(
pthread_mutex_t *GIT_RESTRICT mutex,
fn = (th & 1) ? cache_parsed : cache_raw;
#ifdef GIT_THREADS
- cl_git_pass(git_thread_create(&t[th], NULL, fn, data));
+ cl_git_pass(git_thread_create(&t[th], fn, data));
#else
cl_assert(fn(data) == data);
git__free(data);
data[th] = th;
#ifdef GIT_THREADS
cl_git_pass(
- git_thread_create(&t[th], NULL, cache_quick, &data[th]));
+ git_thread_create(&t[th], cache_quick, &data[th]));
#else
cl_assert(cache_quick(&data[th]) == &data[th]);
#endif
for (t = 0; t < THREADS; ++t) {
id[t] = t;
#ifdef GIT_THREADS
- cl_git_pass(git_thread_create(&th[t], NULL, iterate_refs, &id[t]));
+ cl_git_pass(git_thread_create(&th[t], iterate_refs, &id[t]));
#else
th[t] = t;
iterate_refs(&id[t]);
* for now by just running on a single thread...
*/
/* #ifdef GIT_THREADS */
-/* cl_git_pass(git_thread_create(&th[t], NULL, fn, &id[t])); */
+/* cl_git_pass(git_thread_create(&th[t], fn, &id[t])); */
/* #else */
fn(&id[t]);
/* #endif */
for (t = 0; t < THREADS; ++t) {
id[t] = t;
- cl_git_pass(git_thread_create(&th[t], NULL, iterate_refs, &id[t]));
+ cl_git_pass(git_thread_create(&th[t], iterate_refs, &id[t]));
}
for (t = 0; t < THREADS; ++t) {
for (t = 0; t < threads; ++t) {
id[t] = t;
#ifdef GIT_THREADS
- cl_git_pass(git_thread_create(&th[t], NULL, func, &id[t]));
+ cl_git_pass(git_thread_create(&th[t], func, &id[t]));
#else
cl_assert(func(&id[t]) == &id[t]);
#endif