From ba203ef1916dc426afb4a069b00fe7cbed3cd8d9 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Tue, 18 Nov 2008 13:03:34 +0000 Subject: - add __hot and __cold annotations Will spare us quite some likely()/unlikely() occurances. See http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html for details --- include/libc-symbols.h | 8 ++++++++ libc/sysdeps/linux/common/ssp.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index dacc03cf9..64dcf2c07 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -63,6 +63,14 @@ #ifndef unlikely # define unlikely(x) __builtin_expect((!!(x)),0) #endif +#if defined __GNUC__ && !(__GNUC__ == 4 && __GNUC_MINOR__ < 3) +# ifndef __cold +# define __cold __attribute__ ((__cold__)) +# endif +# ifndef __hot +# define __hot __attribute__ ((__hot__)) +# endif +#endif #ifndef __LINUX_COMPILER_H # define __LINUX_COMPILER_H #endif diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index 1563700d5..08ef00d6a 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -64,7 +64,7 @@ static void block_signals(void) sigaction(SSP_SIGTYPE, &sa, NULL); } -static void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3) +static void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3) __cold { write(fd, msg1, strlen(msg1)); write(fd, msg2, strlen(msg2)); @@ -83,7 +83,7 @@ static attribute_noreturn void terminate(void) _exit(127); } -void __stack_smash_handler(char func[], int damaged __attribute__ ((unused))) attribute_noreturn; +void __stack_smash_handler(char func[], int damaged __attribute__ ((unused))) attribute_noreturn __cold; void __stack_smash_handler(char func[], int damaged) { static const char message[] = ": stack smashing attack in function "; @@ -97,7 +97,7 @@ void __stack_smash_handler(char func[], int damaged) terminate(); } -void __stack_chk_fail(void) attribute_noreturn; +void __stack_chk_fail(void) attribute_noreturn __cold; void __stack_chk_fail(void) { static const char msg1[] = "stack smashing detected: "; -- cgit v1.2.3