From: Bruno Haible Date: Sun, 17 Aug 2008 14:36:30 +0000 (+0000) Subject: Move some code from gnulib module 'lock' to gnulib module 'threadlib'. X-Git-Tag: v0.18~368 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe3e8299f1e475a0a6f5eef43da210dfb4282649;p=thirdparty%2Fgettext.git Move some code from gnulib module 'lock' to gnulib module 'threadlib'. --- diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index 588751458..af4d209a6 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,11 @@ +2008-08-17 Bruno Haible + + * threadlib.c: New file, extracted from lock.c. + * lock.c (dummy_thread_func, glthread_in_use): Remove functions. + * Makefile.in (SOURCES): Add threadlib.c. + (OBJECTS): Add threadlib.$lo. + (threadlib.lo): New rule. + 2008-08-14 Bruno Haible * lock.h (glthread_lock_lock, glthread_lock_unlock, diff --git a/gettext-runtime/intl/Makefile.in b/gettext-runtime/intl/Makefile.in index cfed0859a..3d107c368 100644 --- a/gettext-runtime/intl/Makefile.in +++ b/gettext-runtime/intl/Makefile.in @@ -127,6 +127,7 @@ SOURCES = \ plural.y \ plural-exp.c \ localcharset.c \ + threadlib.c \ lock.c \ relocatable.c \ langprefs.c \ @@ -157,6 +158,7 @@ OBJECTS = \ plural.$lo \ plural-exp.$lo \ localcharset.$lo \ + threadlib.$lo \ lock.$lo \ relocatable.$lo \ langprefs.$lo \ @@ -254,6 +256,8 @@ plural-exp.lo: $(srcdir)/plural-exp.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c localcharset.lo: $(srcdir)/localcharset.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c +threadlib.lo: $(srcdir)/threadlib.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/threadlib.c lock.lo: $(srcdir)/lock.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/lock.c relocatable.lo: $(srcdir)/relocatable.c diff --git a/gettext-runtime/intl/lock.c b/gettext-runtime/intl/lock.c index 982e12ea6..31c05bc05 100644 --- a/gettext-runtime/intl/lock.c +++ b/gettext-runtime/intl/lock.c @@ -28,45 +28,6 @@ #if USE_POSIX_THREADS -/* Use the POSIX threads library. */ - -# if PTHREAD_IN_USE_DETECTION_HARD - -/* The function to be executed by a dummy thread. */ -static void * -dummy_thread_func (void *arg) -{ - return arg; -} - -int -glthread_in_use (void) -{ - static int tested; - static int result; /* 1: linked with -lpthread, 0: only with libc */ - - if (!tested) - { - pthread_t thread; - - if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) - /* Thread creation failed. */ - result = 0; - else - { - /* Thread creation works. */ - void *retval; - if (pthread_join (thread, &retval) != 0) - abort (); - result = 1; - } - tested = 1; - } - return result; -} - -# endif - /* -------------------------- gl_lock_t datatype -------------------------- */ /* ------------------------- gl_rwlock_t datatype ------------------------- */ diff --git a/gettext-runtime/intl/threadlib.c b/gettext-runtime/intl/threadlib.c new file mode 100644 index 000000000..72e4bd4d4 --- /dev/null +++ b/gettext-runtime/intl/threadlib.c @@ -0,0 +1,68 @@ +/* Multithreading primitives. + Copyright (C) 2005-2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +/* Written by Bruno Haible , 2005. */ + +#include + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The function to be executed by a dummy thread. */ +static void * +dummy_thread_func (void *arg) +{ + return arg; +} + +int +glthread_in_use (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_t thread; + + if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) + /* Thread creation failed. */ + result = 0; + else + { + /* Thread creation works. */ + void *retval; + if (pthread_join (thread, &retval) != 0) + abort (); + result = 1; + } + tested = 1; + } + return result; +} + +# endif + +#endif + +/* ========================================================================= */