Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[simgrid.git] / include / xbt / log.h
index fe7d3ba..1dcdfde 100644 (file)
@@ -90,6 +90,12 @@ typedef enum {
 #define _XBT_LOGV_CTOR(cat) _XBT_LOG_CONCAT2(_XBT_LOGV(cat), __constructor__)
 #define _XBT_LOG_CONCAT(x, y) x ## y
 #define _XBT_LOG_CONCAT2(x, y) _XBT_LOG_CONCAT(x, y)
+/* Apparently, constructor priorities are not supported by gcc on Macs */
+#if __GNUC__ && __APPLE__
+#  define _XBT_LOGV_CTOR_ATTRIBUTE
+#else
+#  define _XBT_LOGV_CTOR_ATTRIBUTE _XBT_GNUC_CONSTRUCTOR(600)
+#endif
 
 /* The root of the category hierarchy. */
 #define XBT_LOG_ROOT_CAT   root
@@ -120,7 +126,7 @@ typedef enum {
  * to avoid an extra declaration of root when XBT_LOG_NEW_SUBCATEGORY is called by
  * XBT_LOG_NEW_CATEGORY */
 #define XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc)           \
-  XBT_PUBLIC(void) _XBT_LOGV_CTOR(catName)(void) _XBT_GNUC_CONSTRUCTOR(600); \
+  XBT_PUBLIC(void) _XBT_LOGV_CTOR(catName)(void) _XBT_LOGV_CTOR_ATTRIBUTE; \
   void _XBT_LOGV_CTOR(catName)(void)                                    \
   {                                                                     \
     XBT_LOG_EXTERNAL_CATEGORY(catName);                                 \
@@ -492,28 +498,30 @@ extern xbt_log_layout_t xbt_log_default_layout;
  */
 #define XBT_CRITICAL(...) XBT_LOG(xbt_log_priority_critical, __VA_ARGS__)
 
+#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)
+#define _XBT_IN_OUT_ARGN(fmt, ...) \
+  XBT_LOG(xbt_log_priority_trace, fmt, _XBT_FUNCTION, __VA_ARGS__)
+
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log at TRACE priority that we entered in current function, appending a user specified format.
  */
-#define XBT_IN(...) \
-  _XBT_IF_ONE_ARG(_XBT_IN_ARG1, _XBT_IN_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _XBT_IN_ARG1(fmt) \
-  XBT_LOG(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION)
-#define _XBT_IN_ARGN(fmt, ...) \
-  XBT_LOG(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_FUNCTION, __VA_ARGS__)
+#define XBT_IN(...) _XBT_IN_OUT(">> begin of %s" __VA_ARGS__)
 
 /** @ingroup XBT_log
  *  @hideinitializer
- *  @brief Log at TRACE priority that we exited the current function.
+ *  @brief Log at TRACE priority that we exited the current function, appending a user specified format.
  */
-#define XBT_OUT() XBT_LOG(xbt_log_priority_trace, "<< end of %s", _XBT_FUNCTION)
+#define XBT_OUT(...) _XBT_IN_OUT("<< end of %s" __VA_ARGS__)
 
 /** @ingroup XBT_log
  *  @hideinitializer
- *  @brief Log at TRACE priority a message indicating that we reached that point.
+ *  @brief Log at TRACE priority a message indicating that we reached that point, appending a user specified format.
  */
-#define XBT_HERE() XBT_LOG(xbt_log_priority_trace, "-- was here")
+#define XBT_HERE(...) XBT_LOG(xbt_log_priority_trace, "-- was here" __VA_ARGS__)
 
 #ifdef XBT_USE_DEPRECATED