diff options
author | dougb <dougb@FreeBSD.org> | 2007-06-02 23:21:47 +0000 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2007-06-02 23:21:47 +0000 |
commit | 6df9693fc1899de774712d6421c2fc401db2eadd (patch) | |
tree | 6e65ba28d6d850f4d5c07cd37f26842e97b4aecf /contrib/bind9/lib/isc/pthreads | |
parent | fb8cb3b3a3d2367752c01dc81b68c0b7390f7760 (diff) | |
download | FreeBSD-src-6df9693fc1899de774712d6421c2fc401db2eadd.zip FreeBSD-src-6df9693fc1899de774712d6421c2fc401db2eadd.tar.gz |
Vendor import of BIND 9.4.1
Diffstat (limited to 'contrib/bind9/lib/isc/pthreads')
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/Makefile.in | 2 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/condition.c | 8 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/include/Makefile.in | 2 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/include/isc/Makefile.in | 2 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/include/isc/condition.h | 6 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/include/isc/mutex.h | 22 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/include/isc/once.h | 10 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/include/isc/thread.h | 12 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/mutex.c | 59 | ||||
-rw-r--r-- | contrib/bind9/lib/isc/pthreads/thread.c | 6 |
10 files changed, 90 insertions, 39 deletions
diff --git a/contrib/bind9/lib/isc/pthreads/Makefile.in b/contrib/bind9/lib/isc/pthreads/Makefile.in index f245afa..b9cc906 100644 --- a/contrib/bind9/lib/isc/pthreads/Makefile.in +++ b/contrib/bind9/lib/isc/pthreads/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.16.206.1 2004/03/06 08:14:53 marka Exp $ +# $Id: Makefile.in,v 1.17 2004/03/05 05:11:16 marka Exp $ srcdir = @srcdir@ VPATH = @srcdir@ diff --git a/contrib/bind9/lib/isc/pthreads/condition.c b/contrib/bind9/lib/isc/pthreads/condition.c index 489980c..b9c26c6 100644 --- a/contrib/bind9/lib/isc/pthreads/condition.c +++ b/contrib/bind9/lib/isc/pthreads/condition.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: condition.c,v 1.30.2.1.10.1 2004/03/06 08:14:53 marka Exp $ */ +/* $Id: condition.c,v 1.32.18.2 2005/04/29 00:17:05 marka Exp $ */ + +/*! \file */ #include <config.h> @@ -44,7 +46,7 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) { 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. */ diff --git a/contrib/bind9/lib/isc/pthreads/include/Makefile.in b/contrib/bind9/lib/isc/pthreads/include/Makefile.in index 5fec836..b1164b6 100644 --- a/contrib/bind9/lib/isc/pthreads/include/Makefile.in +++ b/contrib/bind9/lib/isc/pthreads/include/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.11.206.1 2004/03/06 08:14:54 marka Exp $ +# $Id: Makefile.in,v 1.12 2004/03/05 05:11:19 marka Exp $ srcdir = @srcdir@ VPATH = @srcdir@ diff --git a/contrib/bind9/lib/isc/pthreads/include/isc/Makefile.in b/contrib/bind9/lib/isc/pthreads/include/isc/Makefile.in index dd15a11..2e11f6c 100644 --- a/contrib/bind9/lib/isc/pthreads/include/isc/Makefile.in +++ b/contrib/bind9/lib/isc/pthreads/include/isc/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.13.206.1 2004/03/06 08:14:56 marka Exp $ +# $Id: Makefile.in,v 1.14 2004/03/05 05:11:40 marka Exp $ srcdir = @srcdir@ VPATH = @srcdir@ diff --git a/contrib/bind9/lib/isc/pthreads/include/isc/condition.h b/contrib/bind9/lib/isc/pthreads/include/isc/condition.h index c33772f..f7cea75 100644 --- a/contrib/bind9/lib/isc/pthreads/include/isc/condition.h +++ b/contrib/bind9/lib/isc/pthreads/include/isc/condition.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,11 +15,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: condition.h,v 1.21.206.1 2004/03/06 08:14:56 marka Exp $ */ +/* $Id: condition.h,v 1.22.18.2 2005/04/29 00:17:05 marka Exp $ */ #ifndef ISC_CONDITION_H #define ISC_CONDITION_H 1 +/*! \file */ + #include <isc/lang.h> #include <isc/mutex.h> #include <isc/result.h> diff --git a/contrib/bind9/lib/isc/pthreads/include/isc/mutex.h b/contrib/bind9/lib/isc/pthreads/include/isc/mutex.h index f6e526d..edafaf6 100644 --- a/contrib/bind9/lib/isc/pthreads/include/isc/mutex.h +++ b/contrib/bind9/lib/isc/pthreads/include/isc/mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,17 +15,22 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mutex.h,v 1.23.26.3 2004/03/08 09:04:55 marka Exp $ */ +/* $Id: mutex.h,v 1.25.18.3 2005/07/12 01:22:33 marka Exp $ */ #ifndef ISC_MUTEX_H #define ISC_MUTEX_H 1 +/*! \file */ + #include <pthread.h> #include <stdio.h> +#include <isc/lang.h> #include <isc/result.h> /* for ISC_R_ codes */ -/* +ISC_LANG_BEGINDECLS + +/*! * Supply mutex attributes that enable deadlock detection * (helpful when debugging). This is system dependent and * currently only supported on NetBSD. @@ -39,7 +44,7 @@ extern pthread_mutexattr_t isc__mutex_attrs; /* XXX We could do fancier error handling... */ -/* +/*! * Define ISC_MUTEX_PROFILE to turn on profiling of mutexes by line. When * enabled, isc_mutex_stats() can be used to print a table showing the * number of times each type of mutex was locked and the amount of time @@ -53,8 +58,8 @@ extern pthread_mutexattr_t isc__mutex_attrs; typedef struct isc_mutexstats isc_mutexstats_t; typedef struct { - pthread_mutex_t mutex; /* The actual mutex. */ - isc_mutexstats_t * stats; /* Mutex statistics. */ + pthread_mutex_t mutex; /*%< The actual mutex. */ + isc_mutexstats_t * stats; /*%< Mutex statistics. */ } isc_mutex_t; #else typedef pthread_mutex_t isc_mutex_t; @@ -70,8 +75,8 @@ typedef pthread_mutex_t isc_mutex_t; isc_mutex_init_errcheck((mp)) #else #define isc_mutex_init(mp) \ - ((pthread_mutex_init((mp), ISC__MUTEX_ATTRS) == 0) ? \ - ISC_R_SUCCESS : ISC_R_UNEXPECTED) + isc__mutex_init((mp), __FILE__, __LINE__) +isc_result_t isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line); #endif #endif @@ -136,4 +141,5 @@ isc_mutex_init_errcheck(isc_mutex_t *mp); #endif /* ISC_MUTEX_PROFILE */ +ISC_LANG_ENDDECLS #endif /* ISC_MUTEX_H */ diff --git a/contrib/bind9/lib/isc/pthreads/include/isc/once.h b/contrib/bind9/lib/isc/pthreads/include/isc/once.h index 39b4885..7e9f672 100644 --- a/contrib/bind9/lib/isc/pthreads/include/isc/once.h +++ b/contrib/bind9/lib/isc/pthreads/include/isc/once.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,11 +15,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: once.h,v 1.8.206.1 2004/03/06 08:14:57 marka Exp $ */ +/* $Id: once.h,v 1.9.18.2 2005/04/29 00:17:06 marka Exp $ */ #ifndef ISC_ONCE_H #define ISC_ONCE_H 1 +/*! \file */ + #include <pthread.h> #include <isc/platform.h> @@ -28,12 +30,12 @@ typedef pthread_once_t isc_once_t; #ifdef ISC_PLATFORM_BRACEPTHREADONCEINIT -/* +/*! * This accomodates systems that define PTHRAD_ONCE_INIT improperly. */ #define ISC_ONCE_INIT { PTHREAD_ONCE_INIT } #else -/* +/*! * This is the usual case. */ #define ISC_ONCE_INIT PTHREAD_ONCE_INIT diff --git a/contrib/bind9/lib/isc/pthreads/include/isc/thread.h b/contrib/bind9/lib/isc/pthreads/include/isc/thread.h index 6287dcd..3262607 100644 --- a/contrib/bind9/lib/isc/pthreads/include/isc/thread.h +++ b/contrib/bind9/lib/isc/pthreads/include/isc/thread.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,11 +15,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: thread.h,v 1.19.206.1 2004/03/06 08:14:57 marka Exp $ */ +/* $Id: thread.h,v 1.20.18.4 2005/09/18 07:58:08 marka Exp $ */ #ifndef ISC_THREAD_H #define ISC_THREAD_H 1 +/*! \file */ + #include <pthread.h> #include <isc/lang.h> @@ -31,6 +33,7 @@ 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 *); @@ -47,6 +50,11 @@ isc_thread_setconcurrency(unsigned int level); #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 /* ISC_THREAD_H */ diff --git a/contrib/bind9/lib/isc/pthreads/mutex.c b/contrib/bind9/lib/isc/pthreads/mutex.c index 71db669..7716980 100644 --- a/contrib/bind9/lib/isc/pthreads/mutex.c +++ b/contrib/bind9/lib/isc/pthreads/mutex.c @@ -15,20 +15,25 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mutex.c,v 1.6.26.5 2005/03/17 03:58:32 marka Exp $ */ +/* $Id: mutex.c,v 1.8.18.4 2005/07/12 01:22:32 marka Exp $ */ + +/*! \file */ #include <config.h> #include <stdio.h> #include <time.h> #include <sys/time.h> +#include <errno.h> #include <isc/mutex.h> #include <isc/util.h> +#include <isc/strerror.h> #if ISC_MUTEX_PROFILE -/* Operations on timevals; adapted from FreeBSD's sys/time.h */ +/*@{*/ +/*% Operations on timevals; adapted from FreeBSD's sys/time.h */ #define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) #define timevaladd(vvp, uvp) \ do { \ @@ -49,6 +54,8 @@ } \ } while (0) +/*@}*/ + #define ISC_MUTEX_MAX_LOCKERS 32 typedef struct { @@ -60,8 +67,8 @@ typedef struct { } isc_mutexlocker_t; struct isc_mutexstats { - const char * file; /* File mutex was created in. */ - int line; /* Line mutex was created on. */ + const char * file; /*%< File mutex was created in. */ + int line; /*%< Line mutex was created on. */ unsigned count; struct timeval lock_t; struct timeval locked_total; @@ -78,10 +85,13 @@ static pthread_mutex_t statslock = PTHREAD_MUTEX_INITIALIZER; isc_result_t isc_mutex_init_profile(isc_mutex_t *mp, const char *file, int line) { - int i; + int i, err; - if (pthread_mutex_init(&mp->mutex, NULL) != 0) - return ISC_R_UNEXPECTED; + err = pthread_mutex_init(&mp->mutex, NULL); + if (err == ENOMEM) + return (ISC_R_NOMEMORY); + if (err != 0) + return (ISC_R_UNEXPECTED); RUNTIME_CHECK(pthread_mutex_lock(&statslock) == 0); @@ -116,7 +126,7 @@ isc_mutex_init_profile(isc_mutex_t *mp, const char *file, int line) { timevalclear(&mp->stats->lockers[i].wait_total); } - return ISC_R_SUCCESS; + return (ISC_R_SUCCESS); } isc_result_t @@ -159,7 +169,7 @@ isc_mutex_lock_profile(isc_mutex_t *mp, const char *file, int line) { mp->stats->cur_locker = locker; - return ISC_R_SUCCESS; + return (ISC_R_SUCCESS); } isc_result_t @@ -219,17 +229,18 @@ isc_result_t isc_mutex_init_errcheck(isc_mutex_t *mp) { pthread_mutexattr_t attr; + int err; if (pthread_mutexattr_init(&attr) != 0) - return ISC_R_UNEXPECTED; + return (ISC_R_UNEXPECTED); if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) - return ISC_R_UNEXPECTED; + return (ISC_R_UNEXPECTED); - if (pthread_mutex_init(mp, &attr) != 0) - return ISC_R_UNEXPECTED; - - return ISC_R_SUCCESS; + err = pthread_mutex_init(mp, &attr) != 0) + if (err == ENOMEM) + return (ISC_R_NOMEMORY); + return ((err == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED); } #endif @@ -239,3 +250,21 @@ pthread_mutexattr_t isc__mutex_attrs = { 0 /* m_flags, which appears to be unused. */ }; #endif + +isc_result_t +isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line) { + char strbuf[ISC_STRERRORSIZE]; + isc_result_t result = ISC_R_SUCCESS; + int err; + + err = pthread_mutex_init(mp, ISC__MUTEX_ATTRS); + if (err == ENOMEM) + return (ISC_R_NOMEMORY); + if (err != 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(file, line, "isc_mutex_init() failed: %s", + strbuf); + result = ISC_R_UNEXPECTED; + } + return (result); +} diff --git a/contrib/bind9/lib/isc/pthreads/thread.c b/contrib/bind9/lib/isc/pthreads/thread.c index a07daf8..bdbb593 100644 --- a/contrib/bind9/lib/isc/pthreads/thread.c +++ b/contrib/bind9/lib/isc/pthreads/thread.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: thread.c,v 1.9.2.2.2.2 2004/12/04 06:50:03 marka Exp $ */ +/* $Id: thread.c,v 1.12.18.3 2005/04/29 00:17:05 marka Exp $ */ + +/*! \file */ #include <config.h> |