assert: Mark __assert_fail as cold

This helps compilers split the codegen for setting up the arguments
(`__expression`, `__filename`, etc...) from the potentially hot cold
where the `assert` is to a presumably cold region on the assertion
failure path.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
Noah Goldstein 2024-07-26 16:35:13 +08:00
parent 89cddc8a70
commit f6f9047459

View File

@ -66,18 +66,18 @@ __BEGIN_DECLS
/* This prints an "Assertion failed" message and aborts. */ /* This prints an "Assertion failed" message and aborts. */
extern void __assert_fail (const char *__assertion, const char *__file, extern void __assert_fail (const char *__assertion, const char *__file,
unsigned int __line, const char *__function) unsigned int __line, const char *__function)
__THROW __attribute__ ((__noreturn__)); __THROW __attribute__ ((__noreturn__)) __COLD;
/* Likewise, but prints the error text for ERRNUM. */ /* Likewise, but prints the error text for ERRNUM. */
extern void __assert_perror_fail (int __errnum, const char *__file, extern void __assert_perror_fail (int __errnum, const char *__file,
unsigned int __line, const char *__function) unsigned int __line, const char *__function)
__THROW __attribute__ ((__noreturn__)); __THROW __attribute__ ((__noreturn__)) __COLD;
/* The following is not at all used here but needed for standard /* The following is not at all used here but needed for standard
compliance. */ compliance. */
extern void __assert (const char *__assertion, const char *__file, int __line) extern void __assert (const char *__assertion, const char *__file, int __line)
__THROW __attribute__ ((__noreturn__)); __THROW __attribute__ ((__noreturn__)) __COLD;
__END_DECLS __END_DECLS