mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-02 15:46:17 +01:00
glib-init: make static assertions about platform assumptions
GLib has a pervasive assumption that function and data pointers are basically interchangeable, which is true in all modern ABIs, but not actually guaranteed by ISO C. If someone tries to use GLib on a platform where function and data pointers are different sizes, fail early. https://bugzilla.gnome.org/show_bug.cgi?id=688406
This commit is contained in:
parent
a4480d5f71
commit
84f3147f43
@ -23,6 +23,8 @@
|
||||
|
||||
#include "glib-init.h"
|
||||
|
||||
#include "glib-private.h"
|
||||
#include "gtypes.h"
|
||||
#include "gutils.h" /* for GDebugKey */
|
||||
#include "gconstructor.h"
|
||||
#include "gmem.h" /* for g_mem_gc_friendly */
|
||||
@ -32,6 +34,16 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* This seems as good a place as any to make static assertions about platform
|
||||
* assumptions we make throughout GLib. */
|
||||
|
||||
/* We assume that data pointers are the same size as function pointers... */
|
||||
G_STATIC_ASSERT (sizeof (gpointer) == sizeof (GFunc));
|
||||
G_STATIC_ASSERT (_g_alignof (gpointer) == _g_alignof (GFunc));
|
||||
/* ... and that all function pointers are the same size. */
|
||||
G_STATIC_ASSERT (sizeof (GFunc) == sizeof (GCompareDataFunc));
|
||||
G_STATIC_ASSERT (_g_alignof (GFunc) == _g_alignof (GCompareDataFunc));
|
||||
|
||||
/**
|
||||
* g_mem_gc_friendly:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user