]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: atomic.c (BIT_OFFSET): Define.
authorWalter Lee <walt@tilera.com>
Sat, 25 Jan 2014 22:48:44 +0000 (22:48 +0000)
committerWalter Lee <walt@gcc.gnu.org>
Sat, 25 Jan 2014 22:48:44 +0000 (22:48 +0000)
2014-01-25  Walter Lee  <walt@tilera.com>

            Backport from mainline
            2014-01-25  Walter Lee  <walt@tilera.com>

            * config/tilepro/atomic.c (BIT_OFFSET): Define.
            (__atomic_subword_cmpxchg): Use BIT_OFFSET.
            (__atomic_subword): Ditto.

From-SVN: r207106

libgcc/ChangeLog
libgcc/config/tilepro/atomic.c

index fe85a23ba1209d41a9d85eaf3af8171b624b0e1c..f5db8569544a3cee6474b803b0d3d7e2c824de30 100644 (file)
@@ -1,3 +1,12 @@
+2014-01-25  Walter Lee  <walt@tilera.com>
+
+       Backport from mainline
+       2014-01-25  Walter Lee  <walt@tilera.com>
+
+       * config/tilepro/atomic.c (BIT_OFFSET): Define.
+       (__atomic_subword_cmpxchg): Use BIT_OFFSET.
+       (__atomic_subword): Ditto.
+
 2014-01-25  Walter Lee  <walt@tilera.com>
 
        Backport from mainline
index 3e1edd3946a4c5989cd4d9f4146aafa9749139c2..7188962ae778a5be83fafd21ed55be322f31241a 100644 (file)
@@ -135,6 +135,12 @@ __atomic_exchange_##size(volatile type* ptr, type val, int model)  \
 __atomic_exchange_methods (int, 4)
 __atomic_exchange_methods (long long, 8)
 
+#ifdef __LITTLE_ENDIAN__
+#define BIT_OFFSET(n, type) ((n) * 8)
+#else
+#define BIT_OFFSET(n, type) ((4 - sizeof(type) - (n)) * 8)
+#endif
+
 /* Subword methods require the same approach for both TILEPro and
    TILE-Gx.  We load the background data for the word, insert the
    desired subword piece, then compare-and-exchange it into place.  */
@@ -150,7 +156,7 @@ __atomic_compare_exchange_##size(volatile type* ptr, type* guess,   \
 {                                                                      \
   pre_atomic_barrier(models);                                          \
   unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL);       \
-  const int shift = ((unsigned long)ptr & 3UL) * 8;                    \
+  const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type);                \
   const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1;          \
   const unsigned int bgmask = ~(valmask << shift);                     \
   unsigned int oldword = *p;                                           \
@@ -177,7 +183,7 @@ proto                                                                       \
 {                                                                      \
   top                                                                  \
   unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL);       \
-  const int shift = ((unsigned long)ptr & 3UL) * 8;                    \
+  const int shift = BIT_OFFSET((unsigned long)ptr & 3UL, type);                \
   const unsigned int valmask = (1 << (sizeof(type) * 8)) - 1;          \
   const unsigned int bgmask = ~(valmask << shift);                     \
   unsigned int oldword, xword = *p;                                    \