summaryrefslogtreecommitdiff
path: root/arch/i386/atomic.h
AgeCommit message (Collapse)AuthorLines
2016-01-21refactor internal atomic.hRich Felker-110/+0
rather than having each arch provide its own atomic.h, there is a new shared atomic.h in src/internal which pulls arch-specific definitions from arc/$(ARCH)/atomic_arch.h. the latter can be extremely minimal, defining only a_cas or new ll/sc type primitives which the shared atomic.h will use to construct everything else. this commit avoids making heavy changes to the individual archs' atomic implementations. definitions which are identical or near-identical to what the new shared atomic.h would produce have been removed, but otherwise the changes made are just hooking up the arch-specific files to the new infrastructure. major changes to take advantage of the new system will come in subsequent commits.
2015-09-09fix missing earlyclobber flag in i386 a_ctz_64 asmRich Felker-1/+1
this error was only found by reading the code, but it seems to have been causing gcc to produce wrong code in malloc: the same register was used for the output and the high word of the input. in principle this could have caused an infinite loop searching for an available bin, but in practice most x86 models seem to implement the "undefined" result of the bsf instruction as "unchanged".
2015-07-28fix missing synchronization in atomic store on i386 and x86_64Rich Felker-1/+1
despite being strongly ordered, the x86 memory model does not preclude reordering of loads across earlier stores. while a plain store suffices as a release barrier, we actually need a full barrier, since users of a_store subsequently load a waiter count to determine whether to issue a futex wait, and using a stale count will result in soft (fail-to-wake) deadlocks. these deadlocks were observed in malloc and possible with stdio locks and other libc-internal locking. on i386, an atomic operation on the caller's stack is used as the barrier rather than performing the store itself using xchg; this avoids the need to read the cache line on which the store is being performed. mfence is used on x86_64 where it's always available, and could be used on i386 with the appropriate cpu model checks if it's shown to perform better.
2015-05-20fix inconsistency in a_and and a_or argument types on x86[_64]Rich Felker-4/+4
conceptually, and on other archs, these functions take a pointer to int, but in the i386, x86_64, and x32 versions of atomic.h, they took a pointer to void instead.
2014-10-10add explicit barrier operation to internal atomic.h APIRich Felker-0/+5
2014-07-27clean up unused and inconsistent atomics in arch dirsRich Felker-23/+0
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.
2011-08-23security hardening: ensure suid programs have valid stdin/out/errRich Felker-0/+5
this behavior (opening fds 0-2 for a suid program) is explicitly allowed (but not required) by POSIX to protect badly-written suid programs from clobbering files they later open. this commit does add some cost in startup code, but the availability of auxv and the security flag will be useful elsewhere in the future. in particular auxv is needed for static-linked vdso support, which is still waiting to be committed (sorry nik!)
2011-04-27add word-sized ctz function to atomic.hRich Felker-2/+8
strictly speaking this and a few other ops should be factored into asm.h or the file should just be renamed to asm.h, but whatever. clean it up someday.
2011-03-17optimize contended normal mutex case; add int compare-and-swap atomicRich Felker-0/+7
2011-02-15move arch-specific internal headers into placeRich Felker-0/+110