2
Copyright (C) 2010 Free Software Foundation, Inc.
4
Written by: Niels Grewe <niels.grewe@halbordnung.de>
6
This file is part of the GNUstep Base Library.
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2 of the License, or (at your option) any later version.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Library General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library; if not, write to the Free
20
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27
* Since glibc does not enable Unix98 extensions by default, we need to tell it
28
* to do so explicitly. That support is switched on by _XOPEN_SOURCE and
29
* __USE_UNIX98 is an internal flag which can cause trouble if enabled alone.
30
* For safety we enable this only on linux and hurd where glibc is likely.
31
* We include features.h explicitely to avoid weird problems.
33
#if defined __linux__ || defined __GNU__
34
# ifndef _XOPEN_SOURCE
35
# define _XOPEN_SOURCE 600
42
* Macro to initialize recursive mutexes in a portable way. Adopted from
45
# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
46
# define GS_INIT_RECURSIVE_MUTEX(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
47
# elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
48
# define GS_INIT_RECURSIVE_MUTEX(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
50
# define GS_INIT_RECURSIVE_MUTEX(x) GSPThreadInitRecursiveMutex(&(x))
52
static inline void GSPThreadInitRecursiveMutex(pthread_mutex_t *x)
54
pthread_mutexattr_t recursiveAttributes;
55
pthread_mutexattr_init(&recursiveAttributes);
56
pthread_mutexattr_settype(&recursiveAttributes, PTHREAD_MUTEX_RECURSIVE);
57
pthread_mutex_init(x, &recursiveAttributes);
58
pthread_mutexattr_destroy(&recursiveAttributes);
60
# endif // PTHREAD_RECURSIVE_MUTEX_INITIALIZER(_NP)
62
#endif // _GSPThread_h_