Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:17:37

0001 /* GLIB - Library of useful routines for C programming
0002  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 /*
0021  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
0022  * file for a list of people on the GLib Team.  See the ChangeLog
0023  * files for a list of changes.  These files are distributed with
0024  * GLib at ftp://ftp.gtk.org/pub/gtk/.
0025  */
0026 
0027 #ifndef __G_TYPES_H__
0028 #define __G_TYPES_H__
0029 
0030 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
0031 #error "Only <glib.h> can be included directly."
0032 #endif
0033 
0034 #include <glibconfig.h>
0035 #include <glib/gmacros.h>
0036 #include <glib/gversionmacros.h>
0037 
0038 /* Must be included after the 3 headers above */
0039 #include <glib/glib-visibility.h>
0040 
0041 #include <time.h>
0042 
0043 G_BEGIN_DECLS
0044 
0045 /* Provide type definitions for commonly used types.
0046  *  These are useful because a "gint8" can be adjusted
0047  *  to be 1 byte (8 bits) on all platforms. Similarly and
0048  *  more importantly, "gint32" can be adjusted to be
0049  *  4 bytes (32 bits) on all platforms.
0050  */
0051 
0052 typedef char   gchar;
0053 typedef short  gshort;
0054 typedef long   glong;
0055 typedef int    gint;
0056 typedef gint   gboolean;
0057 
0058 typedef unsigned char   guchar;
0059 typedef unsigned short  gushort;
0060 typedef unsigned long   gulong;
0061 typedef unsigned int    guint;
0062 
0063 typedef float   gfloat;
0064 typedef double  gdouble;
0065 
0066 /* Define min and max constants for the fixed size numerical types */
0067 /**
0068  * G_MININT8: (value -128)
0069  *
0070  * The minimum value which can be held in a #gint8.
0071  *
0072  * Since: 2.4
0073  */
0074 #define G_MININT8   ((gint8) (-G_MAXINT8 - 1))
0075 #define G_MAXINT8   ((gint8)  0x7f)
0076 #define G_MAXUINT8  ((guint8) 0xff)
0077 
0078 /**
0079  * G_MININT16: (value -32768)
0080  *
0081  * The minimum value which can be held in a #gint16.
0082  *
0083  * Since: 2.4
0084  */
0085 #define G_MININT16  ((gint16) (-G_MAXINT16 - 1))
0086 #define G_MAXINT16  ((gint16)  0x7fff)
0087 #define G_MAXUINT16 ((guint16) 0xffff)
0088 
0089 /**
0090  * G_MININT32: (value -2147483648)
0091  *
0092  * The minimum value which can be held in a #gint32.
0093  *
0094  * Since: 2.4
0095  */
0096 #define G_MININT32  ((gint32) (-G_MAXINT32 - 1))
0097 #define G_MAXINT32  ((gint32)  0x7fffffff)
0098 #define G_MAXUINT32 ((guint32) 0xffffffff)
0099 
0100 /**
0101  * G_MININT64: (value -9223372036854775808)
0102  *
0103  * The minimum value which can be held in a #gint64.
0104  */
0105 #define G_MININT64  ((gint64) (-G_MAXINT64 - G_GINT64_CONSTANT(1)))
0106 #define G_MAXINT64  G_GINT64_CONSTANT(0x7fffffffffffffff)
0107 #define G_MAXUINT64 G_GUINT64_CONSTANT(0xffffffffffffffff)
0108 
0109 typedef void* gpointer;
0110 typedef const void *gconstpointer;
0111 
0112 typedef gint            (*GCompareFunc)         (gconstpointer  a,
0113                                                  gconstpointer  b);
0114 typedef gint            (*GCompareDataFunc)     (gconstpointer  a,
0115                                                  gconstpointer  b,
0116                          gpointer       user_data);
0117 typedef gboolean        (*GEqualFunc)           (gconstpointer  a,
0118                                                  gconstpointer  b);
0119 
0120 /**
0121  * GEqualFuncFull:
0122  * @a: a value
0123  * @b: a value to compare with
0124  * @user_data: user data provided by the caller
0125  *
0126  * Specifies the type of a function used to test two values for
0127  * equality. The function should return %TRUE if both values are equal
0128  * and %FALSE otherwise.
0129  *
0130  * This is a version of #GEqualFunc which provides a @user_data closure from
0131  * the caller.
0132  *
0133  * Returns: %TRUE if @a = @b; %FALSE otherwise
0134  * Since: 2.74
0135  */
0136 typedef gboolean        (*GEqualFuncFull)       (gconstpointer  a,
0137                                                  gconstpointer  b,
0138                                                  gpointer       user_data);
0139 
0140 typedef void            (*GDestroyNotify)       (gpointer       data);
0141 typedef void            (*GFunc)                (gpointer       data,
0142                                                  gpointer       user_data);
0143 typedef guint           (*GHashFunc)            (gconstpointer  key);
0144 typedef void            (*GHFunc)               (gpointer       key,
0145                                                  gpointer       value,
0146                                                  gpointer       user_data);
0147 
0148 /**
0149  * GCopyFunc:
0150  * @src: (not nullable): A pointer to the data which should be copied
0151  * @data: Additional data
0152  *
0153  * A function of this signature is used to copy the node data
0154  * when doing a deep-copy of a tree.
0155  *
0156  * Returns: (not nullable): A pointer to the copy
0157  *
0158  * Since: 2.4
0159  */
0160 typedef gpointer    (*GCopyFunc)            (gconstpointer  src,
0161                                                  gpointer       data);
0162 /**
0163  * GFreeFunc:
0164  * @data: a data pointer
0165  *
0166  * Declares a type of function which takes an arbitrary
0167  * data pointer argument and has no return value. It is
0168  * not currently used in GLib or GTK.
0169  */
0170 typedef void            (*GFreeFunc)            (gpointer       data);
0171 
0172 /**
0173  * GTranslateFunc:
0174  * @str: the untranslated string
0175  * @data: user data specified when installing the function, e.g.
0176  *  in g_option_group_set_translate_func()
0177  * 
0178  * The type of functions which are used to translate user-visible
0179  * strings, for <option>--help</option> output.
0180  * 
0181  * Returns: a translation of the string for the current locale.
0182  *  The returned string is owned by GLib and must not be freed.
0183  */
0184 typedef const gchar *   (*GTranslateFunc)       (const gchar   *str,
0185                          gpointer       data);
0186 
0187 
0188 /* Define some mathematical constants that aren't available
0189  * symbolically in some strict ISO C implementations.
0190  *
0191  * Note that the large number of digits used in these definitions
0192  * doesn't imply that GLib or current computers in general would be
0193  * able to handle floating point numbers with an accuracy like this.
0194  * It's mostly an exercise in futility and future proofing. For
0195  * extended precision floating point support, look somewhere else
0196  * than GLib.
0197  */
0198 #define G_E     2.7182818284590452353602874713526624977572470937000
0199 #define G_LN2   0.69314718055994530941723212145817656807550013436026
0200 #define G_LN10  2.3025850929940456840179914546843642076011014886288
0201 #define G_PI    3.1415926535897932384626433832795028841971693993751
0202 #define G_PI_2  1.5707963267948966192313216916397514420985846996876
0203 #define G_PI_4  0.78539816339744830961566084581987572104929234984378
0204 #define G_SQRT2 1.4142135623730950488016887242096980785696718753769
0205 
0206 /* Portable endian checks and conversions
0207  *
0208  * glibconfig.h defines G_BYTE_ORDER which expands to one of
0209  * the below macros.
0210  */
0211 #define G_LITTLE_ENDIAN 1234
0212 #define G_BIG_ENDIAN    4321
0213 #define G_PDP_ENDIAN    3412        /* unused, need specific PDP check */   
0214 
0215 
0216 /* Basic bit swapping functions
0217  */
0218 #define GUINT16_SWAP_LE_BE_CONSTANT(val)    ((guint16) ( \
0219     (guint16) ((guint16) (val) >> 8) |  \
0220     (guint16) ((guint16) (val) << 8)))
0221 
0222 #define GUINT32_SWAP_LE_BE_CONSTANT(val)    ((guint32) ( \
0223     (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \
0224     (((guint32) (val) & (guint32) 0x0000ff00U) <<  8) | \
0225     (((guint32) (val) & (guint32) 0x00ff0000U) >>  8) | \
0226     (((guint32) (val) & (guint32) 0xff000000U) >> 24)))
0227 
0228 #define GUINT64_SWAP_LE_BE_CONSTANT(val)    ((guint64) ( \
0229       (((guint64) (val) &                       \
0230     (guint64) G_GINT64_CONSTANT (0x00000000000000ffU)) << 56) | \
0231       (((guint64) (val) &                       \
0232     (guint64) G_GINT64_CONSTANT (0x000000000000ff00U)) << 40) | \
0233       (((guint64) (val) &                       \
0234     (guint64) G_GINT64_CONSTANT (0x0000000000ff0000U)) << 24) | \
0235       (((guint64) (val) &                       \
0236     (guint64) G_GINT64_CONSTANT (0x00000000ff000000U)) <<  8) | \
0237       (((guint64) (val) &                       \
0238     (guint64) G_GINT64_CONSTANT (0x000000ff00000000U)) >>  8) | \
0239       (((guint64) (val) &                       \
0240     (guint64) G_GINT64_CONSTANT (0x0000ff0000000000U)) >> 24) | \
0241       (((guint64) (val) &                       \
0242     (guint64) G_GINT64_CONSTANT (0x00ff000000000000U)) >> 40) | \
0243       (((guint64) (val) &                       \
0244     (guint64) G_GINT64_CONSTANT (0xff00000000000000U)) >> 56)))
0245 
0246 /* Arch specific stuff for speed
0247  */
0248 #if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
0249 
0250 #  if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3
0251 #    define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((guint32) (val)))
0252 #    define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((guint64) (val)))
0253 #  endif
0254 
0255 #  if defined (__i386__)
0256 #    define GUINT16_SWAP_LE_BE_IA32(val) \
0257        (G_GNUC_EXTENSION                    \
0258     ({ guint16 __v, __x = ((guint16) (val));        \
0259        if (__builtin_constant_p (__x))          \
0260          __v = GUINT16_SWAP_LE_BE_CONSTANT (__x);       \
0261        else                         \
0262          __asm__ ("rorw $8, %w0"                \
0263               : "=r" (__v)              \
0264               : "0" (__x)               \
0265               : "cc");                  \
0266         __v; }))
0267 #    if !defined (__i486__) && !defined (__i586__) \
0268     && !defined (__pentium__) && !defined (__i686__) \
0269     && !defined (__pentiumpro__) && !defined (__pentium4__)
0270 #       define GUINT32_SWAP_LE_BE_IA32(val) \
0271       (G_GNUC_EXTENSION                 \
0272        ({ guint32 __v, __x = ((guint32) (val));     \
0273           if (__builtin_constant_p (__x))           \
0274         __v = GUINT32_SWAP_LE_BE_CONSTANT (__x);    \
0275           else                      \
0276         __asm__ ("rorw $8, %w0\n\t"         \
0277              "rorl $16, %0\n\t"         \
0278              "rorw $8, %w0"             \
0279              : "=r" (__v)               \
0280              : "0" (__x)                \
0281              : "cc");               \
0282           __v; }))
0283 #    else /* 486 and higher has bswap */
0284 #       define GUINT32_SWAP_LE_BE_IA32(val) \
0285       (G_GNUC_EXTENSION                 \
0286        ({ guint32 __v, __x = ((guint32) (val));     \
0287           if (__builtin_constant_p (__x))           \
0288         __v = GUINT32_SWAP_LE_BE_CONSTANT (__x);    \
0289           else                      \
0290         __asm__ ("bswap %0"             \
0291              : "=r" (__v)               \
0292              : "0" (__x));              \
0293           __v; }))
0294 #    endif /* processor specific 32-bit stuff */
0295 #    define GUINT64_SWAP_LE_BE_IA32(val) \
0296        (G_GNUC_EXTENSION                        \
0297     ({ union { guint64 __ll;                    \
0298            guint32 __l[2]; } __w, __r;              \
0299        __w.__ll = ((guint64) (val));                \
0300        if (__builtin_constant_p (__w.__ll))             \
0301          __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (__w.__ll);     \
0302        else                             \
0303          {                              \
0304            __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]);        \
0305            __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]);        \
0306          }                              \
0307        __r.__ll; }))
0308      /* Possibly just use the constant version and let gcc figure it out? */
0309 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
0310 #    ifndef GUINT32_SWAP_LE_BE
0311 #      define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val))
0312 #    endif
0313 #    ifndef GUINT64_SWAP_LE_BE
0314 #      define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val))
0315 #    endif
0316 #  elif defined (__ia64__)
0317 #    define GUINT16_SWAP_LE_BE_IA64(val) \
0318        (G_GNUC_EXTENSION                    \
0319     ({ guint16 __v, __x = ((guint16) (val));        \
0320        if (__builtin_constant_p (__x))          \
0321          __v = GUINT16_SWAP_LE_BE_CONSTANT (__x);       \
0322        else                         \
0323          __asm__ __volatile__ ("shl %0 = %1, 48 ;;"     \
0324                    "mux1 %0 = %0, @rev ;;"  \
0325                     : "=r" (__v)        \
0326                     : "r" (__x));       \
0327         __v; }))
0328 #    define GUINT32_SWAP_LE_BE_IA64(val) \
0329        (G_GNUC_EXTENSION                    \
0330      ({ guint32 __v, __x = ((guint32) (val));       \
0331         if (__builtin_constant_p (__x))         \
0332           __v = GUINT32_SWAP_LE_BE_CONSTANT (__x);      \
0333         else                        \
0334          __asm__ __volatile__ ("shl %0 = %1, 32 ;;"     \
0335                    "mux1 %0 = %0, @rev ;;"  \
0336                     : "=r" (__v)        \
0337                     : "r" (__x));       \
0338         __v; }))
0339 #    define GUINT64_SWAP_LE_BE_IA64(val) \
0340        (G_GNUC_EXTENSION                    \
0341     ({ guint64 __v, __x = ((guint64) (val));        \
0342        if (__builtin_constant_p (__x))          \
0343          __v = GUINT64_SWAP_LE_BE_CONSTANT (__x);       \
0344        else                         \
0345          __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;"  \
0346                    : "=r" (__v)         \
0347                    : "r" (__x));        \
0348        __v; }))
0349 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val))
0350 #    ifndef GUINT32_SWAP_LE_BE
0351 #      define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val))
0352 #    endif
0353 #    ifndef GUINT64_SWAP_LE_BE
0354 #      define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val))
0355 #    endif
0356 #  elif defined (__x86_64__)
0357 #    define GUINT32_SWAP_LE_BE_X86_64(val) \
0358        (G_GNUC_EXTENSION                    \
0359      ({ guint32 __v, __x = ((guint32) (val));       \
0360         if (__builtin_constant_p (__x))         \
0361           __v = GUINT32_SWAP_LE_BE_CONSTANT (__x);      \
0362         else                        \
0363          __asm__ ("bswapl %0"               \
0364               : "=r" (__v)              \
0365               : "0" (__x));             \
0366         __v; }))
0367 #    define GUINT64_SWAP_LE_BE_X86_64(val) \
0368        (G_GNUC_EXTENSION                    \
0369     ({ guint64 __v, __x = ((guint64) (val));        \
0370        if (__builtin_constant_p (__x))          \
0371          __v = GUINT64_SWAP_LE_BE_CONSTANT (__x);       \
0372        else                         \
0373          __asm__ ("bswapq %0"               \
0374               : "=r" (__v)              \
0375               : "0" (__x));             \
0376        __v; }))
0377      /* gcc seems to figure out optimal code for this on its own */
0378 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
0379 #    ifndef GUINT32_SWAP_LE_BE
0380 #      define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val))
0381 #    endif
0382 #    ifndef GUINT64_SWAP_LE_BE
0383 #      define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val))
0384 #    endif
0385 #  else /* generic gcc */
0386 #    define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
0387 #    ifndef GUINT32_SWAP_LE_BE
0388 #      define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
0389 #    endif
0390 #    ifndef GUINT64_SWAP_LE_BE
0391 #      define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val))
0392 #    endif
0393 #  endif
0394 #else /* generic */
0395 #  define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
0396 #  define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
0397 #  define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val))
0398 #endif /* generic */
0399 
0400 #define GUINT16_SWAP_LE_PDP(val)    ((guint16) (val))
0401 #define GUINT16_SWAP_BE_PDP(val)    (GUINT16_SWAP_LE_BE (val))
0402 #define GUINT32_SWAP_LE_PDP(val)    ((guint32) ( \
0403     (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \
0404     (((guint32) (val) & (guint32) 0xffff0000U) >> 16)))
0405 #define GUINT32_SWAP_BE_PDP(val)    ((guint32) ( \
0406     (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \
0407     (((guint32) (val) & (guint32) 0xff00ff00U) >> 8)))
0408 
0409 /* The G*_TO_?E() macros are defined in glibconfig.h.
0410  * The transformation is symmetric, so the FROM just maps to the TO.
0411  */
0412 #define GINT16_FROM_LE(val) (GINT16_TO_LE (val))
0413 #define GUINT16_FROM_LE(val)    (GUINT16_TO_LE (val))
0414 #define GINT16_FROM_BE(val) (GINT16_TO_BE (val))
0415 #define GUINT16_FROM_BE(val)    (GUINT16_TO_BE (val))
0416 #define GINT32_FROM_LE(val) (GINT32_TO_LE (val))
0417 #define GUINT32_FROM_LE(val)    (GUINT32_TO_LE (val))
0418 #define GINT32_FROM_BE(val) (GINT32_TO_BE (val))
0419 #define GUINT32_FROM_BE(val)    (GUINT32_TO_BE (val))
0420 
0421 #define GINT64_FROM_LE(val) (GINT64_TO_LE (val))
0422 #define GUINT64_FROM_LE(val)    (GUINT64_TO_LE (val))
0423 #define GINT64_FROM_BE(val) (GINT64_TO_BE (val))
0424 #define GUINT64_FROM_BE(val)    (GUINT64_TO_BE (val))
0425 
0426 #define GLONG_FROM_LE(val)  (GLONG_TO_LE (val))
0427 #define GULONG_FROM_LE(val) (GULONG_TO_LE (val))
0428 #define GLONG_FROM_BE(val)  (GLONG_TO_BE (val))
0429 #define GULONG_FROM_BE(val) (GULONG_TO_BE (val))
0430 
0431 #define GINT_FROM_LE(val)   (GINT_TO_LE (val))
0432 #define GUINT_FROM_LE(val)  (GUINT_TO_LE (val))
0433 #define GINT_FROM_BE(val)   (GINT_TO_BE (val))
0434 #define GUINT_FROM_BE(val)  (GUINT_TO_BE (val))
0435 
0436 #define GSIZE_FROM_LE(val)  (GSIZE_TO_LE (val))
0437 #define GSSIZE_FROM_LE(val) (GSSIZE_TO_LE (val))
0438 #define GSIZE_FROM_BE(val)  (GSIZE_TO_BE (val))
0439 #define GSSIZE_FROM_BE(val) (GSSIZE_TO_BE (val))
0440 
0441 /* Portable versions of host-network order stuff
0442  */
0443 #define g_ntohl(val) (GUINT32_FROM_BE (val))
0444 #define g_ntohs(val) (GUINT16_FROM_BE (val))
0445 #define g_htonl(val) (GUINT32_TO_BE (val))
0446 #define g_htons(val) (GUINT16_TO_BE (val))
0447 
0448 /* Overflow-checked unsigned integer arithmetic
0449  */
0450 #ifndef _GLIB_TEST_OVERFLOW_FALLBACK
0451 /* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */
0452 #if __GNUC__ >= 5 && !defined(__INTEL_COMPILER)
0453 #define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
0454 #elif g_macro__has_builtin(__builtin_add_overflow)
0455 #define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
0456 #endif
0457 #endif
0458 
0459 #ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS
0460 
0461 #define g_uint_checked_add(dest, a, b) \
0462     (!__builtin_add_overflow(a, b, dest))
0463 #define g_uint_checked_mul(dest, a, b) \
0464     (!__builtin_mul_overflow(a, b, dest))
0465 
0466 #define g_uint64_checked_add(dest, a, b) \
0467     (!__builtin_add_overflow(a, b, dest))
0468 #define g_uint64_checked_mul(dest, a, b) \
0469     (!__builtin_mul_overflow(a, b, dest))
0470 
0471 #define g_size_checked_add(dest, a, b) \
0472     (!__builtin_add_overflow(a, b, dest))
0473 #define g_size_checked_mul(dest, a, b) \
0474     (!__builtin_mul_overflow(a, b, dest))
0475 
0476 #else  /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */
0477 
0478 /* The names of the following inlines are private.  Use the macro
0479  * definitions above.
0480  */
0481 static inline gboolean _GLIB_CHECKED_ADD_UINT (guint *dest, guint a, guint b) {
0482   *dest = a + b; return *dest >= a; }
0483 static inline gboolean _GLIB_CHECKED_MUL_UINT (guint *dest, guint a, guint b) {
0484   *dest = a * b; return !a || *dest / a == b; }
0485 static inline gboolean _GLIB_CHECKED_ADD_UINT64 (guint64 *dest, guint64 a, guint64 b) {
0486   *dest = a + b; return *dest >= a; }
0487 static inline gboolean _GLIB_CHECKED_MUL_UINT64 (guint64 *dest, guint64 a, guint64 b) {
0488   *dest = a * b; return !a || *dest / a == b; }
0489 static inline gboolean _GLIB_CHECKED_ADD_SIZE (gsize *dest, gsize a, gsize b) {
0490   *dest = a + b; return *dest >= a; }
0491 static inline gboolean _GLIB_CHECKED_MUL_SIZE (gsize *dest, gsize a, gsize b) {
0492   *dest = a * b; return !a || *dest / a == b; }
0493 
0494 #define g_uint_checked_add(dest, a, b) \
0495     _GLIB_CHECKED_ADD_UINT(dest, a, b)
0496 #define g_uint_checked_mul(dest, a, b) \
0497     _GLIB_CHECKED_MUL_UINT(dest, a, b)
0498 
0499 #define g_uint64_checked_add(dest, a, b) \
0500     _GLIB_CHECKED_ADD_UINT64(dest, a, b)
0501 #define g_uint64_checked_mul(dest, a, b) \
0502     _GLIB_CHECKED_MUL_UINT64(dest, a, b)
0503 
0504 #define g_size_checked_add(dest, a, b) \
0505     _GLIB_CHECKED_ADD_SIZE(dest, a, b)
0506 #define g_size_checked_mul(dest, a, b) \
0507     _GLIB_CHECKED_MUL_SIZE(dest, a, b)
0508 
0509 #endif  /* !_GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS */
0510 
0511 /* IEEE Standard 754 Single Precision Storage Format (gfloat):
0512  *
0513  *        31 30           23 22            0
0514  * +--------+---------------+---------------+
0515  * | s 1bit | e[30:23] 8bit | f[22:0] 23bit |
0516  * +--------+---------------+---------------+
0517  * B0------------------->B1------->B2-->B3-->
0518  *
0519  * IEEE Standard 754 Double Precision Storage Format (gdouble):
0520  *
0521  *        63 62            52 51            32   31            0
0522  * +--------+----------------+----------------+ +---------------+
0523  * | s 1bit | e[62:52] 11bit | f[51:32] 20bit | | f[31:0] 32bit |
0524  * +--------+----------------+----------------+ +---------------+
0525  * B0--------------->B1---------->B2--->B3---->  B4->B5->B6->B7->
0526  */
0527 /* subtract from biased_exponent to form base2 exponent (normal numbers) */
0528 typedef union  _GDoubleIEEE754  GDoubleIEEE754;
0529 typedef union  _GFloatIEEE754   GFloatIEEE754;
0530 #define G_IEEE754_FLOAT_BIAS    (127)
0531 #define G_IEEE754_DOUBLE_BIAS   (1023)
0532 /* multiply with base2 exponent to get base10 exponent (normal numbers) */
0533 #define G_LOG_2_BASE_10     (0.30102999566398119521)
0534 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
0535 union _GFloatIEEE754
0536 {
0537   gfloat v_float;
0538   struct {
0539     guint mantissa : 23;
0540     guint biased_exponent : 8;
0541     guint sign : 1;
0542   } mpn;
0543 };
0544 union _GDoubleIEEE754
0545 {
0546   gdouble v_double;
0547   struct {
0548     guint mantissa_low : 32;
0549     guint mantissa_high : 20;
0550     guint biased_exponent : 11;
0551     guint sign : 1;
0552   } mpn;
0553 };
0554 #elif G_BYTE_ORDER == G_BIG_ENDIAN
0555 union _GFloatIEEE754
0556 {
0557   gfloat v_float;
0558   struct {
0559     guint sign : 1;
0560     guint biased_exponent : 8;
0561     guint mantissa : 23;
0562   } mpn;
0563 };
0564 union _GDoubleIEEE754
0565 {
0566   gdouble v_double;
0567   struct {
0568     guint sign : 1;
0569     guint biased_exponent : 11;
0570     guint mantissa_high : 20;
0571     guint mantissa_low : 32;
0572   } mpn;
0573 };
0574 #else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
0575 #error unknown ENDIAN type
0576 #endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
0577 
0578 typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
0579 
0580 struct _GTimeVal
0581 {
0582   glong tv_sec;
0583   glong tv_usec;
0584 } GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime);
0585 
0586 typedef gint grefcount;
0587 typedef gint gatomicrefcount;  /* should be accessed only using atomics */
0588 
0589 G_END_DECLS
0590 
0591 #endif /* __G_TYPES_H__ */