1818
1919#if defined(HAVE_ATOMICS )
2020
21- #include <atomic.h>
22-
2321#define PG_HAVE_ATOMIC_U32_SUPPORT
2422typedef struct pg_atomic_uint32
2523{
@@ -48,9 +46,6 @@ static inline bool
4846pg_atomic_compare_exchange_u32_impl (volatile pg_atomic_uint32 * ptr ,
4947 uint32 * expected , uint32 newval )
5048{
51- bool ret ;
52- uint64 current ;
53-
5449 /*
5550 * xlc's documentation tells us:
5651 * "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,
6257 * XXX: __compare_and_swap is defined to take signed parameters, but that
6358 * shouldn't matter since we don't perform any arithmetic operations.
6459 */
65- current = (uint32 )__compare_and_swap ((volatile int * )ptr -> value ,
66- (int )* expected , (int )newval );
67- ret = current == * expected ;
68- * expected = current ;
69- return ret ;
60+ return __compare_and_swap ((volatile int * )& ptr -> value ,
61+ (int * )expected , (int )newval );
7062}
7163
7264#define PG_HAVE_ATOMIC_FETCH_ADD_U32
7365static inline uint32
7466pg_atomic_fetch_add_u32_impl (volatile pg_atomic_uint32 * ptr , int32 add_ )
7567{
76- return __fetch_and_add (& ptr -> value , add_ );
68+ return __fetch_and_add (( volatile int * ) & ptr -> value , add_ );
7769}
7870
7971#ifdef PG_HAVE_ATOMIC_U64_SUPPORT
@@ -83,23 +75,17 @@ static inline bool
8375pg_atomic_compare_exchange_u64_impl (volatile pg_atomic_uint64 * ptr ,
8476 uint64 * expected , uint64 newval )
8577{
86- bool ret ;
87- uint64 current ;
88-
8978 __isync ();
9079
91- current = (uint64 )__compare_and_swaplp ((volatile long * )ptr -> value ,
92- (long )* expected , (long )newval );
93- ret = current == * expected ;
94- * expected = current ;
95- return ret ;
80+ return __compare_and_swaplp ((volatile long * )& ptr -> value ,
81+ (long * )expected , (long )newval );;
9682}
9783
9884#define PG_HAVE_ATOMIC_FETCH_ADD_U64
9985static inline uint64
10086pg_atomic_fetch_add_u64_impl (volatile pg_atomic_uint64 * ptr , int64 add_ )
10187{
102- return __fetch_and_addlp (& ptr -> value , add_ );
88+ return __fetch_and_addlp (( volatile long * ) & ptr -> value , add_ );
10389}
10490
10591#endif /* PG_HAVE_ATOMIC_U64_SUPPORT */
0 commit comments