summaryrefslogtreecommitdiffstats
path: root/gettext-runtime
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-11-05 00:57:22 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:15:30 +0200
commit3158c1d21d8706e338c5f1f0ff9add674ec07561 (patch)
tree61765f6387c24acbba1bca9251910f5142981e7c /gettext-runtime
parent59b761c8523b73db444a633ed5492bf513640e0d (diff)
downloadexternal_gettext-3158c1d21d8706e338c5f1f0ff9add674ec07561.zip
external_gettext-3158c1d21d8706e338c5f1f0ff9add674ec07561.tar.gz
external_gettext-3158c1d21d8706e338c5f1f0ff9add674ec07561.tar.bz2
Update from gnulib: Protect all macro definitions containing an 'if' statement.
Diffstat (limited to 'gettext-runtime')
-rw-r--r--gettext-runtime/intl/ChangeLog5
-rw-r--r--gettext-runtime/intl/lock.h382
2 files changed, 332 insertions, 55 deletions
diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog
index c636a6e..c5a59ea 100644
--- a/gettext-runtime/intl/ChangeLog
+++ b/gettext-runtime/intl/ChangeLog
@@ -1,5 +1,10 @@
2007-11-04 Bruno Haible <bruno@clisp.org>
+ * lock.h: Protect all macro definitions containing an 'if' statement
+ through a "do { ... } while (0)".
+
+2007-11-04 Bruno Haible <bruno@clisp.org>
+
* vasnprintf.c (DCHAR_IS_TCHAR, DCHAR_CPY): Undefine at the end.
2007-06-11 Bruno Haible <bruno@clisp.org>
diff --git a/gettext-runtime/intl/lock.h b/gettext-runtime/intl/lock.h
index 04d1369..144531d 100644
--- a/gettext-runtime/intl/lock.h
+++ b/gettext-runtime/intl/lock.h
@@ -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
@@ -148,13 +148,33 @@ typedef pthread_mutex_t gl_lock_t;
# define gl_lock_initializer \
PTHREAD_MUTEX_INITIALIZER
# define gl_lock_init(NAME) \
- if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_lock(NAME) \
- if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_unlock(NAME) \
- if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_destroy(NAME) \
- if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
@@ -170,15 +190,40 @@ typedef pthread_rwlock_t gl_rwlock_t;
# define gl_rwlock_initializer \
PTHREAD_RWLOCK_INITIALIZER
# define gl_rwlock_init(NAME) \
- if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_rdlock(NAME) \
- if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_wrlock(NAME) \
- if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_unlock(NAME) \
- if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_destroy(NAME) \
- if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# else
@@ -196,15 +241,40 @@ typedef struct
# define gl_rwlock_initializer \
{ 0, PTHREAD_MUTEX_INITIALIZER }
# define gl_rwlock_init(NAME) \
- if (pthread_in_use ()) glthread_rwlock_init (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_init (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_rdlock(NAME) \
- if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_rdlock (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_wrlock(NAME) \
- if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_wrlock (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_unlock(NAME) \
- if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_unlock (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_destroy(NAME) \
- if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_destroy (&NAME); \
+ } \
+ while (0)
extern void glthread_rwlock_init (gl_rwlock_t *lock);
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
@@ -231,15 +301,40 @@ typedef struct
# define gl_rwlock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
# define gl_rwlock_init(NAME) \
- if (pthread_in_use ()) glthread_rwlock_init (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_init (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_rdlock(NAME) \
- if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_rdlock (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_wrlock(NAME) \
- if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_wrlock (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_unlock(NAME) \
- if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_unlock (&NAME); \
+ } \
+ while (0)
# define gl_rwlock_destroy(NAME) \
- if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_rwlock_destroy (&NAME); \
+ } \
+ while (0)
extern void glthread_rwlock_init (gl_rwlock_t *lock);
extern void glthread_rwlock_rdlock (gl_rwlock_t *lock);
extern void glthread_rwlock_wrlock (gl_rwlock_t *lock);
@@ -267,13 +362,33 @@ typedef pthread_mutex_t gl_recursive_lock_t;
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
# endif
# define gl_recursive_lock_init(NAME) \
- if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_recursive_lock_lock(NAME) \
- if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_recursive_lock_unlock(NAME) \
- if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_recursive_lock_destroy(NAME) \
- if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
+ do \
+ { \
+ if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# else
@@ -291,13 +406,33 @@ typedef struct
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
# define gl_recursive_lock_init(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_init (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_init (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_lock(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_lock (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_unlock(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_unlock (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_destroy(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_destroy (&NAME); \
+ } \
+ while (0)
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
@@ -324,13 +459,33 @@ typedef struct
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
# define gl_recursive_lock_init(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_init (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_init (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_lock(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_lock (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_unlock(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_unlock (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_destroy(NAME) \
- if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
+ do \
+ { \
+ if (pthread_in_use ()) \
+ glthread_recursive_lock_destroy (&NAME); \
+ } \
+ while (0)
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
@@ -410,11 +565,26 @@ typedef pth_mutex_t gl_lock_t;
# define gl_lock_initializer \
PTH_MUTEX_INIT
# define gl_lock_init(NAME) \
- if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_mutex_init (&NAME)) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_lock(NAME) \
- if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_unlock(NAME) \
- if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_mutex_release (&NAME)) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_destroy(NAME) \
(void)(&NAME)
@@ -428,13 +598,35 @@ typedef pth_rwlock_t gl_rwlock_t;
# define gl_rwlock_initializer \
PTH_RWLOCK_INIT
# define gl_rwlock_init(NAME) \
- if (pth_in_use() && !pth_rwlock_init (&NAME)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_rwlock_init (&NAME)) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_rdlock(NAME) \
- if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) abort ()
+ do \
+ { \
+ if (pth_in_use() \
+ && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_wrlock(NAME) \
- if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) abort ()
+ do \
+ { \
+ if (pth_in_use() \
+ && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_unlock(NAME) \
- if (pth_in_use() && !pth_rwlock_release (&NAME)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_rwlock_release (&NAME)) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_destroy(NAME) \
(void)(&NAME)
@@ -449,11 +641,26 @@ typedef pth_mutex_t gl_recursive_lock_t;
# define gl_recursive_lock_initializer \
PTH_MUTEX_INIT
# define gl_recursive_lock_init(NAME) \
- if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_mutex_init (&NAME)) \
+ abort (); \
+ } \
+ while (0)
# define gl_recursive_lock_lock(NAME) \
- if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) \
+ abort (); \
+ } \
+ while (0)
# define gl_recursive_lock_unlock(NAME) \
- if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
+ do \
+ { \
+ if (pth_in_use() && !pth_mutex_release (&NAME)) \
+ abort (); \
+ } \
+ while (0)
# define gl_recursive_lock_destroy(NAME) \
(void)(&NAME)
@@ -535,13 +742,33 @@ typedef mutex_t gl_lock_t;
# define gl_lock_initializer \
DEFAULTMUTEX
# define gl_lock_init(NAME) \
- if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_lock(NAME) \
- if (thread_in_use () && mutex_lock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && mutex_lock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_unlock(NAME) \
- if (thread_in_use () && mutex_unlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && mutex_unlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_lock_destroy(NAME) \
- if (thread_in_use () && mutex_destroy (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && mutex_destroy (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
@@ -553,15 +780,40 @@ typedef rwlock_t gl_rwlock_t;
# define gl_rwlock_initializer \
DEFAULTRWLOCK
# define gl_rwlock_init(NAME) \
- if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_rdlock(NAME) \
- if (thread_in_use () && rw_rdlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && rw_rdlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_wrlock(NAME) \
- if (thread_in_use () && rw_wrlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && rw_wrlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_unlock(NAME) \
- if (thread_in_use () && rw_unlock (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && rw_unlock (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
# define gl_rwlock_destroy(NAME) \
- if (thread_in_use () && rwlock_destroy (&NAME) != 0) abort ()
+ do \
+ { \
+ if (thread_in_use () && rwlock_destroy (&NAME) != 0) \
+ abort (); \
+ } \
+ while (0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
@@ -582,13 +834,33 @@ typedef struct
# define gl_recursive_lock_initializer \
{ DEFAULTMUTEX, (thread_t) 0, 0 }
# define gl_recursive_lock_init(NAME) \
- if (thread_in_use ()) glthread_recursive_lock_init (&NAME)
+ do \
+ { \
+ if (thread_in_use ()) \
+ glthread_recursive_lock_init (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_lock(NAME) \
- if (thread_in_use ()) glthread_recursive_lock_lock (&NAME)
+ do \
+ { \
+ if (thread_in_use ()) \
+ glthread_recursive_lock_lock (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_unlock(NAME) \
- if (thread_in_use ()) glthread_recursive_lock_unlock (&NAME)
+ do \
+ { \
+ if (thread_in_use ()) \
+ glthread_recursive_lock_unlock (&NAME); \
+ } \
+ while (0)
# define gl_recursive_lock_destroy(NAME) \
- if (thread_in_use ()) glthread_recursive_lock_destroy (&NAME)
+ do \
+ { \
+ if (thread_in_use ()) \
+ glthread_recursive_lock_destroy (&NAME); \
+ } \
+ while (0)
extern void glthread_recursive_lock_init (gl_recursive_lock_t *lock);
extern void glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
extern void glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);