[rtems commit] score: Add RTEMS_HAVE_MEMBER_SAME_TYPE()
Sebastian Huber
sebh at rtems.org
Mon Jul 31 07:49:12 UTC 2017
Module: rtems
Branch: master
Commit: af97ba8f295e61f84d147cdc59b3d1d0e6209b4c
Changeset: http://git.rtems.org/rtems/commit/?id=af97ba8f295e61f84d147cdc59b3d1d0e6209b4c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Jul 28 11:57:31 2017 +0200
score: Add RTEMS_HAVE_MEMBER_SAME_TYPE()
This fixes some "variably modified" warnings and a clang compile error.
---
cpukit/score/include/rtems/score/basedefs.h | 19 +++++++++++++++++++
cpukit/score/include/rtems/score/threadqimpl.h | 8 ++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index 288afd4..4994579 100644
--- a/cpukit/score/include/rtems/score/basedefs.h
+++ b/cpukit/score/include/rtems/score/basedefs.h
@@ -373,6 +373,25 @@ extern void RTEMS_DEQUALIFY_types_not_compatible(void);
#endif /*RTEMS_DEQUALIFY*/
/**
+ * @brief Evaluates to true if the members of two types have the same type.
+ *
+ * @param[in] _t_lhs Left hand side type.
+ * @param[in] _m_lhs Left hand side member.
+ * @param[in] _t_rhs Right hand side type.
+ * @param[in] _m_rhs Right hand side member.
+ */
+#ifdef __GNUC__
+ #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
+ __builtin_types_compatible_p( \
+ __typeof( ( (_t_lhs *) 0 )->_m_lhs ), \
+ __typeof( ( (_t_rhs *) 0 )->_m_rhs ) \
+ )
+#else
+ #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \
+ true
+#endif
+
+/**
* @brief Concatenates _x and _y without expanding.
*/
#define RTEMS_CONCAT( _x, _y ) _x##_y
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h
index 574221c..c4a22a5 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -1141,8 +1141,12 @@ typedef struct {
RTEMS_STATIC_ASSERT( \
offsetof( object_type, wait_queue_member ) \
== offsetof( Thread_queue_Object, Wait_queue ) \
- && ( &( ( (object_type *) 0 )->wait_queue_member ) \
- == ( &( (Thread_queue_Object *) 0 )->Wait_queue ) ), \
+ && RTEMS_HAVE_MEMBER_SAME_TYPE( \
+ object_type, \
+ wait_queue_member, \
+ Thread_queue_Object, \
+ Wait_queue \
+ ), \
object_type \
)
More information about the vc
mailing list