selftest/Samba3: make use of 'smbd:FSCTL_SMBTORTURE = yes'
[Samba.git] / lib / replace / system / threads.h
blobd189ed620c518efec1594cbea0dfec129bf00c6d
1 #ifndef _system_threads_h
2 #define _system_threads_h
3 /*
4 Unix SMB/CIFS implementation.
6 macros to go along with the lib/replace/ portability layer code
8 Copyright (C) Volker Lendecke 2012
10 ** NOTE! The following LGPL license applies to the replace
11 ** library. This does NOT imply that all of Samba is released
12 ** under the LGPL
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 3 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 #include <pthread.h>
30 #if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) && \
31 !defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST)
32 #define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np
33 #endif
35 #if defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST_NP) && \
36 !defined(HAVE_DECL_PTHREAD_MUTEX_ROBUST)
37 #define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
38 #endif
40 #if defined(HAVE_PTHREAD_MUTEX_CONSISTENT_NP) && \
41 !defined(HAVE_PTHREAD_MUTEX_CONSISTENT)
42 #define pthread_mutex_consistent pthread_mutex_consistent_np
43 #endif
45 #ifdef HAVE_STDATOMIC_H
46 #include <stdatomic.h>
47 #endif
49 #ifndef HAVE_ATOMIC_THREAD_FENCE
50 #ifdef HAVE___ATOMIC_THREAD_FENCE
51 #define atomic_thread_fence(__ignore_order) __atomic_thread_fence(__ATOMIC_SEQ_CST)
52 #define HAVE_ATOMIC_THREAD_FENCE 1
53 #endif /* HAVE___ATOMIC_THREAD_FENCE */
54 #endif /* not HAVE_ATOMIC_THREAD_FENCE */
56 #ifndef HAVE_ATOMIC_THREAD_FENCE
57 #ifdef HAVE___SYNC_SYNCHRONIZE
58 #define atomic_thread_fence(__ignore_order) __sync_synchronize()
59 #define HAVE_ATOMIC_THREAD_FENCE 1
60 #endif /* HAVE___SYNC_SYNCHRONIZE */
61 #endif /* not HAVE_ATOMIC_THREAD_FENCE */
63 #ifndef HAVE_ATOMIC_THREAD_FENCE
64 #ifdef HAVE_ATOMIC_THREAD_FENCE_SUPPORT
65 #error mismatch_error_between_configure_test_and_header
66 #endif
67 /* make sure the build fails if someone uses it without checking the define */
68 #define atomic_thread_fence(__order) \
69 __function__atomic_thread_fence_not_available_on_this_platform__()
70 #endif /* not HAVE_ATOMIC_THREAD_FENCE */
72 #endif