FreeRDP
Loading...
Searching...
No Matches
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
/* unsupported by clang 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
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
231
#define _M_AMD64 1
232
#endif
233
#endif
234
235
/* Intel ia64 */
236
#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
237
#ifndef _M_IA64
238
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
239
#define _M_IA64 1
240
#endif
241
#endif
242
243
/* Intel x86 or AMD64 (_M_IX86_AMD64) */
244
245
#if defined(_M_IX86) || defined(_M_AMD64)
246
#ifndef _M_IX86_AMD64
247
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
248
#define _M_IX86_AMD64 1
249
#endif
250
#endif
251
252
/* ARM (_M_ARM) */
253
254
#if defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) || \
255
defined(__TARGET_ARCH_THUMB)
256
#ifndef _M_ARM
257
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
258
#define _M_ARM 1
259
#endif
260
#endif
261
262
/* ARM64 (_M_ARM64) */
263
264
#if defined(__aarch64__)
265
#ifndef _M_ARM64
266
#define _M_ARM64 1
267
#endif
268
#endif
269
270
/* MIPS (_M_MIPS) */
271
272
#if defined(mips) || defined(__mips) || defined(__mips__) || defined(__MIPS__)
273
#ifndef _M_MIPS
274
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
275
#define _M_MIPS 1
276
#endif
277
#endif
278
279
/* MIPS64 (_M_MIPS64) */
280
281
#if defined(mips64) || defined(__mips64) || defined(__mips64__) || defined(__MIPS64__)
282
#ifndef _M_MIPS64
283
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
284
#define _M_MIPS64 1
285
#endif
286
#endif
287
288
/* PowerPC (_M_PPC) */
289
290
#if defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || \
291
defined(_ARCH_PPC)
292
#ifndef _M_PPC
293
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
294
#define _M_PPC 1
295
#endif
296
#endif
297
298
/* Intel Itanium (_M_IA64) */
299
300
#if defined(__ia64) || defined(__ia64__) || defined(_IA64) || defined(__IA64__)
301
#ifndef _M_IA64
302
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
303
#define _M_IA64 1
304
#endif
305
#endif
306
307
/* Alpha (_M_ALPHA) */
308
309
#if defined(__alpha) || defined(__alpha__)
310
#ifndef _M_ALPHA
311
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
312
#define _M_ALPHA 1
313
#endif
314
#endif
315
316
/* SPARC (_M_SPARC) */
317
318
#if defined(__sparc) || defined(__sparc__)
319
#ifndef _M_SPARC
320
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
321
#define _M_SPARC 1
322
#endif
323
#endif
324
325
/* E2K (_M_E2K) */
326
327
#if defined(__e2k__)
328
#ifndef _M_E2K
329
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
330
#define _M_E2K 1
331
#endif
332
#endif
333
339
/* Windows (_WIN32) */
340
341
/* WinRT (_WINRT) */
342
343
#if defined(WINAPI_FAMILY)
344
#if (WINAPI_FAMILY == WINAPI_FAMILY_APP)
345
#ifndef _WINRT
346
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
347
#define _WINRT 1
348
#endif
349
#endif
350
#endif
351
352
#if defined(__cplusplus_winrt)
353
#ifndef _WINRT
354
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
355
#define _WINRT 1
356
#endif
357
#endif
358
359
/* Linux (__linux__) */
360
361
#if defined(linux) || defined(__linux)
362
#ifndef __linux__
363
#define __linux__ 1
364
#endif
365
#endif
366
367
/* GNU/Linux (__gnu_linux__) */
368
369
/* Apple Platforms (iOS, Mac OS X) */
370
371
#if (defined(__APPLE__) && defined(__MACH__))
372
373
#include <TargetConditionals.h>
374
375
#if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
376
377
/* iOS (__IOS__) */
378
379
#ifndef __IOS__
380
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
381
#define __IOS__ 1
382
#endif
383
384
#elif (TARGET_OS_MAC == 1)
385
386
/* Mac OS X (__MACOSX__) */
387
388
#ifndef __MACOSX__
389
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
390
#define __MACOSX__ 1
391
#endif
392
393
#endif
394
#endif
395
396
/* Android (__ANDROID__) */
397
398
/* Cygwin (__CYGWIN__) */
399
400
/* FreeBSD (__FreeBSD__) */
401
402
/* NetBSD (__NetBSD__) */
403
404
/* OpenBSD (__OpenBSD__) */
405
406
/* DragonFly (__DragonFly__) */
407
408
/* Solaris (__sun) */
409
410
#if defined(sun)
411
#ifndef __sun
412
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
413
#define __sun 1
414
#endif
415
#endif
416
417
/* IRIX (__sgi) */
418
419
#if defined(sgi)
420
#ifndef __sgi
421
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
422
#define __sgi 1
423
#endif
424
#endif
425
426
/* AIX (_AIX) */
427
428
#if defined(__TOS_AIX__)
429
#ifndef _AIX
430
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
431
#define _AIX 1
432
#endif
433
#endif
434
435
/* HP-UX (__hpux) */
436
437
#if defined(hpux) || defined(_hpux)
438
#ifndef __hpux
439
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
440
#define __hpux 1
441
#endif
442
#endif
443
444
/* BeOS (__BEOS__) */
445
446
/* QNX (__QNXNTO__) */
447
453
#if defined(__gnu_linux__)
454
#include <endian.h>
455
#endif
456
457
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
458
defined(__DragonFly__) || defined(__APPLE__)
459
#include <sys/param.h>
460
#endif
461
462
/* Big-Endian */
463
464
#ifdef __BYTE_ORDER
465
466
#if (__BYTE_ORDER == __BIG_ENDIAN)
467
#ifndef __BIG_ENDIAN__
468
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
469
#define __BIG_ENDIAN__ 1
470
#endif
471
#endif
472
473
#else
474
475
#if defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIPSEB) || \
476
defined(__MIPSEB) || defined(__MIPSEB__)
477
#ifndef __BIG_ENDIAN__
478
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
479
#define __BIG_ENDIAN__ 1
480
#endif
481
#endif
482
483
#endif
/* __BYTE_ORDER */
484
485
/* Little-Endian */
486
487
#ifdef __BYTE_ORDER
488
489
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
490
#ifndef __LITTLE_ENDIAN__
491
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
492
#define __LITTLE_ENDIAN__ 1
493
#endif
494
#endif
495
496
#else
497
498
#if defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || \
499
defined(__MIPSEL) || defined(__MIPSEL__) || defined(__e2k__)
500
#ifndef __LITTLE_ENDIAN__
501
// NOLINTNEXTLINE(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp)
502
#define __LITTLE_ENDIAN__ 1
503
#endif
504
#endif
505
506
#endif
/* __BYTE_ORDER */
507
508
WINPR_PRAGMA_DIAG_POP
509
510
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
511
#define WINPR_DEPRECATED(obj) [[deprecated]] obj
512
#define WINPR_DEPRECATED_VAR(text, obj) [[deprecated(text)]] obj
513
#define WINPR_NORETURN(obj) [[noreturn]] obj
514
#elif defined(WIN32) && !defined(__CYGWIN__)
515
#define WINPR_DEPRECATED(obj) __declspec(deprecated) obj
516
#define WINPR_DEPRECATED_VAR(text, obj) __declspec(deprecated(text)) obj
517
#define WINPR_NORETURN(obj) __declspec(noreturn) obj
518
#elif defined(__GNUC__)
519
#define WINPR_DEPRECATED(obj) obj __attribute__((deprecated))
520
#define WINPR_DEPRECATED_VAR(text, obj) obj __attribute__((deprecated(text)))
521
#define WINPR_NORETURN(obj) __attribute__((__noreturn__)) obj
522
#else
523
#define WINPR_DEPRECATED(obj) obj
524
#define WINPR_DEPRECATED_VAR(text, obj) obj
525
#define WINPR_NORETURN(obj) obj
526
#endif
527
528
#ifdef _WIN32
529
#define INLINE __inline
530
#else
531
#define INLINE inline
532
#endif
533
534
#ifdef WINPR_DLL
535
#if defined _WIN32 || defined __CYGWIN__
536
#ifdef WINPR_EXPORTS
537
#ifdef __GNUC__
538
#define WINPR_API __attribute__((dllexport))
539
#else
540
#define WINPR_API __declspec(dllexport)
541
#endif
542
#else
543
#ifdef __GNUC__
544
#define WINPR_API __attribute__((dllimport))
545
#else
546
#define WINPR_API __declspec(dllimport)
547
#endif
548
#endif
549
#else
550
#if defined(__GNUC__) && (__GNUC__ >= 4)
551
#define WINPR_API __attribute__((visibility("default")))
552
#else
553
#define WINPR_API
554
#endif
555
#endif
556
#else
/* WINPR_DLL */
557
#define WINPR_API
558
#endif
559
560
#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ <= 10)
561
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
562
__attribute__((malloc, warn_unused_result))
563
#elif defined(__GNUC__)
564
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
565
__attribute__((malloc(deallocator, ptrindex), warn_unused_result))
566
#else
567
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) __declspec(restrict)
568
#endif
569
570
#if defined(__GNUC__) || defined(__clang__)
571
#define WINPR_ATTR_FORMAT_ARG(pos, args) __attribute__((__format__(__printf__, pos, args)))
572
#define WINPR_FORMAT_ARG
573
#else
574
#define WINPR_ATTR_FORMAT_ARG(pos, args)
575
#define WINPR_FORMAT_ARG _Printf_format_string_
576
#endif
577
578
#if defined(EXPORT_ALL_SYMBOLS)
579
#define WINPR_LOCAL WINPR_API
580
#else
581
#if defined _WIN32 || defined __CYGWIN__
582
#define WINPR_LOCAL
583
#else
584
#if defined(__GNUC__) && (__GNUC__ >= 4)
585
#define WINPR_LOCAL __attribute__((visibility("hidden")))
586
#else
587
#define WINPR_LOCAL
588
#endif
589
#endif
590
#endif
591
592
// WARNING: *do not* use thread-local storage for new code because it is not portable
593
// It is only used for VirtualChannelInit, and all FreeRDP channels use VirtualChannelInitEx
594
// The old virtual channel API is only realistically used on Windows where TLS is available
595
#if defined _WIN32 || defined __CYGWIN__
596
#ifdef __GNUC__
597
#define WINPR_TLS __thread
598
#else
599
#define WINPR_TLS __declspec(thread)
600
#endif
601
#elif !defined(__IOS__)
602
#define WINPR_TLS __thread
603
#else
604
// thread-local storage is not supported on iOS
605
// don't warn because it isn't actually used on iOS
606
#define WINPR_TLS
607
#endif
608
609
#if defined(__GNUC__) || defined(__clang__)
610
#define WINPR_ALIGN64 __attribute__((aligned(8)))
611
#else
612
#ifdef _WIN32
613
#define WINPR_ALIGN64 __declspec(align(8))
614
#else
615
#define WINPR_ALIGN64
616
#endif
617
#endif
618
619
#if defined(__cplusplus) && (__cplusplus >= 201703L)
620
#define WINPR_ATTR_UNUSED [[maybe_unused]]
621
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202000L)
622
#define WINPR_ATTR_UNUSED [[maybe_unused]]
623
#elif defined(__GNUC__) || defined(__clang__)
624
#define WINPR_ATTR_UNUSED __attribute__((unused))
625
#else
626
#define WINPR_ATTR_UNUSED
627
#endif
628
629
#define WINPR_UNUSED(x) (void)(x)
630
631
#endif
/* WINPR_PLATFORM_H */
winpr
include
winpr
platform.h
Generated by
1.9.8