Skip to content

Commit e9440d4

Browse files
creiter64aggarg
andauthored
Move windows headers to port.c (#1302)
* [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. * [MSVC-MingW] Include correct header for compiler intrinsics --------- Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
1 parent c5bec0e commit e9440d4

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

portable/MSVC-MingW/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
#include "FreeRTOS.h"
3434
#include "task.h"
3535

36+
#ifdef WIN32_LEAN_AND_MEAN
37+
#include <winsock2.h>
38+
#else
39+
#include <winsock.h>
40+
#endif
41+
42+
#include <timeapi.h>
43+
3644
#ifdef __GNUC__
3745
#include "mmsystem.h"
3846
#else

portable/MSVC-MingW/portmacro.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@
2929
#ifndef PORTMACRO_H
3030
#define PORTMACRO_H
3131

32-
#ifdef WIN32_LEAN_AND_MEAN
33-
#include <winsock2.h>
34-
#else
35-
#include <winsock.h>
36-
#endif
37-
38-
#include <windows.h>
39-
#include <timeapi.h>
40-
#include <mmsystem.h>
41-
#include <winbase.h>
42-
4332
#ifdef __cplusplus
4433
extern "C" {
4534
#endif
@@ -156,22 +145,25 @@ void vPortExitCritical( void );
156145
: "cc" )
157146

158147
#else /* __GNUC__ */
148+
#include <intrin.h>
159149

160150
/* BitScanReverse returns the bit position of the most significant '1'
161151
* in the word. */
162152
#if defined( __x86_64__ ) || defined( _M_X64 )
153+
#pragma intrinsic(_BitScanReverse64)
163154

164155
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
165156
do \
166157
{ \
167-
DWORD ulTopPriority; \
158+
unsigned long ulTopPriority; \
168159
_BitScanReverse64( &ulTopPriority, ( uxReadyPriorities ) ); \
169160
uxTopPriority = ulTopPriority; \
170161
} while( 0 )
171162

172163
#else /* #if defined( __x86_64__ ) || defined( _M_X64 ) */
164+
#pragma intrinsic(_BitScanReverse)
173165

174-
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
166+
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( unsigned long * ) &( uxTopPriority ), ( uxReadyPriorities ) )
175167

176168
#endif /* #if defined( __x86_64__ ) || defined( _M_X64 ) */
177169

0 commit comments

Comments
 (0)