23.09.2014, 15:18, Andres Freund kirjoitti:
On 2014-09-23 13:50:28 +0300, Oskari Saarenmaa wrote:
23.09.2014, 00:01, Andres Freund kirjoitti:
The patches:
0001: The actual atomics API


I tried building PG on Solaris 10/Sparc using GCC 4.9.0 (buildfarm animal
dingo) with this patch but regression tests failed due to:

Btw, if you could try sun studio it'd be great. I wrote the support for
it blindly, and I'd be surprised if I got it right on the first try.

I just installed Solaris Studio 12.3 and tried compiling this:

"../../../../src/include/port/atomics/generic-sunpro.h", line 54: return value type mismatch "../../../../src/include/port/atomics/generic-sunpro.h", line 77: return value type mismatch "../../../../src/include/port/atomics/generic-sunpro.h", line 79: #if-less #endif "../../../../src/include/port/atomics/generic-sunpro.h", line 81: #if-less #endif

atomic_add_64 and atomic_add_32 don't return anything (the atomic_add_*_nv variants return the new value) and there were a few extra #endifs. Regression tests pass after applying the attached patch which defines PG_HAS_ATOMIC_ADD_FETCH_U32.

There doesn't seem to be a fallback for defining pg_atomic_fetch_add based on pg_atomic_add_fetch so pg_atomic_add_fetch now gets implemented using pg_atomic_compare_exchange.

Also, it's not possible to compile PG with FORCE_ATOMICS_BASED_SPINLOCKS with these patches:

"../../../../src/include/storage/s_lock.h", line 868: #error: PostgreSQL does not have native spinlock support on this platform....

atomics/generic.h would implement atomic flags using operations exposed by atomics/generic-sunpro.h, but atomics/fallback.h is included before it and it defines functions for flag operations which s_lock.h doesn't want to use.

/ Oskari
>From 42a5bbbab0c8f42c6014ebe12c9963b371168866 Mon Sep 17 00:00:00 2001
From: Oskari Saarenmaa <o...@ohmu.fi>
Date: Tue, 23 Sep 2014 23:53:46 +0300
Subject: [PATCH] atomics: fix atomic add for sunpro and drop invalid #endifs

Solaris Studio compiler has an atomic add operation that returns the new
value, the one with no _nv suffix doesn't return anything.
---
 src/include/port/atomics/generic-sunpro.h | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/include/port/atomics/generic-sunpro.h b/src/include/port/atomics/generic-sunpro.h
index 10ac70d..fedc099 100644
--- a/src/include/port/atomics/generic-sunpro.h
+++ b/src/include/port/atomics/generic-sunpro.h
@@ -47,14 +47,12 @@ pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr,
 	return ret;
 }
 
-#define PG_HAS_ATOMIC_FETCH_ADD_U32
+#define PG_HAS_ATOMIC_ADD_FETCH_U32
 STATIC_IF_INLINE uint32
-pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
+pg_atomic_add_fetch_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
 {
-	return atomic_add_32(&ptr->value, add_);
+	return atomic_add_32_nv(&ptr->value, add_);
 }
-#endif
-
 
 #define PG_HAS_ATOMIC_COMPARE_EXCHANGE_U64
 static inline bool
@@ -70,12 +68,11 @@ pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
 	return ret;
 }
 
-#define PG_HAS_ATOMIC_FETCH_ADD_U64
+#define PG_HAS_ATOMIC_ADD_FETCH_U64
 STATIC_IF_INLINE uint64
-pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
+pg_atomic_add_fetch_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
 {
-	return atomic_add_64(&ptr->value, add_);
+	return atomic_add_64_nv(&ptr->value, add_);
 }
-#endif
 
 #endif
-- 
1.8.4.1

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to