| 0.9.6

- Main Page
- Modules
- Files

- File List

setup.hpp
Go to the documentation of this file.
1
33 #pragma once
34
35 #include <cassert>
36 #include <cstddef>
37
39 // Version
40
41 #define GLM_VERSION 96
42 #define GLM_VERSION_MAJOR 0
43 #define GLM_VERSION_MINOR 9
44 #define GLM_VERSION_PATCH 6
45 #define GLM_VERSION_REVISION 0
46
48 // Platform
49
50 #define GLM_PLATFORM_UNKNOWN 0x00000000
51 #define GLM_PLATFORM_WINDOWS 0x00010000
52 #define GLM_PLATFORM_LINUX 0x00020000
53 #define GLM_PLATFORM_APPLE 0x00040000
54 //#define GLM_PLATFORM_IOS 0x00080000
55 #define GLM_PLATFORM_ANDROID 0x00100000
56 #define GLM_PLATFORM_CHROME_NACL 0x00200000
57 #define GLM_PLATFORM_UNIX 0x00400000
58 #define GLM_PLATFORM_QNXNTO 0x00800000
59 #define GLM_PLATFORM_WINCE 0x01000000
60
61 #ifdef GLM_FORCE_PLATFORM_UNKNOWN
62 # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
63 #elif defined(__QNXNTO__)
64 # define GLM_PLATFORM GLM_PLATFORM_QNXNTO
65 #elif defined(__APPLE__)
66 # define GLM_PLATFORM GLM_PLATFORM_APPLE
67 #elif defined(WINCE)
68 # define GLM_PLATFORM GLM_PLATFORM_WINCE
69 #elif defined(_WIN32)
70 # define GLM_PLATFORM GLM_PLATFORM_WINDOWS
71 #elif defined(__native_client__)
72 # define GLM_PLATFORM GLM_PLATFORM_CHROME_NACL
73 #elif defined(__ANDROID__)
74 # define GLM_PLATFORM GLM_PLATFORM_ANDROID
75 #elif defined(__linux)
76 # define GLM_PLATFORM GLM_PLATFORM_LINUX
77 #elif defined(__unix)
78 # define GLM_PLATFORM GLM_PLATFORM_UNIX
79 #else
80 # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
81 #endif//
82
83 // Report platform detection
84 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_PLATFORM_DISPLAYED))
85 # define GLM_MESSAGE_PLATFORM_DISPLAYED
86 # if(GLM_PLATFORM & GLM_PLATFORM_QNXNTO)
87 # pragma message("GLM: QNX platform detected")
88 //# elif(GLM_PLATFORM & GLM_PLATFORM_IOS)
89 //# pragma message("GLM: iOS platform detected")
90 # elif(GLM_PLATFORM & GLM_PLATFORM_APPLE)
91 # pragma message("GLM: Apple platform detected")
92 # elif(GLM_PLATFORM & GLM_PLATFORM_WINCE)
93 # pragma message("GLM: WinCE platform detected")
94 # elif(GLM_PLATFORM & GLM_PLATFORM_WINDOWS)
95 # pragma message("GLM: Windows platform detected")
96 # elif(GLM_PLATFORM & GLM_PLATFORM_CHROME_NACL)
97 # pragma message("GLM: Native Client detected")
98 # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
99 # pragma message("GLM: Android platform detected")
100 # elif(GLM_PLATFORM & GLM_PLATFORM_LINUX)
101 # pragma message("GLM: Linux platform detected")
102 # elif(GLM_PLATFORM & GLM_PLATFORM_UNIX)
103 # pragma message("GLM: UNIX platform detected")
104 # elif(GLM_PLATFORM & GLM_PLATFORM_UNKNOWN)
105 # pragma message("GLM: platform unknown")
106 # else
107 # pragma message("GLM: platform not detected")
108 # endif
109 #endif//GLM_MESSAGE
110
112 // Compiler
113
114 // User defines: GLM_FORCE_COMPILER_UNKNOWN
115 // TODO ? __llvm__
116
117 #define GLM_COMPILER_UNKNOWN 0x00000000
118
119 // Intel
120 #define GLM_COMPILER_INTEL 0x00100000
121 #define GLM_COMPILER_INTEL12 0x00100010
122 #define GLM_COMPILER_INTEL12_1 0x00100020
123 #define GLM_COMPILER_INTEL13 0x00100030
124 #define GLM_COMPILER_INTEL14 0x00100040
125 #define GLM_COMPILER_INTEL15 0x00100050
126
127 // Visual C++ defines
128 #define GLM_COMPILER_VC 0x01000000
129 #define GLM_COMPILER_VC2010 0x01000090
130 #define GLM_COMPILER_VC2012 0x010000A0
131 #define GLM_COMPILER_VC2013 0x010000B0
132 #define GLM_COMPILER_VC2015 0x010000C0
133
134 // GCC defines
135 #define GLM_COMPILER_GCC 0x02000000
136 #define GLM_COMPILER_GCC44 0x020000B0
137 #define GLM_COMPILER_GCC45 0x020000C0
138 #define GLM_COMPILER_GCC46 0x020000D0
139 #define GLM_COMPILER_GCC47 0x020000E0
140 #define GLM_COMPILER_GCC48 0x020000F0
141 #define GLM_COMPILER_GCC49 0x02000100
142 #define GLM_COMPILER_GCC50 0x02000200
143
144 // CUDA
145 #define GLM_COMPILER_CUDA 0x10000000
146 #define GLM_COMPILER_CUDA40 0x10000040
147 #define GLM_COMPILER_CUDA41 0x10000050
148 #define GLM_COMPILER_CUDA42 0x10000060
149 #define GLM_COMPILER_CUDA50 0x10000070
150 #define GLM_COMPILER_CUDA60 0x10000080
151 #define GLM_COMPILER_CUDA65 0x10000090
152
153 // LLVM
154 #define GLM_COMPILER_LLVM 0x20000000
155 #define GLM_COMPILER_LLVM32 0x20000030
156 #define GLM_COMPILER_LLVM33 0x20000040
157 #define GLM_COMPILER_LLVM34 0x20000050
158 #define GLM_COMPILER_LLVM35 0x20000060
159
160 // Apple Clang
161 #define GLM_COMPILER_APPLE_CLANG 0x40000000
162 #define GLM_COMPILER_APPLE_CLANG40 0x40000010
163 #define GLM_COMPILER_APPLE_CLANG41 0x40000020
164 #define GLM_COMPILER_APPLE_CLANG42 0x40000030
165 #define GLM_COMPILER_APPLE_CLANG50 0x40000040
166 #define GLM_COMPILER_APPLE_CLANG51 0x40000050
167 #define GLM_COMPILER_APPLE_CLANG60 0x40000060
168
169 // Build model
170 #define GLM_MODEL_32 0x00000010
171 #define GLM_MODEL_64 0x00000020
172
173 // Force generic C++ compiler
174 #ifdef GLM_FORCE_COMPILER_UNKNOWN
175 # define GLM_COMPILER GLM_COMPILER_UNKNOWN
176
177 #elif defined(__INTEL_COMPILER)
178 # if __INTEL_COMPILER == 1200
179 # define GLM_COMPILER GLM_COMPILER_INTEL12
180 # elif __INTEL_COMPILER == 1210
181 # define GLM_COMPILER GLM_COMPILER_INTEL12_1
182 # elif __INTEL_COMPILER == 1300
183 # define GLM_COMPILER GLM_COMPILER_INTEL13
184 # elif __INTEL_COMPILER == 1400
185 # define GLM_COMPILER GLM_COMPILER_INTEL14
186 # elif __INTEL_COMPILER >= 1500
187 # define GLM_COMPILER GLM_COMPILER_INTEL15
188 # else
189 # define GLM_COMPILER GLM_COMPILER_INTEL
190 # endif
191
192 // CUDA
193 #elif defined(__CUDACC__)
194 # if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA)
195 # include <cuda.h> // make sure version is defined since nvcc does not define it itself!
196 # endif
197 # if CUDA_VERSION < 3000
198 # error "GLM requires CUDA 3.0 or higher"
199 # else
200 # define GLM_COMPILER GLM_COMPILER_CUDA
201 # endif
202
203 // Visual C++
204 #elif defined(_MSC_VER)
205 # if _MSC_VER < 1600
206 # error "GLM requires Visual C++ 2010 or higher"
207 # elif _MSC_VER == 1600
208 # define GLM_COMPILER GLM_COMPILER_VC2010
209 # elif _MSC_VER == 1700
210 # define GLM_COMPILER GLM_COMPILER_VC2012
211 # elif _MSC_VER == 1800
212 # define GLM_COMPILER GLM_COMPILER_VC2013
213 # elif _MSC_VER >= 1900
214 # define GLM_COMPILER GLM_COMPILER_VC2015
215 # else//_MSC_VER
216 # define GLM_COMPILER GLM_COMPILER_VC
217 # endif//_MSC_VER
218
219 // Clang
220 #elif defined(__clang__)
221 # if GLM_PLATFORM & GLM_PLATFORM_APPLE
222 # if __clang_major__ == 4 && __clang_minor__ == 0
223 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG40
224 # elif __clang_major__ == 4 && __clang_minor__ == 1
225 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG41
226 # elif __clang_major__ == 4 && __clang_minor__ == 2
227 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG42
228 # elif __clang_major__ == 5 && __clang_minor__ == 0
229 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG50
230 # elif __clang_major__ == 5 && __clang_minor__ == 1
231 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG51
232 # elif __clang_major__ >= 6
233 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG60
234 # endif
235 # else
236 # if __clang_major__ == 3 && __clang_minor__ == 0
237 # define GLM_COMPILER GLM_COMPILER_LLVM30
238 # elif __clang_major__ == 3 && __clang_minor__ == 1
239 # define GLM_COMPILER GLM_COMPILER_LLVM31
240 # elif __clang_major__ == 3 && __clang_minor__ == 2
241 # define GLM_COMPILER GLM_COMPILER_LLVM32
242 # elif __clang_major__ == 3 && __clang_minor__ == 3
243 # define GLM_COMPILER GLM_COMPILER_LLVM33
244 # elif __clang_major__ == 3 && __clang_minor__ == 4
245 # define GLM_COMPILER GLM_COMPILER_LLVM34
246 # elif __clang_major__ == 3 && __clang_minor__ == 5
247 # define GLM_COMPILER GLM_COMPILER_LLVM35
248 # else
249 # define GLM_COMPILER GLM_COMPILER_LLVM35
250 # endif
251 # endif
252
253 // G++
254 #elif defined(__GNUC__) || defined(__MINGW32__)
255 # if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
256 # define GLM_COMPILER (GLM_COMPILER_GCC42)
257 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
258 # define GLM_COMPILER (GLM_COMPILER_GCC43)
259 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
260 # define GLM_COMPILER (GLM_COMPILER_GCC44)
261 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5)
262 # define GLM_COMPILER (GLM_COMPILER_GCC45)
263 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
264 # define GLM_COMPILER (GLM_COMPILER_GCC46)
265 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
266 # define GLM_COMPILER (GLM_COMPILER_GCC47)
267 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
268 # define GLM_COMPILER (GLM_COMPILER_GCC48)
269 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
270 # define GLM_COMPILER (GLM_COMPILER_GCC49)
271 # elif (__GNUC__ > 4 )
272 # define GLM_COMPILER (GLM_COMPILER_GCC50)
273 # else
274 # define GLM_COMPILER (GLM_COMPILER_GCC)
275 # endif
276
277 #else
278 # define GLM_COMPILER GLM_COMPILER_UNKNOWN
279 #endif
280
281 #ifndef GLM_COMPILER
282 #error "GLM_COMPILER undefined, your compiler may not be supported by GLM. Add #define GLM_COMPILER 0 to ignore this message."
283 #endif//GLM_COMPILER
284
285 // Report compiler detection
286 #if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPILER_DISPLAYED)
287 # define GLM_MESSAGE_COMPILER_DISPLAYED
288 # if GLM_COMPILER & GLM_COMPILER_CUDA
289 # pragma message("GLM: CUDA compiler detected")
290 # elif GLM_COMPILER & GLM_COMPILER_VC
291 # pragma message("GLM: Visual C++ compiler detected")
292 # elif GLM_COMPILER & GLM_COMPILER_APPLE_CLANG
293 # pragma message("GLM: Clang compiler detected")
294 # elif GLM_COMPILER & GLM_COMPILER_LLVM
295 # pragma message("GLM: LLVM compiler detected")
296 # elif GLM_COMPILER & GLM_COMPILER_INTEL
297 # pragma message("GLM: Intel Compiler detected")
298 # elif GLM_COMPILER & GLM_COMPILER_GCC
299 # pragma message("GLM: GCC compiler detected")
300 # else
301 # pragma message("GLM: Compiler not detected")
302 # endif
303 #endif//GLM_MESSAGE
304
306 // Build model
307
308 #if defined(__arch64__) || defined(__LP64__) || defined(_M_X64) || defined(__ppc64__) || defined(__x86_64__)
309 # define GLM_MODEL GLM_MODEL_64
310 #elif defined(__i386__) || defined(__ppc__)
311 # define GLM_MODEL GLM_MODEL_32
312 #else
313 # define GLM_MODEL GLM_MODEL_32
314 #endif//
315
316 #if !defined(GLM_MODEL) && GLM_COMPILER != 0
317 # error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
318 #endif//GLM_MODEL
319
320 #if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_MODEL_DISPLAYED)
321 # define GLM_MESSAGE_MODEL_DISPLAYED
322 # if(GLM_MODEL == GLM_MODEL_64)
323 # pragma message("GLM: 64 bits model")
324 # elif(GLM_MODEL == GLM_MODEL_32)
325 # pragma message("GLM: 32 bits model")
326 # endif//GLM_MODEL
327 #endif//GLM_MESSAGE
328
330 // C++ Version
331
332 // User defines: GLM_FORCE_CXX98
333
334 #define GLM_LANG_CXX98_FLAG (1 << 1)
335 #define GLM_LANG_CXX03_FLAG (1 << 2)
336 #define GLM_LANG_CXX0X_FLAG (1 << 3)
337 #define GLM_LANG_CXX11_FLAG (1 << 4)
338 #define GLM_LANG_CXX1Y_FLAG (1 << 5)
339 #define GLM_LANG_CXXMS_FLAG (1 << 6)
340 #define GLM_LANG_CXXGNU_FLAG (1 << 7)
341
342 #define GLM_LANG_CXX98 GLM_LANG_CXX98_FLAG
343 #define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG)
344 #define GLM_LANG_CXX0X (GLM_LANG_CXX03 | GLM_LANG_CXX0X_FLAG)
345 #define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG)
346 #define GLM_LANG_CXX1Y (GLM_LANG_CXX11 | GLM_LANG_CXX1Y_FLAG)
347 #define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG
348 #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG
349
350 #if defined(GLM_FORCE_CXX1Y)
351 # define GLM_LANG GLM_LANG_CXX1Y
352 #elif defined(GLM_FORCE_CXX11)
353 # define GLM_LANG GLM_LANG_CXX11
354 #elif defined(GLM_FORCE_CXX03)
355 # define GLM_LANG GLM_LANG_CXX03
356 #elif defined(GLM_FORCE_CXX98)
357 # define GLM_LANG GLM_LANG_CXX98
358 #else
359 # if __cplusplus >= 201103L
360 # define GLM_LANG GLM_LANG_CXX11
361 # elif GLM_COMPILER & GLM_COMPILER_CLANG
362 # if(GLM_PLATFORM == GLM_PLATFORM_APPLE)
363 # define GLM_DETAIL_MAJOR 1
364 # else
365 # define GLM_DETAIL_MAJOR 0
366 # endif
367 # if __clang_major__ < (2 + GLM_DETAIL_MAJOR)
368 # define GLM_LANG GLM_LANG_CXX
369 # elif __has_feature(cxx_auto_type)
370 # define GLM_LANG GLM_LANG_CXX0X
371 # else
372 # define GLM_LANG GLM_LANG_CXX98
373 # endif
374 # elif GLM_COMPILER & GLM_COMPILER_GCC
375 # ifdef __GXX_EXPERIMENTAL_CXX0X__
376 # define GLM_LANG GLM_LANG_CXX0X
377 # else
378 # define GLM_LANG GLM_LANG_CXX98
379 # endif
380 # elif GLM_COMPILER & GLM_COMPILER_VC
381 # ifdef _MSC_EXTENSIONS
382 # if GLM_COMPILER >= GLM_COMPILER_VC2010
383 # define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
384 # else
385 # define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
386 # endif
387 # else
388 # if GLM_COMPILER >= GLM_COMPILER_VC2010
389 # define GLM_LANG GLM_LANG_CXX0X
390 # else
391 # define GLM_LANG GLM_LANG_CXX98
392 # endif
393 # endif
394 # elif GLM_COMPILER & GLM_COMPILER_INTEL
395 # ifdef _MSC_EXTENSIONS
396 # if GLM_COMPILER >= GLM_COMPILER_INTEL13
397 # define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_CXXMS_FLAG)
398 # else
399 # define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
400 # endif
401 # else
402 # if GLM_COMPILER >= GLM_COMPILER_INTEL13
403 # define GLM_LANG (GLM_LANG_CXX0X)
404 # else
405 # define GLM_LANG (GLM_LANG_CXX98)
406 # endif
407 # endif
408 # else
409 # if __cplusplus >= 199711L
410 # define GLM_LANG GLM_LANG_CXX98
411 # endif
412 # ifndef GLM_FORCE_CXX98
413 # define GLM_FORCE_CXX98
414 # endif
415 # ifndef GLM_FORCE_PURE
416 # define GLM_FORCE_PURE
417 # endif
418 # endif
419 #endif
420
421 #if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED)
422 # define GLM_MESSAGE_LANG_DISPLAYED
423 # if(GLM_LANG & GLM_LANG_CXXGNU_FLAG)
424 # pragma message("GLM: C++ with language extensions")
425 # elif(GLM_LANG & GLM_LANG_CXXMS_FLAG)
426 # pragma message("GLM: C++ with language extensions")
427 # elif(GLM_LANG & GLM_LANG_CXX11_FLAG)
428 # pragma message("GLM: C++11")
429 # elif(GLM_LANG & GLM_LANG_CXX0X_FLAG)
430 # pragma message("GLM: C++0x")
431 # elif(GLM_LANG & GLM_LANG_CXX03_FLAG)
432 # pragma message("GLM: C++03")
433 # elif(GLM_LANG & GLM_LANG_CXX98_FLAG)
434 # pragma message("GLM: C++98")
435 # else
436 # pragma message("GLM: C++ language undetected")
437 # endif//GLM_MODEL
438 # pragma message("GLM: #define GLM_FORCE_CXX98, GLM_FORCE_CXX03, GLM_LANG_CXX11 or GLM_FORCE_CXX1Y to force using a specific version of the C++ language")
439 #endif//GLM_MESSAGE
440
442 // Has of C++ features
443
444 #ifndef __has_feature
445 # define __has_feature(x) 0 // Compatibility with non-clang compilers.
446 #endif
447 #ifndef __has_extension
448 # define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
449 #endif
450
451 // http://clang.llvm.org/cxx_status.html
452 // http://gcc.gnu.org/projects/cxx0x.html
453 // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx
454
455 // N1720
456 #define GLM_HAS_CXX11_STL ( \
457 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
458 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015)))
459
460 // N1720
461 #define GLM_HAS_STATIC_ASSERT ( \
462 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
463 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010)) || \
464 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
465 __has_feature(cxx_static_assert))
466
467 // N1988
468 #define GLM_HAS_EXTENDED_INTEGER_TYPE ( \
469 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
470 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)) || \
471 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
472 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_LLVM) && (GLM_COMPILER >= GLM_COMPILER_LLVM30)) || \
473 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_APPLE_CLANG) && (GLM_COMPILER >= GLM_COMPILER_APPLE_CLANG40)))
474
475 // N2235
476 #define GLM_HAS_CONSTEXPR ( \
477 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
478 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
479 __has_feature(cxx_constexpr))
480
481 // N2672
482 #define GLM_HAS_INITIALIZER_LISTS ( \
483 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
484 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) || \
485 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \
486 __has_feature(cxx_generalized_initializers))
487
488 // N2544 Unrestricted unions
489 #define GLM_HAS_UNRESTRICTED_UNIONS ( \
490 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
491 (GLM_LANG & GLM_LANG_CXXMS_FLAG) || \
492 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
493 __has_feature(cxx_unrestricted_unions))
494
495 // N2346
496 #define GLM_HAS_DEFAULTED_FUNCTIONS ( \
497 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
498 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) || \
499 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \
500 __has_feature(cxx_defaulted_functions))
501
502 // N2118
503 #define GLM_HAS_RVALUE_REFERENCES ( \
504 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
505 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) || \
506 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)) || \
507 __has_feature(cxx_rvalue_references))
508
509 #define GLM_HAS_STL_ARRAY ( \
510 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
511 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2010))) || \
512 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)))
513
514 #define GLM_HAS_TEMPLATE_ALIASES ( \
515 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) || \
516 __has_feature(cxx_alias_templates))
517
518 #define GLM_HAS_RANGE_FOR ( \
519 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
520 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) || \
521 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \
522 __has_feature(cxx_range_for))
523
524 #define GLM_HAS_ASSIGNABLE ( \
525 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
526 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49)))
527
528 #define GLM_HAS_TRIVIAL_QUERIES ( \
529 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))
530
531 #define GLM_HAS_MAKE_SIGNED ( \
532 (GLM_LANG & GLM_LANG_CXX11_FLAG) || \
533 ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)))
534
535 #define GLM_HAS_BITSCAN_WINDOWS ( \
536 (GLM_ARCH != GLM_ARCH_PURE) && \
537 (GLM_PLATFORM & GLM_PLATFORM_WINDOWS) && \
538 (GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_LLVM | GLM_COMPILER_INTEL)))
539
540 // OpenMP
541 #ifdef _OPENMP
542 # if GLM_COMPILER & GLM_COMPILER_GCC
543 # if GLM_COMPILER >= GLM_COMPILER_GCC47
544 # define GLM_HAS_OPENMP 31
545 # elif GLM_COMPILER >= GLM_COMPILER_GCC44
546 # define GLM_HAS_OPENMP 30
547 # elif GLM_COMPILER >= GLM_COMPILER_GCC42
548 # define GLM_HAS_OPENMP 25
549 # endif
550 # endif// GLM_COMPILER & GLM_COMPILER_GCC
551
552 # if GLM_COMPILER & GLM_COMPILER_VC
553 # if GLM_COMPILER >= GLM_COMPILER_VC2010
554 # define GLM_HAS_OPENMP 20
555 # endif
556 # endif// GLM_COMPILER & GLM_COMPILER_VC
557 #endif
558
559 // Not standard
560 #define GLM_HAS_ANONYMOUS_UNION (GLM_LANG & GLM_LANG_CXXMS_FLAG)
561
563 // Platform
564
565 // User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_SSE3 GLM_FORCE_AVX GLM_FORCE_AVX2
566
567 #define GLM_ARCH_PURE 0x0000
568 #define GLM_ARCH_X86 0x0001
569 #define GLM_ARCH_SSE2 0x0002
570 #define GLM_ARCH_SSE3 0x0004
571 #define GLM_ARCH_SSE4 0x0008
572 #define GLM_ARCH_AVX 0x0010
573 #define GLM_ARCH_AVX2 0x0020
574
575 #if defined(GLM_FORCE_PURE)
576 # define GLM_ARCH GLM_ARCH_PURE
577 #elif defined(GLM_FORCE_AVX2)
578 # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
579 #elif defined(GLM_FORCE_AVX)
580 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
581 #elif defined(GLM_FORCE_SSE4)
582 # define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
583 #elif defined(GLM_FORCE_SSE3)
584 # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
585 #elif defined(GLM_FORCE_SSE2)
586 # define GLM_ARCH (GLM_ARCH_SSE2)
587 #elif (GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM | GLM_COMPILER_GCC)) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_LINUX))
588 # if(__AVX2__)
589 # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
590 # elif(__AVX__)
591 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
592 # elif(__SSE3__)
593 # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
594 # elif(__SSE2__)
595 # define GLM_ARCH (GLM_ARCH_SSE2)
596 # else
597 # define GLM_ARCH GLM_ARCH_PURE
598 # endif
599 #elif (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))
600 # if defined(__AVX2__)
601 # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
602 # elif defined(__AVX__)
603 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
604 # elif _M_IX86_FP == 2
605 # define GLM_ARCH (GLM_ARCH_SSE2)
606 # else
607 # define GLM_ARCH (GLM_ARCH_PURE)
608 # endif
609 #elif (GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__))
610 # if defined(__AVX2__)
611 # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
612 # elif defined(__AVX__)
613 # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
614 # elif defined(__SSE4_1__ )
615 # define GLM_ARCH (GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
616 # elif defined(__SSE3__)
617 # define GLM_ARCH (GLM_ARCH_SSE3 | GLM_ARCH_SSE2)
618 # elif defined(__SSE2__)
619 # define GLM_ARCH (GLM_ARCH_SSE2)
620 # else
621 # define GLM_ARCH (GLM_ARCH_PURE)
622 # endif
623 #else
624 # define GLM_ARCH GLM_ARCH_PURE
625 #endif
626
627 // With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is
628 // that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems.
629 // To fix, we just explicitly include intrin.h here.
630 #if defined(__MINGW32__) && (GLM_ARCH != GLM_ARCH_PURE)
631 # include <intrin.h>
632 #endif
633
634 #if GLM_ARCH & GLM_ARCH_AVX2
635 # include <immintrin.h>
636 #endif//GLM_ARCH
637 #if GLM_ARCH & GLM_ARCH_AVX
638 # include <immintrin.h>
639 #endif//GLM_ARCH
640 #if GLM_ARCH & GLM_ARCH_SSE4
641 # include <smmintrin.h>
642 #endif//GLM_ARCH
643 #if GLM_ARCH & GLM_ARCH_SSE3
644 # include <pmmintrin.h>
645 #endif//GLM_ARCH
646 #if GLM_ARCH & GLM_ARCH_SSE2
647 # include <emmintrin.h>
648 # if(GLM_COMPILER == GLM_COMPILER_VC2005) // VC2005 is missing some intrinsics, workaround
649 inline float _mm_cvtss_f32(__m128 A) { return A.m128_f32[0]; }
650 inline __m128 _mm_castpd_ps(__m128d PD) { union { __m128 ps; __m128d pd; } c; c.pd = PD; return c.ps; }
651 inline __m128d _mm_castps_pd(__m128 PS) { union { __m128 ps; __m128d pd; } c; c.ps = PS; return c.pd; }
652 inline __m128i _mm_castps_si128(__m128 PS) { union { __m128 ps; __m128i pi; } c; c.ps = PS; return c.pi; }
653 inline __m128 _mm_castsi128_ps(__m128i PI) { union { __m128 ps; __m128i pi; } c; c.pi = PI; return c.ps; }
654 # endif
655 #endif//GLM_ARCH
656
657 #if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED)
658 # define GLM_MESSAGE_ARCH_DISPLAYED
659 # if(GLM_ARCH == GLM_ARCH_PURE)
660 # pragma message("GLM: Platform independent code")
661 # elif(GLM_ARCH & GLM_ARCH_AVX2)
662 # pragma message("GLM: AVX2 instruction set")
663 # elif(GLM_ARCH & GLM_ARCH_AVX)
664 # pragma message("GLM: AVX instruction set")
665 # elif(GLM_ARCH & GLM_ARCH_SSE3)
666 # pragma message("GLM: SSE3 instruction set")
667 # elif(GLM_ARCH & GLM_ARCH_SSE2)
668 # pragma message("GLM: SSE2 instruction set")
669 # endif//GLM_ARCH
670 # pragma message("GLM: #define GLM_FORCE_PURE to avoid using platform specific instruction sets")
671 #endif//GLM_MESSAGE
672
674 // Static assert
675
676 #if GLM_HAS_STATIC_ASSERT
677 # define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
678 #elif defined(BOOST_STATIC_ASSERT)
679 # define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
680 #elif GLM_COMPILER & GLM_COMPILER_VC
681 # define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
682 #else
683 # define GLM_STATIC_ASSERT(x, message)
684 # define GLM_STATIC_ASSERT_NULL
685 #endif//GLM_LANG
686
688 // Qualifiers
689
690 #if GLM_COMPILER & GLM_COMPILER_CUDA
691 # define GLM_CUDA_FUNC_DEF __device__ __host__
692 # define GLM_CUDA_FUNC_DECL __device__ __host__
693 #else
694 # define GLM_CUDA_FUNC_DEF
695 # define GLM_CUDA_FUNC_DECL
696 #endif
697
698 #if GLM_COMPILER & GLM_COMPILER_GCC
699 # define GLM_VAR_USED __attribute__ ((unused))
700 #else
701 # define GLM_VAR_USED
702 #endif
703
704 #if defined(GLM_FORCE_INLINE)
705 # if GLM_COMPILER & GLM_COMPILER_VC
706 # define GLM_INLINE __forceinline
707 # define GLM_NEVER_INLINE __declspec((noinline))
708 # elif GLM_COMPILER & GLM_COMPILER_GCC
709 # define GLM_INLINE inline __attribute__((__always_inline__))
710 # define GLM_NEVER_INLINE __attribute__((__noinline__))
711 # elif GLM_COMPILER & (GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM)
712 # define GLM_INLINE __attribute__((__always_inline__))
713 # define GLM_NEVER_INLINE __attribute__((__noinline__))
714 # else
715 # define GLM_INLINE inline
716 # define GLM_NEVER_INLINE
717 # endif//GLM_COMPILER
718 #else
719 # define GLM_INLINE inline
720 # define GLM_NEVER_INLINE
721 #endif//defined(GLM_FORCE_INLINE)
722
723 #define GLM_FUNC_DECL GLM_CUDA_FUNC_DECL
724 #define GLM_FUNC_QUALIFIER GLM_CUDA_FUNC_DEF GLM_INLINE
725
727 // Swizzle operators
728
729 // User defines: GLM_SWIZZLE
730
731 #if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)
732 # define GLM_MESSAGE_SWIZZLE_DISPLAYED
733 # if defined(GLM_SWIZZLE)
734 # pragma message("GLM: Swizzling operators enabled")
735 # else
736 # pragma message("GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators")
737 # endif
738 #endif//GLM_MESSAGE
739
741 // Qualifiers
742
743 #if (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))
744 # define GLM_DEPRECATED __declspec(deprecated)
745 # define GLM_ALIGN(x) __declspec(align(x))
746 # define GLM_ALIGNED_STRUCT(x) struct __declspec(align(x))
747 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef __declspec(align(alignment)) type name
748 # define GLM_RESTRICT __declspec(restrict)
749 # define GLM_RESTRICT_VAR __restrict
750 #elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM | GLM_COMPILER_CUDA | GLM_COMPILER_INTEL)
751 # define GLM_DEPRECATED __attribute__((__deprecated__))
752 # define GLM_ALIGN(x) __attribute__((aligned(x)))
753 # define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
754 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name __attribute__((aligned(alignment)))
755 # define GLM_RESTRICT __restrict__
756 # define GLM_RESTRICT_VAR __restrict__
757 #else
758 # define GLM_DEPRECATED
759 # define GLM_ALIGN
760 # define GLM_ALIGNED_STRUCT(x) struct
761 # define GLM_ALIGNED_TYPEDEF(type, name, alignment) typedef type name
762 # define GLM_RESTRICT
763 # define GLM_RESTRICT_VAR
764 #endif//GLM_COMPILER
765
766 #if GLM_HAS_CONSTEXPR
767 # define GLM_CONSTEXPR constexpr
768 #else
769 # define GLM_CONSTEXPR
770 #endif
771
773 // Length type
774
775 // User defines: GLM_FORCE_SIZE_T_LENGTH GLM_FORCE_SIZE_FUNC
776
777 namespace glm
778 {
779 using std::size_t;
780 #if defined(GLM_FORCE_SIZE_T_LENGTH) || defined(GLM_FORCE_SIZE_FUNC)
781 typedef size_t length_t;
782 #else
783 typedef int length_t;
784 #endif
785
786 namespace detail
787 {
788 # ifdef GLM_FORCE_SIZE_FUNC
789 typedef size_t component_count_t;
790 # else
791 typedef length_t component_count_t;
792 # endif
793
794 template <typename genType>
795 GLM_FUNC_QUALIFIER GLM_CONSTEXPR component_count_t component_count(genType const & m)
796 {
797 # ifdef GLM_FORCE_SIZE_FUNC
798 return m.size();
799 # else
800 return m.length();
801 # endif
802 }
803 }//namespace detail
804 }//namespace glm
805
806 #if defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_FORCE_SIZE_T_LENGTH)
807 # define GLM_MESSAGE_FORCE_SIZE_T_LENGTH
808 # if defined(GLM_FORCE_SIZE_T_LENGTH)
809 # pragma message("GLM: .length() returns glm::length_t, a typedef of std::size_t")
810 # else
811 # pragma message("GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification")
812 # pragma message("GLM: #define GLM_FORCE_SIZE_T_LENGTH for .length() to return a size_t")
813 # endif
814 #endif//GLM_MESSAGE
815
817 // Uninitialize constructors
818
819 namespace glm
820 {
821 enum ctor{uninitialize};
822 }//namespace glm
glm::pi
GLM_FUNC_DECL genType pi()
Return the pi constant.
glm
Definition: _noise.hpp:39