On Wed, Jun 25, 2014 at 07:14:34PM +0200, Andres Freund wrote:
> * gcc, msvc work. acc, xlc, sunpro have blindly written support which
> should be relatively easy to fix up.
I tried this on three xlc configurations.
(1) "IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72)". Getting it working
required the attached patch. None of my xlc configurations have an <atomic.h>
header, and a web search turned up no evidence of one in connection with xlc
platforms. Did you learn of a configuration needing atomic.h under xlc? The
rest of the changes are hopefully self-explanatory in light of the
documentation cited in generic-xlc.h. (Building on AIX has regressed in other
ways unrelated to atomics; I will write more about that in due course.)
(2) "IBM XL C/C++ for Linux, V13.1.2 (5725-C73, 5765-J08)" for ppc64le,
http://www-01.ibm.com/support/docview.wss?uid=swg27044056&aid=1. This
compiler has a Clang-derived C frontend. It defines __GNUC__ and offers
GCC-style __sync_* atomics. Therefore, PostgreSQL selects generic-gcc.h.
test_atomic_ops() fails because __sync_lock_test_and_set() of one-byte types
segfaults at runtime. I have reported this to the vendor. Adding
"pgac_cv_gcc_sync_char_tas=no" to the "configure" invocation is a good
workaround. I could add a comment about that to src/test/regress/sql/lock.sql
for affected folks to see in regression.diffs. To do better, we could make
PGAC_HAVE_GCC__SYNC_CHAR_TAS perform a runtime test where possible. Yet
another option is to force use of generic-xlc.h on this compiler.
(3) "IBM XL C/C++ for Linux, V13.1.2 (5725-C73, 5765-J08)" for ppc64le,
modifying atomics.h to force use of generic-xlc.h. While not a supported
PostgreSQL configuration, I felt this would make an interesting data point.
It worked fine after applying the patch developed for the AIX configuration.
Thanks,
nm
diff --git a/src/include/port/atomics/generic-xlc.h
b/src/include/port/atomics/generic-xlc.h
index 1c743f2..0ad9168 100644
--- a/src/include/port/atomics/generic-xlc.h
+++ b/src/include/port/atomics/generic-xlc.h
@@ -18,8 +18,6 @@
#if defined(HAVE_ATOMICS)
-#include <atomic.h>
-
#define PG_HAVE_ATOMIC_U32_SUPPORT
typedef struct pg_atomic_uint32
{
@@ -48,9 +46,6 @@ static inline bool
pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr,
uint32
*expected, uint32 newval)
{
- bool ret;
- uint64 current;
-
/*
* xlc's documentation tells us:
* "If __compare_and_swap is used as a locking primitive, insert a call
to
@@ -62,18 +57,15 @@ pg_atomic_compare_exchange_u32_impl(volatile
pg_atomic_uint32 *ptr,
* XXX: __compare_and_swap is defined to take signed parameters, but
that
* shouldn't matter since we don't perform any arithmetic operations.
*/
- current = (uint32)__compare_and_swap((volatile int*)ptr->value,
-
(int)*expected, (int)newval);
- ret = current == *expected;
- *expected = current;
- return ret;
+ return __compare_and_swap((volatile int*)&ptr->value,
+ (int *)expected,
(int)newval);
}
#define PG_HAVE_ATOMIC_FETCH_ADD_U32
static inline uint32
pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
{
- return __fetch_and_add(&ptr->value, add_);
+ return __fetch_and_add((volatile int *)&ptr->value, add_);
}
#ifdef PG_HAVE_ATOMIC_U64_SUPPORT
@@ -83,23 +75,17 @@ static inline bool
pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
uint64
*expected, uint64 newval)
{
- bool ret;
- uint64 current;
-
__isync();
- current = (uint64)__compare_and_swaplp((volatile long*)ptr->value,
-
(long)*expected, (long)newval);
- ret = current == *expected;
- *expected = current;
- return ret;
+ return __compare_and_swaplp((volatile long*)&ptr->value,
+ (long
*)expected, (long)newval);;
}
#define PG_HAVE_ATOMIC_FETCH_ADD_U64
static inline uint64
pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
{
- return __fetch_and_addlp(&ptr->value, add_);
+ return __fetch_and_addlp((volatile long *)&ptr->value, add_);
}
#endif /* PG_HAVE_ATOMIC_U64_SUPPORT */
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers