]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_aux.h
Import dlmalloc (public domain) as a malloc implementation. Add stub opt/notime
[pdclib] / internals / _PDCLIB_aux.h
1 #ifndef _PDCLIB_AUX_H
2 #define _PDCLIB_AUX_H
3
4 /* Auxiliary PDCLib code <_PDCLIB_aux.h>
5
6    This file is part of the Public Domain C Library (PDCLib).
7    Permission is granted to use, modify, and / or redistribute at will.
8 */
9
10 /* -------------------------------------------------------------------------- */
11 /* You should not have to edit anything in this file; if you DO have to, it   */
12 /* would be considered a bug / missing feature: notify the author(s).         */
13 /* -------------------------------------------------------------------------- */
14
15 /* -------------------------------------------------------------------------- */
16 /* Standard Version                                                           */
17 /* -------------------------------------------------------------------------- */
18
19 /* Many a compiler gets this wrong, so you might have to hardcode it instead. */
20
21 #if __STDC__ != 1
22 #error Compiler does not define _ _STDC_ _ to 1 (not standard-compliant)!
23 #endif
24
25 #if defined(_PDCLIB_C_VERSION)
26         /* Pass - conditional simplification case */
27 #elif !defined(__STDC_VERSION__)
28         #define _PDCLIB_C_VERSION 1990
29 #elif __STDC_VERSION__ == 199409L
30         #define _PDCLIB_C_VERSION 1995
31 #elif __STDC_VERSION__ == 199901L
32         #define _PDCLIB_C_VERSION 1999
33 #elif __STDC_VERSION__ == 201112L
34         #define _PDCLIB_C_VERSION 2011
35 #else
36         #error Unsupported _ _STDC_VERSION_ _ (__STDC_VERSION__) (supported: ISO/IEC 9899:1990, 9899/AMD1:1995, 9899:1999, 9899:2011).
37 #endif
38
39 #if !defined(__cplusplus) || defined(_PDCLIB_CXX_VERSION)
40         /* Pass - conditional simplification case */
41 #elif __cplusplus == 201103L
42         #define _PDCLIB_CXX_VERSION 2011
43         #if _PDCLIB_C_VERSION < 2011
44                 #undef _PDCLIB_C_VERSION
45                 #define _PDCLIB_C_VERSION 2011
46         #endif
47 #elif __cplusplus == 199711L
48    #define _PDCLIB_CXX_VERSION 1997
49 #else
50    #error Unsupported _ _cplusplus (__cplusplus) (supported: ISO/IEC 14882:1997, ISO/IEC 14882:2011).
51 #endif
52
53 #if _PDCLIB_C_VERSION >= 1999 || defined(__cplusplus)
54         #ifndef __cplusplus
55                 #define _PDCLIB_restrict restrict
56         #endif
57         #define _PDCLIB_inline   inline
58 #endif
59
60 #if _PDCLIB_CXX_VERSION >= 2011
61         #define _PDCLIB_noreturn [[noreturn]]
62 #elif _PDCLIB_C_VERSION >= 2011
63         #define _PDCLIB_noreturn _Noreturn
64 #endif
65
66 #ifdef _WIN32
67    #define _PDCLIB_EXPORT __declspec(dllexport)
68    #define _PDCLIB_IMPORT __declspec(dllimport)
69 #endif
70
71 #ifdef __GNUC__
72         #ifndef _PDCLIB_EXPORT
73                 #define _PDCLIB_EXPORT __attribute__((__visibility__("protected")))
74         #endif
75
76         #ifndef _PDCLIB_IMPORT
77                 #define _PDCLIB_IMPORT
78         #endif
79
80         #ifndef _PDCLIB_HIDDEN
81                 #define _PDCLIB_HIDDEN __attribute__((__visibility__("hidden")))
82         #endif
83
84         #ifndef _PDCLIB_restrict
85                 #define _PDCLIB_restrict __restrict
86         #endif
87
88         #ifndef _PDCLIB_inline
89                 #define _PDCLIB_inline __inline
90         #endif
91
92         #ifndef _PDCLIB_noreturn
93                 #define _PDCLIB_noreturn __attribute__((noreturn))
94         #endif
95 #endif
96
97 #ifndef _PDCLIB_EXPORT
98         #define _PDCLIB_EXPORT
99 #endif
100 #ifndef _PDCLIB_IMPORT
101         #define _PDCLIB_IMPORT
102 #endif
103 #ifndef _PDCLIB_HIDDEN
104         #define _PDCLIB_HIDDEN
105 #endif
106
107 #if defined(_PDCLIB_SHARED) 
108         #if defined(_PDCLIB_BUILD)
109                 #define _PDCLIB_API _PDCLIB_EXPORT
110         #else
111                 #define _PDCLIB_API _PDCLIB_IMPORT
112         #endif
113 #else
114         #define _PDCLIB_API _PDCLIB_HIDDEN
115 #endif
116
117 #ifndef _PDCLIB_restrict
118         #define _PDCLIB_restrict
119 #endif
120
121 #ifndef _PDCLIB_inline
122         #define _PDCLIB_inline
123 #endif
124
125 #ifndef _PDCLIB_noreturn
126         #define _PDCLIB_noreturn
127 #endif
128
129 #ifndef __STDC_HOSTED__
130 #error Compiler does not define _ _STDC_HOSTED_ _ (not standard-compliant)!
131 #elif __STDC_HOSTED__ == 0
132 #define _PDCLIB_HOSTED 0
133 #elif __STDC_HOSTED__ == 1
134 #define _PDCLIB_HOSTED 1
135 #else
136 #error Compiler does not define _ _STDC_HOSTED_ _ to 0 or 1 (not standard-compliant)!
137 #endif
138
139 #ifdef __cplusplus
140         #define _PDCLIB_BEGIN_EXTERN_C extern "C" {
141         #define _PDCLIB_END_EXTERN_C }
142 #else
143    #define _PDCLIB_BEGIN_EXTERN_C
144    #define _PDCLIB_END_EXTERN_C
145 #endif
146
147 /*#if _PDCLIB_C_VERSION != 1999
148 #error PDCLib might not be fully conforming to either C89 or C95 prior to v2.x.
149 #endif*/
150
151 /* -------------------------------------------------------------------------- */
152 /* Helper macros:                                                             */
153 /* _PDCLIB_cc( x, y ) concatenates two preprocessor tokens without extending  */
154 /* _PDCLIB_concat( x, y ) concatenates two preprocessor tokens with extending */
155 /* -------------------------------------------------------------------------- */
156
157 #define _PDCLIB_cc( x, y )     x ## y
158 #define _PDCLIB_concat( x, y ) _PDCLIB_cc( x, y )
159
160 #define _PDCLIB_symbol2value( x ) #x
161 #define _PDCLIB_symbol2string( x ) _PDCLIB_symbol2value( x )
162
163 #ifndef __PDCLIB_PURE
164     #define __PDCLIB_PURE 0
165 #endif
166
167 #ifndef _PDCLIB_POSIX_EX
168     #define _PDCLIB_POSIX_EX (!__PDCLIB_PURE)
169 #endif
170 #endif