From b27722a30e86eeec62fd85daac488362547a02c7 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Wed, 30 Jul 2025 16:06:30 +0200 Subject: [PATCH 1/2] [MSVC-MingW] Move windows headers to port.c This prevents the inclusion of windows.h. into all header files using FreeRTOS.h and thus defining several macros conflicting with common definitions. --- portable/MSVC-MingW/port.c | 8 ++++++++ portable/MSVC-MingW/portmacro.h | 11 ----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index 9ce0c1b158..74dd777ef0 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -33,6 +33,14 @@ #include "FreeRTOS.h" #include "task.h" +#ifdef WIN32_LEAN_AND_MEAN + #include +#else + #include +#endif + +#include + #ifdef __GNUC__ #include "mmsystem.h" #else diff --git a/portable/MSVC-MingW/portmacro.h b/portable/MSVC-MingW/portmacro.h index eb94758be6..1a4cd16228 100644 --- a/portable/MSVC-MingW/portmacro.h +++ b/portable/MSVC-MingW/portmacro.h @@ -29,17 +29,6 @@ #ifndef PORTMACRO_H #define PORTMACRO_H -#ifdef WIN32_LEAN_AND_MEAN - #include -#else - #include -#endif - -#include -#include -#include -#include - #ifdef __cplusplus extern "C" { #endif From 7381ffd414552d4f429728221ef9e542d77e6d86 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 4 Aug 2025 09:17:51 +0200 Subject: [PATCH 2/2] [MSVC-MingW] Include correct header for compiler intrinsics --- portable/MSVC-MingW/portmacro.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/portable/MSVC-MingW/portmacro.h b/portable/MSVC-MingW/portmacro.h index 1a4cd16228..37bfb25869 100644 --- a/portable/MSVC-MingW/portmacro.h +++ b/portable/MSVC-MingW/portmacro.h @@ -145,22 +145,25 @@ void vPortExitCritical( void ); : "cc" ) #else /* __GNUC__ */ + #include /* BitScanReverse returns the bit position of the most significant '1' * in the word. */ #if defined( __x86_64__ ) || defined( _M_X64 ) + #pragma intrinsic(_BitScanReverse64) #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \ do \ { \ - DWORD ulTopPriority; \ + unsigned long ulTopPriority; \ _BitScanReverse64( &ulTopPriority, ( uxReadyPriorities ) ); \ uxTopPriority = ulTopPriority; \ } while( 0 ) #else /* #if defined( __x86_64__ ) || defined( _M_X64 ) */ + #pragma intrinsic(_BitScanReverse) - #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) ) + #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( unsigned long * ) &( uxTopPriority ), ( uxReadyPriorities ) ) #endif /* #if defined( __x86_64__ ) || defined( _M_X64 ) */