foobar2000 SDK  2015-08-03
pfc.h
Go to the documentation of this file.
1 #ifndef ___PFC_H___
2 #define ___PFC_H___
3 
4 // Global flag - whether it's OK to leak static objects as they'll be released anyway by process death
5 #ifndef PFC_LEAK_STATIC_OBJECTS
6 #define PFC_LEAK_STATIC_OBJECTS 1
7 #endif
8 
9 
10 #ifdef __clang__
11 // Suppress a warning for a common practice in pfc/fb2k code
12 #pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
13 #endif
14 
15 #if !defined(_WINDOWS) && (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(_WIN32_WCE))
16 #define _WINDOWS
17 #endif
18 
19 
20 #define PFC_DLL_EXPORT
21 
22 #ifdef _WINDOWS
23 
24 #ifndef STRICT
25 #define STRICT
26 #endif
27 
28 #ifndef _SYS_GUID_OPERATOR_EQ_
29 #define _NO_SYS_GUID_OPERATOR_EQ_ //fix retarded warning with operator== on GUID returning int
30 #endif
31 
32 #include <windows.h>
33 
34 #if !defined(PFC_WINDOWS_STORE_APP) && !defined(PFC_WINDOWS_DESKTOP_APP)
35 
36 #ifdef WINAPI_FAMILY_PARTITION
37 #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
38 #define PFC_WINDOWS_STORE_APP // Windows store or Windows phone app, not a desktop app
39 #endif // #if ! WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
40 #endif // #ifdef WINAPI_FAMILY_PARTITION
41 
42 #ifndef PFC_WINDOWS_STORE_APP
43 #define PFC_WINDOWS_DESKTOP_APP
44 #endif
45 
46 #endif // #if !defined(PFC_WINDOWS_STORE_APP) && !defined(PFC_WINDOWS_DESKTOP_APP)
47 
48 #ifndef _SYS_GUID_OPERATOR_EQ_
49 __inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
50 {
51  return (
52  ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
53  ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
54  ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
55  ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
56 }
57 
58 inline bool operator==(REFGUID guidOne, REFGUID guidOther) {return __InlineIsEqualGUID(guidOne,guidOther);}
59 inline bool operator!=(REFGUID guidOne, REFGUID guidOther) {return !__InlineIsEqualGUID(guidOne,guidOther);}
60 #endif
61 
62 #include <tchar.h>
63 
64 #else
65 
66 #include <stdint.h>
67 #include <stdlib.h>
68 #include <stdarg.h>
69 #include <string.h> // memcmp
70 
71 typedef struct {
72  uint32_t Data1;
73  uint16_t Data2;
74  uint16_t Data3;
75  uint8_t Data4[ 8 ];
76  } GUID; //same as win32 GUID
77 
78 inline bool operator==(const GUID & p_item1,const GUID & p_item2) {
79  return memcmp(&p_item1,&p_item2,sizeof(GUID)) == 0;
80 }
81 
82 inline bool operator!=(const GUID & p_item1,const GUID & p_item2) {
83  return memcmp(&p_item1,&p_item2,sizeof(GUID)) != 0;
84 }
85 
86 #endif
87 
88 
89 
90 #define PFC_MEMORY_SPACE_LIMIT ((t_uint64)1<<(sizeof(void*)*8-1))
91 
92 #define PFC_ALLOCA_LIMIT (4096)
93 
94 #define INDEX_INVALID ((unsigned)(-1))
95 
96 
97 #include <exception>
98 #include <stdexcept>
99 #include <new>
100 
101 #define _PFC_WIDESTRING(_String) L ## _String
102 #define PFC_WIDESTRING(_String) _PFC_WIDESTRING(_String)
103 
104 #if defined(_DEBUG) || defined(DEBUG)
105 #define PFC_DEBUG 1
106 #else
107 #define PFC_DEBUG 0
108 #endif
109 
110 #if ! PFC_DEBUG
111 #define PFC_ASSERT(_Expression) ((void)0)
112 #define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0)
113 #define PFC_ASSERT_NO_EXCEPTION(_Expression) { _Expression; }
114 #else
115 
116 #ifdef _WIN32
117 namespace pfc { void myassert_win32(const wchar_t * _Message, const wchar_t *_File, unsigned _Line); }
118 #define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert_win32(PFC_WIDESTRING(#_Expression), PFC_WIDESTRING(__FILE__), __LINE__), 0) )
119 #define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT(_Expression)
120 #else
121 namespace pfc { void myassert (const char * _Message, const char *_File, unsigned _Line); }
122 #define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert(#_Expression, __FILE__, __LINE__), 0) )
123 #define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT( _Expression )
124 #endif
125 
126 #define PFC_ASSERT_NO_EXCEPTION(_Expression) { try { _Expression; } catch(...) { PFC_ASSERT(!"Should not get here - unexpected exception"); } }
127 #endif
128 
129 #ifdef _MSC_VER
130 
131 #if PFC_DEBUG
132 #define NOVTABLE
133 #else
134 #define NOVTABLE _declspec(novtable)
135 #endif
136 
137 #if PFC_DEBUG
138 #define ASSUME(X) PFC_ASSERT(X)
139 #else
140 #define ASSUME(X) __assume(X)
141 #endif
142 
143 #define PFC_DEPRECATE(X) // __declspec(deprecated(X)) don't do this since VS2015 defaults to erroring these
144 #define PFC_NORETURN __declspec(noreturn)
145 #define PFC_NOINLINE __declspec(noinline)
146 #else
147 
148 #define NOVTABLE
149 #define ASSUME(X) PFC_ASSERT(X)
150 #define PFC_DEPRECATE(X)
151 #define PFC_NORETURN __attribute__ ((noreturn))
152 #define PFC_NOINLINE
153 
154 #endif
155 
156 namespace pfc {
157  void selftest();
158 }
159 
160 #include "int_types.h"
161 #include "traits.h"
162 #include "bit_array.h"
163 #include "primitives.h"
164 #include "alloc.h"
165 #include "array.h"
166 #include "bit_array_impl.h"
167 #include "binary_search.h"
168 #include "bsearch_inline.h"
169 #include "bsearch.h"
170 #include "sort.h"
171 #include "order_helper.h"
172 #include "list.h"
173 #include "ptr_list.h"
174 #include "string_base.h"
175 #include "string_list.h"
176 #include "ref_counter.h"
177 #include "iterators.h"
178 #include "avltree.h"
179 #include "map.h"
180 #include "bit_array_impl_part2.h"
181 #include "timers.h"
182 #include "guid.h"
183 #include "byte_order_helper.h"
184 #include "other.h"
185 #include "chain_list_v2.h"
186 #include "rcptr.h"
187 #include "com_ptr_t.h"
188 #include "string_conv.h"
189 #include "stringNew.h"
190 #include "pathUtils.h"
191 #include "instance_tracker.h"
192 #include "threads.h"
193 #include "base64.h"
194 #include "primitives_part2.h"
195 #include "cpuid.h"
196 #include "memalign.h"
197 
198 #ifdef _WIN32
199 #include "synchro_win.h"
200 #else
201 #include "synchro_nix.h"
202 #endif
203 
204 #include "syncd_storage.h"
205 
206 #ifdef _WIN32
207 #include "win-objects.h"
208 #else
209 #include "nix-objects.h"
210 #endif
211 
212 #include "event.h"
213 
214 #include "audio_sample.h"
215 #include "wildcard.h"
216 #include "filehandle.h"
217 
218 #define PFC_INCLUDED 1
219 
220 #endif //___PFC_H___
__inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: pfc.h:49
Definition: pfc.h:71
bool operator==(REFGUID guidOne, REFGUID guidOther)
Definition: pfc.h:58
uint16_t Data3
Definition: pfc.h:74
void selftest()
Definition: selftest.cpp:79
uint16_t Data2
Definition: pfc.h:73
void myassert(const char *_Message, const char *_File, unsigned _Line)
Definition: other.cpp:151
bool operator!=(REFGUID guidOne, REFGUID guidOther)
Definition: pfc.h:59
void myassert_win32(const wchar_t *_Message, const wchar_t *_File, unsigned _Line)
Definition: other.cpp:145
uint32_t Data1
Definition: pfc.h:72