From fb2cbe1f039528440c5bf51b230e20596801d97f Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Mon, 6 Nov 2023 14:30:35 +0100 Subject: [PATCH] cmake,udp: improve QOS_FLOWID and PQOS_FLOWID detection (#1002) --- cmake/re-config.cmake | 15 +++++++++++++++ src/udp/udp.c | 14 ++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/cmake/re-config.cmake b/cmake/re-config.cmake index 34ebe80a5..04023d923 100644 --- a/cmake/re-config.cmake +++ b/cmake/re-config.cmake @@ -1,6 +1,7 @@ include(CheckIncludeFile) include(CheckFunctionExists) include(CheckSymbolExists) +include(CheckTypeSize) option(USE_MBEDTLS "Enable MbedTLS" OFF) @@ -135,6 +136,20 @@ if(WIN32) WIN32 _WIN32_WINNT=0x0600 ) + + unset(CMAKE_EXTRA_INCLUDE_FILES) + set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h;qos2.h") + check_type_size("QOS_FLOWID" HAVE_QOS_FLOWID BUILTIN_TYPES_ONLY) + check_type_size("PQOS_FLOWID" HAVE_PQOS_FLOWID BUILTIN_TYPES_ONLY) + unset(CMAKE_EXTRA_INCLUDE_FILES) + + if(HAVE_QOS_FLOWID) + list(APPEND RE_DEFINITIONS HAVE_QOS_FLOWID) + endif() + + if(HAVE_PQOS_FLOWID) + list(APPEND RE_DEFINITIONS HAVE_PQOS_FLOWID) + endif() endif() if(USE_OPENSSL) diff --git a/src/udp/udp.c b/src/udp/udp.c index 496e7581d..18b58d8f3 100644 --- a/src/udp/udp.c +++ b/src/udp/udp.c @@ -28,13 +28,19 @@ #include #include #ifdef WIN32 -#if !defined(_MSC_VER) -typedef UINT32 QOS_FLOWID, *PQOS_FLOWID; +#ifndef HAVE_QOS_FLOWID +typedef UINT32 QOS_FLOWID; +#endif + +#ifndef HAVE_PQOS_FLOWID +typedef UINT32 *PQOS_FLOWID; +#endif + +#include + #ifndef QOS_NON_ADAPTIVE_FLOW #define QOS_NON_ADAPTIVE_FLOW 0x00000002 #endif -#endif /*!_MSC_VER*/ -#include #endif /*WIN32*/ #define DEBUG_MODULE "udp"