FreeWRL / FreeX3D 4.3.0
system_threads.h
1/*
2
3
4FreeWRL support library.
5Internal header: threading library, and processor control (sched).
6
7*/
8
9/****************************************************************************
10 This file is part of the FreeWRL/FreeX3D Distribution.
11
12 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
13
14 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
15 it under the terms of the GNU Lesser Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 FreeWRL/FreeX3D 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
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
26****************************************************************************/
27
28
29#ifndef __LIBFREEWRL_SYSTEM_THREADS_H__
30#define __LIBFREEWRL_SYSTEM_THREADS_H__
31
32
33#if HAVE_PTHREAD
34# include <pthread.h>
35# include <errno.h>
36#endif
37
38#if HAVE_SCHED_H
39#include <sched.h>
40#endif
41
45#if !defined(WIN32)
46
47#define DEF_THREAD(_t) pthread_t _t = (pthread_t)0
48#define TEST_NULL_THREAD(_t) (_t == (pthread_t)0)
49#define ID_THREAD(_t) ((unsigned int) _t)
50#define ZERO_THREAD(_t) (_t = (pthread_t)0)
51
52#else /* !defined(WIN32) */
53
54#define DEF_THREAD(_t) pthread_t _t = { NULL, 0 }
55#define TEST_NULL_THREAD(_t) (_t.p == NULL)
56#define ID_THREAD(_t) ((unsigned int) _t.p)
57#define ZERO_THREAD(_t) { _t.p = NULL; }
58
59#endif
60extern pthread_t _THREAD_NULL_;
61
62#endif /* __LIBFREEWRL_SYSTEM_THREADS_H__ */