Sha256: cab2fb8b9f977fcf1810056e4941870e6a57fd4d7574bd42b99162cd25c480c7

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

/*
 * Copyright (C) 2009-2012 the libgit2 contributors
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */

#include "pthread.h"

int pthread_create(
	pthread_t *GIT_RESTRICT thread,
	const pthread_attr_t *GIT_RESTRICT attr,
	void *(*start_routine)(void*),
	void *GIT_RESTRICT arg)
{
	GIT_UNUSED(attr);
	*thread = (pthread_t) CreateThread(
		NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, arg, 0, NULL);
	return *thread ? 0 : -1;
}

int pthread_join(pthread_t thread, void **value_ptr)
{
	int ret;
	ret = WaitForSingleObject(thread, INFINITE);
	if (ret && value_ptr)
		GetExitCodeThread(thread, (void*) value_ptr);
	return -(!!ret);
}

int pthread_mutex_init(pthread_mutex_t *GIT_RESTRICT mutex,
						const pthread_mutexattr_t *GIT_RESTRICT mutexattr)
{
	GIT_UNUSED(mutexattr);
	InitializeCriticalSection(mutex);
	return 0;
}

int pthread_mutex_destroy(pthread_mutex_t *mutex)
{
	DeleteCriticalSection(mutex);
	return 0;
}

int pthread_mutex_lock(pthread_mutex_t *mutex)
{
	EnterCriticalSection(mutex);
	return 0;
}

int pthread_mutex_unlock(pthread_mutex_t *mutex)
{
	LeaveCriticalSection(mutex);
	return 0;
}

int pthread_num_processors_np(void)
{
	DWORD_PTR p, s;
	int n = 0;

	if (GetProcessAffinityMask(GetCurrentProcess(), &p, &s))
		for (; p; p >>= 1)
			n += p&1;

	return n ? n : 1;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rugged-0.17.0.b6 vendor/libgit2/src/win32/pthread.c
rugged-0.17.0b2 ext/rugged/vendor/libgit2-dist/src/win32/pthread.c
rugged-0.17.0b1 ext/rugged/vendor/libgit2-dist/src/win32/pthread.c