1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 // vim: expandtab:ts=8:sw=4:softtabstop=4: 3 /////////////////////////////////////////////////////////////////////////////// 4 // 5 /// \file mythread.h 6 /// \brief Wrappers for threads 7 // 8 // Author: Lasse Collin 9 // 10 // This file has been put into the public domain. 11 // You can do whatever you want with this file. 12 // 13 /////////////////////////////////////////////////////////////////////////////// 14 15 #include "sysdefs.h" 16 17 18 #ifdef HAVE_PTHREAD 19 # include <pthread.h> 20 21 # define mythread_once(func) \ 22 do { \ 23 static pthread_once_t once_ = PTHREAD_ONCE_INIT; \ 24 pthread_once(&once_, &func); \ 25 } while (0) 26 27 # define mythread_sigmask(how, set, oset) \ 28 pthread_sigmask(how, set, oset) 29 30 #else 31 32 # define mythread_once(func) \ 33 do { \ 34 static bool once_ = false; \ 35 if (!once_) { \ 36 func(); \ 37 once_ = true; \ 38 } \ 39 } while (0) 40 41 # define mythread_sigmask(how, set, oset) \ 42 sigprocmask(how, set, oset) 43 44 #endif 45