FreeRDP
platform.h
1
20
#ifndef WINPR_PLATFORM_H
21
#define WINPR_PLATFORM_H
22
23
#include <stdlib.h>
24
25
/* MSVC only defines _Pragma if you compile with /std:c11 with no extensions
26
* see
27
* https://learn.microsoft.com/en-us/cpp/preprocessor/pragma-directives-and-the-pragma-keyword?view=msvc-170#the-pragma-preprocessing-operator
28
*/
29
#if !defined(_MSC_VER)
30
#define WINPR_DO_PRAGMA(x) _Pragma(#x)
31
#else
32
#define WINPR_DO_PRAGMA(x) __pragma(#x)
33
#endif
34
35
/* COVERITY_BUILD must be defined by build system */
36
#if !defined(COVERITY_BUILD)
37
#define WINPR_DO_COVERITY_PRAGMA(x)
38
#else
39
#define WINPR_DO_COVERITY_PRAGMA(x) WINPR_DO_PRAGMA(x)
40
#endif
41
42
#if defined(__GNUC__)
43
#define WINPR_PRAGMA_WARNING(msg) WINPR_DO_PRAGMA(GCC warning #msg)
44
#elif defined(__clang__)
45
#define WINPR_PRAGMA_WARNING(msg) WINPR_DO_PRAGMA(GCC warning #msg)
46
#elif defined(_MSC_VER) && (_MSC_VER >= 1920)
47
#define WINPR_PRAGMA_WARNING(msg) WINPR_DO_PRAGMA(message \x28 #msg \x29)
48
#else
49
#define WINPR_PRAGMA_WARNING(msg)
50
#endif
51
52
// C99 related macros
53
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
54
#define WINPR_RESTRICT restrict
55
#elif defined(_MSC_VER) && _MSC_VER >= 1900
56
#define WINPR_RESTRICT __restrict
57
#else
58
#define WINPR_RESTRICT
59
#endif
60
61
// C23 related macros
62
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
63
#define WINPR_FALLTHROUGH \
64
(void)0; \
65
[[fallthrough]];
66
#elif defined(__clang__)
67
#define WINPR_FALLTHROUGH \
68
(void)0; \
69
__attribute__((fallthrough));
70
#elif defined(__GNUC__) && (__GNUC__ >= 7)
71
#define WINPR_FALLTHROUGH \
72
(void)0; \
73
__attribute__((fallthrough));
74
#else
75
#define WINPR_FALLTHROUGH (void)0;
76
#endif
77
78
#if defined(__clang__)
79
#define WINPR_PRAGMA_DIAG_PUSH WINPR_DO_PRAGMA(clang diagnostic push)
80
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \
81
WINPR_DO_PRAGMA(clang diagnostic ignored "-Woverlength-strings"
)
82
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \
83
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wdiscarded-qualifiers"
)
84
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC WINPR_DO_PRAGMA(clang diagnostic ignored "-Wpedantic"
)
85
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \
86
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wmissing-prototypes"
)
87
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \
88
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wstrict-prototypes"
)
89
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO \
90
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wreserved-id-macro"
)
91
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO \
92
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wunused-macros"
)
93
#define WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
94
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wunknown-pragmas"
)
96
#if __clang_major__ >= 13
97
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER \
98
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wreserved-identifier"
)
99
#else
100
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
101
#endif
102
103
#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST \
104
WINPR_DO_PRAGMA(clang diagnostic ignored "-Watomic-implicit-seq-cst"
)
105
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \
106
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wunused-const-variable"
)
107
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \
108
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wformat-security"
)
109
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
110
WINPR_DO_PRAGMA(clang diagnostic ignored \
111
"-Wtautological-constant-out-of-range-compare"
)
115
#if __clang_major__ >= 12
116
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
117
WINPR_DO_PRAGMA(clang diagnostic ignored \
118
"-Wtautological-value-range-compare"
)
120
#else
121
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE
122
#endif
123
124
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \
125
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wformat-nonliteral"
)
126
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
/* not supported \
127
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wmismatched-dealloc") */
128
#define WINPR_PRAGMA_DIAG_POP WINPR_DO_PRAGMA(clang diagnostic pop)
129
#define WINPR_PRAGMA_UNROLL_LOOP \
130
_Pragma("clang loop vectorize_width(8) interleave_count(8)"
)
132
#elif defined(__GNUC__)
133
#define WINPR_PRAGMA_DIAG_PUSH WINPR_DO_PRAGMA(GCC diagnostic push)
134
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \
135
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Woverlength-strings"
)
136
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \
137
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wdiscarded-qualifiers"
)
138
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wpedantic"
)
139
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \
140
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wmissing-prototypes"
)
141
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \
142
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wstrict-prototypes"
)
143
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
/* not supported WINPR_DO_PRAGMA(GCC \
144
diagnostic ignored "-Wreserved-id-macro") \
145
*/
146
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO \
147
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wunused-macros"
)
148
#define WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
149
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas"
)
151
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
152
/* not supported WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wreserved-identifier") */
153
#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST
/* not supported WINPR_DO_PRAGMA(GCC diagnostic \
154
ignored \
155
"-Watomic-implicit-seq-cst") */
156
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \
157
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wunused-const-variable"
)
158
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \
159
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wformat-security"
)
160
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE
/* not supported
161
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare") */
162
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE
/* not supported
163
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wtautological-value-range-compare") */
164
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \
165
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wformat-nonliteral"
)
166
#if __GNUC__ >= 11
167
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC \
168
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wmismatched-dealloc"
)
169
#else
170
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
171
#endif
172
#define WINPR_PRAGMA_DIAG_POP WINPR_DO_PRAGMA(GCC diagnostic pop)
173
#define WINPR_PRAGMA_UNROLL_LOOP \
174
WINPR_DO_PRAGMA(GCC unroll 8) WINPR_DO_PRAGMA(GCC ivdep)
175
#else
176
#define WINPR_PRAGMA_DIAG_PUSH
177
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC
178
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
179
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS
180
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES
181
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES
182
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
183
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO
184
#define WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS
185
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
186
#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST
187
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR
188
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY
189
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE
190
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE
191
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL
192
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
193
#define WINPR_PRAGMA_DIAG_POP
194
#define WINPR_PRAGMA_UNROLL_LOOP
195
#endif
196
197
#if defined(MSVC)
198
#undef WINPR_PRAGMA_UNROLL_LOOP
199
#define WINPR_PRAGMA_UNROLL_LOOP WINPR_DO_PRAGMA(loop(ivdep))
200
#endif
201
202
WINPR_PRAGMA_DIAG_PUSH
203
204
WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
205
206
/*
207
* Processor Architectures:
208
* http://sourceforge.net/p/predef/wiki/Architectures/
209
*
210
* Visual Studio Predefined Macros:
211
* http://msdn.microsoft.com/en-ca/library/vstudio/b0084kay.aspx
212
*/
213
214
/* Intel x86 (_M_IX86) */
215
216
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \
217
defined(__i586__) || defined(__i686__) || defined(__X86__) || defined(_X86_) || \
218
defined(__I86__) || defined(__IA32__) || defined(__THW_INTEL__) || defined(__INTEL__) || \
219
defined(_M_IX86)
220
#ifndef _M_IX86
221
#define _M_IX86 1
222
#endif
223
#endif
224
225
/* AMD64 (_M_AMD64) */
226
227
#if defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || \
228
defined(_M_X64)
229
#ifndef _M_AMD64
230
#define _M_AMD64 1
231
#endif
232
#endif
233
234
/* Intel ia64 */
235
#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
236
#ifndef _M_IA64
237
#define _M_IA64 1
238
#endif
239
#endif
240
241
/* Intel x86 or AMD64 (_M_IX86_AMD64) */
242
243
#if defined(_M_IX86) || defined(_M_AMD64)
244
#ifndef _M_IX86_AMD64
245
#define _M_IX86_AMD64 1
246
#endif
247
#endif
248
249
/* ARM (_M_ARM) */
250
251
#if defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) || \
252
defined(__TARGET_ARCH_THUMB)
253
#ifndef _M_ARM
254
#define _M_ARM 1
255
#endif
256
#endif
257
258
/* ARM64 (_M_ARM64) */
259
260
#if defined(__aarch64__)
261
#ifndef _M_ARM64
262
#define _M_ARM64 1
263
#endif
264
#endif
265
266
/* MIPS (_M_MIPS) */
267
268
#if defined(mips) || defined(__mips) || defined(__mips__) || defined(__MIPS__)
269
#ifndef _M_MIPS
270
#define _M_MIPS 1
271
#endif
272
#endif
273
274
/* MIPS64 (_M_MIPS64) */
275
276
#if defined(mips64) || defined(__mips64) || defined(__mips64__) || defined(__MIPS64__)
277
#ifndef _M_MIPS64
278
#define _M_MIPS64 1
279
#endif
280
#endif
281
282
/* PowerPC (_M_PPC) */
283
284
#if defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || \
285
defined(_ARCH_PPC)
286
#ifndef _M_PPC
287
#define _M_PPC 1
288
#endif
289
#endif
290
291
/* Intel Itanium (_M_IA64) */
292
293
#if defined(__ia64) || defined(__ia64__) || defined(_IA64) || defined(__IA64__)
294
#ifndef _M_IA64
295
#define _M_IA64 1
296
#endif
297
#endif
298
299
/* Alpha (_M_ALPHA) */
300
301
#if defined(__alpha) || defined(__alpha__)
302
#ifndef _M_ALPHA
303
#define _M_ALPHA 1
304
#endif
305
#endif
306
307
/* SPARC (_M_SPARC) */
308
309
#if defined(__sparc) || defined(__sparc__)
310
#ifndef _M_SPARC
311
#define _M_SPARC 1
312
#endif
313
#endif
314
315
/* E2K (_M_E2K) */
316
317
#if defined(__e2k__)
318
#ifndef _M_E2K
319
#define _M_E2K 1
320
#endif
321
#endif
322
328
/* Windows (_WIN32) */
329
330
/* WinRT (_WINRT) */
331
332
#if defined(WINAPI_FAMILY)
333
#if (WINAPI_FAMILY == WINAPI_FAMILY_APP)
334
#ifndef _WINRT
335
#define _WINRT 1
336
#endif
337
#endif
338
#endif
339
340
#if defined(__cplusplus_winrt)
341
#ifndef _WINRT
342
#define _WINRT 1
343
#endif
344
#endif
345
346
/* Linux (__linux__) */
347
348
#if defined(linux) || defined(__linux)
349
#ifndef __linux__
350
#define __linux__ 1
351
#endif
352
#endif
353
354
/* GNU/Linux (__gnu_linux__) */
355
356
/* Apple Platforms (iOS, Mac OS X) */
357
358
#if (defined(__APPLE__) && defined(__MACH__))
359
360
#include <TargetConditionals.h>
361
362
#if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
363
364
/* iOS (__IOS__) */
365
366
#ifndef __IOS__
367
#define __IOS__ 1
368
#endif
369
370
#elif (TARGET_OS_MAC == 1)
371
372
/* Mac OS X (__MACOSX__) */
373
374
#ifndef __MACOSX__
375
#define __MACOSX__ 1
376
#endif
377
378
#endif
379
#endif
380
381
/* Android (__ANDROID__) */
382
383
/* Cygwin (__CYGWIN__) */
384
385
/* FreeBSD (__FreeBSD__) */
386
387
/* NetBSD (__NetBSD__) */
388
389
/* OpenBSD (__OpenBSD__) */
390
391
/* DragonFly (__DragonFly__) */
392
393
/* Solaris (__sun) */
394
395
#if defined(sun)
396
#ifndef __sun
397
#define __sun 1
398
#endif
399
#endif
400
401
/* IRIX (__sgi) */
402
403
#if defined(sgi)
404
#ifndef __sgi
405
#define __sgi 1
406
#endif
407
#endif
408
409
/* AIX (_AIX) */
410
411
#if defined(__TOS_AIX__)
412
#ifndef _AIX
413
#define _AIX 1
414
#endif
415
#endif
416
417
/* HP-UX (__hpux) */
418
419
#if defined(hpux) || defined(_hpux)
420
#ifndef __hpux
421
#define __hpux 1
422
#endif
423
#endif
424
425
/* BeOS (__BEOS__) */
426
427
/* QNX (__QNXNTO__) */
428
434
#if defined(__gnu_linux__)
435
#include <endian.h>
436
#endif
437
438
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
439
defined(__DragonFly__) || defined(__APPLE__)
440
#include <sys/param.h>
441
#endif
442
443
/* Big-Endian */
444
445
#ifdef __BYTE_ORDER
446
447
#if (__BYTE_ORDER == __BIG_ENDIAN)
448
#ifndef __BIG_ENDIAN__
449
#define __BIG_ENDIAN__ 1
450
#endif
451
#endif
452
453
#else
454
455
#if defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIPSEB) || \
456
defined(__MIPSEB) || defined(__MIPSEB__)
457
#ifndef __BIG_ENDIAN__
458
#define __BIG_ENDIAN__ 1
459
#endif
460
#endif
461
462
#endif
/* __BYTE_ORDER */
463
464
/* Little-Endian */
465
466
#ifdef __BYTE_ORDER
467
468
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
469
#ifndef __LITTLE_ENDIAN__
470
#define __LITTLE_ENDIAN__ 1
471
#endif
472
#endif
473
474
#else
475
476
#if defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || \
477
defined(__MIPSEL) || defined(__MIPSEL__) || defined(__e2k__)
478
#ifndef __LITTLE_ENDIAN__
479
#define __LITTLE_ENDIAN__ 1
480
#endif
481
#endif
482
483
#endif
/* __BYTE_ORDER */
484
485
WINPR_PRAGMA_DIAG_POP
486
487
#endif
/* WINPR_PLATFORM_H */
winpr
include
winpr
platform.h
Generated by
1.9.1