18
18
19
19
#if defined(HAVE_ATOMICS )
20
20
21
- #include <atomic.h>
22
-
23
21
#define PG_HAVE_ATOMIC_U32_SUPPORT
24
22
typedef struct pg_atomic_uint32
25
23
{
@@ -48,9 +46,6 @@ static inline bool
48
46
pg_atomic_compare_exchange_u32_impl (volatile pg_atomic_uint32 * ptr ,
49
47
uint32 * expected , uint32 newval )
50
48
{
51
- bool ret ;
52
- uint64 current ;
53
-
54
49
/*
55
50
* xlc's documentation tells us:
56
51
* "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,
62
57
* XXX: __compare_and_swap is defined to take signed parameters, but that
63
58
* shouldn't matter since we don't perform any arithmetic operations.
64
59
*/
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 );
70
62
}
71
63
72
64
#define PG_HAVE_ATOMIC_FETCH_ADD_U32
73
65
static inline uint32
74
66
pg_atomic_fetch_add_u32_impl (volatile pg_atomic_uint32 * ptr , int32 add_ )
75
67
{
76
- return __fetch_and_add (& ptr -> value , add_ );
68
+ return __fetch_and_add (( volatile int * ) & ptr -> value , add_ );
77
69
}
78
70
79
71
#ifdef PG_HAVE_ATOMIC_U64_SUPPORT
@@ -83,23 +75,17 @@ static inline bool
83
75
pg_atomic_compare_exchange_u64_impl (volatile pg_atomic_uint64 * ptr ,
84
76
uint64 * expected , uint64 newval )
85
77
{
86
- bool ret ;
87
- uint64 current ;
88
-
89
78
__isync ();
90
79
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 );;
96
82
}
97
83
98
84
#define PG_HAVE_ATOMIC_FETCH_ADD_U64
99
85
static inline uint64
100
86
pg_atomic_fetch_add_u64_impl (volatile pg_atomic_uint64 * ptr , int64 add_ )
101
87
{
102
- return __fetch_and_addlp (& ptr -> value , add_ );
88
+ return __fetch_and_addlp (( volatile long * ) & ptr -> value , add_ );
103
89
}
104
90
105
91
#endif /* PG_HAVE_ATOMIC_U64_SUPPORT */
0 commit comments