[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix lock and tls macros
From: |
Bruno Haible |
Subject: |
fix lock and tls macros |
Date: |
Mon, 5 Nov 2007 01:55:36 +0100 |
User-agent: |
KMail/1.5.4 |
It's necessary to protect the statements to which the lock and tls macros
expand against use in an 'if' branch. test-tls.c was not compiled the way
it was intented on mingw because an 'else' keyword was connected to the
wrong 'if' statement. This should fix it.
2007-11-04 Bruno Haible <address@hidden>
* lib/lock.h: Protect all macro definitions containing an 'if'
statement through a "do { ... } while (0)".
* lib/tls.h: Likewise.
*** lib/lock.h.orig 2007-11-05 01:47:01.000000000 +0100
--- lib/lock.h 2007-11-05 01:46:53.000000000 +0100
***************
*** 1,5 ****
/* Locking in multithreaded situations.
! Copyright (C) 2005-2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
--- 1,5 ----
/* Locking in multithreaded situations.
! 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 General Public License as published by
***************
*** 147,159 ****
# define gl_lock_initializer \
PTHREAD_MUTEX_INITIALIZER
# define gl_lock_init(NAME) \
! if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
# define gl_lock_lock(NAME) \
! if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
# define gl_lock_unlock(NAME) \
! if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
# define gl_lock_destroy(NAME) \
! if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
/* ------------------------- gl_rwlock_t datatype ------------------------- */
--- 147,179 ----
# define gl_lock_initializer \
PTHREAD_MUTEX_INITIALIZER
# define gl_lock_init(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \
! abort (); \
! } \
! while (0)
# define gl_lock_lock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_lock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_lock_destroy(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) \
! abort (); \
! } \
! while (0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
***************
*** 169,183 ****
# define gl_rwlock_initializer \
PTHREAD_RWLOCK_INITIALIZER
# define gl_rwlock_init(NAME) \
! if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) abort
()
# define gl_rwlock_rdlock(NAME) \
! if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) abort ()
# define gl_rwlock_wrlock(NAME) \
! if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) abort ()
# define gl_rwlock_unlock(NAME) \
! if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) abort ()
# define gl_rwlock_destroy(NAME) \
! if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) abort ()
# else
--- 189,228 ----
# define gl_rwlock_initializer \
PTHREAD_RWLOCK_INITIALIZER
# define gl_rwlock_init(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_rwlock_init (&NAME, NULL) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_rdlock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_rwlock_rdlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_wrlock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_rwlock_wrlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_rwlock_unlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_destroy(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_rwlock_destroy (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# else
***************
*** 195,209 ****
# define gl_rwlock_initializer \
{ 0, PTHREAD_MUTEX_INITIALIZER }
# define gl_rwlock_init(NAME) \
! if (pthread_in_use ()) glthread_rwlock_init (&NAME)
# define gl_rwlock_rdlock(NAME) \
! if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
# define gl_rwlock_wrlock(NAME) \
! if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
# define gl_rwlock_unlock(NAME) \
! if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
# define gl_rwlock_destroy(NAME) \
! if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
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);
--- 240,279 ----
# define gl_rwlock_initializer \
{ 0, PTHREAD_MUTEX_INITIALIZER }
# define gl_rwlock_init(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_init (&NAME); \
! } \
! while (0)
# define gl_rwlock_rdlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_rdlock (&NAME); \
! } \
! while (0)
# define gl_rwlock_wrlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_wrlock (&NAME); \
! } \
! while (0)
# define gl_rwlock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_unlock (&NAME); \
! } \
! while (0)
# define gl_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);
***************
*** 230,244 ****
# 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)
# define gl_rwlock_rdlock(NAME) \
! if (pthread_in_use ()) glthread_rwlock_rdlock (&NAME)
# define gl_rwlock_wrlock(NAME) \
! if (pthread_in_use ()) glthread_rwlock_wrlock (&NAME)
# define gl_rwlock_unlock(NAME) \
! if (pthread_in_use ()) glthread_rwlock_unlock (&NAME)
# define gl_rwlock_destroy(NAME) \
! if (pthread_in_use ()) glthread_rwlock_destroy (&NAME)
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);
--- 300,339 ----
# define gl_rwlock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER,
PTHREAD_COND_INITIALIZER, 0, 0 }
# define gl_rwlock_init(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_init (&NAME); \
! } \
! while (0)
# define gl_rwlock_rdlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_rdlock (&NAME); \
! } \
! while (0)
# define gl_rwlock_wrlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_wrlock (&NAME); \
! } \
! while (0)
# define gl_rwlock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_rwlock_unlock (&NAME); \
! } \
! while (0)
# define gl_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);
***************
*** 266,278 ****
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
# endif
# define gl_recursive_lock_init(NAME) \
! if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) abort ()
# define gl_recursive_lock_lock(NAME) \
! if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) abort ()
# define gl_recursive_lock_unlock(NAME) \
! if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) abort ()
# define gl_recursive_lock_destroy(NAME) \
! if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) abort ()
# else
--- 361,393 ----
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
# endif
# define gl_recursive_lock_init(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_init (&NAME, NULL) != 0) \
! abort (); \
! } \
! while (0)
# define gl_recursive_lock_lock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_lock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_recursive_lock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_unlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_recursive_lock_destroy(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_mutex_destroy (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# else
***************
*** 290,302 ****
# 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)
# define gl_recursive_lock_lock(NAME) \
! if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
# define gl_recursive_lock_unlock(NAME) \
! if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
# define gl_recursive_lock_destroy(NAME) \
! if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
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);
--- 405,437 ----
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
# define gl_recursive_lock_init(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_recursive_lock_init (&NAME); \
! } \
! while (0)
# define gl_recursive_lock_lock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_recursive_lock_lock (&NAME); \
! } \
! while (0)
# define gl_recursive_lock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_recursive_lock_unlock (&NAME); \
! } \
! while (0)
# define gl_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);
***************
*** 323,335 ****
# 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)
# define gl_recursive_lock_lock(NAME) \
! if (pthread_in_use ()) glthread_recursive_lock_lock (&NAME)
# define gl_recursive_lock_unlock(NAME) \
! if (pthread_in_use ()) glthread_recursive_lock_unlock (&NAME)
# define gl_recursive_lock_destroy(NAME) \
! if (pthread_in_use ()) glthread_recursive_lock_destroy (&NAME)
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);
--- 458,490 ----
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
# define gl_recursive_lock_init(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_recursive_lock_init (&NAME); \
! } \
! while (0)
# define gl_recursive_lock_lock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_recursive_lock_lock (&NAME); \
! } \
! while (0)
# define gl_recursive_lock_unlock(NAME) \
! do \
! { \
! if (pthread_in_use ()) \
! glthread_recursive_lock_unlock (&NAME); \
! } \
! while (0)
# define gl_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);
***************
*** 409,419 ****
# define gl_lock_initializer \
PTH_MUTEX_INIT
# define gl_lock_init(NAME) \
! if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
# define gl_lock_lock(NAME) \
! if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
# define gl_lock_unlock(NAME) \
! if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
# define gl_lock_destroy(NAME) \
(void)(&NAME)
--- 564,589 ----
# define gl_lock_initializer \
PTH_MUTEX_INIT
# define gl_lock_init(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_mutex_init (&NAME)) \
! abort (); \
! } \
! while (0)
# define gl_lock_lock(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) \
! abort (); \
! } \
! while (0)
# define gl_lock_unlock(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_mutex_release (&NAME)) \
! abort (); \
! } \
! while (0)
# define gl_lock_destroy(NAME) \
(void)(&NAME)
***************
*** 427,439 ****
# define gl_rwlock_initializer \
PTH_RWLOCK_INIT
# define gl_rwlock_init(NAME) \
! if (pth_in_use() && !pth_rwlock_init (&NAME)) abort ()
# define gl_rwlock_rdlock(NAME) \
! if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL))
abort ()
# define gl_rwlock_wrlock(NAME) \
! if (pth_in_use() && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL))
abort ()
# define gl_rwlock_unlock(NAME) \
! if (pth_in_use() && !pth_rwlock_release (&NAME)) abort ()
# define gl_rwlock_destroy(NAME) \
(void)(&NAME)
--- 597,631 ----
# define gl_rwlock_initializer \
PTH_RWLOCK_INIT
# define gl_rwlock_init(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_rwlock_init (&NAME)) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_rdlock(NAME) \
! do \
! { \
! if (pth_in_use() \
! && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RD, 0, NULL)) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_wrlock(NAME) \
! do \
! { \
! if (pth_in_use() \
! && !pth_rwlock_acquire (&NAME, PTH_RWLOCK_RW, 0, NULL)) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_unlock(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_rwlock_release (&NAME)) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_destroy(NAME) \
(void)(&NAME)
***************
*** 448,458 ****
# define gl_recursive_lock_initializer \
PTH_MUTEX_INIT
# define gl_recursive_lock_init(NAME) \
! if (pth_in_use() && !pth_mutex_init (&NAME)) abort ()
# define gl_recursive_lock_lock(NAME) \
! if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) abort ()
# define gl_recursive_lock_unlock(NAME) \
! if (pth_in_use() && !pth_mutex_release (&NAME)) abort ()
# define gl_recursive_lock_destroy(NAME) \
(void)(&NAME)
--- 640,665 ----
# define gl_recursive_lock_initializer \
PTH_MUTEX_INIT
# define gl_recursive_lock_init(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_mutex_init (&NAME)) \
! abort (); \
! } \
! while (0)
# define gl_recursive_lock_lock(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_mutex_acquire (&NAME, 0, NULL)) \
! abort (); \
! } \
! while (0)
# define gl_recursive_lock_unlock(NAME) \
! do \
! { \
! if (pth_in_use() && !pth_mutex_release (&NAME)) \
! abort (); \
! } \
! while (0)
# define gl_recursive_lock_destroy(NAME) \
(void)(&NAME)
***************
*** 534,546 ****
# define gl_lock_initializer \
DEFAULTMUTEX
# define gl_lock_init(NAME) \
! if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0)
abort ()
# define gl_lock_lock(NAME) \
! if (thread_in_use () && mutex_lock (&NAME) != 0) abort ()
# define gl_lock_unlock(NAME) \
! if (thread_in_use () && mutex_unlock (&NAME) != 0) abort ()
# define gl_lock_destroy(NAME) \
! if (thread_in_use () && mutex_destroy (&NAME) != 0) abort ()
/* ------------------------- gl_rwlock_t datatype ------------------------- */
--- 741,773 ----
# define gl_lock_initializer \
DEFAULTMUTEX
# define gl_lock_init(NAME) \
! do \
! { \
! if (thread_in_use () && mutex_init (&NAME, USYNC_THREAD, NULL) != 0) \
! abort (); \
! } \
! while (0)
# define gl_lock_lock(NAME) \
! do \
! { \
! if (thread_in_use () && mutex_lock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_lock_unlock(NAME) \
! do \
! { \
! if (thread_in_use () && mutex_unlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_lock_destroy(NAME) \
! do \
! { \
! if (thread_in_use () && mutex_destroy (&NAME) != 0) \
! abort (); \
! } \
! while (0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
***************
*** 552,566 ****
# define gl_rwlock_initializer \
DEFAULTRWLOCK
# define gl_rwlock_init(NAME) \
! if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0)
abort ()
# define gl_rwlock_rdlock(NAME) \
! if (thread_in_use () && rw_rdlock (&NAME) != 0) abort ()
# define gl_rwlock_wrlock(NAME) \
! if (thread_in_use () && rw_wrlock (&NAME) != 0) abort ()
# define gl_rwlock_unlock(NAME) \
! if (thread_in_use () && rw_unlock (&NAME) != 0) abort ()
# define gl_rwlock_destroy(NAME) \
! if (thread_in_use () && rwlock_destroy (&NAME) != 0) abort ()
/* --------------------- gl_recursive_lock_t datatype --------------------- */
--- 779,818 ----
# define gl_rwlock_initializer \
DEFAULTRWLOCK
# define gl_rwlock_init(NAME) \
! do
\
! {
\
! if (thread_in_use () && rwlock_init (&NAME, USYNC_THREAD, NULL) != 0)
\
! abort ();
\
! }
\
! while (0)
# define gl_rwlock_rdlock(NAME) \
! do \
! { \
! if (thread_in_use () && rw_rdlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_wrlock(NAME) \
! do \
! { \
! if (thread_in_use () && rw_wrlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_unlock(NAME) \
! do \
! { \
! if (thread_in_use () && rw_unlock (&NAME) != 0) \
! abort (); \
! } \
! while (0)
# define gl_rwlock_destroy(NAME) \
! do \
! { \
! if (thread_in_use () && rwlock_destroy (&NAME) != 0) \
! abort (); \
! } \
! while (0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
***************
*** 581,593 ****
# 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)
# define gl_recursive_lock_lock(NAME) \
! if (thread_in_use ()) glthread_recursive_lock_lock (&NAME)
# define gl_recursive_lock_unlock(NAME) \
! if (thread_in_use ()) glthread_recursive_lock_unlock (&NAME)
# define gl_recursive_lock_destroy(NAME) \
! if (thread_in_use ()) glthread_recursive_lock_destroy (&NAME)
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);
--- 833,865 ----
# define gl_recursive_lock_initializer \
{ DEFAULTMUTEX, (thread_t) 0, 0 }
# define gl_recursive_lock_init(NAME) \
! do \
! { \
! if (thread_in_use ()) \
! glthread_recursive_lock_init (&NAME); \
! } \
! while (0)
# define gl_recursive_lock_lock(NAME) \
! do \
! { \
! if (thread_in_use ()) \
! glthread_recursive_lock_lock (&NAME); \
! } \
! while (0)
# define gl_recursive_lock_unlock(NAME) \
! do \
! { \
! if (thread_in_use ()) \
! glthread_recursive_lock_unlock (&NAME); \
! } \
! while (0)
# define gl_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);
*** lib/tls.h.orig 2007-11-05 01:47:01.000000000 +0100
--- lib/tls.h 2007-11-05 01:43:45.000000000 +0100
***************
*** 1,5 ****
/* Thread-local storage in multithreaded situations.
! Copyright (C) 2005 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
--- 1,5 ----
/* Thread-local storage in multithreaded situations.
! 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 General Public License as published by
***************
*** 119,126 ****
} \
while (0)
# define gl_tls_key_destroy(NAME) \
! if (pthread_in_use () && pthread_key_delete ((NAME).key) != 0) \
! abort ()
#endif
--- 119,130 ----
} \
while (0)
# define gl_tls_key_destroy(NAME) \
! do \
! { \
! if (pthread_in_use () && pthread_key_delete ((NAME).key) != 0) \
! abort (); \
! } \
! while (0)
#endif
***************
*** 188,195 ****
} \
while (0)
# define gl_tls_key_destroy(NAME) \
! if (pth_in_use () && !pth_key_delete ((NAME).key)) \
! abort ()
#endif
--- 192,203 ----
} \
while (0)
# define gl_tls_key_destroy(NAME) \
! do \
! { \
! if (pth_in_use () && !pth_key_delete ((NAME).key)) \
! abort (); \
! } \
! while (0)
#endif
***************
*** 273,288 ****
typedef DWORD gl_tls_key_t;
# define gl_tls_key_init(NAME, DESTRUCTOR) \
/* The destructor is unsupported. */ \
! if (((NAME) = TlsAlloc ()) == (DWORD)-1) \
! abort ()
# define gl_tls_get(NAME) \
TlsGetValue (NAME)
# define gl_tls_set(NAME, POINTER) \
! if (!TlsSetValue (NAME, POINTER)) \
! abort ()
# define gl_tls_key_destroy(NAME) \
! if (!TlsFree (NAME)) \
! abort ()
#endif
--- 281,308 ----
typedef DWORD gl_tls_key_t;
# define gl_tls_key_init(NAME, DESTRUCTOR) \
/* The destructor is unsupported. */ \
! do \
! { \
! if (((NAME) = TlsAlloc ()) == (DWORD)-1) \
! abort (); \
! } \
! while (0)
# define gl_tls_get(NAME) \
TlsGetValue (NAME)
# define gl_tls_set(NAME, POINTER) \
! do \
! { \
! if (!TlsSetValue (NAME, POINTER)) \
! abort (); \
! } \
! while (0)
# define gl_tls_key_destroy(NAME) \
! do \
! { \
! if (!TlsFree (NAME)) \
! abort (); \
! } \
! while (0)
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fix lock and tls macros,
Bruno Haible <=