From 96f27c279bcb5dd32cf0e8af04bd273240d298ef Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 9 Mar 2016 01:01:45 +0100 Subject: [PATCH] __func__ is C99 for __FUNCTION__. Kill portability layer --- include/xbt/base.h | 10 ---------- include/xbt/ex.h | 6 +++--- include/xbt/log.h | 32 ++++++++++++++++---------------- src/msg/msg_private.h | 2 +- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/include/xbt/base.h b/include/xbt/base.h index 5a95c38840..a1b6319488 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -53,16 +53,6 @@ # endif # undef _XBT_NEED_INIT_PRAGMA -/* inline and __FUNCTION__ are only in GCC when -ansi is off */ - -#if defined(__GNUC__) && ! defined(__STRICT_ANSI__) -# define _XBT_FUNCTION __FUNCTION__ -#elif (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) -# define _XBT_FUNCTION __func__ /* ISO-C99 compliant */ -#else -# define _XBT_FUNCTION "function" -#endif - #if defined(__GNUC__) # define XBT_ALWAYS_INLINE inline __attribute__ ((always_inline)) #else diff --git a/include/xbt/ex.h b/include/xbt/ex.h index 8ca0a18447..156c820300 100644 --- a/include/xbt/ex.h +++ b/include/xbt/ex.h @@ -435,7 +435,7 @@ XBT_PUBLIC( void )__xbt_ex_terminate_default(xbt_ex_t * e); _throw_ctx->exception.pid = xbt_getpid(); \ _throw_ctx->exception.file = (char*)__FILE__; \ _throw_ctx->exception.line = __LINE__; \ - _throw_ctx->exception.func = (char*)_XBT_FUNCTION; \ + _throw_ctx->exception.func = (char*)__func__; \ _throw_ctx->exception.bt_strings = NULL; \ xbt_backtrace_current((xbt_ex_t *)&(_throw_ctx->exception)); @@ -457,9 +457,9 @@ XBT_PUBLIC( void )__xbt_ex_terminate_default(xbt_ex_t * e); #define THROW_IMPOSSIBLE \ THROWF(unknown_error, 0, "The Impossible Did Happen (yet again)") #define THROW_UNIMPLEMENTED \ - THROWF(unknown_error, 0, "Function %s unimplemented",_XBT_FUNCTION) + THROWF(unknown_error, 0, "Function %s unimplemented",__func__) #define THROW_DEADCODE \ - THROWF(unknown_error, 0, "Function %s was supposed to be DEADCODE, but it's not",_XBT_FUNCTION) + THROWF(unknown_error, 0, "Function %s was supposed to be DEADCODE, but it's not",__func__) #define DIE_IMPOSSIBLE xbt_die("The Impossible Did Happen (yet again)") diff --git a/include/xbt/log.h b/include/xbt/log.h index 56d98712dd..ea7d3ae615 100644 --- a/include/xbt/log.h +++ b/include/xbt/log.h @@ -397,7 +397,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(category); \ _log_ev.priority = (prio); \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -410,7 +410,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = (prio); \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -430,7 +430,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(_XBT_LOGV(categ)); \ _log_ev.priority = xbt_log_priority_debug; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -447,7 +447,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(_XBT_LOGV(categ)); \ _log_ev.priority = xbt_log_priority_verbose; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -464,7 +464,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(_XBT_LOGV(categ)); \ _log_ev.priority = xbt_log_priority_info; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -482,7 +482,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(_XBT_LOGV(categ)); \ _log_ev.priority = xbt_log_priority_warning; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -500,7 +500,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(_XBT_LOGV(categ)); \ _log_ev.priority = xbt_log_priority_error; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -517,7 +517,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = &(_XBT_LOGV(categ)); \ _log_ev.priority = xbt_log_priority_critical; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -536,7 +536,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = xbt_log_priority_debug; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -554,7 +554,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = xbt_log_priority_verbose; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -572,7 +572,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = xbt_log_priority_info; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -590,7 +590,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = xbt_log_priority_warning; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -608,7 +608,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = xbt_log_priority_error; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -626,7 +626,7 @@ extern xbt_log_layout_t xbt_log_default_layout; _log_ev.cat = _simgrid_log_category__default; \ _log_ev.priority = xbt_log_priority_critical; \ _log_ev.fileName = __FILE__; \ - _log_ev.functionName = _XBT_FUNCTION; \ + _log_ev.functionName = __func__; \ _log_ev.lineNum = __LINE__; \ _xbt_log_event_log(&_log_ev, __VA_ARGS__); \ } \ @@ -635,9 +635,9 @@ extern xbt_log_layout_t xbt_log_default_layout; #define _XBT_IN_OUT(...) \ _XBT_IF_ONE_ARG(_XBT_IN_OUT_ARG1, _XBT_IN_OUT_ARGN, __VA_ARGS__)(__VA_ARGS__) #define _XBT_IN_OUT_ARG1(fmt) \ - XBT_LOG(xbt_log_priority_trace, fmt, _XBT_FUNCTION) + XBT_LOG(xbt_log_priority_trace, fmt, __func__) #define _XBT_IN_OUT_ARGN(fmt, ...) \ - XBT_LOG(xbt_log_priority_trace, fmt, _XBT_FUNCTION, __VA_ARGS__) + XBT_LOG(xbt_log_priority_trace, fmt, __func__, __VA_ARGS__) /** @ingroup XBT_log * @hideinitializer diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index b2f710d34c..8327148aa3 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -32,7 +32,7 @@ SG_BEGIN_DECL() _xbt_ex_t->pid = xbt_getpid(); \ _xbt_ex_t->file = (char*)__FILE__; \ _xbt_ex_t->line = __LINE__; \ - _xbt_ex_t->func = (char*)_XBT_FUNCTION; \ + _xbt_ex_t->func = (char*)__func__; \ _xbt_ex_t->bt_strings = NULL; \ xbt_backtrace_current(_xbt_ex_t); \ ptr = _xbt_ex_t; } while(0) -- 2.20.1