Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
__func__ is C99 for __FUNCTION__. Kill portability layer
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 9 Mar 2016 00:01:45 +0000 (01:01 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 9 Mar 2016 00:02:14 +0000 (01:02 +0100)
include/xbt/base.h
include/xbt/ex.h
include/xbt/log.h
src/msg/msg_private.h

index 5a95c38..a1b6319 100644 (file)
 # endif
 # undef _XBT_NEED_INIT_PRAGMA
 
 # 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
 #if defined(__GNUC__)
 #   define XBT_ALWAYS_INLINE inline __attribute__ ((always_inline))
 #else
index 8ca0a18..156c820 100644 (file)
@@ -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.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));
 
   _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 \
 #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 \
 #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)")
 
 
 #define DIE_IMPOSSIBLE xbt_die("The Impossible Did Happen (yet again)")
 
index 56d9871..ea7d3ae 100644 (file)
@@ -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.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__);                        \
     }                                                                   \
       _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.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__);                        \
     }                                                                   \
       _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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.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__);                        \
         }                                                                   \
           _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) \
 #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, ...) \
 #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
 
 /** @ingroup XBT_log
  *  @hideinitializer
index b2f710d..8327148 100644 (file)
@@ -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->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)
   _xbt_ex_t->bt_strings = NULL;                              \
   xbt_backtrace_current(_xbt_ex_t); \
   ptr = _xbt_ex_t; } while(0)