Commit Graph

11 Commits

Author SHA1 Message Date
Rich Felker 867b1822f3 add explicit barrier operation to internal atomic.h API 2014-10-10 18:17:09 -04:00
Rich Felker ea818ea834 add working a_spin() atomic for non-x86 targets
conceptually, a_spin needs to be at least a compiler barrier, so the
compiler will not optimize out loops (and the load on each iteration)
while spinning. it should also be a memory barrier, or the spinning
thread might keep spinning without noticing stores from other threads,
thus delaying for longer than it should.

ideally, an optimal a_spin implementation that avoids unnecessary
cache/memory contention should be chosen for each arch, but for now,
the easiest thing is to perform a useless a_cas on the calling
thread's stack.
2014-08-25 15:43:40 -04:00
Rich Felker 90e51e45f5 clean up unused and inconsistent atomics in arch dirs
the a_cas_l, a_swap_l, a_swap_p, and a_store_l operations were
probably used a long time ago when only i386 and x86_64 were
supported. as other archs were added, support for them was
inconsistent, and they are obviously not in use at present. having
them around potentially confuses readers working on new ports, and the
type-punning hacks and inconsistent use of types in their definitions
is not a style I wish to perpetuate in the source tree, so removing
them seems appropriate.
2014-07-27 21:50:24 -04:00
Rich Felker 522a0de210 fix missing barriers in powerpc atomic store 2014-07-19 18:34:10 -04:00
Rich Felker 1456b7ae6b fix missing barrier instructions in powerpc atomic asm 2014-07-19 15:57:48 -04:00
Rich Felker bb3a3befea fix build breakage from ppc asm constraints change
due to a mistake in my testing procedure, the changes in the previous
commit were not correctly tested and wrongly assumed to be valid. the
lwarx and stwcx. instructions do not accept general ppc memory address
expressions and thus the argument associated with the memory
constraint cannot be used directly.

instead, the memory constraint can be left as an argument that the asm
does not actually use, and the address can be provided in a separate
register constraint.
2014-07-19 13:43:46 -04:00
Rich Felker 7fdae458bd fix broken constraints for powerpc atomic cas asm
the register constraint for the address to be accessed did not convey
that the asm can access the pointed-to object. as far as the compiler
could tell, the result of the asm was just a pure function of the
address and the values passed in, and thus the asm could be hoisted
out of loops or omitted entirely if the result was not used.
2014-07-19 12:19:20 -04:00
Rich Felker 7568ee4cbf add missing a_or_l to atomic.h for non-x86 archs
this is needed for recently committed sigaction code
2013-08-11 03:43:25 -04:00
Rich Felker e7257d3e63 fix powerpc atomic compare-and-swap function
previous version did not compare at all; it was just a fancy atomic
write. untested. further atomic fixes may be needed.
2012-11-14 14:24:22 -05:00
Rich Felker 574d01a696 update ppc atomic code to match the endian-agnostic version on other archs 2012-11-14 14:08:33 -05:00
rofl0r 1c8eb8bad7 PPC port cleaned up, static linking works well now. 2012-11-13 19:12:25 +01:00