summaryrefslogtreecommitdiff
path: root/storage/tokudb/PerconaFT/third_party/xz-4.999.9beta/src/common/mythread.h
blob: c1cc659ccc239964fdab1674e7b8609734a7588e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: expandtab:ts=8:sw=4:softtabstop=4:
///////////////////////////////////////////////////////////////////////////////
//
/// \file       mythread.h
/// \brief      Wrappers for threads
//
//  Author:     Lasse Collin
//
//  This file has been put into the public domain.
//  You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////

#include "sysdefs.h"


#ifdef HAVE_PTHREAD
#	include <pthread.h>

#	define mythread_once(func) \
	do { \
		static pthread_once_t once_ = PTHREAD_ONCE_INIT; \
		pthread_once(&once_, &func); \
	} while (0)

#	define mythread_sigmask(how, set, oset) \
		pthread_sigmask(how, set, oset)

#else

#	define mythread_once(func) \
	do { \
		static bool once_ = false; \
		if (!once_) { \
			func(); \
			once_ = true; \
		} \
	} while (0)

#	define mythread_sigmask(how, set, oset) \
		sigprocmask(how, set, oset)

#endif