Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d32d2e

Browse files
committed
Finish generic-xlc.h draft atomics implementation.
Back-patch to 9.5, where commitb64d92fintroduced this file.
1 parentbe8b06c commit0d32d2e

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

‎src/include/port/atomics/generic-xlc.h

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#if defined(HAVE_ATOMICS)
2020

21-
#include<atomic.h>
22-
2321
#definePG_HAVE_ATOMIC_U32_SUPPORT
2422
typedefstructpg_atomic_uint32
2523
{
@@ -48,9 +46,6 @@ static inline bool
4846
pg_atomic_compare_exchange_u32_impl(volatilepg_atomic_uint32*ptr,
4947
uint32*expected,uint32newval)
5048
{
51-
boolret;
52-
uint64current;
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((volatileint*)ptr->value,
66-
(int)*expected, (int)newval);
67-
ret=current==*expected;
68-
*expected=current;
69-
returnret;
60+
return__compare_and_swap((volatileint*)&ptr->value,
61+
(int*)expected, (int)newval);
7062
}
7163

7264
#definePG_HAVE_ATOMIC_FETCH_ADD_U32
7365
staticinlineuint32
7466
pg_atomic_fetch_add_u32_impl(volatilepg_atomic_uint32*ptr,int32add_)
7567
{
76-
return__fetch_and_add(&ptr->value,add_);
68+
return__fetch_and_add((volatileint*)&ptr->value,add_);
7769
}
7870

7971
#ifdefPG_HAVE_ATOMIC_U64_SUPPORT
@@ -83,23 +75,17 @@ static inline bool
8375
pg_atomic_compare_exchange_u64_impl(volatilepg_atomic_uint64*ptr,
8476
uint64*expected,uint64newval)
8577
{
86-
boolret;
87-
uint64current;
88-
8978
__isync();
9079

91-
current= (uint64)__compare_and_swaplp((volatilelong*)ptr->value,
92-
(long)*expected, (long)newval);
93-
ret=current==*expected;
94-
*expected=current;
95-
returnret;
80+
return__compare_and_swaplp((volatilelong*)&ptr->value,
81+
(long*)expected, (long)newval);;
9682
}
9783

9884
#definePG_HAVE_ATOMIC_FETCH_ADD_U64
9985
staticinlineuint64
10086
pg_atomic_fetch_add_u64_impl(volatilepg_atomic_uint64*ptr,int64add_)
10187
{
102-
return__fetch_and_addlp(&ptr->value,add_);
88+
return__fetch_and_addlp((volatilelong*)&ptr->value,add_);
10389
}
10490

10591
#endif/* PG_HAVE_ATOMIC_U64_SUPPORT */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp