foobar2000 SDK  2015-01-14
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 #if !defined(_WINDOWS) && (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(_WIN32_WCE))
10 #define _WINDOWS
11 #endif
12 
13 
14 #define PFC_DLL_EXPORT
15 
16 #ifdef _WINDOWS
17 
18 #ifndef STRICT
19 #define STRICT
20 #endif
21 
22 #ifndef _SYS_GUID_OPERATOR_EQ_
23 #define _NO_SYS_GUID_OPERATOR_EQ_ //fix retarded warning with operator== on GUID returning int
24 #endif
25 
26 #ifndef _WIN32_WINNT
27 #define _WIN32_WINNT 0x500
28 #endif
29 
30 #include <windows.h>
31 
32 #ifndef _SYS_GUID_OPERATOR_EQ_
33 __inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
34 {
35  return (
36  ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
37  ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
38  ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
39  ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
40 }
41 
42 inline bool operator==(REFGUID guidOne, REFGUID guidOther) {return __InlineIsEqualGUID(guidOne,guidOther);}
43 inline bool operator!=(REFGUID guidOne, REFGUID guidOther) {return !__InlineIsEqualGUID(guidOne,guidOther);}
44 #endif
45 
46 #include <tchar.h>
47 
48 #else
49 
50 #include <stdint.h>
51 #include <stdlib.h>
52 #include <memory.h>
53 typedef struct {
54  uint32_t Data1;
55  uint16_t Data2;
56  uint16_t Data3;
57  uint8_t Data4[ 8 ];
58  } GUID; //same as win32 GUID
59 
60 inline bool operator==(const GUID & p_item1,const GUID & p_item2) {
61  return memcmp(&p_item1,&p_item2,sizeof(GUID)) == 0;
62 }
63 
64 inline bool operator!=(const GUID & p_item1,const GUID & p_item2) {
65  return memcmp(&p_item1,&p_item2,sizeof(GUID)) != 0;
66 }
67 
68 #endif
69 
70 
71 
72 #define PFC_MEMORY_SPACE_LIMIT ((t_uint64)1<<(sizeof(void*)*8-1))
73 
74 #define PFC_ALLOCA_LIMIT (4096)
75 
76 #define INDEX_INVALID ((unsigned)(-1))
77 
78 
79 #include <exception>
80 #include <stdexcept>
81 #include <new>
82 
83 #include <stdio.h>
84 
85 #include <assert.h>
86 
87 #include <math.h>
88 #include <float.h>
89 
90 #define _PFC_WIDESTRING(_String) L ## _String
91 #define PFC_WIDESTRING(_String) _PFC_WIDESTRING(_String)
92 
93 #if defined(_DEBUG) || defined(DEBUG)
94 #define PFC_DEBUG 1
95 #else
96 #define PFC_DEBUG 0
97 #endif
98 
99 #if ! PFC_DEBUG
100 #define PFC_ASSERT(_Expression) ((void)0)
101 #define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0)
102 #define PFC_ASSERT_NO_EXCEPTION(_Expression) { _Expression; }
103 #else
104 
105 #ifdef _WIN32
106 namespace pfc { void myassert(const wchar_t * _Message, const wchar_t *_File, unsigned _Line); }
107 #define PFC_ASSERT(_Expression) (void)( (!!(_Expression)) || (pfc::myassert(PFC_WIDESTRING(#_Expression), PFC_WIDESTRING(__FILE__), __LINE__), 0) )
108 #define PFC_ASSERT_SUCCESS(_Expression) PFC_ASSERT(_Expression)
109 #else
110 #define PFC_ASSERT(_Expression) assert(_Expression)
111 #define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0) //FIXME
112 #endif
113 
114 #define PFC_ASSERT_NO_EXCEPTION(_Expression) { try { _Expression; } catch(...) { PFC_ASSERT(!"Should not get here - unexpected exception"); } }
115 #endif
116 
117 #ifdef _MSC_VER
118 
119 #if PFC_DEBUG
120 #define NOVTABLE
121 #else
122 #define NOVTABLE _declspec(novtable)
123 #endif
124 
125 #if PFC_DEBUG
126 #define ASSUME(X) PFC_ASSERT(X)
127 #else
128 #define ASSUME(X) __assume(X)
129 #endif
130 
131 #define PFC_DEPRECATE(X) __declspec(deprecated(X))
132 #define PFC_NORETURN __declspec(noreturn)
133 #define PFC_NOINLINE __declspec(noinline)
134 #else
135 
136 #define NOVTABLE
137 #define ASSUME(X) PFC_ASSERT(X)
138 #define PFC_DEPRECATE(X)
139 #define PFC_NORETURN __attribute__ ((noreturn))
140 #define PFC_NOINLINE
141 
142 #endif
143 
144 #include "int_types.h"
145 #include "traits.h"
146 #include "bit_array.h"
147 #include "primitives.h"
148 #include "alloc.h"
149 #include "array.h"
150 #include "bit_array_impl.h"
151 #include "binary_search.h"
152 #include "bsearch_inline.h"
153 #include "bsearch.h"
154 #include "sort.h"
155 #include "order_helper.h"
156 #include "list.h"
157 #include "ptr_list.h"
158 #include "string_base.h"
159 #include "string_list.h"
160 #include "ref_counter.h"
161 #include "iterators.h"
162 #include "avltree.h"
163 #include "map.h"
164 #include "bit_array_impl_part2.h"
165 #include "timers.h"
166 #include "guid.h"
167 #include "byte_order_helper.h"
168 #include "other.h"
169 #include "chain_list_v2.h"
170 #include "rcptr.h"
171 #include "com_ptr_t.h"
172 #include "string_conv.h"
173 #include "stringNew.h"
174 #include "pathUtils.h"
175 #include "instance_tracker.h"
176 #include "threads.h"
177 #include "base64.h"
178 #include "primitives_part2.h"
179 #include "cpuid.h"
180 #include "memalign.h"
181 
182 #ifdef _WIN32
183 #include "synchro_win.h"
184 #else
185 #include "synchro_nix.h"
186 #endif
187 
188 #include "syncd_storage.h"
189 
190 #ifdef _WIN32
191 #include "win-objects.h"
192 #else
193 #include "nix-objects.h"
194 #endif
195 
196 #include "event.h"
197 
198 #include "audio_sample.h"
199 #include "wildcard.h"
200 #include "filehandle.h"
201 
202 #define PFC_INCLUDED 1
203 
204 #endif //___PFC_H___
__inline bool __InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: pfc.h:33
Definition: pfc.h:53
bool operator==(REFGUID guidOne, REFGUID guidOther)
Definition: pfc.h:42
uint16_t Data3
Definition: pfc.h:56
void myassert(const wchar_t *_Message, const wchar_t *_File, unsigned _Line)
Definition: other.cpp:121
uint16_t Data2
Definition: pfc.h:55
bool operator!=(REFGUID guidOne, REFGUID guidOther)
Definition: pfc.h:43
uint32_t Data1
Definition: pfc.h:54