1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

core/cpu: put __builtin_unreachable() into one place

This commit is contained in:
René Kijewski 2014-05-06 17:43:22 +02:00
parent 5879ccbcd3
commit 6f3d0871aa
5 changed files with 17 additions and 29 deletions

View File

@ -56,6 +56,18 @@
#define PURE
#endif
/**
* @def UNREACHABLE()
* @brief Tell the compiler that this line of code cannot be reached.
* @details Most useful in junction with #NORETURN.
* Use this if the compiler cannot tell that e.g.
* an assembler instruction causes a longjmp, or a write causes a reboot.
*/
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 5)
#define UNREACHABLE() __builtin_unreachable()
#else
#define UNREACHABLE() do { /* nothing */ } while (1)
#endif
#endif /* ATTRIBUTES_H_ */
/** @} */

View File

@ -63,11 +63,5 @@ NORETURN void core_panic(int crash_code, const char *message)
/* tell the compiler that we won't return from this function
(even if we actually won't even get here...) */
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 5)
__builtin_unreachable();
#else
while (1) {
/* do nothing, but do it often */
}
#endif
UNREACHABLE();
}

View File

@ -64,11 +64,5 @@ NORETURN void core_panic(int crash_code, const char *message)
/* tell the compiler that we won't return from this function
(even if we actually won't even get here...) */
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 5)
__builtin_unreachable();
#else
while (1) {
/* do nothing, but do it often */
}
#endif
UNREACHABLE();
}

View File

@ -63,11 +63,5 @@ NORETURN void core_panic(int crash_code, const char *message)
/* tell the compiler that we won't return from this function
(even if we actually won't even get here...) */
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 5)
__builtin_unreachable();
#else
while (1) {
/* do nothing, but do it often */
}
#endif
UNREACHABLE();
}

View File

@ -60,11 +60,5 @@ NORETURN void core_panic(int crash_code, const char *message)
/* tell the compiler that we won't return from this function
(even if we actually won't even get here...) */
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 5)
__builtin_unreachable();
#else
while (1) {
/* do nothing, but do it often */
}
#endif
UNREACHABLE();
}