Bug 556186 – gpoll.h breaks gmain.h inclusion
[platform/upstream/glib.git] / glib / gmessages.c
index 8f63b3e..7b90a02 100644 (file)
@@ -44,7 +44,7 @@
 #include "glib.h"
 #include "gdebug.h"
 #include "gprintfint.h"
-#include "gthreadinit.h"
+#include "gthreadprivate.h"
 #include "galias.h"
 
 #ifdef G_OS_WIN32
@@ -144,7 +144,7 @@ g_messages_prefixed_init (void)
       
       if (val)
        {
-         static const GDebugKey keys[] = {
+         const GDebugKey keys[] = {
            { "error", G_LOG_LEVEL_ERROR },
            { "critical", G_LOG_LEVEL_CRITICAL },
            { "warning", G_LOG_LEVEL_WARNING },
@@ -485,8 +485,8 @@ g_logv (const gchar   *log_domain,
                          MB_ICONERROR|MB_SETFOREGROUND);
              if (IsDebuggerPresent () && !(test_level & G_LOG_FLAG_RECURSION))
                G_BREAKPOINT ();
-
-             abort ();
+             else
+               abort ();
 #else
 #if defined (G_ENABLE_DEBUG) && defined (SIGTRAP)
              if (!(test_level & G_LOG_FLAG_RECURSION))
@@ -537,6 +537,27 @@ g_return_if_fail_warning (const char *log_domain,
 }
 
 void
+g_warn_message (const char     *domain,
+                const char     *file,
+                int             line,
+                const char     *func,
+                const char     *warnexpr)
+{
+  char *s, lstr[32];
+  g_snprintf (lstr, 32, "%d", line);
+  if (warnexpr)
+    s = g_strconcat ("(", file, ":", lstr, "):",
+                     func, func[0] ? ":" : "",
+                     " runtime check failed: (", warnexpr, ")", NULL);
+  else
+    s = g_strconcat ("(", file, ":", lstr, "):",
+                     func, func[0] ? ":" : "",
+                     " ", "code should not be reached", NULL);
+  g_log (domain, G_LOG_LEVEL_WARNING, "%s", s);
+  g_free (s);
+}
+
+void
 g_assert_warning (const char *log_domain,
                  const char *file,
                  const int   line,
@@ -1041,20 +1062,14 @@ g_printf_string_upper_bound (const gchar *format,
 }
 
 void
-_g_messages_thread_init (void)
+_g_messages_thread_init_nomessage (void)
 {
   g_messages_lock = g_mutex_new ();
+  g_log_depth = g_private_new (NULL);
   g_messages_prefixed_init ();
   _g_debug_init ();
 }
 
-void
-_g_messages_thread_private_init (void)
-{
-  g_assert (g_log_depth == NULL);
-  g_log_depth = g_private_new (NULL);
-}
-
 gboolean _g_debug_initialized = FALSE;
 guint _g_debug_flags = 0;
 
@@ -1068,8 +1083,9 @@ _g_debug_init (void)
   val = g_getenv ("G_DEBUG");
   if (val != NULL)
     {
-      static const GDebugKey keys[] = {
-       {"fatal_warnings", G_DEBUG_FATAL_WARNINGS}
+      const GDebugKey keys[] = {
+       {"fatal_warnings", G_DEBUG_FATAL_WARNINGS},
+       {"fatal_criticals", G_DEBUG_FATAL_CRITICALS}
       };
       
       _g_debug_flags = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
@@ -1083,6 +1099,15 @@ _g_debug_init (void)
       fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
       g_log_set_always_fatal (fatal_mask);
     }
+  
+  if (_g_debug_flags & G_DEBUG_FATAL_CRITICALS) 
+    {
+      GLogLevelFlags fatal_mask;
+      
+      fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
+      fatal_mask |= G_LOG_LEVEL_CRITICAL;
+      g_log_set_always_fatal (fatal_mask);
+    }
 }
 
 #define __G_MESSAGES_C__