1207753Smm///////////////////////////////////////////////////////////////////////////////
2207753Smm//
3207753Smm/// \file       mythread.h
4207753Smm/// \brief      Wrappers for threads
5207753Smm//
6207753Smm//  Author:     Lasse Collin
7207753Smm//
8207753Smm//  This file has been put into the public domain.
9207753Smm//  You can do whatever you want with this file.
10207753Smm//
11207753Smm///////////////////////////////////////////////////////////////////////////////
12207753Smm
13207753Smm#include "sysdefs.h"
14207753Smm
15207753Smm
16207753Smm#ifdef HAVE_PTHREAD
17207753Smm#	include <pthread.h>
18207753Smm
19207753Smm#	define mythread_once(func) \
20207753Smm	do { \
21207753Smm		static pthread_once_t once_ = PTHREAD_ONCE_INIT; \
22207753Smm		pthread_once(&once_, &func); \
23207753Smm	} while (0)
24207753Smm
25207753Smm#	define mythread_sigmask(how, set, oset) \
26207753Smm		pthread_sigmask(how, set, oset)
27207753Smm
28207753Smm#else
29207753Smm
30207753Smm#	define mythread_once(func) \
31207753Smm	do { \
32207753Smm		static bool once_ = false; \
33207753Smm		if (!once_) { \
34207753Smm			func(); \
35207753Smm			once_ = true; \
36207753Smm		} \
37207753Smm	} while (0)
38207753Smm
39207753Smm#	define mythread_sigmask(how, set, oset) \
40207753Smm		sigprocmask(how, set, oset)
41207753Smm
42207753Smm#endif
43