Merge branch 'wip/smcv/gsize-is-guintptr-for-now' into 'main'

Add a (temporary) assertion that sizeof(gsize) == sizeof(guintptr)

See merge request GNOME/glib!3262
This commit is contained in:
Simon McVittie 2023-02-10 13:17:36 +00:00
commit 6631e6dc1f

View File

@ -126,7 +126,18 @@ G_STATIC_ASSERT (G_ALIGNOF (gssize) == G_ALIGNOF (size_t));
* However, we do not assume that GPOINTER_TO_SIZE can store an arbitrary
* pointer in a gsize (known to be false on CHERI). */
G_STATIC_ASSERT (sizeof (size_t) <= sizeof (void *));
/* Standard C does not guarantee that size_t is the same as uintptr_t,
* but GLib currently assumes they are the same: see
* <https://gitlab.gnome.org/GNOME/glib/-/issues/2842>.
*
* To enable working on bringup for new architectures these assertions
* can be disabled with -DG_ENABLE_EXPERIMENTAL_ABI_COMPILATION.
*
* FIXME: remove these assertions once the API/ABI has stabilized. */
#ifndef G_ENABLE_EXPERIMENTAL_ABI_COMPILATION
G_STATIC_ASSERT (sizeof (size_t) == sizeof (uintptr_t));
G_STATIC_ASSERT (G_ALIGNOF (size_t) == G_ALIGNOF (uintptr_t));
#endif
/* goffset is always 64-bit, even if off_t is only 32-bit
* (compiling without large-file-support on 32-bit) */
G_STATIC_ASSERT (sizeof (goffset) == sizeof (gint64));