Moriyoshi Koizumi
moriy****@users*****
2002年 12月 31日 (火) 01:43:15 JST
moriyoshi 02/12/31 01:43:15 Modified: . configure.in mbfl mbfl_arraylist.c Makefile.am Makefile.bcc32 Log: Improved threading support Revision Changes Path 1.5 +27 -8 libmbfl/configure.in Index: configure.in =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/configure.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- configure.in 29 Dec 2002 06:41:49 -0000 1.4 +++ configure.in 30 Dec 2002 16:43:15 -0000 1.5 @@ -1,8 +1,9 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([libmbfl],[0.0.0]) -AM_INIT_AUTOMAKE +AC_INIT([mbfl/mbfilter.h]) +AM_INIT_AUTOMAKE([libmbfl], [0,0]) AC_CONFIG_SRCDIR([mbfl/mbfilter.c]) AC_CONFIG_HEADER([config.h]) +AM_MAINTAINER_MODE # Checks for programs. AC_PROG_CC @@ -51,13 +52,31 @@ fi if test "$enable_threads" != "no"; then - CFLAGS="$CFLAGS -D_REENTRANT" + AC_DEFINE([ENABLE_THREADS],[1],[Define to 1 if threading support is enabled]) +# Thread configuration stolen from mono project + case "$host" in + *-*-mingw*|*-*-cygwin*) + CPPFLAGS="$CPPFLAGS" + ;; + + *-*-*bsd*) + CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" + ;; + + *-*-linux*) + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + *-*-solaris*) + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + case "$enable_threads" in - "pthread" [)] - AC_DEFINE([USE_PTHREAD],[1],[Define to 1 if pthread is adopted for threading]) - ;; - "win32native" [)] - AC_DEFINE([USE_WIN32_NATIVE_THREAD],[1],[Define to 1 if win32 native thread is adopted for threading]) + "pthread" [)] + AC_DEFINE([USE_PTHREAD],[1],[Define to 1 if pthread is adopted for threading]) + ;; + "win32native" [)] + AC_DEFINE([USE_WIN32_NATIVE_THREAD],[1],[Define to 1 if win32 native thread is adopted for threading]) esac fi 1.2 +15 -15 libmbfl/mbfl/mbfl_arraylist.c Index: mbfl_arraylist.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_arraylist.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mbfl_arraylist.c 29 Dec 2002 06:41:49 -0000 1.1 +++ mbfl_arraylist.c 30 Dec 2002 16:43:15 -0000 1.2 @@ -82,7 +82,7 @@ if ((err = mbfl_list_ctor(&(al_d->_super))) != 0) { return err; } -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if ((al_d->mutex = mbfl_mutex_new()) == NULL) { return -1; } @@ -105,7 +105,7 @@ { assert(al_d != NULL); -#ifdef _REENTRANT +#ifdef ENABLE_THREADS assert(al_d->mutex != NULL); mbfl_mutex_free(al_d->mutex); #endif @@ -124,12 +124,12 @@ int err = 0; mbfl_arraylist_entry *new_entry; -#ifdef _REENTRANT +#ifdef ENABLE_THREADS int mutex_locked = 0; #endif assert(al_d != NULL); -#ifdef _REENTRANT +#ifdef ENABLE_THREADS assert(al_d->mutex != NULL); #endif @@ -141,7 +141,7 @@ unsigned int i; unsigned int new_ent_size; unsigned int required_size; -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_lock(al_d->mutex) != 0) { err = -1; goto out; @@ -188,7 +188,7 @@ unsigned int new_size; void *new_entries; -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (!mutex_locked) { if (mbfl_mutex_lock(al_d->mutex) != 0) { err = -1; @@ -211,7 +211,7 @@ al_d->allocated_size = new_size; } -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (!mutex_locked) { if (mbfl_mutex_lock(al_d->mutex) != 0) { return -1; @@ -231,7 +231,7 @@ al_d->_super._super.num_items++; out: -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mutex_locked && mbfl_mutex_unlock(al_d->mutex) != 0) { return -1; } @@ -244,7 +244,7 @@ mbfl_arraylist_entry *entry; unsigned int ent_size; -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_lock(al_d->mutex) != 0) { return -1; } @@ -261,7 +261,7 @@ al_d->entries_size -= ent_size; al_d->_super._super.num_items--; -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_unlock(al_d->mutex) != 0) { return -1; } @@ -282,7 +282,7 @@ return 1; } -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_lock(al_d->mutex) != 0) { return -1; } @@ -298,7 +298,7 @@ *pobj_size = entry->size; out: -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_unlock(al_d->mutex) != 0) { return -1; } @@ -314,13 +314,13 @@ assert(al_d != NULL); assert(pretval != NULL); -#ifdef _REENTRANT +#ifdef ENABLE_THREADS assert(al_d->mutex != NULL); #endif entry = (mbfl_arraylist_entry *)al_d->entries; -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_lock(al_d->mutex) != 0) { return -1; } @@ -335,7 +335,7 @@ } ((char *)entry) += MBFL_AL_ENT_SIZE(al_d->max_obj_size); } -#ifdef _REENTRANT +#ifdef ENABLE_THREADS if (mbfl_mutex_unlock(al_d->mutex) != 0) { return -1; } 1.12 +2 -2 libmbfl/mbfl/Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Makefile.am 26 Dec 2002 23:39:40 -0000 1.11 +++ Makefile.am 30 Dec 2002 16:43:15 -0000 1.12 @@ -1,10 +1,10 @@ lib_LTLIBRARIES=libmbfl.la -libmbfl_la_SOURCES=mbfilter.c mbfl_string.c mbfl_language.c mbfl_encoding.c mbfl_convert.c mbfl_ident.c mbfl_memory_device.c mbfl_allocators.c mbfl_filter_output.c mbfilter_pass.c mbfilter_wchar.c mbfilter_8bit.c mbfl_buffer_converter.c mbfl_wchar_device.c +libmbfl_la_SOURCES=mbfilter.c mbfl_string.c mbfl_language.c mbfl_encoding.c mbfl_convert.c mbfl_ident.c mbfl_memory_device.c mbfl_allocators.c mbfl_filter_output.c mbfilter_pass.c mbfilter_wchar.c mbfilter_8bit.c mbfl_buffer_converter.c mbfl_wchar_device.c mbfl_mutex.c mbfl_collection.c mbfl_list.c mbfl_arraylist.c mbfl_iterator.c libmbfl_filters_la=../filters/libmbfl_filters.la libmbfl_nls_la=../nls/libmbfl_nls.la libmbfl_la_LIBADD=$(libmbfl_filters_la) $(libmbfl_nls_la) libmbfl_includedir=$(includedir)/mbfl -libmbfl_include_HEADERS=mbfilter.h mbfl_consts.h mbfl_encoding.h mbfl_language.h mbfl_string.h mbfl_convert.h mbfl_ident.h mbfl_memory_device.h mbfl_allocators.h mbfl_buffer_converter.h mbfl_defs.h mbfl_wchar_device.h +libmbfl_include_HEADERS=mbfilter.h mbfl_consts.h mbfl_encoding.h mbfl_language.h mbfl_string.h mbfl_convert.h mbfl_ident.h mbfl_memory_device.h mbfl_allocators.h mbfl_buffer_converter.h mbfl_defs.h mbfl_wchar_device.h mbfl_mutex.h mbfl_collection.h mbfl_list.h mbfl_arraylist.h mbfl_iterator.h $(libmbfl_filters_la): $(MAKE) -C `dirname $(libmbfl_filters_la)` 1.4 +1 -1 libmbfl/mbfl/Makefile.bcc32 Index: Makefile.bcc32 =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/Makefile.bcc32,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Makefile.bcc32 26 Dec 2002 23:39:40 -0000 1.3 +++ Makefile.bcc32 30 Dec 2002 16:43:15 -0000 1.4 @@ -1,5 +1,5 @@ !include ..\rules.mak.bcc32 -OBJS=mbfilter.obj mbfl_string.obj mbfl_language.obj mbfl_encoding.obj mbfl_convert.obj mbfl_ident.obj mbfl_memory_device.obj mbfl_allocators.obj mbfl_filter_output.obj mbfilter_pass.obj mbfilter_wchar.obj mbfilter_8bit.obj mbfl_buffer_converter.obj mbfl_wchar_device.obj +OBJS=mbfilter.obj mbfl_string.obj mbfl_language.obj mbfl_encoding.obj mbfl_convert.obj mbfl_ident.obj mbfl_memory_device.obj mbfl_allocators.obj mbfl_filter_output.obj mbfilter_pass.obj mbfilter_wchar.obj mbfilter_8bit.obj mbfl_buffer_converter.obj mbfl_wchar_device.obj mbfl_mutex.obj mbfl_collection.obj mbfl_list.obj mbfl_arraylist.obj mbfl_iterator.obj all: $(OBJS)