]> granicus.if.org Git - esp-idf/commitdiff
FreeRTOS: Use C11 _Static_assert to verify static "dummy" structs at compile time
authorAngus Gratton <angus@espressif.com>
Tue, 22 Nov 2016 22:42:35 +0000 (09:42 +1100)
committerAngus Gratton <angus@espressif.com>
Tue, 22 Nov 2016 23:22:19 +0000 (10:22 +1100)
Includes a tweak to make Static_task_t equal size to TCB_t when using
MPU_WRAPPERS . Matches tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE macro
in tasks.c. This isn't actually a bug (if static task allocation is off,
there is no use for Static_task_t), but it allows us to make consistent
compile-time checks that Static_task_t == TCB_t.

components/freertos/include/freertos/FreeRTOS.h
components/freertos/include/freertos/list.h
components/freertos/queue.c
components/freertos/tasks.c

index 67bdc6db12bfd29ed912da741060ebdd4269a77f..4c60308f78033fb55dc0ef85e6c7552fd1763487 100644 (file)
@@ -895,7 +895,8 @@ typedef struct xSTATIC_TCB
                uint32_t                ulDummy18;
                uint32_t                ucDummy19;
        #endif
-       #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
+       #if( ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) \
+                || ( portUSING_MPU_WRAPPERS == 1 ) )
                uint8_t                 uxDummy20;
        #endif
 
index b63df7f7244e7022b0dc78a34ec28a5819ee67c4..8606deba5aef12c122d2a99b8e3d04f9c048f964 100644 (file)
@@ -190,6 +190,10 @@ struct xLIST_ITEM
 };
 typedef struct xLIST_ITEM ListItem_t;                                  /* For some reason lint wants this as two separate definitions. */
 
+#if __GNUC_PREREQ(4, 6)
+_Static_assert(sizeof(StaticListItem_t) == sizeof(ListItem_t), "StaticListItem_t != ListItem_t");
+#endif
+
 struct xMINI_LIST_ITEM
 {
        listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE                               /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
@@ -199,6 +203,11 @@ struct xMINI_LIST_ITEM
 };
 typedef struct xMINI_LIST_ITEM MiniListItem_t;
 
+#if __GNUC_PREREQ(4, 6)
+_Static_assert(sizeof(StaticMiniListItem_t) == sizeof(MiniListItem_t), "StaticMiniListItem_t != MiniListItem_t");
+#endif
+
+
 /*
  * Definition of the type of queue used by the scheduler.
  */
@@ -211,6 +220,10 @@ typedef struct xLIST
        listSECOND_LIST_INTEGRITY_CHECK_VALUE                           /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
 } List_t;
 
+#if __GNUC_PREREQ(4, 6)
+_Static_assert(sizeof(StaticList_t) == sizeof(List_t), "StaticList_t != List_t");
+#endif
+
 /*
  * Access macro to set the owner of a list item.  The owner of a list item
  * is the object (usually a TCB) that contains the list item.
index f404a243e6c56b7334cf6b5b7fc0319e695e2b38..7c491f6952ff69356f518570479a4e9e8855656a 100644 (file)
@@ -179,6 +179,11 @@ typedef struct QueueDefinition
 name below to enable the use of older kernel aware debuggers. */
 typedef xQUEUE Queue_t;
 
+#if __GNUC_PREREQ(4, 6)
+_Static_assert(sizeof(StaticQueue_t) == sizeof(Queue_t), "StaticQueue_t != Queue_t");
+#endif
+
+
 /*-----------------------------------------------------------*/
 
 /*
index 26103ee2364b8341c2317f64c0f0d438fba5d7fd..16cce3b967cfe496b9eb6e853d55a445a5ab28be 100644 (file)
@@ -242,6 +242,10 @@ typedef struct tskTaskControlBlock
 below to enable the use of older kernel aware debuggers. */
 typedef tskTCB TCB_t;
 
+#if __GNUC_PREREQ(4, 6)
+_Static_assert(sizeof(StaticTask_t) == sizeof(TCB_t), "StaticTask_t != TCB_t");
+#endif
+
 /*
  * Some kernel aware debuggers require the data the debugger needs access to to
  * be global, rather than file scope.