1 | /*
|
---|
2 | * Module: _ptw32.h
|
---|
3 | *
|
---|
4 | * Purpose:
|
---|
5 | * Pthreads-win32 internal macros, to be shared by other headers
|
---|
6 | * comprising the pthreads-win32 package.
|
---|
7 | *
|
---|
8 | * --------------------------------------------------------------------------
|
---|
9 | *
|
---|
10 | * Pthreads-win32 - POSIX Threads Library for Win32
|
---|
11 | * Copyright(C) 1998 John E. Bossom
|
---|
12 | * Copyright(C) 1999-2012, 2016, Pthreads-win32 contributors
|
---|
13 | *
|
---|
14 | * Homepage1: http://sourceware.org/pthreads-win32/
|
---|
15 | * Homepage2: http://sourceforge.net/projects/pthreads4w/
|
---|
16 | *
|
---|
17 | * The current list of contributors is contained
|
---|
18 | * in the file CONTRIBUTORS included with the source
|
---|
19 | * code distribution. The list can also be seen at the
|
---|
20 | * following World Wide Web location:
|
---|
21 | * http://sources.redhat.com/pthreads-win32/contributors.html
|
---|
22 | *
|
---|
23 | * This library is free software; you can redistribute it and/or
|
---|
24 | * modify it under the terms of the GNU Lesser General Public
|
---|
25 | * License as published by the Free Software Foundation; either
|
---|
26 | * version 2 of the License, or (at your option) any later version.
|
---|
27 | *
|
---|
28 | * This library is distributed in the hope that it will be useful,
|
---|
29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
31 | * Lesser General Public License for more details.
|
---|
32 | *
|
---|
33 | * You should have received a copy of the GNU Lesser General Public
|
---|
34 | * License along with this library in the file COPYING.LIB;
|
---|
35 | * if not, write to the Free Software Foundation, Inc.,
|
---|
36 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
---|
37 | *
|
---|
38 | */
|
---|
39 | #ifndef __PTW32_H
|
---|
40 | #define __PTW32_H
|
---|
41 |
|
---|
42 | /* See the README file for an explanation of the pthreads-win32
|
---|
43 | * version numbering scheme and how the DLL is named etc.
|
---|
44 | */
|
---|
45 | #define __PTW32_VERSION_MAJOR 2
|
---|
46 | #define __PTW32_VERSION_MINOR 10
|
---|
47 | #define __PTW32_VERSION_MICRO 0
|
---|
48 | #define __PTW32_VERSION_BUILD 0
|
---|
49 | #define __PTW32_VERSION 2,10,0,0
|
---|
50 | #define __PTW32_VERSION_STRING "2, 10, 0, 0\0"
|
---|
51 |
|
---|
52 | #if defined(__GNUC__)
|
---|
53 | # pragma GCC system_header
|
---|
54 | # if ! defined __declspec
|
---|
55 | # error "Please upgrade your GNU compiler to one that supports __declspec."
|
---|
56 | # endif
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | #if defined (__cplusplus)
|
---|
60 | # define __PTW32_BEGIN_C_DECLS extern "C" {
|
---|
61 | # define __PTW32_END_C_DECLS }
|
---|
62 | #else
|
---|
63 | # define __PTW32_BEGIN_C_DECLS
|
---|
64 | # define __PTW32_END_C_DECLS
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | /* When building the library, __PTW32_BUILD should be defined, so that the
|
---|
68 | * variables/functions are exported correctly. When using the library, you
|
---|
69 | * should NOT define __PTW32_BUILD, thus ensuring that variables/functions
|
---|
70 | * will be imported correctly, via an appropriate __PTW32_DECLSPEC.
|
---|
71 | */
|
---|
72 | #undef __PTW32_DECLSPEC
|
---|
73 | #undef __PTW32_USE_DLLIMPORT_DECORATION
|
---|
74 |
|
---|
75 | #if defined PTW32_STATIC_LIB
|
---|
76 | /* Upstream pthreads-win32 uses this user-specified feature test to declare
|
---|
77 | * explicitly that the pthreads library is to be linked statically; this is
|
---|
78 | * contrary to POSIX.1's mandate that feature test names should begin with
|
---|
79 | * an underscore character.
|
---|
80 | */
|
---|
81 | # warning "PTW32_STATIC_LIB is deprecated; use _PTW32_STATIC_LIB."
|
---|
82 | # ifndef _PTW32_STATIC_LIB
|
---|
83 | # define _PTW32_STATIC_LIB 1
|
---|
84 | # endif
|
---|
85 | # undef PTW32_STATIC_LIB
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | #ifndef _PTW32_STATIC_LIB
|
---|
89 | /* When the intention is NOT to link statically...
|
---|
90 | */
|
---|
91 | # if defined __PTW32_BUILD
|
---|
92 | /* ...and when actually implementing the pthreads library, then we want
|
---|
93 | * to explicitly identify those entities which are to be exported from
|
---|
94 | * the pthreads DLL, which is being built.
|
---|
95 | */
|
---|
96 | # define __PTW32_DECLSPEC __declspec(dllexport) __PTW32_CDECL
|
---|
97 |
|
---|
98 | # elif defined _MSC_VER || defined _DLLIMPORT_DECORATED
|
---|
99 | /* ...but, when NOT building the pthreads library, just signal that we
|
---|
100 | * want to decorate the declarations of imported entities, either when
|
---|
101 | * using MSVC, or the user explicitly requested it; in this case, we
|
---|
102 | * will complete the __PTW32_DECLSPEC definition below.
|
---|
103 | */
|
---|
104 | # define __USE_DLLIMPORT_DECORATION 1
|
---|
105 | # endif
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | #ifndef __PTW32_DECLSPEC
|
---|
109 | /* We still need to complete this definition...
|
---|
110 | */
|
---|
111 | # if __PTW32_USE_DLLIMPORT_DECORATION
|
---|
112 | /* ...either for a pthreads DLL client which explicitly wants to, (or
|
---|
113 | * needs to), link via explicitly decorated entity declarations...
|
---|
114 | */
|
---|
115 | # define __PTW32_DECLSPEC __declspec(dllimport) __PTW32_CDECL
|
---|
116 | # else
|
---|
117 | /* ...or for a statically linked client, (or indeed, a client which
|
---|
118 | * wishes to support a choice between static linking, or alternatively,
|
---|
119 | * dynamic linking via an import library).
|
---|
120 | */
|
---|
121 | # define __PTW32_DECLSPEC __PTW32_CDECL
|
---|
122 | # endif
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | #ifndef __PTW32_CDECL
|
---|
126 | /* Nominally, we prefer to use __cdecl calling convention for all our
|
---|
127 | * functions, but we map it through this macro alias to facilitate the
|
---|
128 | * possible choice of alternatives; for example:
|
---|
129 | */
|
---|
130 | # ifdef _OPEN_WATCOM_SOURCE
|
---|
131 | /* The Open Watcom C/C++ compiler uses a non-standard default calling
|
---|
132 | * convention, (similar to __fastcall), which passes function arguments
|
---|
133 | * in registers, unless the __cdecl convention is explicitly specified
|
---|
134 | * in exposed function prototypes.
|
---|
135 | *
|
---|
136 | * Our preference is to specify the __cdecl convention for all calls,
|
---|
137 | * even though this could slow Watcom code down slightly. If you know
|
---|
138 | * that the Watcom compiler will be used to build both the DLL and your
|
---|
139 | * application, then you may #define _OPEN_WATCOM_SOURCE, so disabling
|
---|
140 | * the forced specification of __cdecl for all function declarations;
|
---|
141 | * remember that this must be defined consistently, for both the DLL
|
---|
142 | * build, and the application build.
|
---|
143 | */
|
---|
144 | # define __PTW32_CDECL
|
---|
145 | # else
|
---|
146 | # define __PTW32_CDECL __cdecl
|
---|
147 | # endif
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | /* If the user has previously included <errno.h>, as witnessed by the
|
---|
151 | * prior definition of EDOM, (which is chosen because it is one of only
|
---|
152 | * three error codes required by ISO-C), then we must ensure that those
|
---|
153 | * non-Windows error codes required by pthreads-win32, and witnessed by
|
---|
154 | * definition of _PTW32_ERRNO_H, are also defined.
|
---|
155 | */
|
---|
156 | #if defined EDOM && ! defined _PTW32_ERRNO_H
|
---|
157 | # include "ptw32_errno.h"
|
---|
158 | #endif
|
---|
159 |
|
---|
160 | #endif /* !__PTW32_H */
|
---|