[glib] GBitLock: turn assumptions of g_futex_int_address into a static assertion



commit 1425aa664d5efa56d9e2cc29f8aa1292463e1f5a
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Tue Dec 6 11:35:02 2011 +0000

    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 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/glib/gbitlock.c b/glib/gbitlock.c
index 7674f9a..7b879be 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



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