|
Packit Bot |
06c835 |
/* GLIB - Library of useful routines for C programming
|
|
Packit Bot |
06c835 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
Packit Bot |
06c835 |
*
|
|
Packit Bot |
06c835 |
* This library is free software; you can redistribute it and/or
|
|
Packit Bot |
06c835 |
* modify it under the terms of the GNU General Public
|
|
Packit Bot |
06c835 |
* License as published by the Free Software Foundation; either
|
|
Packit Bot |
06c835 |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Bot |
06c835 |
*
|
|
Packit Bot |
06c835 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Bot |
06c835 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Bot |
06c835 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Bot |
06c835 |
* General Public License for more details.
|
|
Packit Bot |
06c835 |
*
|
|
Packit Bot |
06c835 |
* You should have received a copy of the GNU General Public
|
|
Packit Bot |
06c835 |
* License along with this library; if not, write to the
|
|
Packit Bot |
06c835 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit Bot |
06c835 |
* Boston, MA 02111-1307, USA.
|
|
Packit Bot |
06c835 |
*/
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/*
|
|
Packit Bot |
06c835 |
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
|
Packit Bot |
06c835 |
* file for a list of people on the GLib Team. See the ChangeLog
|
|
Packit Bot |
06c835 |
* files for a list of changes. These files are distributed with
|
|
Packit Bot |
06c835 |
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
|
Packit Bot |
06c835 |
*/
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/*
|
|
Packit Bot |
06c835 |
* Modified by Bruno Haible for use as a gnulib module.
|
|
Packit Bot |
06c835 |
*/
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ====================== Substitute for glibconfig.h ====================== */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include <stddef.h>
|
|
Packit Bot |
06c835 |
#include <sys/types.h>
|
|
Packit Bot |
06c835 |
#include <stdint.h>
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
typedef uint16_t guint16;
|
|
Packit Bot |
06c835 |
typedef uint32_t guint32;
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
typedef size_t gsize;
|
|
Packit Bot |
06c835 |
typedef ssize_t gssize;
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define GPOINTER_TO_INT(p) ((gint) (intptr_t) (p))
|
|
Packit Bot |
06c835 |
#define GPOINTER_TO_UINT(p) ((guint) (uintptr_t) (p))
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define GINT_TO_POINTER(i) ((gpointer) (intptr_t) (i))
|
|
Packit Bot |
06c835 |
#define GUINT_TO_POINTER(u) ((gpointer) (uintptr_t) (u))
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_memmove memmove
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ================ Abridged version of for <glib/macros.h> ================ */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
|
|
Packit Bot |
06c835 |
#define G_GNUC_PURE \
|
|
Packit Bot |
06c835 |
__attribute__((__pure__))
|
|
Packit Bot |
06c835 |
#define G_GNUC_MALLOC \
|
|
Packit Bot |
06c835 |
__attribute__((__malloc__))
|
|
Packit Bot |
06c835 |
#else
|
|
Packit Bot |
06c835 |
#define G_GNUC_PURE
|
|
Packit Bot |
06c835 |
#define G_GNUC_MALLOC
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#if __GNUC__ >= 4
|
|
Packit Bot |
06c835 |
#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
|
|
Packit Bot |
06c835 |
#else
|
|
Packit Bot |
06c835 |
#define G_GNUC_NULL_TERMINATED
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
|
|
Packit Bot |
06c835 |
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
|
|
Packit Bot |
06c835 |
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
|
|
Packit Bot |
06c835 |
#define G_GNUC_SCANF( format_idx, arg_idx ) \
|
|
Packit Bot |
06c835 |
__attribute__((__format__ (__scanf__, format_idx, arg_idx)))
|
|
Packit Bot |
06c835 |
#define G_GNUC_FORMAT( arg_idx ) \
|
|
Packit Bot |
06c835 |
__attribute__((__format_arg__ (arg_idx)))
|
|
Packit Bot |
06c835 |
#define G_GNUC_NORETURN \
|
|
Packit Bot |
06c835 |
__attribute__((__noreturn__))
|
|
Packit Bot |
06c835 |
#define G_GNUC_CONST \
|
|
Packit Bot |
06c835 |
__attribute__((__const__))
|
|
Packit Bot |
06c835 |
#define G_GNUC_UNUSED \
|
|
Packit Bot |
06c835 |
__attribute__((__unused__))
|
|
Packit Bot |
06c835 |
#define G_GNUC_NO_INSTRUMENT \
|
|
Packit Bot |
06c835 |
__attribute__((__no_instrument_function__))
|
|
Packit Bot |
06c835 |
#else /* !__GNUC__ */
|
|
Packit Bot |
06c835 |
#define G_GNUC_PRINTF( format_idx, arg_idx )
|
|
Packit Bot |
06c835 |
#define G_GNUC_SCANF( format_idx, arg_idx )
|
|
Packit Bot |
06c835 |
#define G_GNUC_FORMAT( arg_idx )
|
|
Packit Bot |
06c835 |
#define G_GNUC_NORETURN
|
|
Packit Bot |
06c835 |
#define G_GNUC_CONST
|
|
Packit Bot |
06c835 |
#define G_GNUC_UNUSED
|
|
Packit Bot |
06c835 |
#define G_GNUC_NO_INSTRUMENT
|
|
Packit Bot |
06c835 |
#endif /* !__GNUC__ */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
|
Packit Bot |
06c835 |
#define G_GNUC_WARN_UNUSED_RESULT \
|
|
Packit Bot |
06c835 |
__attribute__((warn_unused_result))
|
|
Packit Bot |
06c835 |
#else
|
|
Packit Bot |
06c835 |
#define G_GNUC_WARN_UNUSED_RESULT
|
|
Packit Bot |
06c835 |
#endif /* __GNUC__ */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#ifdef __cplusplus
|
|
Packit Bot |
06c835 |
# define G_BEGIN_DECLS extern "C" {
|
|
Packit Bot |
06c835 |
# define G_END_DECLS }
|
|
Packit Bot |
06c835 |
#else
|
|
Packit Bot |
06c835 |
# define G_BEGIN_DECLS
|
|
Packit Bot |
06c835 |
# define G_END_DECLS
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#ifndef FALSE
|
|
Packit Bot |
06c835 |
#define FALSE (0)
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#ifndef TRUE
|
|
Packit Bot |
06c835 |
#define TRUE (!FALSE)
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#undef MAX
|
|
Packit Bot |
06c835 |
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#undef MIN
|
|
Packit Bot |
06c835 |
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define G_STMT_START
|
|
Packit Bot |
06c835 |
#define G_STMT_END
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ====================== Substitute for <glib/gmem.h> ====================== */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include "xalloc.h"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_malloc(n) xmalloc (n)
|
|
Packit Bot |
06c835 |
#define g_malloc0(n) xzalloc (n)
|
|
Packit Bot |
06c835 |
#define g_realloc(p,n) xrealloc (p, n)
|
|
Packit Bot |
06c835 |
#define g_free(p) free (p)
|
|
Packit Bot |
06c835 |
#define g_try_malloc(n) xmalloc (n)
|
|
Packit Bot |
06c835 |
#define g_try_malloc0(n) xzalloc (n)
|
|
Packit Bot |
06c835 |
#define g_try_realloc(p,n) xrealloc (p, n)
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_new(t,n) ((t *) xnmalloc (n, sizeof (t)))
|
|
Packit Bot |
06c835 |
#define g_new0(t,n) ((t *) xcalloc (n, sizeof (t)))
|
|
Packit Bot |
06c835 |
#define g_try_new(t,n) ((t *) xnmalloc (n, sizeof (t)))
|
|
Packit Bot |
06c835 |
#define g_try_new0(t,n) ((t *) xcalloc (n, sizeof (t)))
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* =================== Substitute for <glib/gmessages.h> =================== */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include <stdlib.h>
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_assert(expr) if (!(expr)) abort ()
|
|
Packit Bot |
06c835 |
#define g_assert_not_reached() abort ()
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_return_if_fail(expr) if (!(expr)) return
|
|
Packit Bot |
06c835 |
#define g_return_val_if_fail(expr,val) if (!(expr)) return (val)
|
|
Packit Bot |
06c835 |
#define g_return_if_reached() return
|
|
Packit Bot |
06c835 |
#define g_return_val_if_reached(val) return (val)
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define G_LOG_LEVEL_CRITICAL 0
|
|
Packit Bot |
06c835 |
#define G_LOG_LEVEL_INFO 0
|
|
Packit Bot |
06c835 |
#define G_LOG_LEVEL_DEBUG 0
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
extern void g_printerr (const char *format, ...) G_GNUC_PRINTF (1, 2);
|
|
Packit Bot |
06c835 |
extern void g_warning (const char *format, ...) G_GNUC_PRINTF (1, 2);
|
|
Packit Bot |
06c835 |
extern void g_log (const char *domain, int level, const char *format, ...) G_GNUC_PRINTF (3, 4);
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ==================== Substitute for <glib/gprintf.h> ==================== */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include <stdio.h>
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_printf printf
|
|
Packit Bot |
06c835 |
#define g_fprintf fprintf
|
|
Packit Bot |
06c835 |
#define g_sprintf sprintf
|
|
Packit Bot |
06c835 |
#define g_vprintf vprintf
|
|
Packit Bot |
06c835 |
#define g_vfprintf vfprintf
|
|
Packit Bot |
06c835 |
#define g_vsprintf vsprintf
|
|
Packit Bot |
06c835 |
#define g_vasprintf vasprintf
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ===================== Substitute for <glib/gslice.h> ===================== */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_slice_new(t) XMALLOC (t)
|
|
Packit Bot |
06c835 |
#define g_slice_new0(t) XZALLOC (t)
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define g_slice_free(t,p) free (p)
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ======================= Helper for <glib/gtypes.h> ======================= */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* We don't need to export variables from a shared library. */
|
|
Packit Bot |
06c835 |
#define GLIB_VAR extern
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* ==================== Substitute for <glib/gunicode.h> ==================== */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
typedef unsigned int gunichar;
|