From 1425aa664d5efa56d9e2cc29f8aa1292463e1f5a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 6 Dec 2011 11:35:02 +0000 Subject: [PATCH] GBitLock: turn assumptions of g_futex_int_address into a static assertion We'll probably never encounter a platform where these fail, but that's what static assertions are for... https://bugzilla.gnome.org/show_bug.cgi?id=548954 --- glib/gbitlock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/glib/gbitlock.c b/glib/gbitlock.c index 7674f9a31..7b879be21 100644 --- a/glib/gbitlock.c +++ b/glib/gbitlock.c @@ -366,6 +366,12 @@ g_futex_int_address (const volatile void *address) { const volatile gint *int_address = address; + /* this implementation makes these (reasonable) assumptions: */ + G_STATIC_ASSERT (G_BYTE_ORDER == G_LITTLE_ENDIAN || + (G_BYTE_ORDER == G_BIG_ENDIAN && + sizeof (int) == 4 && + (sizeof (gpointer) == 4 || sizeof (gpointer) == 8))); + #if G_BYTE_ORDER == G_BIG_ENDIAN && GLIB_SIZEOF_VOID_P == 8 int_address++; #endif