Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GLib Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GLib at ftp://ftp.gtk.org/pub/gtk/.
28 #ifndef __G_MESSAGES_H__
29 #define __G_MESSAGES_H__
33 #include <glib/gtypes.h>
34 #include <glib/gmacros.h>
36 /* Suppress warnings when GCC is in -pedantic mode and not -std=c99
38 #if (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
39 #pragma GCC system_header
44 /* calculate a string size, guaranteed to fit format + args.
46 IMPORT_C gsize g_printf_string_upper_bound (const gchar* format,
49 /* Log level shift offset for user defined
50 * log levels (0-7 are used by GLib).
52 #define G_LOG_LEVEL_USER_SHIFT (8)
54 /* Glib log levels and flags.
59 G_LOG_FLAG_RECURSION = 1 << 0,
60 G_LOG_FLAG_FATAL = 1 << 1,
63 G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
64 G_LOG_LEVEL_CRITICAL = 1 << 3,
65 G_LOG_LEVEL_WARNING = 1 << 4,
66 G_LOG_LEVEL_MESSAGE = 1 << 5,
67 G_LOG_LEVEL_INFO = 1 << 6,
68 G_LOG_LEVEL_DEBUG = 1 << 7,
70 G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
73 /* GLib log levels that are considered fatal by default */
74 #define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
76 typedef void (*GLogFunc) (const gchar *log_domain,
77 GLogLevelFlags log_level,
83 IMPORT_C guint g_log_set_handler (const gchar *log_domain,
84 GLogLevelFlags log_levels,
87 IMPORT_C void g_log_remove_handler (const gchar *log_domain,
89 IMPORT_C void g_log_default_handler (const gchar *log_domain,
90 GLogLevelFlags log_level,
92 gpointer unused_data);
93 IMPORT_C GLogFunc g_log_set_default_handler (GLogFunc log_func,
95 IMPORT_C void g_log (const gchar *log_domain,
96 GLogLevelFlags log_level,
98 ...) G_GNUC_PRINTF (3, 4);
99 IMPORT_C void g_logv (const gchar *log_domain,
100 GLogLevelFlags log_level,
103 IMPORT_C GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain,
104 GLogLevelFlags fatal_mask);
105 IMPORT_C GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
108 void _g_log_fallback_handler (const gchar *log_domain,
109 GLogLevelFlags log_level,
110 const gchar *message,
111 gpointer unused_data) G_GNUC_INTERNAL;
113 /* Internal functions, used to implement the following macros */
114 IMPORT_C void g_return_if_fail_warning (const char *log_domain,
115 const char *pretty_function,
116 const char *expression);
117 IMPORT_C void g_assert_warning (const char *log_domain,
120 const char *pretty_function,
121 const char *expression) G_GNUC_NORETURN;
125 #define G_LOG_DOMAIN ((gchar*) 0)
126 #endif /* G_LOG_DOMAIN */
127 #ifdef G_HAVE_ISO_VARARGS
128 #define g_error(...) g_log (G_LOG_DOMAIN, \
131 #define g_message(...) g_log (G_LOG_DOMAIN, \
132 G_LOG_LEVEL_MESSAGE, \
134 #define g_critical(...) g_log (G_LOG_DOMAIN, \
135 G_LOG_LEVEL_CRITICAL, \
137 #define g_warning(...) g_log (G_LOG_DOMAIN, \
138 G_LOG_LEVEL_WARNING, \
140 #define g_debug(...) g_log (G_LOG_DOMAIN, \
143 #elif defined(G_HAVE_GNUC_VARARGS)
144 #define g_error(format...) g_log (G_LOG_DOMAIN, \
147 #define g_message(format...) g_log (G_LOG_DOMAIN, \
148 G_LOG_LEVEL_MESSAGE, \
150 #define g_critical(format...) g_log (G_LOG_DOMAIN, \
151 G_LOG_LEVEL_CRITICAL, \
153 #define g_warning(format...) g_log (G_LOG_DOMAIN, \
154 G_LOG_LEVEL_WARNING, \
156 #define g_debug(format...) g_log (G_LOG_DOMAIN, \
159 #else /* no varargs macros */
161 g_error (const gchar *format,
165 va_start (args, format);
166 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
170 g_message (const gchar *format,
174 va_start (args, format);
175 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args);
179 g_critical (const gchar *format,
183 va_start (args, format);
184 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, args);
188 g_warning (const gchar *format,
192 va_start (args, format);
193 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args);
197 g_debug (const gchar *format,
201 va_start (args, format);
202 g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
205 #endif /* !__GNUC__ */
207 typedef void (*GPrintFunc) (const gchar *string);
208 IMPORT_C void g_print (const gchar *format,
209 ...) G_GNUC_PRINTF (1, 2);
210 IMPORT_C GPrintFunc g_set_print_handler (GPrintFunc func);
211 IMPORT_C void g_printerr (const gchar *format,
212 ...) G_GNUC_PRINTF (1, 2);
213 IMPORT_C GPrintFunc g_set_printerr_handler (GPrintFunc func);
216 /* Provide macros for error handling. The "assert" macros will
217 * exit on failure. The "return" macros will exit the current
218 * function. Two different definitions are given for the macros
219 * if G_DISABLE_ASSERT is not defined, in order to support gcc's
220 * __PRETTY_FUNCTION__ capability.
223 #ifdef G_DISABLE_ASSERT
225 #define g_assert(expr) G_STMT_START{ (void)0; }G_STMT_END
226 #define g_assert_not_reached() G_STMT_START{ (void)0; }G_STMT_END
228 #else /* !G_DISABLE_ASSERT */
232 #define g_assert(expr) G_STMT_START{ \
233 if G_LIKELY(expr) { } else \
234 g_assert_warning (G_LOG_DOMAIN, \
237 __PRETTY_FUNCTION__, \
240 #define g_assert_not_reached() G_STMT_START{ \
241 g_assert_warning (G_LOG_DOMAIN, \
244 __PRETTY_FUNCTION__, \
247 #else /* !__GNUC__ */
249 #define g_assert(expr) G_STMT_START{ \
251 g_log (G_LOG_DOMAIN, \
253 "file %s: line %d: assertion failed: (%s)", \
258 #define g_assert_not_reached() G_STMT_START{ \
259 g_log (G_LOG_DOMAIN, \
261 "file %s: line %d: should not be reached", \
263 __LINE__); }G_STMT_END
265 #endif /* __GNUC__ */
267 #endif /* !G_DISABLE_ASSERT */
270 #ifdef G_DISABLE_CHECKS
272 #define g_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END
273 #define g_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END
274 #define g_return_if_reached() G_STMT_START{ return; }G_STMT_END
275 #define g_return_val_if_reached(val) G_STMT_START{ return (val); }G_STMT_END
277 #else /* !G_DISABLE_CHECKS */
281 #define g_return_if_fail(expr) G_STMT_START{ \
282 if G_LIKELY(expr) { } else \
284 g_return_if_fail_warning (G_LOG_DOMAIN, \
285 __PRETTY_FUNCTION__, \
290 #define g_return_val_if_fail(expr,val) G_STMT_START{ \
291 if G_LIKELY(expr) { } else \
293 g_return_if_fail_warning (G_LOG_DOMAIN, \
294 __PRETTY_FUNCTION__, \
299 #define g_return_if_reached() G_STMT_START{ \
300 g_log (G_LOG_DOMAIN, \
301 G_LOG_LEVEL_CRITICAL, \
302 "file %s: line %d (%s): should not be reached", \
305 __PRETTY_FUNCTION__); \
308 #define g_return_val_if_reached(val) G_STMT_START{ \
309 g_log (G_LOG_DOMAIN, \
310 G_LOG_LEVEL_CRITICAL, \
311 "file %s: line %d (%s): should not be reached", \
314 __PRETTY_FUNCTION__); \
315 return (val); }G_STMT_END
317 #else /* !__GNUC__ */
319 #define g_return_if_fail(expr) G_STMT_START{ \
322 g_log (G_LOG_DOMAIN, \
323 G_LOG_LEVEL_CRITICAL, \
324 "file %s: line %d: assertion `%s' failed", \
331 #define g_return_val_if_fail(expr, val) G_STMT_START{ \
334 g_log (G_LOG_DOMAIN, \
335 G_LOG_LEVEL_CRITICAL, \
336 "file %s: line %d: assertion `%s' failed", \
343 #define g_return_if_reached() G_STMT_START{ \
344 g_log (G_LOG_DOMAIN, \
345 G_LOG_LEVEL_CRITICAL, \
346 "file %s: line %d: should not be reached", \
351 #define g_return_val_if_reached(val) G_STMT_START{ \
352 g_log (G_LOG_DOMAIN, \
353 G_LOG_LEVEL_CRITICAL, \
354 "file %s: line %d: should not be reached", \
357 return (val); }G_STMT_END
359 #endif /* !__GNUC__ */
361 #endif /* !G_DISABLE_CHECKS */
365 #endif /* __G_MESSAGES_H__ */