Moriyoshi Koizumi
moriy****@sourc*****
2004年 6月 29日 (火) 20:10:36 JST
moriyoshi 04/06/29 20:10:36 Modified: . acinclude.m4 mbfl mbfl_mutex.c Log: - Fix configure to check whether PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_RECURSIVE_NP is defined, for some pthread implementations (mostly from *BSD). Further work should be needed, because the flag is anyway non-portable (NP is short for these words actually) and EnterCriticalSection() on win32 doesn't seem to handle recursive mutex acquirements. Revision Changes Path 1.3 +26 -0 libmbfl/acinclude.m4 Index: acinclude.m4 =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/acinclude.m4,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- acinclude.m4 3 Jan 2003 09:19:03 -0000 1.2 +++ acinclude.m4 29 Jun 2004 11:10:36 -0000 1.3 @@ -6,6 +6,32 @@ AC_CHECK_FUNC([pthread_mutex_lock], [], [avail_pthread_funcs=0]) AC_CHECK_FUNC([pthread_mutex_unlock], [], [vail_pthread_funcs=0]) if test "$avail_pthread_funcs"; then + AC_MSG_CHECKING([if PTHREAD_MUTEX_RECURSIVE is defined]) + AC_TRY_CPP([ +#include <pthread.h> + +#ifndef PTHREAD_MUTEX_RECURSIVE +#error choke me +#endif + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], [Define to 1 if PTHREAD_MUTEX_RECURSIVE is defined]) + ], [ + AC_MSG_RESULT([no]) + AC_MSG_CHECKING([if PTHREAD_MUTEX_RECURSIVE_NP is defined]) + AC_TRY_CPP([ +#include <pthread.h> + +#ifndef PTHREAD_MUTEX_RECURSIVE_NP +#error choke me +#endif + ], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], [1], [Define to 1 if PTHREAD_MUTEX_RECURSIVE_NP is defined]) + ], [ + AC_MSG_RESULT([no]) + ]) + ]) AC_DEFINE([HAVE_PTHREAD], [1], [Define to 1 if pthread is available]) $1 fi 1.9 +6 -0 libmbfl/mbfl/mbfl_mutex.c Index: mbfl_mutex.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_mutex.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- mbfl_mutex.c 25 Aug 2003 01:01:29 -0000 1.8 +++ mbfl_mutex.c 29 Jun 2004 11:10:36 -0000 1.9 @@ -72,7 +72,13 @@ pthread_mutexattr_init(&mattr); pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_PRIVATE); +#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE + pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE); +#else +#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE_NP pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE_NP); +#endif +#endif pthread_mutex_init(mutex, &mattr); pthread_mutexattr_destroy(&mattr); #elif defined(USE_WIN32_NATIVE_THREAD)