Skip to content

Commit

Permalink
Fix cmake example errors (FreeRTOS#1037)
Browse files Browse the repository at this point in the history
Add typecasts to prevent compiler warnings. Remove ULL suffix to adhere
to C90.
  • Loading branch information
kar-rahul-aws authored Apr 18, 2024
1 parent e143832 commit bbc0589
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 50 deletions.
3 changes: 2 additions & 1 deletion examples/cmake_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.15)

project(example)

set(FREERTOS_KERNEL_PATH "../../")
Expand Down Expand Up @@ -71,3 +70,5 @@ add_executable(${PROJECT_NAME}
)

target_link_libraries(${PROJECT_NAME} freertos_kernel freertos_config)

set_property(TARGET freertos_kernel PROPERTY C_STANDARD 90)
24 changes: 12 additions & 12 deletions include/event_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
* item value. It is important they don't clash with the
* taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint16_t ) 0x0100U )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint16_t ) 0x0200U )
#define eventWAIT_FOR_ALL_BITS ( ( uint16_t ) 0x0400U )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint16_t ) 0xff00U )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint16_t ) 0x0100 )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint16_t ) 0x0200 )
#define eventWAIT_FOR_ALL_BITS ( ( uint16_t ) 0x0400 )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint16_t ) 0xff00 )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint32_t ) 0x01000000UL )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint32_t ) 0x02000000UL )
#define eventWAIT_FOR_ALL_BITS ( ( uint32_t ) 0x04000000UL )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint32_t ) 0xff000000UL )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint32_t ) 0x01000000 )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint32_t ) 0x02000000 )
#define eventWAIT_FOR_ALL_BITS ( ( uint32_t ) 0x04000000 )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint32_t ) 0xff000000 )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint64_t ) 0x0100000000000000ULL )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint64_t ) 0x0200000000000000ULL )
#define eventWAIT_FOR_ALL_BITS ( ( uint64_t ) 0x0400000000000000ULL )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint64_t ) 0xff00000000000000ULL )
#define eventCLEAR_EVENTS_ON_EXIT_BIT ( ( uint64_t ) 0x0100000000000000 )
#define eventUNBLOCKED_DUE_TO_BIT_SET ( ( uint64_t ) 0x0200000000000000 )
#define eventWAIT_FOR_ALL_BITS ( ( uint64_t ) 0x0400000000000000 )
#define eventEVENT_BITS_CONTROL_BYTES ( ( uint64_t ) 0xff00000000000000 )
#endif /* if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) */

/* *INDENT-OFF* */
Expand Down
48 changes: 24 additions & 24 deletions include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,19 @@ typedef struct xLIST
#define listREMOVE_ITEM( pxItemToRemove ) \
do { \
/* The list item knows which list it is in. Obtain the list from the list \
* item. */ \
List_t * const pxList = ( pxItemToRemove )->pxContainer; \
\
( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \
( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \
/* Make sure the index is left pointing to a valid item. */ \
if( pxList->pxIndex == ( pxItemToRemove ) ) \
{ \
pxList->pxIndex = ( pxItemToRemove )->pxPrevious; \
} \
\
( pxItemToRemove )->pxContainer = NULL; \
( ( pxList )->uxNumberOfItems ) -= ( UBaseType_t ) 1U; \
* item. */ \
List_t * const pxList = ( pxItemToRemove )->pxContainer; \
\
( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \
( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \
/* Make sure the index is left pointing to a valid item. */ \
if( pxList->pxIndex == ( pxItemToRemove ) ) \
{ \
pxList->pxIndex = ( pxItemToRemove )->pxPrevious; \
} \
\
( pxItemToRemove )->pxContainer = NULL; \
( ( pxList )->uxNumberOfItems ) = ( UBaseType_t ) ( ( ( pxList )->uxNumberOfItems ) - 1U ); \
} while( 0 )

/*
Expand Down Expand Up @@ -371,17 +371,17 @@ typedef struct xLIST
\
/* Insert a new list item into ( pxList ), but rather than sort the list, \
* makes the new list item the last item to be removed by a call to \
* listGET_OWNER_OF_NEXT_ENTRY(). */ \
( pxNewListItem )->pxNext = pxIndex; \
( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
\
pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
pxIndex->pxPrevious = ( pxNewListItem ); \
\
/* Remember which list the item is in. */ \
( pxNewListItem )->pxContainer = ( pxList ); \
\
( ( pxList )->uxNumberOfItems ) += ( UBaseType_t ) 1U; \
* listGET_OWNER_OF_NEXT_ENTRY(). */ \
( pxNewListItem )->pxNext = pxIndex; \
( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \
\
pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \
pxIndex->pxPrevious = ( pxNewListItem ); \
\
/* Remember which list the item is in. */ \
( pxNewListItem )->pxContainer = ( pxList ); \
\
( ( pxList )->uxNumberOfItems ) = ( UBaseType_t ) ( ( ( pxList )->uxNumberOfItems ) + 1U ); \
} while( 0 )

/*
Expand Down
6 changes: 3 additions & 3 deletions list.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void vListInsertEnd( List_t * const pxList,
/* Remember which list the item is in. */
pxNewListItem->pxContainer = pxList;

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

traceRETURN_vListInsertEnd();
}
Expand Down Expand Up @@ -205,7 +205,7 @@ void vListInsert( List_t * const pxList,
* item later. */
pxNewListItem->pxContainer = pxList;

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

traceRETURN_vListInsert();
}
Expand Down Expand Up @@ -237,7 +237,7 @@ UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
}

pxItemToRemove->pxContainer = NULL;
( pxList->uxNumberOfItems ) -= ( UBaseType_t ) 1U;
( pxList->uxNumberOfItems ) = ( UBaseType_t ) ( pxList->uxNumberOfItems - 1U );

traceRETURN_uxListRemove( pxList->uxNumberOfItems );

Expand Down
2 changes: 1 addition & 1 deletion portable/template/portmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ typedef unsigned char UBaseType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
typedef uint64_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffULL
#define portMAX_DELAY ( TickType_t ) 0xffffffffffffffff
#else
#error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
#endif
Expand Down
18 changes: 9 additions & 9 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
pxTemp = pxDelayedTaskList; \
pxDelayedTaskList = pxOverflowDelayedTaskList; \
pxOverflowDelayedTaskList = pxTemp; \
xNumOfOverflows += ( BaseType_t ) 1; \
xNumOfOverflows = ( BaseType_t ) ( xNumOfOverflows + 1 ); \
prvResetNextTaskUnblockTime(); \
} while( 0 )

Expand Down Expand Up @@ -291,11 +291,11 @@
* responsibility of whichever module is using the value to ensure it gets set back
* to its original value when it is released. */
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint16_t ) 0x8000U )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint16_t ) 0x8000 )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000UL )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000 )
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint64_t ) 0x8000000000000000ULL )
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint64_t ) 0x8000000000000000 )
#endif

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

if( ( taskTASK_IS_RUNNING( pxCurrentTCBs[ xCoreID ] ) != pdFALSE ) && ( xYieldPendings[ xCoreID ] == pdFALSE ) )
Expand Down Expand Up @@ -2022,7 +2022,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
* updated. */
taskENTER_CRITICAL();
{
uxCurrentNumberOfTasks += ( UBaseType_t ) 1U;
uxCurrentNumberOfTasks = ( UBaseType_t ) ( uxCurrentNumberOfTasks + 1U );

if( pxCurrentTCB == NULL )
{
Expand Down Expand Up @@ -3594,7 +3594,7 @@ static BaseType_t prvCreateIdleTasks( void )
}
else
{
vApplicationGetPassiveIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &uxIdleTaskStackSize, xCoreID - 1 );
vApplicationGetPassiveIdleTaskMemory( &pxIdleTaskTCBBuffer, &pxIdleTaskStackBuffer, &uxIdleTaskStackSize, ( BaseType_t ) ( xCoreID - 1 ) );
}
}
#endif /* if ( configNUMBER_OF_CORES == 1 ) */
Expand Down Expand Up @@ -3816,7 +3816,7 @@ void vTaskSuspendAll( void )

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

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

uxSchedulerSuspended -= ( UBaseType_t ) 1U;
uxSchedulerSuspended = ( UBaseType_t ) ( uxSchedulerSuspended - 1U );
portRELEASE_TASK_LOCK();

if( uxSchedulerSuspended == ( UBaseType_t ) 0U )
Expand Down

0 comments on commit bbc0589

Please sign in to comment.