LibC: Turn CRASH() into a function and add noreturn attribute

This way CRASH() can be used in functions that are themselves
marked as noreturn.
This commit is contained in:
Gunnar Beutner 2021-04-11 18:22:48 +02:00 committed by Andreas Kling
parent d5e1250061
commit 44486e8818
Notes: sideshowbarker 2024-07-18 20:28:03 +09:00
2 changed files with 9 additions and 4 deletions

View file

@ -53,3 +53,9 @@ void __assertion_failed(const char* msg)
} }
#endif #endif
} }
void __crash()
{
asm volatile("ud2");
__builtin_unreachable();
}

View file

@ -45,10 +45,9 @@ __attribute__((noreturn)) void __assertion_failed(const char* msg);
# define VERIFY_NOT_REACHED() CRASH() # define VERIFY_NOT_REACHED() CRASH()
#endif #endif
#define CRASH() \ __attribute__((noreturn)) void __crash();
do { \
asm volatile("ud2"); \ #define CRASH() __crash()
} while (0)
#define VERIFY assert #define VERIFY assert
#define TODO VERIFY_NOT_REACHED #define TODO VERIFY_NOT_REACHED