[attributes] update attribute definitions

* support C++
* support C23
* replace __inline et al with C11 inline
This commit is contained in:
Armin Novak
2026-02-25 10:22:58 +01:00
parent 8016117eb7
commit e9723d1b61
12 changed files with 107 additions and 57 deletions

View File

@@ -24,6 +24,12 @@
#define FREERDP_CHANNEL_CLIPRDR_CLIENT_FORMAT_H
#include <winpr/wtypes.h>
#include <winpr/stream.h>
#include <freerdp/api.h>
#include <freerdp/channels/cliprdr.h>
#include "cliprdr_main.h"
WINPR_ATTR_NODISCARD
FREERDP_LOCAL

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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),

View File

@@ -33,7 +33,7 @@
#define TAG FREERDP_TAG("timer")
#endif
typedef ALIGN64 struct
typedef struct ALIGN64
{
FreeRDP_TimerID id;
uint64_t intervallNS;

View File

@@ -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

View File

@@ -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

View File

@@ -27,7 +27,13 @@
#include <stdbool.h>
#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

View File

@@ -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 */

View File

@@ -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