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/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 6082776c5..4349e2f6e 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1696,7 +1696,7 @@ static BOOL rdpdr_check_channel_state(rdpdrPlugin* rdpdr, UINT16 packetid) * then reinitialize the channel after login successful */ if (!rdpdr_state_advance(rdpdr, RDPDR_CHANNEL_STATE_INITIAL)) - return ERROR_INVALID_STATE; + return FALSE; return rdpdr_state_check(rdpdr, packetid, RDPDR_CHANNEL_STATE_ANNOUNCE, 1, RDPDR_CHANNEL_STATE_INITIAL); case PAKID_CORE_SERVER_CAPABILITY: diff --git a/channels/rdpgfx/client/rdpgfx_codec.h b/channels/rdpgfx/client/rdpgfx_codec.h index ef519edae..c1a05388c 100644 --- a/channels/rdpgfx/client/rdpgfx_codec.h +++ b/channels/rdpgfx/client/rdpgfx_codec.h @@ -30,7 +30,7 @@ #include "rdpgfx_main.h" -FREERDP_LOCAL +WINPR_ATTR_NODISCARD FREERDP_LOCAL UINT rdpgfx_decode(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd); #endif /* FREERDP_CHANNEL_RDPGFX_CLIENT_CODEC_H */ 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/ci/cmake-preloads/config-android.txt b/ci/cmake-preloads/config-android.txt index 64b732432..36db9fe31 100644 --- a/ci/cmake-preloads/config-android.txt +++ b/ci/cmake-preloads/config-android.txt @@ -6,6 +6,8 @@ set(FREERDP_EXTERNAL_SSL_PATH $ENV{ANDROID_SSL_PATH} CACHE PATH "android ssl") # ANDROID_NDK and ANDROID_SDK must be set as environment variable #set(ANDROID_NDK $ENV{ANDROID_SDK} CACHE PATH "Android NDK") #set(ANDROID_SDK "${ANDROID_NDK}" CACHE PATH "android SDK") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(WITH_FREERDP_DEPRECATED_COMMANDLINE ON CACHE BOOL "Enable deprecated command line options") set(WITH_KRB5 OFF CACHE BOOL "Kerberos support") set(WITH_CLIENT_SDL OFF CACHE BOOL "SDL client") diff --git a/ci/cmake-preloads/config-coverity.txt b/ci/cmake-preloads/config-coverity.txt index f2e025926..c2add011b 100644 --- a/ci/cmake-preloads/config-coverity.txt +++ b/ci/cmake-preloads/config-coverity.txt @@ -1,4 +1,6 @@ set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(WINPR_UTILS_IMAGE_JPEG ON CACHE BOOL "preload") set(WINPR_UTILS_IMAGE_WEBP ON CACHE BOOL "preload") set(WINPR_UTILS_IMAGE_PNG ON CACHE BOOL "preload") diff --git a/ci/cmake-preloads/config-freebsd.txt b/ci/cmake-preloads/config-freebsd.txt index b16e81378..755a4ec1d 100644 --- a/ci/cmake-preloads/config-freebsd.txt +++ b/ci/cmake-preloads/config-freebsd.txt @@ -2,6 +2,8 @@ message("PRELOADING cache") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(BUILD_TESTING_INTERNAL ON CACHE BOOL "preload") set(WITH_MANPAGES ON CACHE BOOL "preload") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "preload") set(WITH_CAIRO ON CACHE BOOL "preload") set(WITH_ALSA ON CACHE BOOL "preload") diff --git a/ci/cmake-preloads/config-ios-shared.txt b/ci/cmake-preloads/config-ios-shared.txt index 41ca459f9..0a983ebc2 100644 --- a/ci/cmake-preloads/config-ios-shared.txt +++ b/ci/cmake-preloads/config-ios-shared.txt @@ -1,4 +1,6 @@ message("PRELOADING iOS cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/ios.toolchain.cmake" CACHE PATH "cmake toolchain file") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "build type") diff --git a/ci/cmake-preloads/config-ios.txt b/ci/cmake-preloads/config-ios.txt index 37dae19b6..0cc967f92 100644 --- a/ci/cmake-preloads/config-ios.txt +++ b/ci/cmake-preloads/config-ios.txt @@ -1,5 +1,7 @@ message("PRELOADING iOS cache") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/ios.toolchain.cmake" CACHE PATH "cmake toolchain file") set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "build type") set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "iOS platform to build") diff --git a/ci/cmake-preloads/config-linux-all.txt b/ci/cmake-preloads/config-linux-all.txt index 6fb498a16..1a3063caa 100644 --- a/ci/cmake-preloads/config-linux-all.txt +++ b/ci/cmake-preloads/config-linux-all.txt @@ -1,4 +1,6 @@ message("PRELOADING cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(BUILD_TESTING_INTERNAL ON CACHE BOOL "preload") set(WITH_MANPAGES ON CACHE BOOL "preload") diff --git a/ci/cmake-preloads/config-linux-alt-arch.txt b/ci/cmake-preloads/config-linux-alt-arch.txt index 4e5c7a7e1..824cfdfae 100644 --- a/ci/cmake-preloads/config-linux-alt-arch.txt +++ b/ci/cmake-preloads/config-linux-alt-arch.txt @@ -1,4 +1,6 @@ message("PRELOADING cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(BUILD_TESTING_INTERNAL ON CACHE BOOL "preload") set(WITH_MANPAGES OFF CACHE BOOL "preload") diff --git a/ci/cmake-preloads/config-macosx.txt b/ci/cmake-preloads/config-macosx.txt index f5b19f5e8..ef433c066 100644 --- a/ci/cmake-preloads/config-macosx.txt +++ b/ci/cmake-preloads/config-macosx.txt @@ -1,4 +1,6 @@ message("PRELOADING mac cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(WITH_MANPAGES OFF CACHE BOOL "man pages") set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "build type") diff --git a/ci/cmake-preloads/config-oss-fuzz.cmake b/ci/cmake-preloads/config-oss-fuzz.cmake index 34cb17067..ac9fb5a2a 100644 --- a/ci/cmake-preloads/config-oss-fuzz.cmake +++ b/ci/cmake-preloads/config-oss-fuzz.cmake @@ -1,4 +1,6 @@ message("PRELOADING cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(WITH_VERBOSE_WINPR_ASSERT ON CACHE BOOL "oss fuzz") diff --git a/ci/cmake-preloads/config-qa-static.cmake b/ci/cmake-preloads/config-qa-static.cmake index 0dcb1e420..735857834 100644 --- a/ci/cmake-preloads/config-qa-static.cmake +++ b/ci/cmake-preloads/config-qa-static.cmake @@ -1,4 +1,6 @@ message("PRELOADING cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(WITH_SERVER ON CACHE BOOL "qa default") set(WITH_SAMPLE ON CACHE BOOL "qa default") diff --git a/ci/cmake-preloads/config-qa.cmake b/ci/cmake-preloads/config-qa.cmake index 358872bad..990cdb6e4 100644 --- a/ci/cmake-preloads/config-qa.cmake +++ b/ci/cmake-preloads/config-qa.cmake @@ -1,4 +1,6 @@ set(BUILD_TESTING_INTERNAL ON CACHE BOOL "qa default") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") +set(CMAKE_C_FLAGS "-Wno-pre-c23-compat" CACHE STRING "preload") set(WITH_STREAMPOOL_DEBUG ON CACHE BOOL "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(ENABLE_WARNING_VERBOSE ON CACHE BOOL "preload") diff --git a/ci/cmake-preloads/config-ubuntu-1204.txt b/ci/cmake-preloads/config-ubuntu-1204.txt deleted file mode 100644 index 7e2050049..000000000 --- a/ci/cmake-preloads/config-ubuntu-1204.txt +++ /dev/null @@ -1,15 +0,0 @@ -message("PRELOADING cache") -set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") -set(WITH_MANPAGES ON CACHE BOOL "man pages") -set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "build type") -set(WITH_CUPS OFF CACHE BOOL "CUPS printing") -set(WITH_KRB5 ON CACHE BOOL "Kerberos support") -set(WITH_ALSA OFF CACHE BOOL "alsa audio") -set(WITH_FFMPEG OFF CACHE BOOL "ffmepg support") -set(WITH_XV OFF CACHE BOOL "xvideo support") -set(BUILD_TESTING_INTERNAL ON CACHE BOOL "build testing") -set(WITH_XSHM OFF CACHE BOOL "build with xshm support") -set(WITH_SERVER ON CACHE BOOL "build with server") -set(WITH_SAMPLE ON CACHE BOOL "build with sample") -set(WITH_SANITIZE_ADDRESS ON) -set(WITH_FREERDP_DEPRECATED_COMMANDLINE ON CACHE BOOL "Enable deprecated command line options") diff --git a/ci/cmake-preloads/config-windows.txt b/ci/cmake-preloads/config-windows.txt index 3ee05f10a..68387d254 100644 --- a/ci/cmake-preloads/config-windows.txt +++ b/ci/cmake-preloads/config-windows.txt @@ -1,4 +1,5 @@ message("PRELOADING windows cache") +set(CMAKE_C_STANDARD 23 CACHE STRING "preload") set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "preload") set(CMAKE_WINDOWS_VERSION "WIN7" CACHE STRING "windows build version") set(BUILD_SHARED_LIBS OFF CACHE BOOL "build static linked executable") 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/include/freerdp/codec/audio.h b/include/freerdp/codec/audio.h index 57de3c55d..52676c461 100644 --- a/include/freerdp/codec/audio.h +++ b/include/freerdp/codec/audio.h @@ -21,6 +21,7 @@ #define FREERDP_CODEC_AUDIO_H #include +#include #include #include diff --git a/libfreerdp/codec/dsp.c b/libfreerdp/codec/dsp.c index 610814251..37b19c31c 100644 --- a/libfreerdp/codec/dsp.c +++ b/libfreerdp/codec/dsp.c @@ -613,23 +613,21 @@ static BOOL freerdp_dsp_decode_opus(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context, const BYTE* WINPR_RESTRICT src, size_t size, wStream* WINPR_RESTRICT out) { - size_t max_size = 5760; - int frames; - if (!context || !src || !out) return FALSE; /* Max packet duration is 120ms (5760 at 48KHz) */ - max_size = OPUS_MAX_FRAMES * context->common.format.nChannels * sizeof(int16_t); + const size_t max_size = OPUS_MAX_FRAMES * context->common.format.nChannels * sizeof(int16_t); if (!Stream_EnsureRemainingCapacity(context->common.buffer, max_size)) return FALSE; - frames = opus_decode(context->opus_decoder, src, WINPR_ASSERTING_INT_CAST(opus_int32, size), - Stream_Pointer(out), OPUS_MAX_FRAMES, 0); + const opus_int32 frames = + opus_decode(context->opus_decoder, src, WINPR_ASSERTING_INT_CAST(opus_int32, size), + Stream_Pointer(out), OPUS_MAX_FRAMES, 0); if (frames < 0) return FALSE; - Stream_Seek(out, frames * context->common.format.nChannels * sizeof(int16_t)); + Stream_Seek(out, (size_t)frames * context->common.format.nChannels * sizeof(int16_t)); return TRUE; } @@ -648,12 +646,13 @@ static BOOL freerdp_dsp_encode_opus(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context, const size_t src_frames = size / sizeof(opus_int16) / context->common.format.nChannels; const opus_int16* src_data = (const opus_int16*)src; - const int frames = opus_encode( + const opus_int32 frames = opus_encode( context->opus_encoder, src_data, WINPR_ASSERTING_INT_CAST(opus_int32, src_frames), Stream_Pointer(out), WINPR_ASSERTING_INT_CAST(opus_int32, max_size)); if (frames < 0) return FALSE; - return Stream_SafeSeek(out, frames * context->common.format.nChannels * sizeof(int16_t)); + return Stream_SafeSeek(out, + (size_t)frames * context->common.format.nChannels * sizeof(int16_t)); } #endif @@ -1450,8 +1449,6 @@ BOOL freerdp_dsp_supports_format(const AUDIO_FORMAT* WINPR_RESTRICT format, BOOL case WAVE_FORMAT_OPUS: return opus_is_valid_samplerate(format); #endif - /* fallthrough */ - WINPR_FALLTHROUGH default: return FALSE; } @@ -1509,9 +1506,9 @@ BOOL freerdp_dsp_context_reset(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context, { int opus_error = OPUS_OK; - context->opus_decoder = - opus_decoder_create(context->common.format.nSamplesPerSec, - context->common.format.nChannels, &opus_error); + context->opus_decoder = opus_decoder_create( + WINPR_ASSERTING_INT_CAST(opus_int32, context->common.format.nSamplesPerSec), + context->common.format.nChannels, &opus_error); if (opus_error != OPUS_OK) return FALSE; } @@ -1519,9 +1516,9 @@ BOOL freerdp_dsp_context_reset(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context, { int opus_error = OPUS_OK; - context->opus_encoder = opus_encoder_create(context->common.format.nSamplesPerSec, - context->common.format.nChannels, - OPUS_APPLICATION_VOIP, &opus_error); + context->opus_encoder = opus_encoder_create( + WINPR_ASSERTING_INT_CAST(opus_int32, context->common.format.nSamplesPerSec), + context->common.format.nChannels, OPUS_APPLICATION_VOIP, &opus_error); if (opus_error != OPUS_OK) return FALSE; 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/locale/keyboard_apple.h b/libfreerdp/locale/keyboard_apple.h index fe8ebb56b..cd3c3e7be 100644 --- a/libfreerdp/locale/keyboard_apple.h +++ b/libfreerdp/locale/keyboard_apple.h @@ -23,7 +23,6 @@ #include -WINPR_ATTR_NODISCARD FREERDP_LOCAL int freerdp_detect_keyboard_layout_from_cf(DWORD* keyboardLayoutId); #endif /* FREERDP_LOCALE_KEYBOARD_APPLE_H */ 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..34aaa2a87 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)) @@ -93,6 +95,14 @@ #define WINPR_ATTR_NODISCARD #endif +/* GCC does not like [[nodiscard]] on function pointers. + * it does not complain when using attribute syntax thoug... + */ +#if defined(__GNUC__) && !defined(__clang__) +#undef WINPR_ATTR_NODISCARD +#define WINPR_ATTR_NODISCARD __attribute__((warn_unused_result)) +#endif + #if defined(__clang__) #define WINPR_PRAGMA_DIAG_PUSH WINPR_DO_PRAGMA(clang diagnostic push) #define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \ @@ -532,7 +542,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 +556,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 +587,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 +602,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 +672,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 diff --git a/winpr/libwinpr/file/test/TestFileGetStdHandle.c b/winpr/libwinpr/file/test/TestFileGetStdHandle.c index 7728f8418..b28cabc16 100644 --- a/winpr/libwinpr/file/test/TestFileGetStdHandle.c +++ b/winpr/libwinpr/file/test/TestFileGetStdHandle.c @@ -37,7 +37,7 @@ int TestFileGetStdHandle(int argc, char* argv[]) (void)fprintf(stderr, "GetStdHandle failed ;(\n"); return -1; } - WriteFile(so, buf, strnlen(buf, sizeof(buf)), &bytesWritten, FALSE); + WriteFile(so, buf, strnlen(buf, sizeof(buf)), &bytesWritten, NULL); if (bytesWritten != strnlen(buf, sizeof(buf))) { (void)fprintf(stderr, "write failed\n");