|
1
|
1 #pragma once
|
|
|
2
|
|
|
3
|
|
|
4 #ifdef _MSC_VER // MSVC sucks, doesn't set __cplusplus properly by default
|
|
|
5 #if _MSVC_LANG < 201703L
|
|
|
6 #error C++17 please
|
|
|
7 #endif
|
|
|
8 #else // not MSVC
|
|
|
9 #if __cplusplus < 201703L
|
|
|
10 #error C++17 please
|
|
|
11 #endif
|
|
|
12 #endif
|
|
|
13
|
|
|
14 // Global flag - whether it's OK to leak static objects as they'll be released anyway by process death
|
|
|
15 #ifndef PFC_LEAK_STATIC_OBJECTS
|
|
|
16 #define PFC_LEAK_STATIC_OBJECTS 1
|
|
|
17 #endif
|
|
|
18
|
|
|
19
|
|
|
20 #ifdef __clang__
|
|
|
21 // Suppress a warning for a common practice in pfc/fb2k code
|
|
|
22 #pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
|
|
|
23 #endif
|
|
|
24
|
|
|
25 #if !defined(_WINDOWS) && (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(_WIN32_WCE))
|
|
|
26 #define _WINDOWS
|
|
|
27 #endif
|
|
|
28
|
|
|
29
|
|
|
30 #ifdef _WINDOWS
|
|
|
31 #include "targetver.h"
|
|
|
32
|
|
|
33 #ifndef STRICT
|
|
|
34 #define STRICT
|
|
|
35 #endif
|
|
|
36
|
|
|
37 #ifndef _SYS_GUID_OPERATOR_EQ_
|
|
|
38 #define _NO_SYS_GUID_OPERATOR_EQ_ //fix retarded warning with operator== on GUID returning int
|
|
|
39 #endif
|
|
|
40
|
|
|
41 // WinSock2.h *before* Windows.h or else VS2017 15.3 breaks
|
|
|
42 #include <WinSock2.h>
|
|
|
43 #include <windows.h>
|
|
|
44
|
|
|
45 #if !defined(PFC_WINDOWS_STORE_APP) && !defined(PFC_WINDOWS_DESKTOP_APP)
|
|
|
46
|
|
|
47 #ifdef WINAPI_FAMILY_PARTITION
|
|
|
48 #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
|
|
49 #define PFC_WINDOWS_STORE_APP // Windows store or Windows phone app, not a desktop app
|
|
|
50 #endif // #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
|
|
51 #endif // #ifdef WINAPI_FAMILY_PARTITION
|
|
|
52
|
|
|
53 #ifndef PFC_WINDOWS_STORE_APP
|
|
|
54 #define PFC_WINDOWS_DESKTOP_APP
|
|
|
55 #endif
|
|
|
56
|
|
|
57 #endif // #if !defined(PFC_WINDOWS_STORE_APP) && !defined(PFC_WINDOWS_DESKTOP_APP)
|
|
|
58
|
|
|
59 #ifndef _SYS_GUID_OPERATOR_EQ_
|
|
|
60 __inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
|
|
|
61 {
|
|
|
62 return (
|
|
|
63 ((unsigned long*)&rguid1)[0] == ((unsigned long*)&rguid2)[0] &&
|
|
|
64 ((unsigned long*)&rguid1)[1] == ((unsigned long*)&rguid2)[1] &&
|
|
|
65 ((unsigned long*)&rguid1)[2] == ((unsigned long*)&rguid2)[2] &&
|
|
|
66 ((unsigned long*)&rguid1)[3] == ((unsigned long*)&rguid2)[3]);
|
|
|
67 }
|
|
|
68
|
|
|
69 inline bool operator==(REFGUID guidOne, REFGUID guidOther) { return __InlineIsEqualGUID(guidOne, guidOther); }
|
|
|
70 inline bool operator!=(REFGUID guidOne, REFGUID guidOther) { return !__InlineIsEqualGUID(guidOne, guidOther); }
|
|
|
71 #endif
|
|
|
72
|
|
|
73 #include <tchar.h>
|
|
|
74
|
|
|
75 #else // not Windows
|
|
|
76
|
|
|
77 #include <stdint.h>
|
|
|
78 #include <stdlib.h>
|
|
|
79 #include <stdarg.h>
|
|
|
80 #include <string.h> // memcmp
|
|
|
81
|
|
|
82 #ifndef GUID_DEFINED
|
|
|
83 #define GUID_DEFINED
|
|
|
84
|
|
|
85
|
|
|
86 struct GUID {
|
|
|
87 uint32_t Data1;
|
|
|
88 uint16_t Data2;
|
|
|
89 uint16_t Data3;
|
|
|
90 uint8_t Data4[ 8 ];
|
|
|
91 } __attribute__((packed));
|
|
|
92
|
|
|
93 inline bool operator==(const GUID & p_item1,const GUID & p_item2) {
|
|
|
94 return memcmp(&p_item1,&p_item2,sizeof(GUID)) == 0;
|
|
|
95 }
|
|
|
96
|
|
|
97 inline bool operator!=(const GUID & p_item1,const GUID & p_item2) {
|
|
|
98 return memcmp(&p_item1,&p_item2,sizeof(GUID)) != 0;
|
|
|
99 }
|
|
|
100
|
|
|
101 #endif // GUID_DEFINED
|
|
|
102
|
|
|
103 #endif
|
|
|
104
|
|
|
105
|
|
|
106
|
|
|
107 #define PFC_MEMORY_SPACE_LIMIT ((t_uint64)1<<(sizeof(void*)*8-1))
|
|
|
108
|
|
|
109 #define PFC_ALLOCA_LIMIT (4096)
|
|
|
110
|
|
|
111 #include <exception>
|
|
|
112 #include <stdexcept>
|
|
|
113 #include <new>
|
|
|
114
|
|
|
115 #define _PFC_WIDESTRING(_String) L ## _String
|
|
|
116 #define PFC_WIDESTRING(_String) _PFC_WIDESTRING(_String)
|
|
|
117
|
|
|
118 #if defined(_DEBUG) || defined(DEBUG)
|
|
|
119 #define PFC_DEBUG 1
|
|
|
120 #else
|
|
|
121 #define PFC_DEBUG 0
|
|
|
122 #endif
|
|
|
123
|
|
|
124 #if ! PFC_DEBUG
|
|
|
125
|
|
|
126 #ifndef NDEBUG
|
|
|
127 #pragma message("WARNING: release build without NDEBUG")
|
|
|
128 #endif
|
|
|
129
|
|
|
130 #define PFC_ASSERT(_Expression) ((void)0)
|
|
|
131 #define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0)
|
|
|
132 #define PFC_ASSERT_NO_EXCEPTION(_Expression) { _Expression; }
|
|
|
133 #else
|
|
|
134
|
|
|
135 #ifdef _WIN32
|
|
|
136 namespace pfc { void myassert_win32(const wchar_t* _Message, const wchar_t* _File, unsigned _Line); }
|
|
|
137 #define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert_win32(PFC_WIDESTRING(#_Expression), PFC_WIDESTRING(__FILE__), __LINE__), 0) )
|
|
|
138 #define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT(_Expression)
|
|
|
139 #else
|
|
|
140 namespace pfc { void myassert(const char* _Message, const char* _File, unsigned _Line); }
|
|
|
141 #define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert(#_Expression, __FILE__, __LINE__), 0) )
|
|
|
142 #define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT( _Expression )
|
|
|
143 #endif
|
|
|
144
|
|
|
145 #define PFC_ASSERT_NO_EXCEPTION(_Expression) { try { _Expression; } catch(...) { PFC_ASSERT(!"Should not get here - unexpected exception"); } }
|
|
|
146 #endif
|
|
|
147
|
|
|
148 #ifdef _MSC_VER
|
|
|
149
|
|
|
150 #if PFC_DEBUG
|
|
|
151 #define NOVTABLE
|
|
|
152 #else
|
|
|
153 #define NOVTABLE _declspec(novtable)
|
|
|
154 #endif
|
|
|
155
|
|
|
156 #if PFC_DEBUG
|
|
|
157 #define ASSUME(X) PFC_ASSERT(X)
|
|
|
158 #else
|
|
|
159 #define ASSUME(X) __assume(X)
|
|
|
160 #endif
|
|
|
161
|
|
|
162 #define PFC_DEPRECATE(X) // __declspec(deprecated(X)) don't do this since VS2015 defaults to erroring these
|
|
|
163 #define PFC_NORETURN __declspec(noreturn)
|
|
|
164 #define PFC_NOINLINE __declspec(noinline)
|
|
|
165 #else // else not MSVC
|
|
|
166
|
|
|
167 #define NOVTABLE
|
|
|
168 #define ASSUME(X) PFC_ASSERT(X)
|
|
|
169 #define PFC_DEPRECATE(X)
|
|
|
170 #define PFC_NORETURN __attribute__ ((noreturn))
|
|
|
171 #define PFC_NOINLINE
|
|
|
172
|
|
|
173 #endif // end not MSVC
|
|
|
174
|
|
|
175 #include "int_types.h"
|
|
|
176 #include "string-interface.h"
|
|
|
177 #include "string-lite.h"
|
|
|
178
|
|
|
179 namespace pfc {
|
|
|
180 // forward types
|
|
|
181 class bit_array;
|
|
|
182 class bit_array_var;
|
|
|
183
|
|
|
184 template<typename T> class list_base_const_t;
|
|
|
185 template<typename T> class list_base_t;
|
|
|
186 }
|