v0.3.0
Fast, portable C library for geometry input/output
Main Page
Modules
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Modules
gmio_core
global.h
Go to the documentation of this file.
1
/****************************************************************************
2
** Copyright (c) 2016, Fougue Ltd. <http://www.fougue.pro>
3
** All rights reserved.
4
**
5
** Redistribution and use in source and binary forms, with or without
6
** modification, are permitted provided that the following conditions
7
** are met:
8
**
9
** 1. Redistributions of source code must retain the above copyright
10
** notice, this list of conditions and the following disclaimer.
11
**
12
** 2. Redistributions in binary form must reproduce the above
13
** copyright notice, this list of conditions and the following
14
** disclaimer in the documentation and/or other materials provided
15
** with the distribution.
16
**
17
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
****************************************************************************/
29
41
#ifndef GMIO_GLOBAL_H
42
#define GMIO_GLOBAL_H
43
44
/* "config.h" is generated by cmake, it should reside in the out-of-source
45
* build dir.
46
* In CMakeFiles.txt, the directory where resides "config.h" is added to the
47
* include path list
48
*/
49
#include "config.h"
50
51
/* GMIO_OS_WIN */
52
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) \
53
|| defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
54
|| defined(__NT__)
55
# define GMIO_OS_WIN
56
#endif
57
58
/* GMIO_OS_LINUX */
59
#if defined(__linux) || defined(__linux__) || defined(linux)
60
# define GMIO_OS_LINUX
61
#endif
62
63
/* GMIO_OS_MAC */
64
#if defined(__APPLE__)
65
# define GMIO_OS_MAC
66
#endif
67
68
/* GMIO_DECL_IMPORT */
69
/* GMIO_DECL_EXPORT */
70
#ifdef GMIO_OS_WIN
71
# define GMIO_DECL_EXPORT __declspec(dllexport)
72
# define GMIO_DECL_IMPORT __declspec(dllimport)
73
#else
74
75
# define GMIO_DECL_EXPORT
76
77
# define GMIO_DECL_IMPORT
78
#endif
79
80
/* GMIO_API */
81
#ifdef GMIO_DLL
82
# ifdef GMIO_MAKING_DLL
83
# define GMIO_API GMIO_DECL_EXPORT
84
# else
85
# define GMIO_API GMIO_DECL_IMPORT
86
# endif
/* GMIO_MAKING_DLL */
87
#else
88
90
# define GMIO_API
91
#endif
92
93
/* GMIO_HAVE_INT64_TYPE */
94
#if defined(GMIO_HAVE_INT64_T) \
95
|| defined(GMIO_HAVE_MSVC_INT64) \
96
|| defined(GMIO_HAVE_LONG_LONG)
97
# define GMIO_HAVE_INT64_TYPE
98
#endif
99
100
/* Typedefs for specific width integers */
101
#ifdef GMIO_HAVE_STDINT_H
102
# include <stdint.h>
103
#else
104
typedef
char
int8_t;
105
typedef
unsigned
char
uint8_t;
106
107
# if GMIO_SIZEOF_SHORT == 2
108
typedef
short
int16_t;
109
typedef
unsigned
short
uint16_t;
110
# else
111
# error Not supported: sizeof(short) != 2
112
# endif
113
114
# if GMIO_SIZEOF_INT == 4
115
typedef
int
int32_t;
116
typedef
unsigned
int
uint32_t;
117
# elif GMIO_SIZEOF_LONG == 4
118
typedef
long
int32_t;
119
typedef
unsigned
long
uint32_t;
120
# else
121
# error Failed to find a 32bit integer type with 'int' and 'long'
122
# endif
123
124
# ifndef GMIO_HAVE_INT64_T
125
# if defined(GMIO_HAVE_MSVC_INT64)
126
typedef
__int64_t int64_t;
127
typedef
unsigned
__int64_t uint64_t;
128
# elif defined(GMIO_HAVE_LONG_LONG)
129
typedef
long
long
int64_t;
130
typedef
unsigned
long
long
uint64_t;
131
# endif
132
#endif
133
134
# ifdef GMIO_HAVE_INT64_TYPE
135
typedef
int64_t intmax_t;
136
typedef
uint64_t uintmax_t;
137
# else
138
typedef
int32_t intmax_t;
139
typedef
uint32_t uintmax_t;
140
# endif
141
142
#endif
143
144
/* GMIO_HAVE_STDBOOL_H */
145
#ifdef GMIO_HAVE_STDBOOL_H
146
# include <stdbool.h>
147
#elif !defined(DOXYGEN) && !defined(__cplusplus)
148
typedef
int
bool;
149
enum
gmio_bool_value
150
{
151
false
= 0,
152
true
= 1
153
};
154
#endif
155
156
/* GMIO_UNUSED */
158
#define GMIO_UNUSED(x) (void)x;
159
160
/* GMIO_INLINE */
161
#ifndef GMIO_INLINE
162
# if defined(__GNUC__)
163
# define GMIO_INLINE __inline__ static
/* Compatible with C90 */
164
# elif defined(_MSC_VER)
165
# define GMIO_INLINE __inline static
166
# elif !defined(DOXYGEN)
167
# define GMIO_INLINE static
168
# else
169
170
# define GMIO_INLINE
171
# endif
172
#endif
173
174
/* GMIO_RESTRICT */
175
#ifndef GMIO_RESTRICT
176
# if defined(__GNUC__)
177
# define GMIO_RESTRICT __restrict__
/* Compatible with C90 */
178
# elif defined(_MSC_VER)
179
# define GMIO_RESTRICT __restrict
180
# elif defined(GMIO_HAVE_C99_RESTRICT)
/* TODO: add cmake detectection */
181
# define GMIO_RESTRICT restrict
182
# else
183
184
# define GMIO_RESTRICT
185
# endif
186
#endif
187
188
/* GMIO_C_LINKAGE_BEGIN */
189
/* GMIO_C_LINKAGE_END */
190
#ifdef __cplusplus
191
# define GMIO_C_LINKAGE_BEGIN extern "C" {
192
# define GMIO_C_LINKAGE_END }
193
#else
194
195
# define GMIO_C_LINKAGE_BEGIN
196
197
# define GMIO_C_LINKAGE_END
198
#endif
199
200
/* GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE */
201
/* GMIO_PRAGMA_MSVC_WARNING_POP */
202
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Visual C++ 2008 */
203
# define GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(__code__) \
204
__pragma(warning(push)) \
205
__pragma(warning(disable: __code__))
206
# define GMIO_PRAGMA_MSVC_WARNING_POP() \
207
__pragma(warning(pop))
208
#else
209
217
# define GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(__code__)
218
225
# define GMIO_PRAGMA_MSVC_WARNING_POP()
226
#endif
227
229
#define GMIO_ARRAY_SIZE(array) sizeof(array) / sizeof(*array)
230
231
#endif
/* GMIO_GLOBAL_H */
232
Fougue © 2016
Last Update: Tue Jul 5 2016