1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
4 * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 **************************************************************************/
34 #if defined(WIN32) && defined(_MSC_VER)
35 #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
36 #pragma warning(disable : 4127) // conditional expression is constant
37 #pragma warning(disable : 4793) // function compiled as native
38 #pragma warning(disable : 4324) // structure was padded due to __declspec(align())
39 #pragma warning(disable : 4100) // unreferenced formal parameter
42 #if defined(WIN32) && !defined(VOGL_ANSI_CPLUSPLUS)
43 #define VOGL_PLATFORM_PC 1
44 #define VOGL_USE_WIN32_API 1
46 // MSVC or MinGW, x86 or x64, Win32 API's for threading and Win32 Interlocked API's or GCC built-ins for atomic ops.
48 // Ensure checked iterators are disabled. Note: Be sure anything else that links against this lib also #define's this stuff, or remove this crap!
50 #define _HAS_ITERATOR_DEBUGGING 0
53 // If we're using the DLL form of the run-time libs, we're also going to be enabling exceptions because we'll be building CLR apps.
54 // Otherwise, we disable exceptions for a small speed boost.
55 #define _HAS_EXCEPTIONS 0
59 #if defined(__MINGW32__) || defined(__MINGW64__)
60 #define VOGL_USE_GCC_ATOMIC_BUILTINS 1
62 #define VOGL_USE_WIN32_ATOMIC_FUNCTIONS 1
65 #if defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__)
66 #define VOGL_PLATFORM_PC_X64 1
67 #define VOGL_64BIT_POINTERS 1
68 #define VOGL_CPU_HAS_64BIT_REGISTERS 1
69 #define VOGL_LITTLE_ENDIAN_CPU 1
71 #define VOGL_PLATFORM_PC_X86 1
72 #define VOGL_64BIT_POINTERS 0
73 #define VOGL_CPU_HAS_64BIT_REGISTERS 0
74 #define VOGL_LITTLE_ENDIAN_CPU 1
77 #define VOGL_USE_UNALIGNED_INT_LOADS 1
78 #define VOGL_RESTRICT __restrict
79 #define VOGL_FORCE_INLINE __forceinline
80 #define VOGL_SELECT_ANY __declspec(selectany)
82 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
83 #define VOGL_USE_MSVC_INTRINSICS 1
86 #define VOGL_STDCALL __stdcall
87 #define VOGL_MEMORY_IMPORT_BARRIER
88 #define VOGL_MEMORY_EXPORT_BARRIER
90 #define VOGL_FUNCTION_NAME __FUNCTION__
92 // for gcc/clang: string_index is the param index of the format string, 1 is the first param for static funcs, 2 for member funcs
93 // first_index is the first param to check, specify 0 to just check the format string for consistency
94 #define VOGL_ATTRIBUTE_PRINTF(string_index, first_index)
96 #define VOGL_NOTE_UNUSED(x) (void) x
98 #elif defined(__GNUC__) && !defined(VOGL_ANSI_CPLUSPLUS)
99 // GCC x86 or x64, pthreads for threading and GCC built-ins for atomic ops.
100 #define VOGL_PLATFORM_PC 1
102 #define VOGL_USE_LINUX_API 1
105 #if defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__)
106 #define VOGL_PLATFORM_PC_X64 1
107 #define VOGL_64BIT_POINTERS 1
108 #define VOGL_CPU_HAS_64BIT_REGISTERS 1
110 #define VOGL_PLATFORM_PC_X86 1
111 #define VOGL_64BIT_POINTERS 0
112 #define VOGL_CPU_HAS_64BIT_REGISTERS 0
115 #define VOGL_USE_UNALIGNED_INT_LOADS 1
117 #define VOGL_LITTLE_ENDIAN_CPU 1
119 #define VOGL_USE_PTHREADS_API 1
120 #define VOGL_USE_GCC_ATOMIC_BUILTINS 1
122 #define VOGL_RESTRICT
125 #include "../extlib/clang_warnings/clang_warnings.h"
126 // FIXME - clang interprets forceinline in a subtly different way vs. gcc/MSVS, which causes multiple func definitions
127 #define VOGL_FORCE_INLINE inline
129 #define VOGL_FORCE_INLINE inline __attribute__((__always_inline__, __gnu_inline__))
132 #define VOGL_SELECT_ANY
135 #define VOGL_MEMORY_IMPORT_BARRIER
136 #define VOGL_MEMORY_EXPORT_BARRIER
138 #define VOGL_FUNCTION_NAME __FUNCTION__
140 #define VOGL_ATTRIBUTE_PRINTF(string_index, first_index) __attribute__((format(printf, string_index, first_index)))
142 #define VOGL_NOTE_UNUSED(x) (void) x
144 #ifndef _LARGEFILE64_SOURCE
145 #define _LARGEFILE64_SOURCE 1
148 #ifndef D_FILE_OFFSET_BITS
149 #define _FILE_OFFSET_BITS 64
152 // Vanilla ANSI-C/C++
153 // No threading support, unaligned loads are NOT okay.
154 #if defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__)
155 #define VOGL_64BIT_POINTERS 1
156 #define VOGL_CPU_HAS_64BIT_REGISTERS 1
158 #define VOGL_64BIT_POINTERS 0
159 #define VOGL_CPU_HAS_64BIT_REGISTERS 0
162 #define VOGL_USE_UNALIGNED_INT_LOADS 0
165 #define VOGL_BIG_ENDIAN_CPU 1
167 #define VOGL_LITTLE_ENDIAN_CPU 1
170 #define VOGL_USE_GCC_ATOMIC_BUILTINS 0
171 #define VOGL_USE_WIN32_ATOMIC_FUNCTIONS 0
173 #define VOGL_RESTRICT
174 #define VOGL_FORCE_INLINE inline
175 #define VOGL_SELECT_ANY
178 #define VOGL_MEMORY_IMPORT_BARRIER
179 #define VOGL_MEMORY_EXPORT_BARRIER
181 #define VOGL_FUNCTION_NAME __FUNCTION__
183 #define VOGL_ATTRIBUTE_PRINTF(string_index, first_index)
185 #define VOGL_NOTE_UNUSED(x) (void) x
188 #ifndef VOGL_ENABLE_ASSERTIONS_IN_ALL_BUILDS
189 #define VOGL_ENABLE_ASSERTIONS_IN_ALL_BUILDS 0
207 #include <functional>
218 #define VOGL_FALSE (0)
219 #define VOGL_TRUE (1)
220 #define VOGL_MAX_PATH (260)
222 #define VOGL_NAMESPACE_BEGIN(x) \
225 #define VOGL_NAMESPACE_END(x) }
227 #if defined(_DEBUG) || defined(DEBUG)
228 #define VOGL_BUILD_DEBUG
231 #error NDEBUG cannot be defined in VOGL_BUILD_DEBUG
234 #define VOGL_BUILD_RELEASE
240 #if defined(DEBUG) || defined(_DEBUG)
241 #error DEBUG and _DEBUG cannot be defined in VOGL_BUILD_RELEASE
245 #include "vogl_types.h"
246 #include "vogl_assert.h"
247 #include "vogl_platform.h"
248 #include "vogl_helpers.h"
249 #include "vogl_traits.h"
250 #include "vogl_mem.h"
251 #include "vogl_math.h"
252 #include "vogl_utils.h"
253 #include "vogl_hash.h"
254 #include "vogl_rand.h"
255 #include "vogl_introsort.h"
256 #include "vogl_vector.h"
257 #include "vogl_fixed_string.h"
258 #include "vogl_dynamic_string.h"
259 #include "vogl_timer.h"
261 #endif // VOGL_CORE_H