22 #include <winpr/platform.h>
25 #if defined _WIN32 || defined __CYGWIN__
28 #define WINPR_API __attribute__((dllexport))
30 #define WINPR_API __declspec(dllexport)
34 #define WINPR_API __attribute__((dllimport))
36 #define WINPR_API __declspec(dllimport)
40 #if defined(__GNUC__) && (__GNUC__ >= 4)
41 #define WINPR_API __attribute__((visibility("default")))
50 #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ <= 10)
51 #define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
52 __attribute__((malloc, warn_unused_result))
53 #elif defined(__GNUC__)
54 #define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
55 __attribute__((malloc(deallocator, ptrindex), warn_unused_result))
57 #define WINPR_ATTR_MALLOC(deallocator, ptrindex) __declspec(restrict)
60 #if defined(__GNUC__) || defined(__clang__)
61 #define WINPR_ATTR_FORMAT_ARG(pos, args) __attribute__((__format__(__printf__, pos, args)))
62 #define WINPR_FORMAT_ARG
64 #define WINPR_ATTR_FORMAT_ARG(pos, args)
65 #define WINPR_FORMAT_ARG _Printf_format_string_
68 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
69 #define WINPR_DEPRECATED(obj) [[deprecated]] obj
70 #define WINPR_DEPRECATED_VAR(text, obj) [[deprecated(text)]] obj
71 #define WINPR_NORETURN(obj) [[noreturn]] obj
72 #elif defined(WIN32) && !defined(__CYGWIN__)
73 #define WINPR_DEPRECATED(obj) __declspec(deprecated) obj
74 #define WINPR_DEPRECATED_VAR(text, obj) __declspec(deprecated(text)) obj
75 #define WINPR_NORETURN(obj) __declspec(noreturn) obj
76 #elif defined(__GNUC__)
77 #define WINPR_DEPRECATED(obj) obj __attribute__((deprecated))
78 #define WINPR_DEPRECATED_VAR(text, obj) obj __attribute__((deprecated(text)))
79 #define WINPR_NORETURN(obj) __attribute__((__noreturn__)) obj
81 #define WINPR_DEPRECATED(obj) obj
82 #define WINPR_DEPRECATED_VAR(text, obj) obj
83 #define WINPR_NORETURN(obj) obj
86 #if defined(EXPORT_ALL_SYMBOLS)
87 #define WINPR_LOCAL WINPR_API
89 #if defined _WIN32 || defined __CYGWIN__
92 #if defined(__GNUC__) && (__GNUC__ >= 4)
93 #define WINPR_LOCAL __attribute__((visibility("hidden")))
103 #if defined _WIN32 || defined __CYGWIN__
105 #define WINPR_TLS __thread
107 #define WINPR_TLS __declspec(thread)
109 #elif !defined(__IOS__)
110 #define WINPR_TLS __thread
118 #define INLINE __inline
120 #define INLINE inline
123 #if defined(__GNUC__) || defined(__clang__)
124 #define WINPR_ALIGN64 __attribute__((aligned(8)))
127 #define WINPR_ALIGN64 __declspec(align(8))
129 #define WINPR_ALIGN64
133 WINPR_API
void winpr_get_version(
int* major,
int* minor,
int* revision);
134 WINPR_API
const char* winpr_get_version_string(
void);
135 WINPR_API
const char* winpr_get_build_revision(
void);
136 WINPR_API
const char* winpr_get_build_config(
void);
138 #define WINPR_UNUSED(x) (void)(x)
140 #if defined(__GNUC__) || defined(__clang__)
148 #define WINPR_REINTERPRET_CAST(ptr, srcType, dstType) \
166 #define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) \
184 #define WINPR_FUNC_PTR_CAST(ptr, dstType) \
195 #define WINPR_REINTERPRET_CAST(ptr, srcType, dstType) (dstType) ptr
196 #define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) (dstType) ptr
197 #define WINPR_FUNC_PTR_CAST(ptr, dstType) (dstType)(uintptr_t) ptr