[Asterisk-Dev] More portable pthread initializers

Thorsten Lockert tholo at sigmasoft.com
Sun Apr 27 13:41:57 MST 2003


Some of the pthread initializers used by Asterisk are non-standard,
this patch will use more standard ones where the non-standard ones
are not available.

Index: include/asterisk/lock.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/lock.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 lock.h
--- include/asterisk/lock.h	12 Feb 2003 13:59:15 -0000	1.1.1.1
+++ include/asterisk/lock.h	27 Apr 2003 20:47:06 -0000
@@ -29,10 +29,17 @@
 // #define AST_MUTEX_KIND             PTHREAD_MUTEX_RECURSIVE_NP
 #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
 #define AST_MUTEX_INITIALIZER         PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
+#else
+#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#define AST_MUTEX_INITIALIZER         PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#else
+#define AST_MUTEX_INITIALIZER         PTHREAD_MUTEX_INITIALIZER
+#endif
+#endif
+#ifdef PTHREAD_MUTEX_ERRORCHECK_NP
 #define AST_MUTEX_KIND                PTHREAD_MUTEX_ERRORCHECK_NP
 #else
-#define AST_MUTEX_INITIALIZER      PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-#define AST_MUTEX_KIND             PTHREAD_MUTEX_RECURSIVE_NP
+#define AST_MUTEX_KIND                PTHREAD_MUTEX_ERRORCHECK
 #endif
 
 struct mutex_info {
@@ -96,7 +103,11 @@
 #else
 
 #define AST_MUTEX_INITIALIZER      PTHREAD_MUTEX_INITIALIZER
+#ifdef PTHREAD_MUTEX_FAST_NP
 #define AST_MUTEX_KIND             PTHREAD_MUTEX_FAST_NP
+#else
+#define AST_MUTEX_KIND             PTHREAD_NORMAL
+#endif
 
 #define ast_pthread_mutex_init(mutex) pthread_mutex_init(mutex, NULL)
 #define ast_pthread_mutex_lock pthread_mutex_lock
--
Thorsten Lockert      | tholo at sigmasoft.com | Universe, n.:
2121 N. Lakeshore Dr. | tholo at openbsd.org   |         The problem.
Chapel Hill, NC 27514 |                     |



More information about the asterisk-dev mailing list