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:
parent
5879ccbcd3
commit
6f3d0871aa
@ -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_ */
|
||||
/** @} */
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user