Hi,
[sorry for the second copy Robert]
Attached is a new version of the atomic operations patch. Lots has
changed since the last post:
* gcc, msvc work. acc, xlc, sunpro have blindly written support which
should be relatively easy to fix up. All try to implement TAS, 32 bit
atomic add, 32 bit compare exchange; some do it for 64bit as well.
* x86 gcc inline assembly means that we support every gcc version on x86
>= i486; even when the __sync APIs aren't available yet.
* 'inline' support isn't required anymore. We fall back to
ATOMICS_INCLUDE_DEFINITIONS/STATIC_IF_INLINE etc. trickery.
* When the current platform doesn't have support for atomic operations a
spinlock backed implementation is used. This can be forced using
--disable-atomics.
That even works when semaphores are used to implement spinlocks (a
separate array is used there to avoid nesting problems). It contrast
to an earlier implementation this even works when atomics are mapped
to different addresses in individual processes (think dsm).
* s_lock.h falls back to the atomics.h provided APIs iff it doesn't have
native support for the current platform. This can be forced by
defining USE_ATOMICS_BASED_SPINLOCKS. Due to generic compiler
intrinsics based implementations that should make it easier to bring
up postgres on different platfomrs.
* I tried to improve the documentation of the facilities in
src/include/storage/atomics.h. Including documentation of the various
barrier semantics.
* There's tests in regress.c that get call via a SQL function from the
regression tests.
* Lots of other details changed, but that's the major pieces.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services