[php-i18n-commits] cvs commit: libmbfl/mbfl mbfl_mutex.c

Back to archive index

Moriyoshi Koizumi moriy****@users*****
2003年 1月 3日 (金) 18:19:04 JST


moriyoshi    03/01/03 18:19:04

  Modified:    .        acinclude.m4 configure.in
               mbfl     mbfl_mutex.c
  Log:
  Added basic support for GNUPth
  
  Revision  Changes    Path
  1.2       +14 -0     libmbfl/acinclude.m4
  
  Index: acinclude.m4
  ===================================================================
  RCS file: /cvsroot/php-i18n/libmbfl/acinclude.m4,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- acinclude.m4	29 Dec 2002 06:41:49 -0000	1.1
  +++ acinclude.m4	3 Jan 2003 09:19:03 -0000	1.2
  @@ -26,3 +26,17 @@
     ],[$2])
   ])
   
  +AC_DEFUN([MBFL_GNUPTH], [
  +  AC_CHECK_HEADER([pth.h], [
  +    avail_gnupth_funcs=1
  +    AC_CHECK_FUNC([pth_mutex_init], [], [avail_gnupth_funcs=0])
  +    AC_CHECK_FUNC([pth_mutex_acquire], [], [avail_gnupth_funcs=0])
  +    AC_CHECK_FUNC([pth_mutex_release], [], [avail_gnupth_funcs=0])
  +    if test "$avail_gnupth_funcs"; then
  +      AC_DEFINE([HAVE_GNUPTH], [1], [Define to 1 if GNUPth is available])
  +      $1
  +    fi
  +  ],[$2])
  +])
  +
  +
  
  
  
  1.7       +11 -0     libmbfl/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /cvsroot/php-i18n/libmbfl/configure.in,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- configure.in	30 Dec 2002 20:59:39 -0000	1.6
  +++ configure.in	3 Jan 2003 09:19:03 -0000	1.7
  @@ -43,11 +43,20 @@
       avail_win32_native_thread="no"
     ])
   
  +  MBFL_GNUPTH([
  +    avail_gnupth="yes"
  +  ],[
  +    avail_gnupth="no"
  +  ])
  +
     if test "$enable_threads" == "autodetect"; then
       enable_threads="no"
       if test "$avail_pthread" != "no"; then
         enable_threads="pthread"
       fi
  +    if test "$avail_gnupth" != "no"; then
  +      enable_threads="gnupth"
  +    fi
     fi
   fi
   
  @@ -77,6 +86,8 @@
         ;;
       "win32native" [)]
         AC_DEFINE([USE_WIN32_NATIVE_THREAD],[1],[Define to 1 if win32 native thread is adopted for threading])
  +    "gnupth" [)]
  +      AC_DEFINE([USE_GNUPTH],[1],[Define to 1 if GNUPth is adopted for threading])
     esac
   fi
   
  
  
  
  1.3       +29 -0     libmbfl/mbfl/mbfl_mutex.c
  
  Index: mbfl_mutex.c
  ===================================================================
  RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_mutex.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mbfl_mutex.c	30 Dec 2002 19:02:12 -0000	1.2
  +++ mbfl_mutex.c	3 Jan 2003 09:19:04 -0000	1.3
  @@ -31,6 +31,10 @@
   #else
   #error "You can't enable win32 native thread support in this build" 
   #endif
  +#elif USE_GNUPTH
  +#if defined(HAVE_GNUPTH)
  +#include <pth.h>
  +#endif
   #endif
   
   #include <assert.h>
  @@ -61,6 +65,13 @@
   	}
   
   	InitializeCriticalSection(mutex);
  +#elif defined(USE_GNUPTH)
  +	pth_mutex_t *mutex = NULL;
  +
  +	if ((mutex = mbfl_malloc(sizeof(pth_mutex_t))) == NULL) {
  +		return NULL;
  +	}
  +	pth_mutex_init(mutex);
   #endif
   	return (mbfl_mutex *)mutex;
   }
  @@ -78,6 +89,14 @@
   	if (GetLastError() == STATUS_INVALID_HANDLE) {
   		return -1;
   	}
  +#elif defined(USE_GNUPTH)
  +	switch (pth_mutex_acquire((pth_mutex_t *)mutex), 0, NULL) {
  +		/* FIXME: paste proper errno handling code here */
  +		case 0:
  +			break;
  +		default:
  +			return -1;
  +	}
   #endif
   	return 0;
   }
  @@ -98,6 +117,14 @@
   	if (GetLastError() == STATUS_INVALID_HANDLE) {
   		return -1;
   	}
  +#elif defined(USE_GNUPTH)
  +	switch (pth_mutex_release((pth_mutex_t *)mutex)) {
  +		/* FIXME: paste proper errno handling code here */
  +		case 0:
  +			break;
  +		default:
  +			return -1;
  +	}
   #endif
   	return 0;
   }
  @@ -108,6 +135,8 @@
   	pthread_mutex_destroy((pthread_mutex_t *)mutex);
   #elif defined(USE_WIN32_NATIVE_THREAD)
   	DeleteCriticalSection((CRITICAL_SECTION *)mutex);
  +#elif defined(USE_GNUPTH)
  +	/* GNU Pth mutexes don't need destruction */
   #endif
   	mbfl_free(mutex);
   }
  
  
  



php-i18n-commits メーリングリストの案内
Back to archive index