• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3  *
4  * This file is not part of the GNU gettext program, but is used with
5  * GNU gettext.
6  *
7  * The original copyright notice is as follows:
8  */
9 
10 /* GLIB - Library of useful routines for C programming
11  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the
25  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26  * Boston, MA 02111-1307, USA.
27  */
28 
29 /*
30  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
31  * file for a list of people on the GLib Team.  See the ChangeLog
32  * files for a list of changes.  These files are distributed with
33  * GLib at ftp://ftp.gtk.org/pub/gtk/.
34  */
35 
36 /*
37  * Modified by Bruno Haible for use as a gnulib module.
38  */
39 
40 /* ====================== Substitute for glibconfig.h ====================== */
41 
42 #include <stddef.h>
43 #include <sys/types.h>
44 #include <stdint.h>
45 
46 typedef uint16_t guint16;
47 typedef uint32_t guint32;
48 
49 typedef size_t gsize;
50 typedef ssize_t gssize;
51 
52 #define GPOINTER_TO_INT(p)	((gint)  (intptr_t)  (p))
53 #define GPOINTER_TO_UINT(p)	((guint) (uintptr_t) (p))
54 
55 #define GINT_TO_POINTER(i)	((gpointer) (intptr_t)  (i))
56 #define GUINT_TO_POINTER(u)	((gpointer) (uintptr_t) (u))
57 
58 #define g_memmove memmove
59 
60 /* ================ Abridged version of for <glib/macros.h> ================ */
61 
62 #if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
63 #define G_GNUC_PURE                            \
64   __attribute__((__pure__))
65 #define G_GNUC_MALLOC    			\
66   __attribute__((__malloc__))
67 #else
68 #define G_GNUC_PURE
69 #define G_GNUC_MALLOC
70 #endif
71 
72 #if     __GNUC__ >= 4
73 #define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
74 #else
75 #define G_GNUC_NULL_TERMINATED
76 #endif
77 
78 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
79 #define G_GNUC_PRINTF( format_idx, arg_idx )    \
80   __attribute__((__format__ (__printf__, format_idx, arg_idx)))
81 #define G_GNUC_SCANF( format_idx, arg_idx )     \
82   __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
83 #define G_GNUC_FORMAT( arg_idx )                \
84   __attribute__((__format_arg__ (arg_idx)))
85 #define G_GNUC_NORETURN                         \
86   __attribute__((__noreturn__))
87 #define G_GNUC_CONST                            \
88   __attribute__((__const__))
89 #define G_GNUC_UNUSED                           \
90   __attribute__((__unused__))
91 #define G_GNUC_NO_INSTRUMENT			\
92   __attribute__((__no_instrument_function__))
93 #else   /* !__GNUC__ */
94 #define G_GNUC_PRINTF( format_idx, arg_idx )
95 #define G_GNUC_SCANF( format_idx, arg_idx )
96 #define G_GNUC_FORMAT( arg_idx )
97 #define G_GNUC_NORETURN
98 #define G_GNUC_CONST
99 #define G_GNUC_UNUSED
100 #define G_GNUC_NO_INSTRUMENT
101 #endif  /* !__GNUC__ */
102 
103 #if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
104 #define G_GNUC_WARN_UNUSED_RESULT 		\
105   __attribute__((warn_unused_result))
106 #else
107 #define G_GNUC_WARN_UNUSED_RESULT
108 #endif /* __GNUC__ */
109 
110 #ifdef  __cplusplus
111 # define G_BEGIN_DECLS  extern "C" {
112 # define G_END_DECLS    }
113 #else
114 # define G_BEGIN_DECLS
115 # define G_END_DECLS
116 #endif
117 
118 #ifndef	FALSE
119 #define	FALSE	(0)
120 #endif
121 
122 #ifndef	TRUE
123 #define	TRUE	(!FALSE)
124 #endif
125 
126 #undef	MAX
127 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
128 
129 #undef	MIN
130 #define MIN(a, b)  (((a) < (b)) ? (a) : (b))
131 
132 #define G_STMT_START
133 #define G_STMT_END
134 
135 /* ====================== Substitute for <glib/gmem.h> ====================== */
136 
137 #include "xalloc.h"
138 
139 #define g_malloc(n) xmalloc (n)
140 #define g_malloc0(n) xzalloc (n)
141 #define g_realloc(p,n) xrealloc (p, n)
142 #define g_free(p) free (p)
143 #define g_try_malloc(n) xmalloc (n)
144 #define g_try_malloc0(n) xzalloc (n)
145 #define g_try_realloc(p,n) xrealloc (p, n)
146 
147 #define g_new(t,n) ((t *) xnmalloc (n, sizeof (t)))
148 #define g_new0(t,n) ((t *) xcalloc (n, sizeof (t)))
149 #define g_try_new(t,n) ((t *) xnmalloc (n, sizeof (t)))
150 #define g_try_new0(t,n) ((t *) xcalloc (n, sizeof (t)))
151 
152 /* =================== Substitute for <glib/gmessages.h> =================== */
153 
154 #include <stdlib.h>
155 
156 #define g_assert(expr)                 if (!(expr)) abort ()
157 #define g_assert_not_reached()         abort ()
158 
159 #define g_return_if_fail(expr)         if (!(expr)) return
160 #define g_return_val_if_fail(expr,val) if (!(expr)) return (val)
161 #define g_return_if_reached()          return
162 #define g_return_val_if_reached(val)   return (val)
163 
164 #define G_LOG_LEVEL_CRITICAL 0
165 #define G_LOG_LEVEL_INFO     0
166 #define G_LOG_LEVEL_DEBUG    0
167 
168 extern void g_printerr (const char *format, ...) G_GNUC_PRINTF (1, 2);
169 extern void g_warning (const char *format, ...) G_GNUC_PRINTF (1, 2);
170 extern void g_log (const char *domain, int level, const char *format, ...) G_GNUC_PRINTF (3, 4);
171 
172 /* ==================== Substitute for <glib/gprintf.h> ==================== */
173 
174 #include <stdio.h>
175 
176 #define g_printf printf
177 #define g_fprintf fprintf
178 #define g_sprintf sprintf
179 #define g_vprintf vprintf
180 #define g_vfprintf vfprintf
181 #define g_vsprintf vsprintf
182 #define g_vasprintf vasprintf
183 
184 /* ===================== Substitute for <glib/gslice.h> ===================== */
185 
186 #define g_slice_new(t) XMALLOC (t)
187 #define g_slice_new0(t) XZALLOC (t)
188 
189 #define g_slice_free(t,p) free (p)
190 
191 /* ======================= Helper for <glib/gtypes.h> ======================= */
192 
193 /* We don't need to export variables from a shared library.  */
194 #define GLIB_VAR extern
195 
196 /* ==================== Substitute for <glib/gunicode.h> ==================== */
197 
198 typedef unsigned int gunichar;
199