diff --git a/client/mysqltest.cc b/client/mysqltest.cc index b4bd2b65276..05113f02a44 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -574,15 +574,17 @@ struct st_replace *glob_replace= 0; void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, const char *from, int len); -static void cleanup_and_exit(int exit_code) __attribute__((noreturn)); +ATTRIBUTE_NORETURN +static void cleanup_and_exit(int exit_code); -void really_die(const char *msg) __attribute__((noreturn)); +ATTRIBUTE_NORETURN +void really_die(const char *msg); void report_or_die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -void die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) - __attribute__((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void die(const char *fmt, ...); static void make_error_message(char *buf, size_t len, const char *fmt, va_list args); -void abort_not_supported_test(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2) - __attribute__((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void abort_not_supported_test(const char *fmt, ...); void verbose_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); void log_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); diff --git a/include/my_compiler.h b/include/my_compiler.h index 000d4e42848..97e6f9ae106 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -148,6 +148,29 @@ struct my_aligned_storage #define MY_ALIGNED(size) #endif +#ifdef __GNUC__ +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +# if MY_GNUC_PREREQ(4,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 ATTRIBUTE_COLD __attribute__((cold)) +# endif +#elif defined _WIN32 +# define ATTRIBUTE_NORETURN __declspec(noreturn) +#else +# define ATTRIBUTE_NORETURN /* empty */ +#endif + +#ifndef ATTRIBUTE_COLD +# define ATTRIBUTE_COLD /* empty */ +#endif + #include #endif /* MY_COMPILER_INCLUDED */ diff --git a/sql/init.h b/sql/init.h index 88cd8e6e178..af2621e5e70 100644 --- a/sql/init.h +++ b/sql/init.h @@ -19,6 +19,6 @@ #include "my_global.h" /* ulong */ void unireg_init(ulong options); -void unireg_end(void) __attribute__((noreturn)); +ATTRIBUTE_NORETURN void unireg_end(void); #endif /* INIT_INCLUDED */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 01d65413f08..329d1492342 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1570,7 +1570,7 @@ static void close_server_sock(); static void clean_up_mutexes(void); static void wait_for_signal_thread_to_end(void); static void create_pid_file(); -static void mysqld_exit(int exit_code) __attribute__((noreturn)); +ATTRIBUTE_NORETURN static void mysqld_exit(int exit_code); #endif static void delete_pid_file(myf flags); static void end_ssl(); diff --git a/sql/mysqld.h b/sql/mysqld.h index bff2f010b93..912fe3696ae 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -708,7 +708,7 @@ enum enum_query_type /* query_id */ extern query_id_t global_query_id; -void unireg_end(void) __attribute__((noreturn)); +ATTRIBUTE_NORETURN void unireg_end(void); /* increment query_id and return it. */ inline __attribute__((warn_unused_result)) query_id_t next_query_id() diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index d34c8f91514..eaa678bba3b 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1005,7 +1005,7 @@ skip_flush: @param[in] size desired size in number of pages @param[out] success whether the operation succeeded @return whether the operation should be retried */ -static UNIV_COLD __attribute__((warn_unused_result, nonnull)) +static ATTRIBUTE_COLD __attribute__((warn_unused_result, nonnull)) bool fil_space_extend_must_retry( fil_space_t* space, diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 9f499d7ca1e..80303314d9f 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -102,7 +102,7 @@ then we will not allocate more extents @param[in,out] space tablespace @param[in,out] header tablespace header @param[in,out] mtr mini-transaction */ -static UNIV_COLD +static ATTRIBUTE_COLD void fsp_fill_free_list( bool init_space, @@ -899,7 +899,7 @@ data file. @param[in,out] header tablespace header @param[in,out] mtr mini-transaction @return true if success */ -static UNIV_COLD MY_ATTRIBUTE((warn_unused_result)) +static ATTRIBUTE_COLD __attribute__((warn_unused_result)) bool fsp_try_extend_data_file_with_pages( fil_space_t* space, @@ -932,7 +932,7 @@ fsp_try_extend_data_file_with_pages( @param[in,out] mtr mini-transaction @return number of pages added @retval 0 if the tablespace was not extended */ -UNIV_COLD MY_ATTRIBUTE((nonnull)) +ATTRIBUTE_COLD __attribute__((nonnull)) static ulint fsp_try_extend_data_file(fil_space_t* space, fsp_header_t* header, mtr_t* mtr) diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 3bcf4f710f6..1140cef8452 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -271,7 +271,7 @@ innobase_get_int_col_max_value( const Field* field); /*!< in: MySQL field */ /* Report an InnoDB error to the client by invoking my_error(). */ -static UNIV_COLD MY_ATTRIBUTE((nonnull)) +static ATTRIBUTE_COLD __attribute__((nonnull)) void my_error_innodb( /*============*/ diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index a5409c3ad4c..1d7710a1496 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -172,7 +172,7 @@ btr_corruption_report( /*==================*/ const buf_block_t* block, /*!< in: corrupted block */ const dict_index_t* index) /*!< in: index tree */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Assert that a B-tree page is not corrupted. @param block buffer block containing a B-tree page diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 8836e858018..04baf032ded 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1867,7 +1867,7 @@ dict_set_corrupted( dict_index_t* index, /*!< in/out: index */ trx_t* trx, /*!< in/out: transaction */ const char* ctx) /*!< in: context */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Flags an index corrupted in the data dictionary cache only. This is used mostly to mark a corrupted index when index's own dictionary diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index d4430f5ebce..c240f5dacdd 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -128,10 +128,8 @@ os_thread_join( /** Exits the current thread. @param[in] detach if true, the thread will be detached right before exiting. If false, another thread is responsible for joining this thread */ -void -os_thread_exit( - bool detach = true) - UNIV_COLD MY_ATTRIBUTE((noreturn)); +ATTRIBUTE_NORETURN ATTRIBUTE_COLD +void os_thread_exit(bool detach = true); /*****************************************************************//** Returns the thread identifier of current thread. diff --git a/storage/innobase/include/row0log.h b/storage/innobase/include/row0log.h index 980facee427..5657e09cc22 100644 --- a/storage/innobase/include/row0log.h +++ b/storage/innobase/include/row0log.h @@ -101,7 +101,7 @@ row_log_online_op( const dtuple_t* tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, or 0 for delete */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /******************************************************//** Gets the error status of the online index rebuild log. @@ -137,7 +137,7 @@ row_log_table_delete( const ulint* offsets,/*!< in: rec_get_offsets(rec,index) */ const byte* sys) /*!< in: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec */ - UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,3))); + ATTRIBUTE_COLD __attribute__((nonnull(1,2,3))); /******************************************************//** Logs an update operation to a table that is being rebuilt. @@ -174,7 +174,7 @@ row_log_table_get_pk( byte* sys, /*!< out: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL */ mem_heap_t** heap) /*!< in/out: memory heap where allocated */ - UNIV_COLD MY_ATTRIBUTE((nonnull(1,2,5), warn_unused_result)); + ATTRIBUTE_COLD __attribute__((nonnull(1,2,5), warn_unused_result)); /******************************************************//** Logs an insert to a table that is being rebuilt. @@ -195,7 +195,7 @@ row_log_table_blob_free( /*====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /******************************************************//** Notes that a BLOB is being allocated during online ALTER TABLE. */ void @@ -203,7 +203,7 @@ row_log_table_blob_alloc( /*=====================*/ dict_index_t* index, /*!< in/out: clustered index, X-latched */ ulint page_no)/*!< in: starting page number of the BLOB */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /** Apply the row_log_table log to a table upon completing rebuild. @param[in] thr query graph diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index cdf97b6a9cf..b1d442a9acf 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -319,7 +319,7 @@ void trx_undo_free_prepared( /*===================*/ trx_t* trx) /*!< in/out: PREPARED transaction */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); /* Forward declaration. */ namespace undo { diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 21ca95bacb7..e797fd7bef7 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -258,23 +258,6 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */ #endif #endif -#if defined(COMPILER_HINTS) \ - && 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 MY_ATTRIBUTE((cold)) -#else -# define UNIV_COLD /* empty */ -#endif - #define UNIV_INLINE static inline #define UNIV_WORD_SIZE SIZEOF_SIZE_T diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index 706579a3b9f..fd9a064ba35 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -39,13 +39,13 @@ Created 1/30/1994 Heikki Tuuri /*************************************************************//** Report a failed assertion. */ +ATTRIBUTE_NORETURN ATTRIBUTE_COLD __attribute__((nonnull(2))) void ut_dbg_assertion_failed( /*====================*/ const char* expr, /*!< in: the failed assertion */ const char* file, /*!< in: source file containing the assertion */ - unsigned line) /*!< in: line number of the assertion */ - UNIV_COLD MY_ATTRIBUTE((nonnull(2), noreturn)); + unsigned line); /*!< in: line number of the assertion */ /** Abort execution if EXPR does not evaluate to nonzero. @param EXPR assertion expression that should hold */ diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 7082d18da53..b8282b7d0de 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -299,7 +299,7 @@ void ut_print_timestamp( /*===============*/ FILE* file) /*!< in: file where to print */ - UNIV_COLD MY_ATTRIBUTE((nonnull)); + ATTRIBUTE_COLD __attribute__((nonnull)); #ifndef UNIV_INNOCHECKSUM @@ -505,6 +505,7 @@ use this class directly, instead use one of the derived classes. */ class logger { public: template + ATTRIBUTE_COLD logger& operator<<(const T& rhs) { m_oss << rhs; @@ -515,6 +516,7 @@ public: @param[in] buf the buffer whose contents will be logged. @param[in] count the length of the buffer buf. @return the output stream into which buffer was written. */ + ATTRIBUTE_COLD std::ostream& write( const char* buf, @@ -527,6 +529,7 @@ public: @param[in] buf the buffer whose contents will be logged. @param[in] count the length of the buffer buf. @return the output stream into which buffer was written. */ + ATTRIBUTE_COLD std::ostream& write( const byte* buf, @@ -539,6 +542,7 @@ public: protected: /* This class must not be used directly, hence making the default constructor protected. */ + ATTRIBUTE_COLD logger() {} }; @@ -555,6 +559,7 @@ statement. If a named object is created, then the log message will be emitted only when it goes out of scope or destroyed. */ class info : public logger { public: + ATTRIBUTE_COLD ~info(); }; @@ -562,6 +567,7 @@ public: class info for further details. */ class warn : public logger { public: + ATTRIBUTE_COLD ~warn(); }; @@ -569,6 +575,7 @@ public: documentation of class info for further details. */ class error : public logger { public: + ATTRIBUTE_COLD ~error(); }; @@ -577,6 +584,7 @@ by crashing it. Use this class when MySQL server needs to be stopped immediately. Refer to the documentation of class info for usage details. */ class fatal : public logger { public: + ATTRIBUTE_NORETURN ~fatal(); }; @@ -584,10 +592,12 @@ public: warning message */ class error_or_warn : public logger { public: + ATTRIBUTE_COLD error_or_warn(bool pred) : m_error(pred) {} + ATTRIBUTE_COLD ~error_or_warn(); private: const bool m_error; @@ -597,10 +607,12 @@ private: error message. */ class fatal_or_error : public logger { public: + ATTRIBUTE_COLD fatal_or_error(bool pred) : m_fatal(pred) {} + ATTRIBUTE_COLD ~fatal_or_error(); private: const bool m_fatal; diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index fde743a9074..3986c4f4c44 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -174,9 +174,9 @@ os_thread_join( /** Exits the current thread. @param[in] detach if true, the thread will be detached right before exiting. If false, another thread is responsible for joining this thread */ +ATTRIBUTE_NORETURN void -os_thread_exit( - bool detach) +os_thread_exit(bool detach) { #ifdef UNIV_DEBUG_THREAD_CREATION ib::info() << "Thread exits, id " diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index ffe93ac8612..7c965f791be 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -158,7 +158,7 @@ TODO: Remove this function. Everything should use MYSQL_TYPE_NEWDECIMAL. @param[in] b_length length of b, in bytes (not UNIV_SQL_NULL) @return positive, 0, negative, if a is greater, equal, less than b, respectively */ -static UNIV_COLD +static ATTRIBUTE_COLD int cmp_decimal( const byte* a, diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc index fff1f0e6687..28643645de9 100644 --- a/storage/innobase/ut/ut0dbg.cc +++ b/storage/innobase/ut/ut0dbg.cc @@ -30,6 +30,7 @@ Created 1/30/1994 Heikki Tuuri /*************************************************************//** Report a failed assertion. */ +ATTRIBUTE_NORETURN void ut_dbg_assertion_failed( /*====================*/ diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 4eb9d45b0dc..7393a24b72c 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -834,6 +834,7 @@ error::~error() sql_print_error("InnoDB: %s", m_oss.str().c_str()); } +ATTRIBUTE_NORETURN fatal::~fatal() { sql_print_error("[FATAL] InnoDB: %s", m_oss.str().c_str()); diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 2b6f8164135..fc3d3492252 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -89,7 +89,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param, MARIA_PAGE *page, uint sortkey, File new_file, my_bool update_index); static my_bool write_log_record(HA_CHECK *param); -static void my_exit(int exit_code) __attribute__ ((noreturn)); +ATTRIBUTE_NORETURN static void my_exit(int exit_code); HA_CHECK check_param;