Commit 2b8312e5 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 2d4d5f25
...@@ -109,7 +109,7 @@ os_thread_exit( ...@@ -109,7 +109,7 @@ os_thread_exit(
/*===========*/ /*===========*/
void* exit_value) /*!< in: exit value; in Windows this void* void* exit_value) /*!< in: exit value; in Windows this void*
is cast as a DWORD */ is cast as a DWORD */
__attribute__((cold, noreturn)); UNIV_COLD __attribute__((noreturn));
/*****************************************************************//** /*****************************************************************//**
Returns the thread identifier of current thread. Returns the thread identifier of current thread.
@return current thread identifier */ @return current thread identifier */
......
...@@ -255,6 +255,19 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ ...@@ -255,6 +255,19 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */
#else #else
# define UNIV_INTERN # define UNIV_INTERN
#endif #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 #ifndef UNIV_MUST_NOT_INLINE
/* Definition for inline version */ /* Definition for inline version */
......
...@@ -53,7 +53,7 @@ ut_dbg_assertion_failed( ...@@ -53,7 +53,7 @@ ut_dbg_assertion_failed(
const char* expr, /*!< in: the failed assertion */ const char* expr, /*!< in: the failed assertion */
const char* file, /*!< in: source file containing the assertion */ const char* file, /*!< in: source file containing the assertion */
ulint line) /*!< in: line number of 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) #if defined(__WIN__) || defined(__INTEL_COMPILER)
# undef UT_DBG_USE_ABORT # undef UT_DBG_USE_ABORT
......
...@@ -276,7 +276,7 @@ void ...@@ -276,7 +276,7 @@ void
ut_print_timestamp( ut_print_timestamp(
/*===============*/ /*===============*/
FILE* file) /*!< in: file where to print */ 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. */ Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */
UNIV_INTERN UNIV_INTERN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment