瀏覽代碼

Move DEBUG macro

bel2125 7 年之前
父節點
當前提交
dfabe52290
共有 1 個文件被更改,包括 34 次插入29 次删除
  1. 34 29
      src/civetweb.c

+ 34 - 29
src/civetweb.c

@@ -133,6 +133,40 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
 #include "civetweb.h"
 #endif
 
+#if !defined(DEBUG_TRACE)
+#if defined(DEBUG)
+static void DEBUG_TRACE_FUNC(const char *func,
+                             unsigned line,
+                             PRINTF_FORMAT_STRING(const char *fmt),
+                             ...) PRINTF_ARGS(3, 4);
+
+#define DEBUG_TRACE(fmt, ...)                                                  \
+    DEBUG_TRACE_FUNC(__func__, __LINE__, fmt, __VA_ARGS__)
+
+#else
+#define DEBUG_TRACE(fmt, ...)                                                  \
+    do {                                                                       \
+    } while (0)
+#endif /* DEBUG */
+#endif /* DEBUG_TRACE */
+
+
+#if !defined(DEBUG_ASSERT)
+#if defined(DEBUG)
+#define DEBUG_ASSERT(cond)                                                     \
+    do {                                                                       \
+        if (!(cond)) {                                                         \
+            DEBUG_TRACE("ASSERTION FAILED: %s", #cond);                        \
+            exit(2); /* Exit with error */                                     \
+        }                                                                      \
+    } while (0)
+#else
+#define DEBUG_ASSERT(cond)                                                     \
+    do {                                                                       \
+    } while (0)
+#endif /* DEBUG */
+#endif
+
 
 #ifndef IGNORE_UNUSED_RESULT
 #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
@@ -1473,11 +1507,6 @@ mg_get_current_time_ns(void)
 
 #if !defined(DEBUG_TRACE)
 #if defined(DEBUG)
-static void DEBUG_TRACE_FUNC(const char *func,
-                             unsigned line,
-                             PRINTF_FORMAT_STRING(const char *fmt),
-                             ...) PRINTF_ARGS(3, 4);
-
 static void
 DEBUG_TRACE_FUNC(const char *func, unsigned line, const char *fmt, ...)
 {
@@ -1513,34 +1542,10 @@ DEBUG_TRACE_FUNC(const char *func, unsigned line, const char *fmt, ...)
 	funlockfile(stdout);
 	nslast = nsnow;
 }
-
-#define DEBUG_TRACE(fmt, ...)                                                  \
-	DEBUG_TRACE_FUNC(__func__, __LINE__, fmt, __VA_ARGS__)
-
-#else
-#define DEBUG_TRACE(fmt, ...)                                                  \
-	do {                                                                       \
-	} while (0)
 #endif /* DEBUG */
 #endif /* DEBUG_TRACE */
 
 
-#if !defined(DEBUG_ASSERT)
-#if defined(DEBUG)
-#define DEBUG_ASSERT(cond)                                                     \
-	do {                                                                       \
-		if (!(cond)) {                                                         \
-			DEBUG_TRACE("ASSERTION FAILED: %s", #cond);                        \
-			exit(2); /* Exit with error */                                     \
-		}                                                                      \
-	} while (0)
-#else
-#define DEBUG_ASSERT(cond)                                                     \
-	do {                                                                       \
-	} while (0)
-#endif /* DEBUG */
-#endif
-
 #define MD5_STATIC static
 #include "md5.inl"