From 1d39e96470b27195d35a69cc94551c403b7980bd Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 5 Oct 2018 08:11:09 +0200 Subject: score: Fix legacy RTEMS_STATIC_ASSERT() In standard C pointer operands are not allowed in integer constant expressions. Avoid a static assertion based on an array typedef since this could lead to warnings ("variably modified 'x' at file scope" and "typedef 'x' locally defined but not used"); This implementation requires unique messages. --- cpukit/include/rtems/score/basedefs.h | 3 ++- cpukit/include/rtems/score/threadqimpl.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'cpukit/include/rtems/score') diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h index fd803e1b45..0a2bf8dd17 100644 --- a/cpukit/include/rtems/score/basedefs.h +++ b/cpukit/include/rtems/score/basedefs.h @@ -317,7 +317,8 @@ _Static_assert(cond, # msg) #else #define RTEMS_STATIC_ASSERT(cond, msg) \ - typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1] + struct rtems_static_assert_ ## msg \ + { int rtems_static_assert_ ## msg : (cond) ? 1 : -1; } #endif #define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h index ecbd8fd42f..8d537cc9e3 100644 --- a/cpukit/include/rtems/score/threadqimpl.h +++ b/cpukit/include/rtems/score/threadqimpl.h @@ -1207,7 +1207,7 @@ typedef struct { Thread_queue_Control Wait_queue; } Thread_queue_Object; -#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member ) \ +#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member, msg ) \ RTEMS_STATIC_ASSERT( \ offsetof( object_type, wait_queue_member ) \ == offsetof( Thread_queue_Object, Wait_queue ) \ @@ -1217,7 +1217,7 @@ typedef struct { Thread_queue_Object, \ Wait_queue \ ), \ - object_type \ + msg \ ) #define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \ -- cgit v1.2.3