Avoid misaligned atomic operations

Andrew Waterman <waterman@cs.berkeley.edu>

 * fop_n.c (libat_fetch_op): Align address to word boundary.
 (libat_op_fetch): Likewise.

From-SVN: r219954
This commit is contained in:
Andrew Waterman 2015-01-21 17:17:03 +00:00 committed by Richard Henderson
parent f81f49c180
commit 122a5d603b
2 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2015-01-21 Andrew Waterman <waterman@cs.berkeley.edu>
* fop_n.c (libat_fetch_op): Align address to word boundary.
(libat_op_fetch): Likewise.
2015-01-16 Ilya Verbin <ilya.verbin@intel.com>
PR testsuite/64605

View File

@ -112,9 +112,9 @@ SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel)
pre_barrier (smodel);
wptr = (UWORD *)mptr;
shift = 0;
mask = -1;
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
mask = SIZE(MASK) << shift;
wopval = (UWORD)opval << shift;
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
@ -136,9 +136,9 @@ SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
pre_barrier (smodel);
wptr = (UWORD *)mptr;
shift = 0;
mask = -1;
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
mask = SIZE(MASK) << shift;
wopval = (UWORD)opval << shift;
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);