diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-22 07:24:14 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-23 07:33:42 +0100 |
commit | e8d9b26f43b87c0a128109e0c0e1ac3d0e3a1278 (patch) | |
tree | 414eb4dbd91f4cf40f7c44c0434e61fa44978db8 | |
parent | cpukit/rtems/include/rtems/rtems/sem.h: Remove junk in comment (diff) | |
download | rtems-e8d9b26f43b87c0a128109e0c0e1ac3d0e3a1278.tar.bz2 |
score: Add and use RTEMS_UNREACHABLE
-rw-r--r-- | cpukit/score/include/rtems/score/assert.h | 9 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/basedefs.h | 19 | ||||
-rw-r--r-- | cpukit/score/src/threadglobalconstruction.c | 3 | ||||
-rw-r--r-- | cpukit/score/src/threadrestart.c | 6 |
4 files changed, 22 insertions, 15 deletions
diff --git a/cpukit/score/include/rtems/score/assert.h b/cpukit/score/include/rtems/score/assert.h index d4253f87da..69736ae70e 100644 --- a/cpukit/score/include/rtems/score/assert.h +++ b/cpukit/score/include/rtems/score/assert.h @@ -120,15 +120,6 @@ extern "C" { bool _Debug_Is_owner_of_allocator( void ); #endif -/** - * @brief Asserts that this point is not reached during run-time. - */ -#if RTEMS_SCHEDSIM -#define _Assert_Not_reached() -#else -#define _Assert_Not_reached() _Assert( 0 ) -#endif - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h index facaed9547..24a56f2f51 100644 --- a/cpukit/score/include/rtems/score/basedefs.h +++ b/cpukit/score/include/rtems/score/basedefs.h @@ -191,6 +191,25 @@ /* Provided for backward compatibility */ #define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED +#if defined(RTEMS_DEBUG) && !defined(RTEMS_SCHEDSIM) + #define _Assert_Unreachable() _Assert( 0 ) +#else + #define _Assert_Unreachable() do { } while ( 0 ) +#endif + +/** + * @brief Tells the compiler that this program point is unreachable. + */ +#if defined(__GNUC__) && !defined(RTEMS_SCHEDSIM) + #define RTEMS_UNREACHABLE() \ + do { \ + __builtin_unreachable(); \ + _Assert_Unreachable(); \ + } while ( 0 ) +#else + #define RTEMS_UNREACHABLE() _Assert_Unreachable() +#endif + #if __cplusplus >= 201103L #define RTEMS_STATIC_ASSERT(cond, msg) \ static_assert(cond, # msg) diff --git a/cpukit/score/src/threadglobalconstruction.c b/cpukit/score/src/threadglobalconstruction.c index 1e84124c55..997f285a67 100644 --- a/cpukit/score/src/threadglobalconstruction.c +++ b/cpukit/score/src/threadglobalconstruction.c @@ -61,6 +61,5 @@ void _Thread_Global_construction( _Thread_Disable_dispatch(); _Thread_Restart( executing, executing, entry ); _Thread_Enable_dispatch(); - - _Assert_Not_reached(); + RTEMS_UNREACHABLE(); } diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index 155acaa8d1..59754a86fb 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -237,8 +237,7 @@ void _Thread_Life_action_handler( } _Thread_Enable_dispatch(); - - _Assert_Not_reached(); + RTEMS_UNREACHABLE(); } else { _Assert( _Thread_Is_life_restarting( previous_life_state ) ); @@ -258,8 +257,7 @@ void _Thread_Life_action_handler( _Thread_Load_environment( executing ); _Thread_Restart_self( executing ); - - _Assert_Not_reached(); + RTEMS_UNREACHABLE(); } } } |