[libatomic PATCH] Fix libatomic behavior for big endian toolchain
Shiva Chen
shiva0217@gmail.com
Fri Oct 17 16:36:00 GMT 2014
Hi, Joseph
I have been modify the patch as your suggestion
use # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
in architecture-independent files
Is it ok for trunk ?
And I don't have svn write access
Could you help me to commit this patch?
Shiva
2014-10-17 23:41 GMT+08:00 Joseph S. Myers <joseph@codesourcery.com>:
> Changes to architecture-independent files must use
> architecture-independent conditionals, so __BYTE_ORDER__ not __ARMEB__.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
-------------- next part --------------
diff --git a/libatomic/cas_n.c b/libatomic/cas_n.c
index 801262d..5b5b8d7 100644
--- a/libatomic/cas_n.c
+++ b/libatomic/cas_n.c
@@ -60,7 +60,11 @@ SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
if (N < WORDSIZE)
{
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
- shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ shift = ((WORDSIZE - N - ((uintptr_t)mptr % WORDSIZE)) * CHAR_BIT);
+#else
+ shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT);
+#endif
mask = SIZE(MASK) << shift;
}
else
diff --git a/libatomic/config/arm/exch_n.c b/libatomic/config/arm/exch_n.c
index c90d57f..0d71c5a 100644
--- a/libatomic/config/arm/exch_n.c
+++ b/libatomic/config/arm/exch_n.c
@@ -88,7 +88,11 @@ SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
__atomic_thread_fence (__ATOMIC_SEQ_CST);
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
- shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ INVERT_MASK_1;
+#ifdef __ARMEB__
+ shift = ((WORDSIZE - N - ((uintptr_t)mptr % WORDSIZE)) * CHAR_BIT);
+#else
+ shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT);
+#endif
mask = MASK_1 << shift;
wnewval = newval << shift;
diff --git a/libatomic/exch_n.c b/libatomic/exch_n.c
index 23558b0..4418f1f 100644
--- a/libatomic/exch_n.c
+++ b/libatomic/exch_n.c
@@ -77,7 +77,11 @@ SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
if (N < WORDSIZE)
{
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
- shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ shift = ((WORDSIZE - N - ((uintptr_t)mptr % WORDSIZE)) * CHAR_BIT);
+#else
+ shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT);
+#endif
mask = SIZE(MASK) << shift;
}
else
diff --git a/libatomic/fop_n.c b/libatomic/fop_n.c
index 4a18da9..5d26cde 100644
--- a/libatomic/fop_n.c
+++ b/libatomic/fop_n.c
@@ -113,7 +113,11 @@ SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel)
pre_barrier (smodel);
wptr = (UWORD *)mptr;
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ shift = (WORDSIZE - N) * CHAR_BIT;
+#else
shift = 0;
+#endif
mask = -1;
wopval = (UWORD)opval << shift;
@@ -137,7 +141,11 @@ SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
pre_barrier (smodel);
wptr = (UWORD *)mptr;
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ shift = (WORDSIZE - N) * CHAR_BIT;
+#else
shift = 0;
+#endif
mask = -1;
wopval = (UWORD)opval << shift;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Changelog
Type: application/octet-stream
Size: 367 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141017/5ba5c4b1/attachment.obj>
More information about the Gcc-patches
mailing list