[ntpsec commit] Remove the remainder of the ISC mutex/ threads layer in favor of ANSI pthreads.

Eric S. Raymond esr at ntpsec.org
Tue Sep 29 09:18:39 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    7948d6dac8d6bae9ce1a99c42eb9b7539a1a4945
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=7948d6dac8d6bae9ce1a99c42eb9b7539a1a4945

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Tue Sep 29 05:17:34 2015 -0400

Remove the remainder of the ISC mutex/threads layer in favor of ANSI pthreads.

---

 lib/isc/pthreads/condition.c             |  67 --------
 lib/isc/pthreads/include/isc/condition.h |  58 -------
 lib/isc/pthreads/include/isc/thread.h    |  55 -------
 lib/isc/pthreads/thread.c                |  71 ---------
 lib/isc/win32/condition.c                | 258 -------------------------------
 lib/isc/win32/include/isc/condition.h    |  64 --------
 lib/isc/win32/include/isc/thread.h       |  95 ------------
 lib/isc/win32/thread.c                   |  86 -----------
 lib/isc/wscript                          |   8 +-
 9 files changed, 1 insertion(+), 761 deletions(-)

diff --git a/lib/isc/pthreads/condition.c b/lib/isc/pthreads/condition.c
deleted file mode 100644
index 77c9852..0000000
--- a/lib/isc/pthreads/condition.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*! \file */
-
-#include <config.h>
-
-#include <errno.h>
-#include <string.h>
-
-#include <isc/condition.h>
-#include <isc/msgs.h>
-#include <isc/time.h>
-#include <isc/util.h>
-
-isc_result_t
-isc_condition_waituntil(isc_condition_t *c, pthread_mutex_t *m, isc_time_t *t) {
-	int presult;
-	isc_result_t result;
-	struct timespec ts;
-	char strbuf[1024];
-
-	REQUIRE(c != NULL && m != NULL && t != NULL);
-
-	/*
-	 * POSIX defines a timespec's tv_sec as time_t.
-	 */
-	result = isc_time_secondsastimet(t, &ts.tv_sec);
-	if (result != ISC_R_SUCCESS)
-		return (result);
-
-	/*!
-	 * POSIX defines a timespec's tv_nsec as long.  isc_time_nanoseconds
-	 * ensures its return value is < 1 billion, which will fit in a long.
-	 */
-	ts.tv_nsec = (long)isc_time_nanoseconds(t);
-
-	do {
-		presult = pthread_cond_timedwait(c, m, &ts);
-		if (presult == 0)
-			return (ISC_R_SUCCESS);
-		if (presult == ETIMEDOUT)
-			return (ISC_R_TIMEDOUT);
-	} while (presult == EINTR);
-
-	ISC_IGNORE(strerror_r(presult, strbuf, sizeof(strbuf)));
-	UNEXPECTED_ERROR(__FILE__, __LINE__,
-			 "pthread_cond_timedwait() %s %s",
-			 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
-					ISC_MSG_RETURNED, "returned"),
-			 strbuf);
-	return (ISC_R_UNEXPECTED);
-}
diff --git a/lib/isc/pthreads/include/isc/condition.h b/lib/isc/pthreads/include/isc/condition.h
deleted file mode 100644
index 281509f..0000000
--- a/lib/isc/pthreads/include/isc/condition.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef GUARD_ISC_CONDITION_H
-#define GUARD_ISC_CONDITION_H 1
-
-/*! \file */
-
-#include <pthread.h>
-
-#include <isc/lang.h>
-#include <isc/result.h>
-#include <isc/types.h>
-
-typedef pthread_cond_t isc_condition_t;
-
-#define isc_condition_init(cp) \
-	((pthread_cond_init((cp), NULL) == 0) ? \
-	 ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-
-#define isc_condition_wait(cp, mp) \
-	((pthread_cond_wait((cp), (mp)) == 0) ? \
-	 ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-
-#define isc_condition_signal(cp) \
-	((pthread_cond_signal((cp)) == 0) ? \
-	 ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-
-#define isc_condition_broadcast(cp) \
-	((pthread_cond_broadcast((cp)) == 0) ? \
-	 ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-
-#define isc_condition_destroy(cp) \
-	((pthread_cond_destroy((cp)) == 0) ? \
-	 ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-
-ISC_LANG_BEGINDECLS
-
-isc_result_t
-isc_condition_waituntil(isc_condition_t *, pthread_mutex_t *, isc_time_t *);
-
-ISC_LANG_ENDDECLS
-
-#endif /* GUARD_ISC_CONDITION_H */
diff --git a/lib/isc/pthreads/include/isc/thread.h b/lib/isc/pthreads/include/isc/thread.h
deleted file mode 100644
index 35013ba..0000000
--- a/lib/isc/pthreads/include/isc/thread.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef GUARD_ISC_THREAD_H
-#define GUARD_ISC_THREAD_H 1
-
-/*! \file */
-
-#include <pthread.h>
-
-#include <isc/lang.h>
-#include <isc/result.h>
-
-ISC_LANG_BEGINDECLS
-
-typedef pthread_t isc_thread_t;
-typedef void * isc_threadresult_t;
-typedef void * isc_threadarg_t;
-typedef isc_threadresult_t (*isc_threadfunc_t)(isc_threadarg_t);
-typedef pthread_key_t isc_thread_key_t;
-
-isc_result_t
-isc_thread_create(isc_threadfunc_t, isc_threadarg_t, isc_thread_t *);
-
-/* XXX We could do fancier error handling... */
-
-#define isc_thread_join(t, rp) \
-	((pthread_join((t), (rp)) == 0) ? \
-	 ISC_R_SUCCESS : ISC_R_UNEXPECTED)
-
-#define isc_thread_self \
-	(unsigned long)pthread_self
-
-#define isc_thread_key_create pthread_key_create
-#define isc_thread_key_getspecific pthread_getspecific
-#define isc_thread_key_setspecific pthread_setspecific
-#define isc_thread_key_delete pthread_key_delete
-
-ISC_LANG_ENDDECLS
-
-#endif /* GUARD_ISC_THREAD_H */
diff --git a/lib/isc/pthreads/thread.c b/lib/isc/pthreads/thread.c
deleted file mode 100644
index 7ce998f..0000000
--- a/lib/isc/pthreads/thread.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 2000, 2001, 2003  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: thread.c,v 1.17 2007/06/19 23:47:18 tbox Exp $ */
-
-/*! \file */
-
-#include <config.h>
-
-#include <isc/thread.h>
-#include <isc/util.h>
-
-#ifndef THREAD_MINSTACKSIZE
-#define THREAD_MINSTACKSIZE		(64U * 1024)
-#endif
-
-isc_result_t
-isc_thread_create(isc_threadfunc_t func, isc_threadarg_t arg,
-		  isc_thread_t *thread)
-{
-	pthread_attr_t attr;
-#if defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE) && \
-    defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE)
-	size_t stacksize;
-#endif
-	int ret;
-
-	pthread_attr_init(&attr);
-
-#if defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE) && \
-    defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE)
-	ret = pthread_attr_getstacksize(&attr, &stacksize);
-	if (ret != 0)
-		return (ISC_R_UNEXPECTED);
-
-	if (stacksize < THREAD_MINSTACKSIZE) {
-		ret = pthread_attr_setstacksize(&attr, THREAD_MINSTACKSIZE);
-		if (ret != 0)
-			return (ISC_R_UNEXPECTED);
-	}
-#endif
-
-#if defined(PTHREAD_SCOPE_SYSTEM) && defined(NEED_PTHREAD_SCOPE_SYSTEM)
-	ret = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
-	if (ret != 0)
-		return (ISC_R_UNEXPECTED);
-#endif
-
-	ret = pthread_create(thread, &attr, func, arg);
-	if (ret != 0)
-		return (ISC_R_UNEXPECTED);
-
-	pthread_attr_destroy(&attr);
-
-	return (ISC_R_SUCCESS);
-}
-
diff --git a/lib/isc/win32/condition.c b/lib/isc/win32/condition.c
deleted file mode 100644
index 16b4421..0000000
--- a/lib/isc/win32/condition.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: condition.c,v 1.23 2007/06/18 23:47:49 tbox Exp $ */
-
-#include <config.h>
-
-#include <isc/condition.h>
-#include <isc/assertions.h>
-#include <isc/util.h>
-#include <isc/thread.h>
-#include <isc/time.h>
-
-#define LSIGNAL		0
-#define LBROADCAST	1
-
-isc_result_t
-isc_condition_init(isc_condition_t *cond) {
-	HANDLE h;
-
-	REQUIRE(cond != NULL);
-
-	cond->waiters = 0;
-	/*
-	 * This handle is shared across all threads
-	 */
-	h = CreateEvent(NULL, FALSE, FALSE, NULL);
-	if (h == NULL) {
-		/* XXX */
-		return (ISC_R_UNEXPECTED);
-	}
-	cond->events[LSIGNAL] = h;
-
-	/*
-	 * The threadlist will hold the actual events needed
-	 * for the wait condition
-	 */
-	ISC_LIST_INIT(cond->threadlist);
-
-	return (ISC_R_SUCCESS);
-}
-
-/*
- * Add the thread to the threadlist along with the required events
- */
-static isc_result_t
-register_thread(unsigned long thrd, isc_condition_t *gblcond,
-		isc_condition_thread_t **localcond)
-{
-	HANDLE hc;
-	isc_condition_thread_t *newthread;
-
-	REQUIRE(localcond != NULL && *localcond == NULL);
-
-	newthread = malloc(sizeof(isc_condition_thread_t));
-	if (newthread == NULL)
-		return (ISC_R_NOMEMORY);
-
-	/*
-	 * Create the thread-specific handle
-	 */
-	hc = CreateEvent(NULL, FALSE, FALSE, NULL);
-	if (hc == NULL) {
-		free(newthread);
-		return (ISC_R_UNEXPECTED);
-	}
-
-	/*
-	 * Add the thread ID and handles to list of threads for broadcast
-	 */
-	newthread->handle[LSIGNAL] = gblcond->events[LSIGNAL];
-	newthread->handle[LBROADCAST] = hc;
-	newthread->th = thrd;
-
-	/*
-	 * The thread is holding the manager lock so this is safe
-	 */
-	ISC_LIST_APPEND(gblcond->threadlist, newthread, link);
-	*localcond = newthread;
-	return (ISC_R_SUCCESS);
-}
-
-static isc_result_t
-find_thread_condition(unsigned long thrd, isc_condition_t *cond,
-		      isc_condition_thread_t **threadcondp)
-{
-	isc_condition_thread_t *threadcond;
-
-	REQUIRE(threadcondp != NULL && *threadcondp == NULL);
-
-	/*
-	 * Look for the thread ID.
-	 */
-	for (threadcond = ISC_LIST_HEAD(cond->threadlist);
-	     threadcond != NULL;
-	     threadcond = ISC_LIST_NEXT(threadcond, link)) {
-
-		if (threadcond->th == thrd) {
-			*threadcondp = threadcond;
-			return (ISC_R_SUCCESS);
-		}
-	}
-
-	/*
-	 * Not found, so add it.
-	 */
-	return (register_thread(thrd, cond, threadcondp));
-}
-
-isc_result_t
-isc_condition_signal(isc_condition_t *cond) {
-
-	/*
-	 * Unlike pthreads, the caller MUST hold the lock associated with
-	 * the condition variable when calling us.
-	 */
-	REQUIRE(cond != NULL);
-
-	if (!SetEvent(cond->events[LSIGNAL])) {
-		/* XXX */
-		return (ISC_R_UNEXPECTED);
-	}
-
-	return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_condition_broadcast(isc_condition_t *cond) {
-
-	isc_condition_thread_t *threadcond;
-	bool failed = false;
-
-	/*
-	 * Unlike pthreads, the caller MUST hold the lock associated with
-	 * the condition variable when calling us.
-	 */
-	REQUIRE(cond != NULL);
-
-	/*
-	 * Notify every thread registered for this
-	 */
-	for (threadcond = ISC_LIST_HEAD(cond->threadlist);
-	     threadcond != NULL;
-	     threadcond = ISC_LIST_NEXT(threadcond, link)) {
-
-		if (!SetEvent(threadcond->handle[LBROADCAST]))
-			failed = true;
-	}
-
-	if (failed)
-		return (ISC_R_UNEXPECTED);
-
-	return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_condition_destroy(isc_condition_t *cond) {
-
-	isc_condition_thread_t *next, *threadcond;
-
-	REQUIRE(cond != NULL);
-	REQUIRE(cond->waiters == 0);
-
-	(void)CloseHandle(cond->events[LSIGNAL]);
-
-	/*
-	 * Delete the threadlist
-	 */
-	threadcond = ISC_LIST_HEAD(cond->threadlist);
-
-	while (threadcond != NULL) {
-		next = ISC_LIST_NEXT(threadcond, link);
-		DEQUEUE(cond->threadlist, threadcond, link);
-		(void) CloseHandle(threadcond->handle[LBROADCAST]);
-		free(threadcond);
-		threadcond = next;
-	}
-
-	return (ISC_R_SUCCESS);
-}
-
-/*
- * This is always called when the mutex (lock) is held, but because
- * we are waiting we need to release it and reacquire it as soon as the wait
- * is over. This allows other threads to make use of the object guarded
- * by the mutex but it should never try to delete it as long as the
- * number of waiters > 0. Always reacquire the mutex regardless of the
- * result of the wait. Note that EnterCriticalSection will wait to acquire
- * the mutex.
- */
-static isc_result_t
-wait(isc_condition_t *cond, pthread_mutex_t *mutex, DWORD milliseconds) {
-	DWORD result;
-	isc_result_t tresult;
-	isc_condition_thread_t *threadcond = NULL;
-
-	/*
-	 * Get the thread events needed for the wait
-	 */
-	tresult = find_thread_condition(isc_thread_self(), cond, &threadcond);
-	if (tresult !=  ISC_R_SUCCESS)
-		return (tresult);
-
-	cond->waiters++;
-	LeaveCriticalSection(mutex);
-	result = WaitForMultipleObjects(2, threadcond->handle, FALSE,
-					milliseconds);
-	EnterCriticalSection(mutex);
-	cond->waiters--;
-	if (result == WAIT_FAILED) {
-		/* XXX */
-		return (ISC_R_UNEXPECTED);
-	}
-	if (result == WAIT_TIMEOUT)
-		return (ISC_R_TIMEDOUT);
-
-	return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_condition_wait(isc_condition_t *cond, pthread_mutex_t *mutex) {
-	return (wait(cond, mutex, INFINITE));
-}
-
-isc_result_t
-isc_condition_waituntil(isc_condition_t *cond, pthread_mutex_t *mutex,
-			isc_time_t *t) {
-	DWORD milliseconds;
-	isc_uint64_t microseconds;
-	isc_time_t now;
-
-	if (isc_time_now(&now) != ISC_R_SUCCESS) {
-		/* XXX */
-		return (ISC_R_UNEXPECTED);
-	}
-
-	microseconds = isc_time_microdiff(t, &now);
-	if (microseconds > 0xFFFFFFFFi64 * 1000)
-		milliseconds = 0xFFFFFFFF;
-	else
-		milliseconds = (DWORD)(microseconds / 1000);
-
-	return (wait(cond, mutex, milliseconds));
-}
diff --git a/lib/isc/win32/include/isc/condition.h b/lib/isc/win32/include/isc/condition.h
deleted file mode 100644
index 96ef291..0000000
--- a/lib/isc/win32/include/isc/condition.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef GUARD_ISC_CONDITION_H
-#define GUARD_ISC_CONDITION_H 1
-
-#include <windows.h>
-
-#include <isc/lang.h>
-#include <isc/thread.h>
-#include <isc/types.h>
-
-typedef struct isc_condition_thread isc_condition_thread_t;
-
-struct isc_condition_thread {
-	unsigned long				th;
-	HANDLE					handle[2];
-	ISC_LINK(isc_condition_thread_t)	link;
-
-};
-
-typedef struct isc_condition {
-	HANDLE 		events[2];
-	unsigned int	waiters;
-	ISC_LIST(isc_condition_thread_t) threadlist;
-} isc_condition_t;
-
-ISC_LANG_BEGINDECLS
-
-isc_result_t
-isc_condition_init(isc_condition_t *);
-
-isc_result_t
-isc_condition_wait(isc_condition_t *, pthread_mutex_t *);
-
-isc_result_t
-isc_condition_signal(isc_condition_t *);
-
-isc_result_t
-isc_condition_broadcast(isc_condition_t *);
-
-isc_result_t
-isc_condition_destroy(isc_condition_t *);
-
-isc_result_t
-isc_condition_waituntil(isc_condition_t *, pthread_mutex_t *, isc_time_t *);
-
-ISC_LANG_ENDDECLS
-
-#endif /* GUARD_ISC_CONDITION_H */
diff --git a/lib/isc/win32/include/isc/thread.h b/lib/isc/win32/include/isc/thread.h
deleted file mode 100644
index c8cc1aa..0000000
--- a/lib/isc/win32/include/isc/thread.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007, 2009  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef GUARD_ISC_THREAD_H
-#define GUARD_ISC_THREAD_H 1
-
-#include <windows.h>
-
-#include <isc/lang.h>
-#include <isc/result.h>
-
-/*
- * Inlines to help with wait retrun checking
- */
-
-/* check handle for NULL and INVALID_HANDLE */
-inline BOOL IsValidHandle( HANDLE hHandle) {
-    return ((hHandle != NULL) && (hHandle != INVALID_HANDLE_VALUE));
-}
-
-/* validate wait return codes... */
-inline BOOL WaitSucceeded( DWORD dwWaitResult, DWORD dwHandleCount) {
-    return ((dwWaitResult >= WAIT_OBJECT_0) &&
-	    (dwWaitResult < WAIT_OBJECT_0 + dwHandleCount));
-}
-
-inline BOOL WaitAbandoned( DWORD dwWaitResult, DWORD dwHandleCount) {
-    return ((dwWaitResult >= WAIT_ABANDONED_0) &&
-	    (dwWaitResult < WAIT_ABANDONED_0 + dwHandleCount));
-}
-
-inline BOOL WaitTimeout( DWORD dwWaitResult) {
-    return (dwWaitResult == WAIT_TIMEOUT);
-}
-
-inline BOOL WaitFailed( DWORD dwWaitResult) {
-    return (dwWaitResult == WAIT_FAILED);
-}
-
-/* compute object indices for waits... */
-inline DWORD WaitSucceededIndex( DWORD dwWaitResult) {
-    return (dwWaitResult - WAIT_OBJECT_0);
-}
-
-inline DWORD WaitAbandonedIndex( DWORD dwWaitResult) {
-    return (dwWaitResult - WAIT_ABANDONED_0);
-}
-
-
-
-typedef HANDLE isc_thread_t;
-typedef DWORD isc_threadresult_t;
-typedef void * isc_threadarg_t;
-typedef isc_threadresult_t (WINAPI *isc_threadfunc_t)(isc_threadarg_t);
-typedef DWORD isc_thread_key_t;
-
-#define isc_thread_self (unsigned long)GetCurrentThreadId
-
-ISC_LANG_BEGINDECLS
-
-isc_result_t
-isc_thread_create(isc_threadfunc_t, isc_threadarg_t, isc_thread_t *);
-
-isc_result_t
-isc_thread_join(isc_thread_t, isc_threadresult_t *);
-
-int
-isc_thread_key_create(isc_thread_key_t *key, void (*func)(void *));
-
-int
-isc_thread_key_delete(isc_thread_key_t key);
-
-void *
-isc_thread_key_getspecific(isc_thread_key_t);
-
-int
-isc_thread_key_setspecific(isc_thread_key_t key, void *value);
-
-ISC_LANG_ENDDECLS
-
-#endif /* GUARD_ISC_THREAD_H */
diff --git a/lib/isc/win32/thread.c b/lib/isc/win32/thread.c
deleted file mode 100644
index 4327aaa..0000000
--- a/lib/isc/win32/thread.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2001  Internet Software Consortium.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: thread.c,v 1.24 2007/06/19 23:47:19 tbox Exp $ */
-
-#include <config.h>
-
-#include <process.h>
-
-#include <isc/thread.h>
-
-isc_result_t
-isc_thread_create(isc_threadfunc_t start, isc_threadarg_t arg,
-		  isc_thread_t *threadp)
-{
-	isc_thread_t thread;
-	unsigned int id;
-
-	thread = (isc_thread_t)_beginthreadex(NULL, 0, start, arg, 0, &id);
-	if (thread == NULL) {
-		/* XXX */
-		return (ISC_R_UNEXPECTED);
-	}
-
-	*threadp = thread;
-
-	return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_thread_join(isc_thread_t thread, isc_threadresult_t *rp) {
-	DWORD result;
-	DWORD threadrc;
-
-	result = WaitForSingleObject(thread, INFINITE);
-	if (result != WAIT_OBJECT_0) {
-		/* XXX */
-		return (ISC_R_UNEXPECTED);
-	}
-	if (rp != NULL) {
-		if(!GetExitCodeThread(thread, &threadrc)) {
-			/* XXX */
-			return (ISC_R_UNEXPECTED);
-		}
-		*rp = threadrc;
-	}
-	(void)CloseHandle(thread);
-
-	return (ISC_R_SUCCESS);
-}
-
-void *
-isc_thread_key_getspecific(isc_thread_key_t key) {
-	return(TlsGetValue(key));
-}
-
-int
-isc_thread_key_setspecific(isc_thread_key_t key, void *value) {
-	return (TlsSetValue(key, value) ? 0 : GetLastError());
-}
-
-int
-isc_thread_key_create(isc_thread_key_t *key, void (*func)(void *)) {
-	*key = TlsAlloc();
-
-	return ((*key != -1) ? 0 : GetLastError());
-}
-
-int
-isc_thread_key_delete(isc_thread_key_t key) {
-	return (TlsFree(key) ? 0 : GetLastError());
-}
diff --git a/lib/isc/wscript b/lib/isc/wscript
index d59bd35..00b0362 100644
--- a/lib/isc/wscript
+++ b/lib/isc/wscript
@@ -48,16 +48,10 @@ def build(ctx):
 		"unix/time.c"
 	]
 
-	libisc_source_thread = [
-		"pthreads/condition.c",
-		"pthreads/thread.c",
-	]
-
-
 	ctx(
 		target		= "libisc_obj",
 		features	= "c bld_include src_include",
-		source		= libisc_source + libisc_source_thread,
+		source		= libisc_source,
 		includes	= [
 						"%s/lib/isc/include/" % ctx.srcnode.abspath(),
 						"%s/lib/isc/unix/include/" % ctx.srcnode.abspath(), # XXX: platform: requires unix/win32 switch.



More information about the vc mailing list