]> git.ipfire.org Git - thirdparty/json-c.git/blobdiff - debug.h
Merge pull request #861 from bhaible/handle-another-oom-condition
[thirdparty/json-c.git] / debug.h
diff --git a/debug.h b/debug.h
index 07fcc380b3c671aa60619a7f0b4b02f1ae66860d..4af0ba9236066b7a5e7324a05c48011ce4947fd6 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -14,8 +14,8 @@
  * @file
  * @brief Do not use, json-c internal, may be changed or removed at any time.
  */
-#ifndef _DEBUG_H_
-#define _DEBUG_H_
+#ifndef _JSON_C_DEBUG_H_
+#define _JSON_C_DEBUG_H_
 
 #include <stdlib.h>
 
 extern "C" {
 #endif
 
-extern void mc_set_debug(int debug);
-extern int mc_get_debug(void);
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) && defined(JSON_C_DLL)
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+JSON_EXPORT void mc_set_debug(int debug);
+JSON_EXPORT int mc_get_debug(void);
 
-extern void mc_set_syslog(int syslog);
+JSON_EXPORT void mc_set_syslog(int syslog);
 
-extern void mc_debug(const char *msg, ...);
-extern void mc_error(const char *msg, ...);
-extern void mc_info(const char *msg, ...);
+JSON_EXPORT void mc_debug(const char *msg, ...);
+JSON_EXPORT void mc_error(const char *msg, ...);
+JSON_EXPORT void mc_info(const char *msg, ...);
 
 #ifndef __STRING
 #define __STRING(x) #x
@@ -38,17 +46,24 @@ extern void mc_info(const char *msg, ...);
 
 #ifndef PARSER_BROKEN_FIXED
 
-#define JASSERT(cond) do {} while(0)
+#define JASSERT(cond) \
+       do            \
+       {             \
+       } while (0)
 
 #else
 
-#define JASSERT(cond) do { \
-               if (!(cond)) { \
-                       mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", __FILE__, __LINE__); \
-                       *(int *)0 = 1;\
-                       abort(); \
-               }\
-       } while(0)
+#define JASSERT(cond)                                                                              \
+       do                                                                                         \
+       {                                                                                          \
+               if (!(cond))                                                                       \
+               {                                                                                  \
+                       mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", \
+                                __FILE__, __LINE__);                                              \
+                       *(int *)0 = 1;                                                             \
+                       abort();                                                                   \
+               }                                                                                  \
+       } while (0)
 
 #endif
 
@@ -61,11 +76,19 @@ extern void mc_info(const char *msg, ...);
 #define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__)
 #define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__)
 #else
-#define MC_SET_DEBUG(x) if (0) mc_set_debug(x)
+#define MC_SET_DEBUG(x) \
+       if (0)          \
+       mc_set_debug(x)
 #define MC_GET_DEBUG() (0)
-#define MC_SET_SYSLOG(x) if (0) mc_set_syslog(x)
-#define MC_DEBUG(x, ...) if (0) mc_debug(x, ##__VA_ARGS__)
-#define MC_INFO(x, ...) if (0) mc_info(x, ##__VA_ARGS__)
+#define MC_SET_SYSLOG(x) \
+       if (0)           \
+       mc_set_syslog(x)
+#define MC_DEBUG(x, ...) \
+       if (0)           \
+       mc_debug(x, ##__VA_ARGS__)
+#define MC_INFO(x, ...) \
+       if (0)          \
+       mc_info(x, ##__VA_ARGS__)
 #endif
 
 #ifdef __cplusplus