Commit 4d6d3bc5 by Walter Lee Committed by Walter Lee

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
parent cbd9890e
2014-01-25 Walter Lee <walt@tilera.com> 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>
* config/tilepro/atomic.c (__atomic_do_and_fetch): Add * config/tilepro/atomic.c (__atomic_do_and_fetch): Add
a prefix op argument. a prefix op argument.
(__atomic_nand_fetch_4): Add prefix op. (__atomic_nand_fetch_4): Add prefix op.
......
...@@ -135,6 +135,12 @@ __atomic_exchange_##size(volatile type* ptr, type val, int model) \ ...@@ -135,6 +135,12 @@ __atomic_exchange_##size(volatile type* ptr, type val, int model) \
__atomic_exchange_methods (int, 4) __atomic_exchange_methods (int, 4)
__atomic_exchange_methods (long long, 8) __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 /* Subword methods require the same approach for both TILEPro and
TILE-Gx. We load the background data for the word, insert the TILE-Gx. We load the background data for the word, insert the
desired subword piece, then compare-and-exchange it into place. */ desired subword piece, then compare-and-exchange it into place. */
...@@ -150,7 +156,7 @@ __atomic_compare_exchange_##size(volatile type* ptr, type* guess, \ ...@@ -150,7 +156,7 @@ __atomic_compare_exchange_##size(volatile type* ptr, type* guess, \
{ \ { \
pre_atomic_barrier(models); \ pre_atomic_barrier(models); \
unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ 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 valmask = (1 << (sizeof(type) * 8)) - 1; \
const unsigned int bgmask = ~(valmask << shift); \ const unsigned int bgmask = ~(valmask << shift); \
unsigned int oldword = *p; \ unsigned int oldword = *p; \
...@@ -177,7 +183,7 @@ proto \ ...@@ -177,7 +183,7 @@ proto \
{ \ { \
top \ top \
unsigned int *p = (unsigned int *)((unsigned long)ptr & ~3UL); \ 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 valmask = (1 << (sizeof(type) * 8)) - 1; \
const unsigned int bgmask = ~(valmask << shift); \ const unsigned int bgmask = ~(valmask << shift); \
unsigned int oldword, xword = *p; \ unsigned int oldword, xword = *p; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment