gdk: Codify the requirement that gsize is pointer-sized
This is widely assumed, but is not guaranteed by Standard C, and is known to be false on CHERI architectures (which have 64-bit sizes and 128-bit tagged pointers). Add a static assertion to ensure that GTK will not build on platforms where this assumption does not hold. As discussed on GNOME/gtk!7510, if GTK switches from gsize to uintptr_t as its representation of the underlying bits in a pointer, GTK maintainers would prefer that to be done project-wide so that it's done consistently, after which this static assertion could be removed. At the time of writing, GLib makes the same assumption (GNOME/glib#2842), but GLib contributors are gradually removing it (mostly by replacing gsize with uintptr_t where a pointer-sized quantity is needed). Finishing that work in GLib would be a prerequisite for being able to make GTK work on the affected platforms. Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
@@ -43,6 +43,14 @@
|
||||
|
||||
#include <fribidi.h>
|
||||
|
||||
/* GTK has a general architectural assumption that gsize is pointer-sized
|
||||
* (equivalent to uintptr_t), making it non-portable to architectures like
|
||||
* CHERI where that isn't true. If a future release relaxes that
|
||||
* assumption, changes will be needed in numerous places.
|
||||
* See also https://gitlab.gnome.org/GNOME/glib/-/issues/2842 for the
|
||||
* equivalent in GLib, which would be a prerequisite. */
|
||||
G_STATIC_ASSERT (sizeof (gsize) == sizeof (void *));
|
||||
G_STATIC_ASSERT (G_ALIGNOF (gsize) == G_ALIGNOF (void *));
|
||||
|
||||
/**
|
||||
* GDK_WINDOWING_X11:
|
||||
|
||||
Reference in New Issue
Block a user