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

Commit585fc56

Browse files
committed
Test pg_atomic_fetch_add_ with variable addend and 16-bit edge cases.
Back-patch to 9.5, which introduced these functions.Reviewed by Tom Lane.Discussion:https://postgr.es/m/20190831071157.GA3251746@rfd.leadboat.com
1 parent41f3d26 commit585fc56

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

‎src/test/regress/regress.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ test_atomic_uint32(void)
679679
if (pg_atomic_read_u32(&var)!=3)
680680
elog(ERROR,"atomic_read_u32() #2 wrong");
681681

682-
if (pg_atomic_fetch_add_u32(&var,1)!=3)
682+
if (pg_atomic_fetch_add_u32(&var,pg_atomic_read_u32(&var)-2)!=3)
683683
elog(ERROR,"atomic_fetch_add_u32() #1 wrong");
684684

685685
if (pg_atomic_fetch_sub_u32(&var,1)!=4)
@@ -704,6 +704,20 @@ test_atomic_uint32(void)
704704
if (pg_atomic_fetch_add_u32(&var,INT_MAX)!=INT_MAX)
705705
elog(ERROR,"pg_atomic_add_fetch_u32() #3 wrong");
706706

707+
pg_atomic_fetch_add_u32(&var,2);/* wrap to 0 */
708+
709+
if (pg_atomic_fetch_add_u32(&var,PG_INT16_MAX)!=0)
710+
elog(ERROR,"pg_atomic_fetch_add_u32() #3 wrong");
711+
712+
if (pg_atomic_fetch_add_u32(&var,PG_INT16_MAX+1)!=PG_INT16_MAX)
713+
elog(ERROR,"pg_atomic_fetch_add_u32() #4 wrong");
714+
715+
if (pg_atomic_fetch_add_u32(&var,PG_INT16_MIN)!=2*PG_INT16_MAX+1)
716+
elog(ERROR,"pg_atomic_fetch_add_u32() #5 wrong");
717+
718+
if (pg_atomic_fetch_add_u32(&var,PG_INT16_MIN-1)!=PG_INT16_MAX)
719+
elog(ERROR,"pg_atomic_fetch_add_u32() #6 wrong");
720+
707721
pg_atomic_fetch_add_u32(&var,1);/* top up to UINT_MAX */
708722

709723
if (pg_atomic_read_u32(&var)!=UINT_MAX)
@@ -779,7 +793,7 @@ test_atomic_uint64(void)
779793
if (pg_atomic_read_u64(&var)!=3)
780794
elog(ERROR,"atomic_read_u64() #2 wrong");
781795

782-
if (pg_atomic_fetch_add_u64(&var,1)!=3)
796+
if (pg_atomic_fetch_add_u64(&var,pg_atomic_read_u64(&var)-2)!=3)
783797
elog(ERROR,"atomic_fetch_add_u64() #1 wrong");
784798

785799
if (pg_atomic_fetch_sub_u64(&var,1)!=4)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp