gnome-games r7292 - trunk/libgames-support



Author: chpe
Date: Tue Jan 29 20:49:27 2008
New Revision: 7292
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7292&view=rev

Log:
2008-01-29  Christian Persch  <chpe gnome org>

	* games-card.h: Use __attribute__((__packed__)) for the Card struct.
	Bug #512799.

Modified:
   trunk/libgames-support/ChangeLog
   trunk/libgames-support/games-card.h

Modified: trunk/libgames-support/games-card.h
==============================================================================
--- trunk/libgames-support/games-card.h	(original)
+++ trunk/libgames-support/games-card.h	Tue Jan 29 20:49:27 2008
@@ -27,6 +27,16 @@
 
 G_BEGIN_DECLS
 
+/* __attribute__((__packed__)) is needed on some archs to make
+ * the Card type below fit into one byte. See bug #512799.
+ */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6)
+#define GNOME_GAMES_GNUC_PACKED \
+  __attribute__((__packed__))
+#else
+#define GNOME_GAMES_GNUC_PACKED
+#endif  /* !__GNUC__ */
+
 /* A card */
 
 /* Black Joker: value = 0, suit = spade or club
@@ -38,8 +48,8 @@
     guint8 face_down : 1;
     guint8 suit : 2;
     guint8 rank : 4;
-  } attr;
-} Card;
+  } GNOME_GAMES_GNUC_PACKED attr;
+} GNOME_GAMES_GNUC_PACKED Card;
 
 typedef int _games_card_size_assert[sizeof (Card) == sizeof (guint8) ? 1 : -1]; /* static assertion */
 
@@ -49,7 +59,6 @@
 #define CARD_GET_SUIT(c)      (c.attr.suit)
 #define CARD_GET_RANK(c)      (c.attr.rank)
 #define CARD_GET_FACE_DOWN(c) (c.attr.face_down)
-#define CARD_FACE_UP(c)       (!CARD_FACE_DOWN(c))
 
 #define POINTER_TO_CARD(ptr)  ((Card) (guint8) GPOINTER_TO_UINT (ptr))
 #define CARD_TO_POINTER(card) (GUINT_TO_POINTER((guint) card.value))



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