diff --git a/channels/cliprdr/client/cliprdr_format.h b/channels/cliprdr/client/cliprdr_format.h index 80c10841f..8c8893353 100644 --- a/channels/cliprdr/client/cliprdr_format.h +++ b/channels/cliprdr/client/cliprdr_format.h @@ -24,6 +24,12 @@ #define FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H #include +#include + +#include +#include + +#include "cliprdr_main.h" WINPR_ATTR_NODISCARD FREERDP_LOCAL diff --git a/channels/rdpsnd/client/ios/TPCircularBuffer.h b/channels/rdpsnd/client/ios/TPCircularBuffer.h index 97e109541..cc338a67f 100644 --- a/channels/rdpsnd/client/ios/TPCircularBuffer.h +++ b/channels/rdpsnd/client/ios/TPCircularBuffer.h @@ -102,7 +102,7 @@ extern "C" * @param availableBytes On output, the number of bytes ready for reading * @return Pointer to the first bytes ready for reading, or NULL if buffer is empty */ - static __inline__ __attribute__((always_inline)) void* + static inline __attribute__((always_inline)) void* TPCircularBufferTail(TPCircularBuffer* buffer, int32_t* availableBytes) { *availableBytes = buffer->fillCount; @@ -119,7 +119,7 @@ extern "C" * @param buffer Circular buffer * @param amount Number of bytes to consume */ - static __inline__ __attribute__((always_inline)) void + static inline __attribute__((always_inline)) void TPCircularBufferConsume(TPCircularBuffer* buffer, int32_t amount) { buffer->tail = (buffer->tail + amount) % buffer->length; @@ -131,7 +131,7 @@ extern "C" * Version of TPCircularBufferConsume without the memory barrier, for more optimal use in * single-threaded contexts */ - static __inline__ __attribute__((always_inline)) void + static inline __attribute__((always_inline)) void TPCircularBufferConsumeNoBarrier(TPCircularBuffer* buffer, int32_t amount) { buffer->tail = (buffer->tail + amount) % buffer->length; @@ -149,7 +149,7 @@ extern "C" * @param availableBytes On output, the number of bytes ready for writing * @return Pointer to the first bytes ready for writing, or NULL if buffer is full */ - static __inline__ __attribute__((always_inline)) void* + static inline __attribute__((always_inline)) void* TPCircularBufferHead(TPCircularBuffer* buffer, int32_t* availableBytes) { *availableBytes = (buffer->length - buffer->fillCount); @@ -168,7 +168,7 @@ extern "C" * @param buffer Circular buffer * @param amount Number of bytes to produce */ - static __inline__ __attribute__((always_inline)) void + static inline __attribute__((always_inline)) void TPCircularBufferProduce(TPCircularBuffer* buffer, int amount) { buffer->head = (buffer->head + amount) % buffer->length; @@ -180,7 +180,7 @@ extern "C" * Version of TPCircularBufferProduce without the memory barrier, for more optimal use in * single-threaded contexts */ - static __inline__ __attribute__((always_inline)) void + static inline __attribute__((always_inline)) void TPCircularBufferProduceNoBarrier(TPCircularBuffer* buffer, int amount) { buffer->head = (buffer->head + amount) % buffer->length; @@ -198,7 +198,7 @@ extern "C" * @param len Number of bytes in source buffer * @return true if bytes copied, false if there was insufficient space */ - static __inline__ __attribute__((always_inline)) bool + static inline __attribute__((always_inline)) bool TPCircularBufferProduceBytes(TPCircularBuffer* buffer, const void* src, int32_t len) { int32_t space; diff --git a/include/freerdp/api.h b/include/freerdp/api.h index 07003bc40..5eef004da 100644 --- a/include/freerdp/api.h +++ b/include/freerdp/api.h @@ -53,7 +53,13 @@ #endif #else #if defined(__GNUC__) && (__GNUC__ >= 4) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define FREERDP_API [[gnu::visibility("default")]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define FREERDP_API [[gnu::visibility("default")]] +#else #define FREERDP_API __attribute__((visibility("default"))) +#endif #else #define FREERDP_API #endif @@ -66,7 +72,13 @@ #define FREERDP_LOCAL #else #if defined(__GNUC__) && (__GNUC__ >= 4) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define FREERDP_LOCAL [[gnu::visibility("hidden")]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define FREERDP_LOCAL [[gnu::visibility("hidden")]] +#else #define FREERDP_LOCAL __attribute__((visibility("hidden"))) +#endif #else #define FREERDP_LOCAL #endif @@ -104,14 +116,6 @@ ((_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return)) #endif -#if defined(__GNUC__) || defined(__clang__) -#define ALIGN64 __attribute__((aligned(8))) -#else -#ifdef _WIN32 -#define ALIGN64 __declspec(align(8)) -#else -#define ALIGN64 -#endif -#endif +#define ALIGN64 DECLSPEC_ALIGN(8) #endif /* FREERDP_API */ diff --git a/libfreerdp/codec/neon/rfx_neon.c b/libfreerdp/codec/neon/rfx_neon.c index c999adf5c..57ad42cf0 100644 --- a/libfreerdp/codec/neon/rfx_neon.c +++ b/libfreerdp/codec/neon/rfx_neon.c @@ -36,7 +36,7 @@ /* rfx_decode_YCbCr_to_RGB_NEON code now resides in the primitives library. */ -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) rfx_quantization_decode_block_NEON(INT16* buffer, const size_t buffer_size, const UINT32 factor) { int16x8_t quantFactors = vdupq_n_s16(factor); @@ -69,7 +69,7 @@ static void rfx_quantization_decode_NEON(INT16* buffer, const UINT32* WINPR_REST rfx_quantization_decode_block_NEON(&buffer[4032], 64, quantVals[0] - 1); /* LL3 */ } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) rfx_dwt_2d_decode_block_horiz_NEON(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT h, INT16* WINPR_RESTRICT dst, size_t subband_width) { @@ -132,7 +132,7 @@ rfx_dwt_2d_decode_block_horiz_NEON(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRIC } } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) rfx_dwt_2d_decode_block_vert_NEON(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT h, INT16* WINPR_RESTRICT dst, size_t subband_width) { @@ -203,7 +203,7 @@ rfx_dwt_2d_decode_block_vert_NEON(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT } } -static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) rfx_dwt_2d_decode_block_NEON(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RESTRICT idwt, size_t subband_width) { diff --git a/libfreerdp/codec/sse/rfx_sse2.c b/libfreerdp/codec/sse/rfx_sse2.c index 870bee8e6..623937bde 100644 --- a/libfreerdp/codec/sse/rfx_sse2.c +++ b/libfreerdp/codec/sse/rfx_sse2.c @@ -50,8 +50,8 @@ #define ATTRIBUTES __gnu_inline__, __always_inline__ #endif -static __inline void __attribute__((ATTRIBUTES)) -mm_prefetch_buffer(char* WINPR_RESTRICT buffer, size_t num_bytes) +static inline void __attribute__((ATTRIBUTES)) mm_prefetch_buffer(char* WINPR_RESTRICT buffer, + size_t num_bytes) { __m128i* buf = (__m128i*)buffer; @@ -64,7 +64,7 @@ mm_prefetch_buffer(char* WINPR_RESTRICT buffer, size_t num_bytes) /* rfx_decode_ycbcr_to_rgb_sse2 code now resides in the primitives library. */ /* rfx_encode_rgb_to_ycbcr_sse2 code now resides in the primitives library. */ -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_quantization_decode_block_sse2(INT16* WINPR_RESTRICT buffer, const size_t buffer_size, const UINT32 factor) { @@ -103,7 +103,7 @@ static void rfx_quantization_decode_sse2(INT16* WINPR_RESTRICT buffer, rfx_quantization_decode_block_sse2(&buffer[4032], 64, quantVals[0] - 1); /* LL3 */ } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_quantization_encode_block_sse2(INT16* WINPR_RESTRICT buffer, const unsigned buffer_size, const INT16 factor) { @@ -160,7 +160,7 @@ static void rfx_quantization_encode_sse2(INT16* WINPR_RESTRICT buffer, rfx_quantization_encode_block_sse2(buffer, 4096, 5); } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_horiz_sse2(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT h, INT16* WINPR_RESTRICT dst, size_t subband_width) { @@ -229,7 +229,7 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRIC } } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_vert_sse2(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT h, INT16* WINPR_RESTRICT dst, size_t subband_width) { @@ -300,7 +300,7 @@ rfx_dwt_2d_decode_block_vert_sse2(INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT } } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RESTRICT idwt, size_t subband_width) { @@ -333,7 +333,7 @@ static void rfx_dwt_2d_decode_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RE rfx_dwt_2d_decode_block_sse2(&buffer[0], dwt_buffer, 32); } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_vert_sse2(INT16* WINPR_RESTRICT src, INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT h, size_t subband_width) { @@ -375,7 +375,7 @@ rfx_dwt_2d_encode_block_vert_sse2(INT16* WINPR_RESTRICT src, INT16* WINPR_RESTRI } } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_horiz_sse2(INT16* WINPR_RESTRICT src, INT16* WINPR_RESTRICT l, INT16* WINPR_RESTRICT h, size_t subband_width) { @@ -418,7 +418,7 @@ rfx_dwt_2d_encode_block_horiz_sse2(INT16* WINPR_RESTRICT src, INT16* WINPR_RESTR } } -static __inline void __attribute__((ATTRIBUTES)) +static inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RESTRICT dwt, size_t subband_width) { diff --git a/libfreerdp/core/gateway/rpc_fault.c b/libfreerdp/core/gateway/rpc_fault.c index dcc201cc0..80be5756b 100644 --- a/libfreerdp/core/gateway/rpc_fault.c +++ b/libfreerdp/core/gateway/rpc_fault.c @@ -27,7 +27,8 @@ #define TAG FREERDP_TAG("core.gateway.rpc") -static ALIGN64 const RPC_FAULT_CODE RPC_FAULT_CODES[] = { +ALIGN64 +static const RPC_FAULT_CODE RPC_FAULT_CODES[] = { DEFINE_RPC_FAULT_CODE(nca_s_fault_object_not_found, CAT_GATEWAY), DEFINE_RPC_FAULT_CODE(nca_s_fault_cancel, CAT_GATEWAY), DEFINE_RPC_FAULT_CODE(nca_s_fault_addr_error, CAT_GATEWAY), diff --git a/libfreerdp/core/timer.c b/libfreerdp/core/timer.c index ae6db8a52..4514d8861 100644 --- a/libfreerdp/core/timer.c +++ b/libfreerdp/core/timer.c @@ -33,7 +33,7 @@ #define TAG FREERDP_TAG("timer") #endif -typedef ALIGN64 struct +typedef struct ALIGN64 { FreeRDP_TimerID id; uint64_t intervallNS; diff --git a/libfreerdp/primitives/prim_internal.h b/libfreerdp/primitives/prim_internal.h index b1af8b2aa..ea09492a0 100644 --- a/libfreerdp/primitives/prim_internal.h +++ b/libfreerdp/primitives/prim_internal.h @@ -25,13 +25,7 @@ #include "../core/simd.h" -#ifdef __GNUC__ -#define PRIM_ALIGN_128 __attribute__((aligned(16))) -#else -#ifdef _WIN32 -#define PRIM_ALIGN_128 __declspec(align(16)) -#endif -#endif +#define PRIM_ALIGN_128 DECLSPEC_ALIGN(16) #if defined(SSE_AVX_INTRINSICS_ENABLED) || defined(NEON_INTRINSICS_ENABLED) || defined(WITH_OPENCL) #define HAVE_OPTIMIZED_PRIMITIVES 1 diff --git a/rdtk/include/rdtk/api.h b/rdtk/include/rdtk/api.h index b5cee542a..0c1ef62fd 100644 --- a/rdtk/include/rdtk/api.h +++ b/rdtk/include/rdtk/api.h @@ -37,7 +37,13 @@ #endif #else #if __GNUC__ >= 4 +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define RDTK_EXPORT [[gnu::visibility("default")]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define RDTK_EXPORT [[gnu::visibility("default")]] +#else #define RDTK_EXPORT __attribute__((visibility("default"))) +#endif #else #define RDTK_EXPORT #endif diff --git a/uwac/include/uwac/uwac.h b/uwac/include/uwac/uwac.h index e1db8de7d..e657399d8 100644 --- a/uwac/include/uwac/uwac.h +++ b/uwac/include/uwac/uwac.h @@ -27,7 +27,13 @@ #include #if defined(__GNUC__) && (__GNUC__ >= 4) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define UWAC_API [[gnu::visibility("default")]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define UWAC_API [[gnu::visibility("default")]] +#else #define UWAC_API __attribute__((visibility("default"))) +#endif #else #define UWAC_API #endif diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h index 681cb5d5a..12e54890d 100644 --- a/winpr/include/winpr/platform.h +++ b/winpr/include/winpr/platform.h @@ -63,7 +63,7 @@ #define WINPR_FALLTHROUGH \ (void)0; \ [[fallthrough]]; -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define WINPR_FALLTHROUGH \ (void)0; \ [[fallthrough]]; @@ -80,7 +80,9 @@ #endif #if defined(WINPR_DEFINE_ATTR_NODISCARD) -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202003L) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define WINPR_ATTR_NODISCARD [[nodiscard]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define WINPR_ATTR_NODISCARD [[nodiscard]] #elif defined(__clang__) #define WINPR_ATTR_NODISCARD __attribute__((warn_unused_result)) @@ -532,7 +534,10 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO WINPR_PRAGMA_DIAG_POP -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define WINPR_DEPRECATED(obj) [[deprecated]] obj +#define WINPR_DEPRECATED_VAR(text, obj) [[deprecated("[deprecated] " text)]] obj +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define WINPR_DEPRECATED(obj) [[deprecated]] obj #define WINPR_DEPRECATED_VAR(text, obj) [[deprecated("[deprecated] " text)]] obj #elif defined(__GNUC__) @@ -543,7 +548,9 @@ WINPR_PRAGMA_DIAG_POP #define WINPR_DEPRECATED_VAR(text, obj) obj #endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202202L) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define WINPR_NORETURN(obj) [[noreturn]] obj +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define WINPR_NORETURN(obj) [[noreturn]] obj #elif defined(WIN32) && !defined(__CYGWIN__) #define WINPR_NORETURN(obj) __declspec(noreturn) obj @@ -572,7 +579,13 @@ WINPR_PRAGMA_DIAG_POP #endif #else #if defined(__GNUC__) && (__GNUC__ >= 4) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define WINPR_API [[gnu::visibility("default")]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define WINPR_API [[gnu::visibility("default")]] +#else #define WINPR_API __attribute__((visibility("default"))) +#endif #else #define WINPR_API #endif @@ -581,13 +594,29 @@ WINPR_PRAGMA_DIAG_POP #define WINPR_API #endif -#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ <= 10) +#if defined(__clang__) +#if defined(__cplusplus) && (__cplusplus >= 201703L) #define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ - __attribute__((malloc, warn_unused_result)) /** @since version 3.3.0 */ -#elif defined(__GNUC__) + [[gnu::malloc, nodiscard]] /** @since version 3.3.0 */ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ + [[gnu::malloc, nodiscard]] /** @since version 3.3.0 */ +#else +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ + [[gnu::malloc, nodiscard]] /** @since version 3.3.0 */ +#endif +#elif defined(__GNUC__) && (__GNUC__ > 10) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ + [[gnu::malloc(deallocator, ptrindex), nodiscard]] /** @since version 3.3.0 */ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ + [[gnu::malloc(deallocator, ptrindex), nodiscard]] /** @since version 3.3.0 */ +#else #define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ __attribute__((malloc(deallocator, ptrindex), warn_unused_result)) /** @since version 3.3.0 */ -#else +#endif +#elif defined(_MSC_VER) #define WINPR_ATTR_MALLOC(deallocator, ptrindex) __declspec(restrict) /** @since version 3.3.0 */ #endif @@ -635,19 +664,11 @@ WINPR_PRAGMA_DIAG_POP #define WINPR_TLS #endif -#if defined(__GNUC__) || defined(__clang__) -#define WINPR_ALIGN64 __attribute__((aligned(8))) /** @since version 3.4.0 */ -#else -#ifdef _WIN32 -#define WINPR_ALIGN64 __declspec(align(8)) /** @since version 3.4.0 */ -#else -#define WINPR_ALIGN64 /** @since version 3.4.0 */ -#endif -#endif +#define WINPR_ALIGN64 DECLSPEC_ALIGN(8) #if defined(__cplusplus) && (__cplusplus >= 201703L) #define WINPR_ATTR_UNUSED [[maybe_unused]] /** @since version 3.12.0 */ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201904L) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define WINPR_ATTR_UNUSED [[maybe_unused]] /** @since version 3.12.0 */ #elif defined(__GNUC__) || defined(__clang__) #define WINPR_ATTR_UNUSED __attribute__((unused)) /** @since version 3.12.0 */ diff --git a/winpr/include/winpr/spec.h b/winpr/include/winpr/spec.h index cd56031e6..29bea1a76 100644 --- a/winpr/include/winpr/spec.h +++ b/winpr/include/winpr/spec.h @@ -82,7 +82,13 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) #elif defined(__GNUC__) +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define DECLSPEC_ALIGN(x) [[gnu::aligned(x)]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define DECLSPEC_ALIGN(x) [[gnu::aligned(x)]] +#else #define DECLSPEC_ALIGN(x) __attribute__((__aligned__(x))) +#endif #else #define DECLSPEC_ALIGN(x) #endif @@ -997,7 +1003,13 @@ extern "C++" #endif /* __GNUC__ */ #else #if defined(__GNUC__) && __GNUC__ >= 4 +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define DECLSPEC_EXPORT [[gnu::visibility("default")]] +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define DECLSPEC_EXPORT [[gnu::visibility("default")]] +#else #define DECLSPEC_EXPORT __attribute__((visibility("default"))) +#endif #define DECLSPEC_IMPORT #else #define DECLSPEC_EXPORT