From af7d9929fab25a2f7029001b194fbe0d2a01207d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 6 Apr 2011 09:22:36 +0300 Subject: [PATCH] Enable __attribute__((cold)) only for GCC 4.3 and later. This attribute was introduced in bzr revision-id marko.makela@oracle.com-20110405073758-b8y733yvkqum940i and caused older GCC versions to emit warnings. --- storage/innobase/include/os0thread.h | 2 +- storage/innobase/include/univ.i | 13 +++++++++++++ storage/innobase/include/ut0dbg.h | 2 +- storage/innobase/include/ut0ut.h | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index 0c4acafa7d7..df3cdb7728e 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -109,7 +109,7 @@ os_thread_exit( /*===========*/ void* exit_value) /*!< in: exit value; in Windows this void* is cast as a DWORD */ - __attribute__((cold, noreturn)); + UNIV_COLD __attribute__((noreturn)); /*****************************************************************//** Returns the thread identifier of current thread. @return current thread identifier */ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index f561226a2de..2c7d32bd1a3 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -255,6 +255,19 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ #else # define UNIV_INTERN #endif +#if defined __GNUC__ && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3) +/** Starting with GCC 4.3, the "cold" attribute is used to inform the +compiler that a function is unlikely executed. The function is +optimized for size rather than speed and on many targets it is placed +into special subsection of the text section so all cold functions +appears close together improving code locality of non-cold parts of +program. The paths leading to call of cold functions within code are +marked as unlikely by the branch prediction mechanism. optimize a +rarely invoked function for size instead for speed. */ +# define UNIV_COLD __attribute__((cold)) +#else +# define UNIV_COLD /* empty */ +#endif #ifndef UNIV_MUST_NOT_INLINE /* Definition for inline version */ diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index 2cb208a4e9e..07730176d81 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -53,7 +53,7 @@ ut_dbg_assertion_failed( const char* expr, /*!< in: the failed assertion */ const char* file, /*!< in: source file containing the assertion */ ulint line) /*!< in: line number of the assertion */ - __attribute__((nonnull(2), cold)); + UNIV_COLD __attribute__((nonnull(2))); #if defined(__WIN__) || defined(__INTEL_COMPILER) # undef UT_DBG_USE_ABORT diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index fe28a573631..cad39e9a34f 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -276,7 +276,7 @@ void ut_print_timestamp( /*===============*/ FILE* file) /*!< in: file where to print */ - __attribute__((nonnull, cold)); + UNIV_COLD __attribute__((nonnull)); /**********************************************************//** Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */ UNIV_INTERN