From: Bruno Haible Date: Fri, 30 Nov 2007 16:08:32 +0000 (+0000) Subject: Update from gnulib. X-Git-Tag: v0.18~490 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92327e763efc25d4e4e03f5f534026a0a0305680;p=thirdparty%2Fgettext.git Update from gnulib. --- diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index 13740698f..b436af627 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,12 @@ +2007-11-30 Bruno Haible + + * lock.h (gl_recursive_lock_init) [PTHREAD && + PTHREAD_RECURSIVE_MUTEX_INITIALIZER]: Call + glthread_recursive_lock_init. + * lock.c (glthread_recursive_lock_init) + [PTHREAD_RECURSIVE_MUTEX_INITIALIZER]: New function. + Reported by Yoann Vandoorselaere . + 2007-11-28 Bruno Haible * libgnuintl.h.in (fprintf, vfprintf, printf, vprintf, sprintf, diff --git a/gettext-runtime/intl/lock.c b/gettext-runtime/intl/lock.c index f60a8d9be..728bd7b5a 100644 --- a/gettext-runtime/intl/lock.c +++ b/gettext-runtime/intl/lock.c @@ -1,5 +1,5 @@ /* Locking in multithreaded situations. - Copyright (C) 2005-2006 Free Software Foundation, Inc. + Copyright (C) 2005-2007 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 @@ -251,7 +251,24 @@ glthread_rwlock_destroy (gl_rwlock_t *lock) # if HAVE_PTHREAD_MUTEX_RECURSIVE -# if !(defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +void +glthread_recursive_lock_init (gl_recursive_lock_t *lock) +{ + pthread_mutexattr_t attributes; + + if (pthread_mutexattr_init (&attributes) != 0) + abort (); + if (pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE) != 0) + abort (); + if (pthread_mutex_init (lock, &attributes) != 0) + abort (); + if (pthread_mutexattr_destroy (&attributes) != 0) + abort (); +} + +# else void glthread_recursive_lock_init (gl_recursive_lock_t *lock) diff --git a/gettext-runtime/intl/lock.h b/gettext-runtime/intl/lock.h index 144531dc5..7642f0fdc 100644 --- a/gettext-runtime/intl/lock.h +++ b/gettext-runtime/intl/lock.h @@ -362,11 +362,11 @@ typedef pthread_mutex_t gl_recursive_lock_t; PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP # endif # define gl_recursive_lock_init(NAME) \ - do \ - { \ - if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \ - abort (); \ - } \ + do \ + { \ + if (pthread_in_use ()) \ + glthread_recursive_lock_init (&NAME); \ + } \ while (0) # define gl_recursive_lock_lock(NAME) \ do \ @@ -389,6 +389,7 @@ typedef pthread_mutex_t gl_recursive_lock_t; abort (); \ } \ while (0) +extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock); # else