root/trunk/dep/include/zthread/Config.h @ 2

Revision 2, 7.0 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (c) 2005, Eric Crahen
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is furnished
9 * to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 *
21 */
22
23#ifndef __ZTCONFIG_H__
24#define __ZTCONFIG_H__
25
26// =====================================================================================
27// The following section describes the symbols the configure program will define.
28// If you are not using configure (autoconf), then you make want to set these by
29// uncommenting them here, or whatever other means you'd like.
30// =====================================================================================
31
32// (configure)
33// Uncomment to disable actually changing the operating systems real thread priority
34// #define ZTHREAD_DISABLE_PRIORITY 1
35
36// (configure)
37// Uncomment to disable compiling the interrupt() hook mechanisms.
38// #define ZTHREAD_DISABLE_INTERRUPT 1
39
40// (configure)
41// Uncomment to select a Win32 ThreadOps implementation that uses _beginthreadex()
42// otherwise, CreateThread() will be used for a Windows compilation
43// #define HAVE_BEGINTHREADEX 1
44
45// (configure)
46// Uncomment to select a pthreads based implementation
47// #define ZT_POSIX 1
48
49// (configure)
50// Uncomment to select a Windows based implementation that uses features not
51// supported by windows 98 and 95
52// #define ZT_WIN32 1
53
54// (configure)
55// Uncomment to select a Windows based implementation that does not use features not
56// supported by windows 98 and 95, but may not be compatible with 64 bit or alpha systems
57// #define ZT_WIN9X 1
58
59// (configure)
60// Uncomment to select a MacOS based implementation
61// #define ZT_MACOS 1
62
63// (configure)
64// Uncomment to prefer vanilla implementations of primatives when possible
65// #define ZT_VANILLA 1
66
67// =====================================================================================
68// The following section can be customized to select the implementation that is compiled
69// Eventually, the configure program will be updated to define these symbols as well.
70// =====================================================================================
71
72// Uncomment to select very simple spinlock based implementations
73// #define ZTHREAD_USE_SPIN_LOCKS 1
74
75// Uncomment to select the vannila dual mutex implementation of FastRecursiveLock
76// #define ZTHREAD_DUAL_LOCKS 1
77
78// Uncomment to select a POSIX implementation of FastRecursiveLock that does not
79// spin, but instead sleeps on a condition variable.
80// #define ZTHREAD_CONDITION_LOCKS 1
81
82// Uncomment if you want to eliminate inlined code used as a part of some template classes
83// #define ZTHREAD_NOINLINE
84
85// Uncomment if you want to compile a DLL version of the library. (Win32)
86// #define ZTHREAD_EXPORTS 1
87
88// Uncomment if you want to compile a client using the DLL version of the library. (Win32)
89// #define ZTHREAD_IMPORTS 1
90
91// ===================================================================================
92// The following section will attempt to guess the best configuration for your system
93// ===================================================================================
94
95// Select an implementation by checking out the environment, first looking for
96// compilers, then by looking for other definitions that could be present
97
98#if !defined(ZT_POSIX) && !defined(ZT_WIN9X) && !defined(ZT_WIN32) && !defined(ZT_MACOS)
99
100// Check for well known compilers
101#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__BCPLUSPLUS__) || defined(__MINGW32__)
102
103#  define ZT_WIN32
104
105#elif defined(__CYGWIN__)
106
107#  define ZT_POSIX
108
109// Check for well known platforms
110#elif defined(__linux__) || \
111      defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
112      defined(__hpux) || \
113      defined(__sgi) || \
114      defined(__sun)
115
116#  define ZT_POSIX
117
118// Check for definitions from well known headers
119#elif defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
120
121#  define ZT_POSIX
122
123#elif defined(WIN32_LEAN_AND_MEAN)
124
125#  define ZT_WIN32
126
127#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
128
129#  define ZT_MACOS
130
131#else
132#  error "Could not select implementation, define ZT_WIN9X, ZT_WIN32, ZT_POSIX or ZT_MACOS"
133#endif
134
135#endif
136
137// Once an implementation has been selected, configure the API decorator
138// for shared libraries if its needed.
139
140#if defined(ZTHREAD_SHARED)  // Compatibility w/ past releases
141
142#  define ZTHREAD_IMPORTS
143
144#elif defined(ZTHREAD_STATIC)
145
146#  undef ZTHREAD_EXPORTS
147#  undef ZTHREAD_IMPORTS
148
149#endif
150
151// Windows users will get a static build by default, unless they
152// define either ZTHREAD_IMPORTS or ZTHREAD_EXPORTS. Client code
153// of a dll version of this library should define the first flag;
154// To build the dll version of this library, define the second.
155
156#if defined(ZTHREAD_IMPORTS) && defined(ZTHREAD_EXPORTS)
157#  error "Import and export declarations are not valid"
158#else
159
160#  if defined(ZTHREAD_IMPORTS)
161#    define ZTHREAD_API __declspec(dllimport)
162#  elif defined(ZTHREAD_EXPORTS)
163#    define ZTHREAD_API __declspec(dllexport)
164#  else
165#    define ZTHREAD_API
166#  endif
167
168#endif
169
170// Once the API decorator is configured, create a macro for
171// explicit template instantiation (whose need can hopefully
172// be removed from the library)
173
174#if defined(ZTHREAD_EXPORTS)
175#  define EXPLICIT_TEMPLATE(X) template class __declspec( dllexport ) X;
176#elif defined(ZTHREAD_IMPORTS)
177#  define EXPLICIT_TEMPLATE(X) template class __declspec( dllimport ) X;
178#else
179#  define EXPLICIT_TEMPLATE(X)
180#endif
181
182// Give libc a hint, should be defined by the user - but people tend
183// to forget.
184
185#if !defined(REENTRANT)
186#  define REENTRANT
187#endif
188
189#if !defined(_REENTRANT)
190#  define _REENTRANT
191#endif
192
193#if defined(_MSC_VER)
194#  pragma warning(disable:4275)
195#  pragma warning(disable:4290)
196#  pragma warning(disable:4786)
197#  pragma warning(disable:4251)
198#  pragma warning(disable:4355)
199#endif
200
201// Ensure that only one implementation is selected
202#if \
203(defined(ZT_POSIX) && defined(ZT_WIN32)) \
204 || (defined(ZT_POSIX) && defined(ZT_WIN9X)) \
205    || (defined(ZT_WIN32) && defined(ZT_WIN9X))
206
207#  error "Only one implementation should be selected!"
208
209#endif
210
211#if defined(ZTHREAD_NOINLINE)
212#  define ZTHREAD_INLINE
213#else
214#  define ZTHREAD_INLINE inline
215#endif
216
217#endif // __ZTCONFIG_H__
218
Note: See TracBrowser for help on using the browser.