1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __G_TYPES_H__
26#define __G_TYPES_H__
27
28#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29#error "Only <glib.h> can be included directly."
30#endif
31
32#include <glibconfig.h>
33#include <glib/gmacros.h>
34#include <glib/gversionmacros.h>
35#include <time.h>
36
37G_BEGIN_DECLS
38
39/* Provide type definitions for commonly used types.
40 * These are useful because a "gint8" can be adjusted
41 * to be 1 byte (8 bits) on all platforms. Similarly and
42 * more importantly, "gint32" can be adjusted to be
43 * 4 bytes (32 bits) on all platforms.
44 */
45
46typedef char gchar;
47typedef short gshort;
48typedef long glong;
49typedef int gint;
50typedef gint gboolean;
51
52typedef unsigned char guchar;
53typedef unsigned short gushort;
54typedef unsigned long gulong;
55typedef unsigned int guint;
56
57typedef float gfloat;
58typedef double gdouble;
59
60/* Define min and max constants for the fixed size numerical types */
61/**
62 * G_MININT8: (value -128)
63 *
64 * The minimum value which can be held in a #gint8.
65 *
66 * Since: 2.4
67 */
68#define G_MININT8 ((gint8) (-G_MAXINT8 - 1))
69#define G_MAXINT8 ((gint8) 0x7f)
70#define G_MAXUINT8 ((guint8) 0xff)
71
72/**
73 * G_MININT16: (value -32768)
74 *
75 * The minimum value which can be held in a #gint16.
76 *
77 * Since: 2.4
78 */
79#define G_MININT16 ((gint16) (-G_MAXINT16 - 1))
80#define G_MAXINT16 ((gint16) 0x7fff)
81#define G_MAXUINT16 ((guint16) 0xffff)
82
83/**
84 * G_MININT32: (value -2147483648)
85 *
86 * The minimum value which can be held in a #gint32.
87 *
88 * Since: 2.4
89 */
90#define G_MININT32 ((gint32) (-G_MAXINT32 - 1))
91#define G_MAXINT32 ((gint32) 0x7fffffff)
92#define G_MAXUINT32 ((guint32) 0xffffffff)
93
94/**
95 * G_MININT64: (value -9223372036854775808)
96 *
97 * The minimum value which can be held in a #gint64.
98 */
99#define G_MININT64 ((gint64) (-G_MAXINT64 - G_GINT64_CONSTANT(1)))
100#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff)
101#define G_MAXUINT64 G_GUINT64_CONSTANT(0xffffffffffffffff)
102
103typedef void* gpointer;
104typedef const void *gconstpointer;
105
106typedef gint (*GCompareFunc) (gconstpointer a,
107 gconstpointer b);
108typedef gint (*GCompareDataFunc) (gconstpointer a,
109 gconstpointer b,
110 gpointer user_data);
111typedef gboolean (*GEqualFunc) (gconstpointer a,
112 gconstpointer b);
113typedef void (*GDestroyNotify) (gpointer data);
114typedef void (*GFunc) (gpointer data,
115 gpointer user_data);
116typedef guint (*GHashFunc) (gconstpointer key);
117typedef void (*GHFunc) (gpointer key,
118 gpointer value,
119 gpointer user_data);
120
121/**
122 * GCopyFunc:
123 * @src: (not nullable): A pointer to the data which should be copied
124 * @data: Additional data
125 *
126 * A function of this signature is used to copy the node data
127 * when doing a deep-copy of a tree.
128 *
129 * Returns: (not nullable): A pointer to the copy
130 *
131 * Since: 2.4
132 */
133typedef gpointer (*GCopyFunc) (gconstpointer src,
134 gpointer data);
135/**
136 * GFreeFunc:
137 * @data: a data pointer
138 *
139 * Declares a type of function which takes an arbitrary
140 * data pointer argument and has no return value. It is
141 * not currently used in GLib or GTK+.
142 */
143typedef void (*GFreeFunc) (gpointer data);
144
145/**
146 * GTranslateFunc:
147 * @str: the untranslated string
148 * @data: user data specified when installing the function, e.g.
149 * in g_option_group_set_translate_func()
150 *
151 * The type of functions which are used to translate user-visible
152 * strings, for <option>--help</option> output.
153 *
154 * Returns: a translation of the string for the current locale.
155 * The returned string is owned by GLib and must not be freed.
156 */
157typedef const gchar * (*GTranslateFunc) (const gchar *str,
158 gpointer data);
159
160
161/* Define some mathematical constants that aren't available
162 * symbolically in some strict ISO C implementations.
163 *
164 * Note that the large number of digits used in these definitions
165 * doesn't imply that GLib or current computers in general would be
166 * able to handle floating point numbers with an accuracy like this.
167 * It's mostly an exercise in futility and future proofing. For
168 * extended precision floating point support, look somewhere else
169 * than GLib.
170 */
171#define G_E 2.7182818284590452353602874713526624977572470937000
172#define G_LN2 0.69314718055994530941723212145817656807550013436026
173#define G_LN10 2.3025850929940456840179914546843642076011014886288
174#define G_PI 3.1415926535897932384626433832795028841971693993751
175#define G_PI_2 1.5707963267948966192313216916397514420985846996876
176#define G_PI_4 0.78539816339744830961566084581987572104929234984378
177#define G_SQRT2 1.4142135623730950488016887242096980785696718753769
178
179/* Portable endian checks and conversions
180 *
181 * glibconfig.h defines G_BYTE_ORDER which expands to one of
182 * the below macros.
183 */
184#define G_LITTLE_ENDIAN 1234
185#define G_BIG_ENDIAN 4321
186#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */
187
188
189/* Basic bit swapping functions
190 */
191#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \
192 (guint16) ((guint16) (val) >> 8) | \
193 (guint16) ((guint16) (val) << 8)))
194
195#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \
196 (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \
197 (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \
198 (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \
199 (((guint32) (val) & (guint32) 0xff000000U) >> 24)))
200
201#define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \
202 (((guint64) (val) & \
203 (guint64) G_GINT64_CONSTANT (0x00000000000000ffU)) << 56) | \
204 (((guint64) (val) & \
205 (guint64) G_GINT64_CONSTANT (0x000000000000ff00U)) << 40) | \
206 (((guint64) (val) & \
207 (guint64) G_GINT64_CONSTANT (0x0000000000ff0000U)) << 24) | \
208 (((guint64) (val) & \
209 (guint64) G_GINT64_CONSTANT (0x00000000ff000000U)) << 8) | \
210 (((guint64) (val) & \
211 (guint64) G_GINT64_CONSTANT (0x000000ff00000000U)) >> 8) | \
212 (((guint64) (val) & \
213 (guint64) G_GINT64_CONSTANT (0x0000ff0000000000U)) >> 24) | \
214 (((guint64) (val) & \
215 (guint64) G_GINT64_CONSTANT (0x00ff000000000000U)) >> 40) | \
216 (((guint64) (val) & \
217 (guint64) G_GINT64_CONSTANT (0xff00000000000000U)) >> 56)))
218
219/* Arch specific stuff for speed
220 */
221#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
222
223# if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3
224# define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((guint32) (val)))
225# define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((guint64) (val)))
226# endif
227
228# if defined (__i386__)
229# define GUINT16_SWAP_LE_BE_IA32(val) \
230 (G_GNUC_EXTENSION \
231 ({ guint16 __v, __x = ((guint16) (val)); \
232 if (__builtin_constant_p (__x)) \
233 __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \
234 else \
235 __asm__ ("rorw $8, %w0" \
236 : "=r" (__v) \
237 : "0" (__x) \
238 : "cc"); \
239 __v; }))
240# if !defined (__i486__) && !defined (__i586__) \
241 && !defined (__pentium__) && !defined (__i686__) \
242 && !defined (__pentiumpro__) && !defined (__pentium4__)
243# define GUINT32_SWAP_LE_BE_IA32(val) \
244 (G_GNUC_EXTENSION \
245 ({ guint32 __v, __x = ((guint32) (val)); \
246 if (__builtin_constant_p (__x)) \
247 __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
248 else \
249 __asm__ ("rorw $8, %w0\n\t" \
250 "rorl $16, %0\n\t" \
251 "rorw $8, %w0" \
252 : "=r" (__v) \
253 : "0" (__x) \
254 : "cc"); \
255 __v; }))
256# else /* 486 and higher has bswap */
257# define GUINT32_SWAP_LE_BE_IA32(val) \
258 (G_GNUC_EXTENSION \
259 ({ guint32 __v, __x = ((guint32) (val)); \
260 if (__builtin_constant_p (__x)) \
261 __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
262 else \
263 __asm__ ("bswap %0" \
264 : "=r" (__v) \
265 : "0" (__x)); \
266 __v; }))
267# endif /* processor specific 32-bit stuff */
268# define GUINT64_SWAP_LE_BE_IA32(val) \
269 (G_GNUC_EXTENSION \
270 ({ union { guint64 __ll; \
271 guint32 __l[2]; } __w, __r; \
272 __w.__ll = ((guint64) (val)); \
273 if (__builtin_constant_p (__w.__ll)) \
274 __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (__w.__ll); \
275 else \
276 { \
277 __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \
278 __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \
279 } \
280 __r.__ll; }))
281 /* Possibly just use the constant version and let gcc figure it out? */
282# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
283# ifndef GUINT32_SWAP_LE_BE
284# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val))
285# endif
286# ifndef GUINT64_SWAP_LE_BE
287# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val))
288# endif
289# elif defined (__ia64__)
290# define GUINT16_SWAP_LE_BE_IA64(val) \
291 (G_GNUC_EXTENSION \
292 ({ guint16 __v, __x = ((guint16) (val)); \
293 if (__builtin_constant_p (__x)) \
294 __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \
295 else \
296 __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \
297 "mux1 %0 = %0, @rev ;;" \
298 : "=r" (__v) \
299 : "r" (__x)); \
300 __v; }))
301# define GUINT32_SWAP_LE_BE_IA64(val) \
302 (G_GNUC_EXTENSION \
303 ({ guint32 __v, __x = ((guint32) (val)); \
304 if (__builtin_constant_p (__x)) \
305 __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
306 else \
307 __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \
308 "mux1 %0 = %0, @rev ;;" \
309 : "=r" (__v) \
310 : "r" (__x)); \
311 __v; }))
312# define GUINT64_SWAP_LE_BE_IA64(val) \
313 (G_GNUC_EXTENSION \
314 ({ guint64 __v, __x = ((guint64) (val)); \
315 if (__builtin_constant_p (__x)) \
316 __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \
317 else \
318 __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \
319 : "=r" (__v) \
320 : "r" (__x)); \
321 __v; }))
322# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val))
323# ifndef GUINT32_SWAP_LE_BE
324# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val))
325# endif
326# ifndef GUINT64_SWAP_LE_BE
327# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val))
328# endif
329# elif defined (__x86_64__)
330# define GUINT32_SWAP_LE_BE_X86_64(val) \
331 (G_GNUC_EXTENSION \
332 ({ guint32 __v, __x = ((guint32) (val)); \
333 if (__builtin_constant_p (__x)) \
334 __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
335 else \
336 __asm__ ("bswapl %0" \
337 : "=r" (__v) \
338 : "0" (__x)); \
339 __v; }))
340# define GUINT64_SWAP_LE_BE_X86_64(val) \
341 (G_GNUC_EXTENSION \
342 ({ guint64 __v, __x = ((guint64) (val)); \
343 if (__builtin_constant_p (__x)) \
344 __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \
345 else \
346 __asm__ ("bswapq %0" \
347 : "=r" (__v) \
348 : "0" (__x)); \
349 __v; }))
350 /* gcc seems to figure out optimal code for this on its own */
351# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
352# ifndef GUINT32_SWAP_LE_BE
353# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val))
354# endif
355# ifndef GUINT64_SWAP_LE_BE
356# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val))
357# endif
358# else /* generic gcc */
359# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
360# ifndef GUINT32_SWAP_LE_BE
361# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
362# endif
363# ifndef GUINT64_SWAP_LE_BE
364# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val))
365# endif
366# endif
367#else /* generic */
368# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
369# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
370# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val))
371#endif /* generic */
372
373#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val))
374#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val))
375#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \
376 (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \
377 (((guint32) (val) & (guint32) 0xffff0000U) >> 16)))
378#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \
379 (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \
380 (((guint32) (val) & (guint32) 0xff00ff00U) >> 8)))
381
382/* The G*_TO_?E() macros are defined in glibconfig.h.
383 * The transformation is symmetric, so the FROM just maps to the TO.
384 */
385#define GINT16_FROM_LE(val) (GINT16_TO_LE (val))
386#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val))
387#define GINT16_FROM_BE(val) (GINT16_TO_BE (val))
388#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val))
389#define GINT32_FROM_LE(val) (GINT32_TO_LE (val))
390#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val))
391#define GINT32_FROM_BE(val) (GINT32_TO_BE (val))
392#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val))
393
394#define GINT64_FROM_LE(val) (GINT64_TO_LE (val))
395#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val))
396#define GINT64_FROM_BE(val) (GINT64_TO_BE (val))
397#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val))
398
399#define GLONG_FROM_LE(val) (GLONG_TO_LE (val))
400#define GULONG_FROM_LE(val) (GULONG_TO_LE (val))
401#define GLONG_FROM_BE(val) (GLONG_TO_BE (val))
402#define GULONG_FROM_BE(val) (GULONG_TO_BE (val))
403
404#define GINT_FROM_LE(val) (GINT_TO_LE (val))
405#define GUINT_FROM_LE(val) (GUINT_TO_LE (val))
406#define GINT_FROM_BE(val) (GINT_TO_BE (val))
407#define GUINT_FROM_BE(val) (GUINT_TO_BE (val))
408
409#define GSIZE_FROM_LE(val) (GSIZE_TO_LE (val))
410#define GSSIZE_FROM_LE(val) (GSSIZE_TO_LE (val))
411#define GSIZE_FROM_BE(val) (GSIZE_TO_BE (val))
412#define GSSIZE_FROM_BE(val) (GSSIZE_TO_BE (val))
413
414/* Portable versions of host-network order stuff
415 */
416#define g_ntohl(val) (GUINT32_FROM_BE (val))
417#define g_ntohs(val) (GUINT16_FROM_BE (val))
418#define g_htonl(val) (GUINT32_TO_BE (val))
419#define g_htons(val) (GUINT16_TO_BE (val))
420
421/* Overflow-checked unsigned integer arithmetic
422 */
423#ifndef _GLIB_TEST_OVERFLOW_FALLBACK
424/* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */
425#if __GNUC__ >= 5 && !defined(__INTEL_COMPILER)
426#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
427#elif g_macro__has_builtin(__builtin_add_overflow)
428#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
429#endif
430#endif
431
432#ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
433
434#define g_uint_checked_add(dest, a, b) \
435 (!__builtin_add_overflow(a, b, dest))
436#define g_uint_checked_mul(dest, a, b) \
437 (!__builtin_mul_overflow(a, b, dest))
438
439#define g_uint64_checked_add(dest, a, b) \
440 (!__builtin_add_overflow(a, b, dest))
441#define g_uint64_checked_mul(dest, a, b) \
442 (!__builtin_mul_overflow(a, b, dest))
443
444#define g_size_checked_add(dest, a, b) \
445 (!__builtin_add_overflow(a, b, dest))
446#define g_size_checked_mul(dest, a, b) \
447 (!__builtin_mul_overflow(a, b, dest))
448
449#else /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */
450
451/* The names of the following inlines are private. Use the macro
452 * definitions above.
453 */
454static inline gboolean _GLIB_CHECKED_ADD_UINT (guint *dest, guint a, guint b) {
455 *dest = a + b; return *dest >= a; }
456static inline gboolean _GLIB_CHECKED_MUL_UINT (guint *dest, guint a, guint b) {
457 *dest = a * b; return !a || *dest / a == b; }
458static inline gboolean _GLIB_CHECKED_ADD_UINT64 (guint64 *dest, guint64 a, guint64 b) {
459 *dest = a + b; return *dest >= a; }
460static inline gboolean _GLIB_CHECKED_MUL_UINT64 (guint64 *dest, guint64 a, guint64 b) {
461 *dest = a * b; return !a || *dest / a == b; }
462static inline gboolean _GLIB_CHECKED_ADD_SIZE (gsize *dest, gsize a, gsize b) {
463 *dest = a + b; return *dest >= a; }
464static inline gboolean _GLIB_CHECKED_MUL_SIZE (gsize *dest, gsize a, gsize b) {
465 *dest = a * b; return !a || *dest / a == b; }
466
467#define g_uint_checked_add(dest, a, b) \
468 _GLIB_CHECKED_ADD_UINT(dest, a, b)
469#define g_uint_checked_mul(dest, a, b) \
470 _GLIB_CHECKED_MUL_UINT(dest, a, b)
471
472#define g_uint64_checked_add(dest, a, b) \
473 _GLIB_CHECKED_ADD_UINT64(dest, a, b)
474#define g_uint64_checked_mul(dest, a, b) \
475 _GLIB_CHECKED_MUL_UINT64(dest, a, b)
476
477#define g_size_checked_add(dest, a, b) \
478 _GLIB_CHECKED_ADD_SIZE(dest, a, b)
479#define g_size_checked_mul(dest, a, b) \
480 _GLIB_CHECKED_MUL_SIZE(dest, a, b)
481
482#endif /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */
483
484/* IEEE Standard 754 Single Precision Storage Format (gfloat):
485 *
486 * 31 30 23 22 0
487 * +--------+---------------+---------------+
488 * | s 1bit | e[30:23] 8bit | f[22:0] 23bit |
489 * +--------+---------------+---------------+
490 * B0------------------->B1------->B2-->B3-->
491 *
492 * IEEE Standard 754 Double Precision Storage Format (gdouble):
493 *
494 * 63 62 52 51 32 31 0
495 * +--------+----------------+----------------+ +---------------+
496 * | s 1bit | e[62:52] 11bit | f[51:32] 20bit | | f[31:0] 32bit |
497 * +--------+----------------+----------------+ +---------------+
498 * B0--------------->B1---------->B2--->B3----> B4->B5->B6->B7->
499 */
500/* subtract from biased_exponent to form base2 exponent (normal numbers) */
501typedef union _GDoubleIEEE754 GDoubleIEEE754;
502typedef union _GFloatIEEE754 GFloatIEEE754;
503#define G_IEEE754_FLOAT_BIAS (127)
504#define G_IEEE754_DOUBLE_BIAS (1023)
505/* multiply with base2 exponent to get base10 exponent (normal numbers) */
506#define G_LOG_2_BASE_10 (0.30102999566398119521)
507#if G_BYTE_ORDER == G_LITTLE_ENDIAN
508union _GFloatIEEE754
509{
510 gfloat v_float;
511 struct {
512 guint mantissa : 23;
513 guint biased_exponent : 8;
514 guint sign : 1;
515 } mpn;
516};
517union _GDoubleIEEE754
518{
519 gdouble v_double;
520 struct {
521 guint mantissa_low : 32;
522 guint mantissa_high : 20;
523 guint biased_exponent : 11;
524 guint sign : 1;
525 } mpn;
526};
527#elif G_BYTE_ORDER == G_BIG_ENDIAN
528union _GFloatIEEE754
529{
530 gfloat v_float;
531 struct {
532 guint sign : 1;
533 guint biased_exponent : 8;
534 guint mantissa : 23;
535 } mpn;
536};
537union _GDoubleIEEE754
538{
539 gdouble v_double;
540 struct {
541 guint sign : 1;
542 guint biased_exponent : 11;
543 guint mantissa_high : 20;
544 guint mantissa_low : 32;
545 } mpn;
546};
547#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
548#error unknown ENDIAN type
549#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
550
551typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
552
553struct _GTimeVal
554{
555 glong tv_sec;
556 glong tv_usec;
557} GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
558
559typedef gint grefcount;
560typedef gint gatomicrefcount; /* should be accessed only using atomics */
561
562G_END_DECLS
563
564/* We prefix variable declarations so they can
565 * properly get exported in Windows DLLs.
566 */
567#ifndef GLIB_VAR
568# ifdef G_PLATFORM_WIN32
569# ifdef GLIB_STATIC_COMPILATION
570# define GLIB_VAR extern
571# else /* !GLIB_STATIC_COMPILATION */
572# ifdef GLIB_COMPILATION
573# ifdef DLL_EXPORT
574# define GLIB_VAR extern __declspec(dllexport)
575# else /* !DLL_EXPORT */
576# define GLIB_VAR extern
577# endif /* !DLL_EXPORT */
578# else /* !GLIB_COMPILATION */
579# define GLIB_VAR extern __declspec(dllimport)
580# endif /* !GLIB_COMPILATION */
581# endif /* !GLIB_STATIC_COMPILATION */
582# else /* !G_PLATFORM_WIN32 */
583# define GLIB_VAR _GLIB_EXTERN
584# endif /* !G_PLATFORM_WIN32 */
585#endif /* GLIB_VAR */
586
587#endif /* __G_TYPES_H__ */
588

source code of include/glib-2.0/glib/gtypes.h