aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config/tilepro
diff options
context:
space:
mode:
authorWalter Lee <walt@tilera.com>2014-01-25 20:34:42 +0000
committerWalter Lee <walt@gcc.gnu.org>2014-01-25 20:34:42 +0000
commit4d6d3bc532e4b1b43f2a57aff835c416b462200d (patch)
treebba32f344440956223bb4a7466b46da1d1dc6adf /libgcc/config/tilepro
parentcbd9890e93bc95ef213702cb65c65836dfea2381 (diff)
downloadgcc-4d6d3bc532e4b1b43f2a57aff835c416b462200d.zip
gcc-4d6d3bc532e4b1b43f2a57aff835c416b462200d.tar.gz
gcc-4d6d3bc532e4b1b43f2a57aff835c416b462200d.tar.bz2
atomic.c (BIT_OFFSET): Define.
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: r207086
Diffstat (limited to 'libgcc/config/tilepro')
-rw-r--r--libgcc/config/tilepro/atomic.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libgcc/config/tilepro/atomic.c b/libgcc/config/tilepro/atomic.c
index 9919323..2ad114a 100644
--- a/libgcc/config/tilepro/atomic.c
+++ b/libgcc/config/tilepro/atomic.c
@@ -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; \