[PATCH] Address regressions from e8ff555b95baab66cc7d060c1e7f9fdd49d3802f
Jeremy Huddleston
jeremyhu at apple.com
Thu Sep 22 19:06:16 PDT 2011
The error attribute appeared in gcc-4.3
The return type of __builtin_constant_p is int
Found by Tinderbox.
Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
include/misc.h | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/misc.h b/include/misc.h
index 1fea73e..0dfffec 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -261,18 +261,23 @@ version_compare(uint16_t a_major, uint16_t a_minor,
#define SwapRestL(stuff) \
SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
-#ifdef __GNUC__
+#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
void __attribute__((error("wrong sized variable passed to swap"))) wrong_size(void);
#else
static inline void wrong_size(void)
{
}
+#endif
-static inline void __builtin_constant_p(int x)
+static inline int constant_p(int x)
{
+/* Does this need versioned guards? */
+#ifdef __GNUC__
+ return __builtin_constant_p(x);
+#else
return 0;
-}
#endif
+}
/* byte swap a 32-bit value */
static inline void swap_uint32(uint32_t *x)
@@ -288,7 +293,7 @@ static inline void swap_uint32(uint32_t *x)
#define swapl(x) do { \
if (sizeof(*(x)) != 4) \
wrong_size(); \
- if (__builtin_constant_p((uintptr_t)(x) & 3) && ((uintptr_t)(x) & 3) == 0) \
+ if (constant_p((uintptr_t)(x) & 3) && ((uintptr_t)(x) & 3) == 0) \
*(x) = lswapl(*(x)); \
else \
swap_uint32((uint32_t *)(x)); \
@@ -305,7 +310,7 @@ static inline void swap_uint16(uint16_t *x)
#define swaps(x) do { \
if (sizeof(*(x)) != 2) \
wrong_size(); \
- if (__builtin_constant_p((uintptr_t)(x) & 1) && ((uintptr_t)(x) & 1) == 0) \
+ if (constant_p((uintptr_t)(x) & 1) && ((uintptr_t)(x) & 1) == 0) \
*(x) = lswaps(*(x)); \
else \
swap_uint16((uint16_t *)(x)); \
--
1.7.6.1
More information about the xorg-devel
mailing list