Skip to content

Commit bbc0589

Browse files
Fix cmake example errors (#1037)
Add typecasts to prevent compiler warnings. Remove ULL suffix to adhere to C90.
1 parent e143832 commit bbc0589

File tree

6 files changed

+51
-50
lines changed

6 files changed

+51
-50
lines changed

examples/cmake_example/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
cmake_minimum_required(VERSION 3.15)
2-
32
project(example)
43

54
set(FREERTOS_KERNEL_PATH "../../")
@@ -71,3 +70,5 @@ add_executable(${PROJECT_NAME}
7170
)
7271

7372
target_link_libraries(${PROJECT_NAME} freertos_kernel freertos_config)
73+
74+
set_property(TARGET freertos_kernel PROPERTY C_STANDARD 90)

include/event_groups.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@
4040
* item value. It is important they don't clash with the
4141
* taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
4242
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
43-
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint16_t ) 0x0100U )
44-
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint16_t ) 0x0200U )
45-
#define eventWAIT_FOR_ALL_BITS ( ( uint16_t ) 0x0400U )
46-
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint16_t ) 0xff00U )
43+
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint16_t ) 0x0100 )
44+
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint16_t ) 0x0200 )
45+
#define eventWAIT_FOR_ALL_BITS ( ( uint16_t ) 0x0400 )
46+
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint16_t ) 0xff00 )
4747
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
48-
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint32_t ) 0x01000000UL )
49-
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint32_t ) 0x02000000UL )
50-
#define eventWAIT_FOR_ALL_BITS ( ( uint32_t ) 0x04000000UL )
51-
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint32_t ) 0xff000000UL )
48+
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint32_t ) 0x01000000 )
49+
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint32_t ) 0x02000000 )
50+
#define eventWAIT_FOR_ALL_BITS ( ( uint32_t ) 0x04000000 )
51+
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint32_t ) 0xff000000 )
5252
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
53-
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint64_t ) 0x0100000000000000ULL )
54-
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint64_t ) 0x0200000000000000ULL )
55-
#define eventWAIT_FOR_ALL_BITS ( ( uint64_t ) 0x0400000000000000ULL )
56-
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint64_t ) 0xff00000000000000ULL )
53+
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint64_t ) 0x0100000000000000 )
54+
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint64_t ) 0x0200000000000000 )
55+
#define eventWAIT_FOR_ALL_BITS ( ( uint64_t ) 0x0400000000000000 )
56+
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint64_t ) 0xff00000000000000 )
5757
#endif /* if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) */
5858

5959
/* *INDENT-OFF* */

include/list.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -322,19 +322,19 @@ typedef struct xLIST
322322
#define listREMOVE_ITEM( pxItemToRemove ) \
323323
do { \
324324
/* The list item knows which list it is in. Obtain the list from the list \
325-
* item. */ \
326-
List_t * const pxList = ( pxItemToRemove )->pxContainer; \
327-
\
328-
( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \
329-
( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \
330-
/* Make sure the index is left pointing to a valid item. */ \
331-
if( pxList->pxIndex == ( pxItemToRemove ) ) \
332-
{ \
333-
pxList->pxIndex = ( pxItemToRemove )->pxPrevious; \
334-
} \
335-
\
336-
( pxItemToRemove )->pxContainer = NULL; \
337-
( ( pxList )->uxNumberOfItems ) -= ( UBaseType_t ) 1U; \
325+
* item. */ \
326+
List_t * const pxList = ( pxItemToRemove )->pxContainer; \
327+
\
328+
( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \
329+
( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \
330+
/* Make sure the index is left pointing to a valid item. */ \
331+
if( pxList->pxIndex == ( pxItemToRemove ) ) \
332+
{ \
333+
pxList->pxIndex = ( pxItemToRemove )->pxPrevious; \
334+
} \
335+
\
336+
( pxItemToRemove )->pxContainer = NULL; \
337+
( ( pxList )->uxNumberOfItems ) = ( UBaseType_t ) ( ( ( pxList )->uxNumberOfItems ) - 1U ); \
338338
} while( 0 )
339339

340340
/*
@@ -371,17 +371,17 @@ typedef struct xLIST
371371
\
372372
/* Insert a new list item into ( pxList ), but rather than sort the list, \
373373
* makes the new list item the last item to be removed by a call to \
374-
* listGET_OWNER_OF_NEXT_ENTRY(). */ \
375-
( pxNewListItem )->pxNext = pxIndex; \
376-
( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
377-
\
378-
pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
379-
pxIndex->pxPrevious = ( pxNewListItem ); \
380-
\
381-
/* Remember which list the item is in. */ \
382-
( pxNewListItem )->pxContainer = ( pxList ); \
383-
\
384-
( ( pxList )->uxNumberOfItems ) += ( UBaseType_t ) 1U; \
374+
* listGET_OWNER_OF_NEXT_ENTRY(). */ \
375+
( pxNewListItem )->pxNext = pxIndex; \
376+
( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
377+
\
378+
pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
379+
pxIndex->pxPrevious = ( pxNewListItem ); \
380+
\
381+
/* Remember which list the item is in. */ \
382+
( pxNewListItem )->pxContainer = ( pxList ); \
383+
\
384+
( ( pxList )->uxNumberOfItems ) = ( UBaseType_t ) ( ( ( pxList )->uxNumberOfItems ) + 1U ); \
385385
} while( 0 )
386386

387387
/*

list.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void vListInsertEnd( List_t * const pxList,
130130
/* Remember which list the item is in. */
131131
pxNewListItem->pxContainer = pxList;
132132

133-
( pxList->uxNumberOfItems ) += ( UBaseType_t ) 1U;
133+
( pxList->uxNumberOfItems ) = ( UBaseType_t ) ( pxList->uxNumberOfItems + 1U );
134134

135135
traceRETURN_vListInsertEnd();
136136
}
@@ -205,7 +205,7 @@ void vListInsert( List_t * const pxList,
205205
* item later. */
206206
pxNewListItem->pxContainer = pxList;
207207

208-
( pxList->uxNumberOfItems ) += ( UBaseType_t ) 1U;
208+
( pxList->uxNumberOfItems ) = ( UBaseType_t ) ( pxList->uxNumberOfItems + 1U );
209209

210210
traceRETURN_vListInsert();
211211
}
@@ -237,7 +237,7 @@ UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
237237
}
238238

239239
pxItemToRemove->pxContainer = NULL;
240-
( pxList->uxNumberOfItems ) -= ( UBaseType_t ) 1U;
240+
( pxList->uxNumberOfItems ) = ( UBaseType_t ) ( pxList->uxNumberOfItems - 1U );
241241

242242
traceRETURN_uxListRemove( pxList->uxNumberOfItems );
243243

portable/template/portmacro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef unsigned char UBaseType_t;
4040
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
4141
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
4242
typedef uint64_t TickType_t;
43-
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffULL
43+
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffff
4444
#else
4545
#error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
4646
#endif

tasks.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
pxTemp = pxDelayedTaskList; \
256256
pxDelayedTaskList = pxOverflowDelayedTaskList; \
257257
pxOverflowDelayedTaskList = pxTemp; \
258-
xNumOfOverflows += ( BaseType_t ) 1; \
258+
xNumOfOverflows = ( BaseType_t ) ( xNumOfOverflows + 1 ); \
259259
prvResetNextTaskUnblockTime(); \
260260
} while( 0 )
261261

@@ -291,11 +291,11 @@
291291
* responsibility of whichever module is using the value to ensure it gets set back
292292
* to its original value when it is released. */
293293
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
294-
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint16_t ) 0x8000U )
294+
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint16_t ) 0x8000 )
295295
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
296-
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000UL )
296+
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000 )
297297
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
298-
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint64_t ) 0x8000000000000000ULL )
298+
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint64_t ) 0x8000000000000000 )
299299
#endif
300300

301301
/* Indicates that the task is not actively running on any core. */
@@ -903,7 +903,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
903903
/* System idle tasks are being assigned a priority of tskIDLE_PRIORITY - 1 here. */
904904
if( ( pxCurrentTCBs[ xCoreID ]->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) != 0U )
905905
{
906-
xCurrentCoreTaskPriority = xCurrentCoreTaskPriority - 1;
906+
xCurrentCoreTaskPriority = ( BaseType_t ) ( xCurrentCoreTaskPriority - 1 );
907907
}
908908

909909
if( ( taskTASK_IS_RUNNING( pxCurrentTCBs[ xCoreID ] ) != pdFALSE ) && ( xYieldPendings[ xCoreID ] == pdFALSE ) )
@@ -2022,7 +2022,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
20222022
* updated. */
20232023
taskENTER_CRITICAL();
20242024
{
2025-
uxCurrentNumberOfTasks += ( UBaseType_t ) 1U;
2025+
uxCurrentNumberOfTasks = ( UBaseType_t ) ( uxCurrentNumberOfTasks + 1U );
20262026

20272027
if( pxCurrentTCB == NULL )
20282028
{
@@ -3594,7 +3594,7 @@ static BaseType_t prvCreateIdleTasks( void )
35943594
}
35953595
else
35963596
{
3597-
vApplicationGetPassiveIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &uxIdleTaskStackSize, xCoreID - 1 );
3597+
vApplicationGetPassiveIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &uxIdleTaskStackSize, ( BaseType_t ) ( xCoreID - 1 ) );
35983598
}
35993599
}
36003600
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
@@ -3816,7 +3816,7 @@ void vTaskSuspendAll( void )
38163816

38173817
/* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
38183818
* is used to allow calls to vTaskSuspendAll() to nest. */
3819-
uxSchedulerSuspended += ( UBaseType_t ) 1U;
3819+
uxSchedulerSuspended = ( UBaseType_t ) ( uxSchedulerSuspended + 1U );
38203820

38213821
/* Enforces ordering for ports and optimised compilers that may otherwise place
38223822
* the above increment elsewhere. */
@@ -3969,7 +3969,7 @@ BaseType_t xTaskResumeAll( void )
39693969
* previous call to vTaskSuspendAll(). */
39703970
configASSERT( uxSchedulerSuspended != 0U );
39713971

3972-
uxSchedulerSuspended -= ( UBaseType_t ) 1U;
3972+
uxSchedulerSuspended = ( UBaseType_t ) ( uxSchedulerSuspended - 1U );
39733973
portRELEASE_TASK_LOCK();
39743974

39753975
if( uxSchedulerSuspended == ( UBaseType_t ) 0U )

0 commit comments

Comments
 (0)