[glib/ebassi/c99-int-types] Drop custom re-implementation of C99 integer types




commit b7f73d920f735e0c8bab7d83dedc3cda7682e142
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Jul 26 13:12:09 2022 +0100

    Drop custom re-implementation of C99 integer types
    
    We have required a strict equivalence between our integer types and
    their C99 counterparts for two years and four cycles, and nobody
    complained about it.
    
    It is time to drop one of the few remaining vestiges of C89
    compatibility.

 glib/glibconfig.h.in | 28 +++++++++++++++-------------
 meson.build          | 18 ------------------
 2 files changed, 15 insertions(+), 31 deletions(-)
---
diff --git a/glib/glibconfig.h.in b/glib/glibconfig.h.in
index ffedee1d2a..270945e477 100644
--- a/glib/glibconfig.h.in
+++ b/glib/glibconfig.h.in
@@ -10,6 +10,8 @@
 
 #include <limits.h>
 #include <float.h>
+#include <stdint.h>
+
 #mesondefine GLIB_HAVE_ALLOCA_H
 
 /* Specifies that GLib's g_print*() functions wrap the
@@ -39,19 +41,18 @@ G_BEGIN_DECLS
 #define G_MAXLONG      LONG_MAX
 #define G_MAXULONG     ULONG_MAX
 
-typedef signed char gint8;
-typedef unsigned char guint8;
+typedef int8_t gint8;
+typedef uint8_t guint8;
 
-typedef signed @gint16@ gint16;
-typedef unsigned @gint16@ guint16;
+typedef int16_t gint16;
+typedef uint16_t guint16;
 
 #define G_GINT16_MODIFIER @gint16_modifier@
 #define G_GINT16_FORMAT @gint16_format@
 #define G_GUINT16_FORMAT @guint16_format@
 
-
-typedef signed @gint32@ gint32;
-typedef unsigned @gint32@ guint32;
+typedef int32_t gint32;
+typedef uint32_t guint32;
 
 #define G_GINT32_MODIFIER @gint32_modifier@
 #define G_GINT32_FORMAT @gint32_format@
@@ -60,8 +61,8 @@ typedef unsigned @gint32@ guint32;
 
 #define G_HAVE_GINT64 1          /* deprecated, always true */
 
-@glib_extension@typedef signed @gint64@ gint64;
-@glib_extension@typedef unsigned @gint64@ guint64;
+typedef int64_t gint64;
+typedef uint64_t guint64;
 
 #define G_GINT64_CONSTANT(val) @gint64_constant@
 #define G_GUINT64_CONSTANT(val)        @guint64_constant@
@@ -76,8 +77,9 @@ typedef unsigned @gint32@ guint32;
 #define GLIB_SIZEOF_SIZE_T @glib_size_t@
 #define GLIB_SIZEOF_SSIZE_T @glib_ssize_t@
 
+typedef size_t gsize;
 typedef signed @glib_size_type_define@ gssize;
-typedef unsigned @glib_size_type_define@ gsize;
+
 #define G_GSIZE_MODIFIER @gsize_modifier@
 #define G_GSSIZE_MODIFIER @gssize_modifier@
 #define G_GSIZE_FORMAT @gsize_format@
@@ -87,7 +89,7 @@ typedef unsigned @glib_size_type_define@ gsize;
 #define G_MINSSIZE     G_MIN@glib_msize_type@
 #define G_MAXSSIZE     G_MAX@glib_msize_type@
 
-typedef gint64 goffset;
+typedef int64_t goffset;
 #define G_MINOFFSET    G_MININT64
 #define G_MAXOFFSET    G_MAXINT64
 
@@ -103,8 +105,8 @@ typedef gint64 goffset;
 #define GINT_TO_POINTER(i)     ((gpointer) @glib_gpi_cast@ (i))
 #define GUINT_TO_POINTER(u)    ((gpointer) @glib_gpui_cast@ (u))
 
-typedef signed @glib_intptr_type_define@ gintptr;
-typedef unsigned @glib_intptr_type_define@ guintptr;
+typedef intptr_t gintptr;
+typedef uintptr_t guintptr;
 
 #define G_GINTPTR_MODIFIER      @gintptr_modifier@
 #define G_GINTPTR_FORMAT        @gintptr_format@
diff --git a/meson.build b/meson.build
index 1d11226270..f00e207230 100644
--- a/meson.build
+++ b/meson.build
@@ -1462,37 +1462,31 @@ glib_conf.set('SIZEOF_VOID_P', voidp_size)
 glib_conf.set('SIZEOF_WCHAR_T', cc.sizeof('wchar_t', prefix: '#include <stddef.h>'))
 
 if short_size == 2
-  gint16 = 'short'
   gint16_modifier='h'
   gint16_format='hi'
   guint16_format='hu'
 elif int_size == 2
-  gint16 = 'int'
   gint16_modifier=''
   gint16_format='i'
   guint16_format='u'
 else
   error('Compiler provides no native 16-bit integer type')
 endif
-glibconfig_conf.set('gint16', gint16)
 glibconfig_conf.set_quoted('gint16_modifier', gint16_modifier)
 glibconfig_conf.set_quoted('gint16_format', gint16_format)
 glibconfig_conf.set_quoted('guint16_format', guint16_format)
 
 if short_size == 4
-  gint32 = 'short'
   gint32_modifier='h'
   gint32_format='hi'
   guint32_format='hu'
   guint32_align = short_align
 elif int_size == 4
-  gint32 = 'int'
   gint32_modifier=''
   gint32_format='i'
   guint32_format='u'
   guint32_align = int_align
 elif long_size == 4
-  gint32 = 'long'
   gint32_modifier='l'
   gint32_format='li'
   guint32_format='lu'
@@ -1500,24 +1494,19 @@ elif long_size == 4
 else
   error('Compiler provides no native 32-bit integer type')
 endif
-glibconfig_conf.set('gint32', gint32)
 glibconfig_conf.set_quoted('gint32_modifier', gint32_modifier)
 glibconfig_conf.set_quoted('gint32_format', gint32_format)
 glibconfig_conf.set_quoted('guint32_format', guint32_format)
 glib_conf.set('ALIGNOF_GUINT32', guint32_align)
 
 if int_size == 8
-  gint64 = 'int'
   gint64_modifier=''
   gint64_format='i'
   guint64_format='u'
-  glib_extension=''
   gint64_constant='(val)'
   guint64_constant='(val)'
   guint64_align = int_align
 elif long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long')
-  gint64 = 'long'
-  glib_extension=''
   gint64_modifier='l'
   gint64_format='li'
   guint64_format='lu'
@@ -1525,8 +1514,6 @@ elif long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long
   guint64_constant='(val##UL)'
   guint64_align = long_align
 elif long_long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long long')
-  gint64 = 'long long'
-  glib_extension='G_GNUC_EXTENSION '
   gint64_modifier=int64_m
   gint64_format=int64_m + 'i'
   guint64_format=int64_m + 'u'
@@ -1536,8 +1523,6 @@ elif long_long_size == 8 and (long_long_size != long_size or int64_t_typedef ==
 else
   error('Compiler provides no native 64-bit integer type')
 endif
-glibconfig_conf.set('glib_extension', glib_extension)
-glibconfig_conf.set('gint64', gint64)
 glibconfig_conf.set_quoted('gint64_modifier', gint64_modifier)
 glibconfig_conf.set_quoted('gint64_format', gint64_format)
 glibconfig_conf.set_quoted('guint64_format', guint64_format)
@@ -1622,21 +1607,18 @@ else
 endif
 
 if voidp_size == int_size
-  glibconfig_conf.set('glib_intptr_type_define', 'int')
   glibconfig_conf.set_quoted('gintptr_modifier', '')
   glibconfig_conf.set_quoted('gintptr_format', 'i')
   glibconfig_conf.set_quoted('guintptr_format', 'u')
   glibconfig_conf.set('glib_gpi_cast', '(gint)')
   glibconfig_conf.set('glib_gpui_cast', '(guint)')
 elif voidp_size == long_size
-  glibconfig_conf.set('glib_intptr_type_define', 'long')
   glibconfig_conf.set_quoted('gintptr_modifier', 'l')
   glibconfig_conf.set_quoted('gintptr_format', 'li')
   glibconfig_conf.set_quoted('guintptr_format', 'lu')
   glibconfig_conf.set('glib_gpi_cast', '(glong)')
   glibconfig_conf.set('glib_gpui_cast', '(gulong)')
 elif voidp_size == long_long_size
-  glibconfig_conf.set('glib_intptr_type_define', 'long long')
   glibconfig_conf.set_quoted('gintptr_modifier', int64_m)
   glibconfig_conf.set_quoted('gintptr_format', int64_m + 'i')
   glibconfig_conf.set_quoted('guintptr_format', int64_m + 'u')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]