s3:torture: call fault_setup() to get usage backtraces
[Samba/gebeck_regimport.git] / lib / util / smb_threads_internal.h
blobafd7559f3b001a536eb8ca977375f20c59f1e130
1 /*
2 SMB/CIFS implementation.
3 SMB thread interface internal macros.
4 Copyright (C) Jeremy Allison, 2009.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _smb_threads_internal_h_
21 #define _smb_threads_internal_h_
23 #define SMB_THREAD_CREATE_MUTEX(name, lockvar) \
24 (global_tfp ? global_tfp->create_mutex((name), &(lockvar), __location__) : 0)
26 #define SMB_THREAD_DESTROY_MUTEX(plock) \
27 do { \
28 if (global_tfp) { \
29 global_tfp->destroy_mutex(plock, __location__); \
30 }; \
31 } while (0)
33 #define SMB_THREAD_LOCK_INTERNAL(plock, type, location) \
34 (global_tfp ? global_tfp->lock_mutex((plock), (type), location) : 0)
36 #define SMB_THREAD_LOCK(plock) \
37 SMB_THREAD_LOCK_INTERNAL(plock, SMB_THREAD_LOCK, __location__)
39 #define SMB_THREAD_UNLOCK(plock) \
40 SMB_THREAD_LOCK_INTERNAL(plock, SMB_THREAD_UNLOCK, __location__)
42 #define SMB_THREAD_ONCE(ponce, init_fn, pdata) \
43 (global_tfp \
44 ? (! *(ponce) \
45 ? smb_thread_once((ponce), (init_fn), (pdata)) \
46 : 0) \
47 : ((init_fn(pdata)), *(ponce) = true, 1))
49 #define SMB_THREAD_CREATE_TLS(keyname, key) \
50 (global_tfp ? global_tfp->create_tls((keyname), &(key), __location__) : 0)
52 #define SMB_THREAD_DESTROY_TLS(key) \
53 do { \
54 if (global_tfp) { \
55 global_tfp->destroy_tls(&(key), __location__); \
56 }; \
57 } while (0)
59 #define SMB_THREAD_SET_TLS(key, val) \
60 (global_tfp ? global_tfp->set_tls((key),(val),__location__) : \
61 ((key) = (val), 0))
63 #define SMB_THREAD_GET_TLS(key) \
64 (global_tfp ? global_tfp->get_tls((key), __location__) : (key))
67 * Global thread lock list.
70 #define NUM_GLOBAL_LOCKS 1
72 #define GLOBAL_LOCK(locknum) (global_lock_array ? global_lock_array[(locknum)] : NULL)
74 #endif