From 8b03fed0cfdd07b367d4deb66980980d44f115ce Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Sun, 18 Sep 2011 14:22:07 -0400 Subject: [PATCH] Remove unused header gdebug.h This was only included from gmessages.c. Nuke the unused parts and merge the rest into gmessages.c. --- glib/Makefile.am | 1 - glib/gdebug.h | 59 -------------------------------- glib/gmessages.c | 89 +++++++++++++++++++++++++----------------------- 3 files changed, 47 insertions(+), 102 deletions(-) delete mode 100644 glib/gdebug.h diff --git a/glib/Makefile.am b/glib/Makefile.am index 880bb658d..81341327c 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -207,7 +207,6 @@ libglib_2_0_la_SOURCES = \ gvarianttype.c \ gwakeup.h \ gwakeup.c \ - gdebug.h \ gprintf.c \ gprintfint.h diff --git a/glib/gdebug.h b/glib/gdebug.h deleted file mode 100644 index dea3dde7d..000000000 --- a/glib/gdebug.h +++ /dev/null @@ -1,59 +0,0 @@ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_DEBUG_H__ -#define __G_DEBUG_H__ - -G_BEGIN_DECLS - -typedef enum { - G_DEBUG_FATAL_WARNINGS = 1 << 0, - G_DEBUG_FATAL_CRITICALS = 1 << 1 -} GDebugFlag; - - -#ifdef G_ENABLE_DEBUG - -#define G_NOTE(type, action) G_STMT_START { \ - if (!_g_debug_initialized) \ - { _g_debug_init (); } \ - if (_g_debug_flags & G_DEBUG_##type) \ - { action; }; } G_STMT_END - -#else /* !G_ENABLE_DEBUG */ - -#define G_NOTE(type, action) - -#endif /* G_ENABLE_DEBUG */ - -GLIB_VAR gboolean _g_debug_initialized; -GLIB_VAR guint _g_debug_flags; - -G_GNUC_INTERNAL void _g_debug_init (void); - -G_END_DECLS - -#endif /* __G_DEBUG_H__ */ diff --git a/glib/gmessages.c b/glib/gmessages.c index 986087567..9df841f0b 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -63,7 +63,6 @@ #include "gbacktrace.h" #include "gconvert.h" -#include "gdebug.h" #include "gmem.h" #include "gprintfint.h" #include "gtestutils.h" @@ -114,6 +113,8 @@ static GLogFunc default_log_func = g_log_default_handler; static gpointer default_log_data = NULL; static GTestLogFatalFunc fatal_log_func = NULL; static gpointer fatal_log_data; +static gboolean g_debug_initialized = FALSE; + /* --- functions --- */ #ifdef G_OS_WIN32 @@ -186,6 +187,48 @@ g_messages_prefixed_init (void) } } +void +g_debug_init (void) +{ + typedef enum { + G_DEBUG_FATAL_WARNINGS = 1 << 0, + G_DEBUG_FATAL_CRITICALS = 1 << 1 + } GDebugFlag; + const gchar *val; + guint flags = 0; + + g_debug_initialized = TRUE; + + val = g_getenv ("G_DEBUG"); + if (val != NULL) + { + const GDebugKey keys[] = { + {"fatal_warnings", G_DEBUG_FATAL_WARNINGS}, + {"fatal_criticals", G_DEBUG_FATAL_CRITICALS} + }; + + flags = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys)); + } + + if (flags & G_DEBUG_FATAL_WARNINGS) + { + GLogLevelFlags fatal_mask; + + fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); + fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; + g_log_set_always_fatal (fatal_mask); + } + + if (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); + } +} + static GLogDomain* g_log_find_domain_L (const gchar *log_domain) { @@ -500,11 +543,11 @@ g_logv (const gchar *log_domain, g_private_set (g_log_depth, GUINT_TO_POINTER (depth)); /* had to defer debug initialization until we can keep track of recursion */ - if (!(test_level & G_LOG_FLAG_RECURSION) && !_g_debug_initialized) + if (!(test_level & G_LOG_FLAG_RECURSION) && !g_debug_initialized) { GLogLevelFlags orig_test_level = test_level; - _g_debug_init (); + g_debug_init (); if ((domain_fatal_mask | g_log_always_fatal) & test_level) test_level |= G_LOG_FLAG_FATAL; if (test_level != orig_test_level) @@ -1174,45 +1217,7 @@ _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 (); + g_debug_init (); } -gboolean _g_debug_initialized = FALSE; -guint _g_debug_flags = 0; -void -_g_debug_init (void) -{ - const gchar *val; - - _g_debug_initialized = TRUE; - - val = g_getenv ("G_DEBUG"); - if (val != NULL) - { - 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)); - } - - if (_g_debug_flags & G_DEBUG_FATAL_WARNINGS) - { - GLogLevelFlags fatal_mask; - - fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); - 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); - } -} -- 2.34.1