]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/atomic/stdatomic-bitint-2.c
c709cb9d7beffa4efba3ace87d7df718f85d35be
2 /* { dg-do run { target bitint } } */
3 /* { dg-options "-std=c2x -pedantic-errors" } */
7 extern void abort ( void );
9 #if __BITINT_MAXWIDTH__ >= 575
10 _Atomic
_BitInt ( 575 ) v
;
11 _BitInt ( 575 ) count
, res
;
12 const _BitInt ( 575 ) init
= ~( _BitInt ( 575 )) 0 wb
;
17 atomic_init (& v
, 59465222573183779324781274162178653782927579944977967117312772499849358939735575735090252965265846823956223131844773977101864574011188590603103408821590130462520809924774161 wb
);
18 count
= 21849324526703540909725517290562575722142104889154621021004438836543599493803029317660194646869455042293514095831327249339063542203879269024249546998746919066599380031180974 wb
;
20 if ( atomic_fetch_add_explicit (& v
, count
, memory_order_relaxed
)
21 != 59465222573183779324781274162178653782927579944977967117312772499849358939735575735090252965265846823956223131844773977101864574011188590603103408821590130462520809924774161 wb
)
24 if ( atomic_fetch_add_explicit (& v
, - 48324598397571087754171506195219221853271763472221035086980364394554212400270766919963305485900701475788840363160834710492683133292253640988518950921616217692973141455340373 wb
,
26 != - 42350653636664946795744469057082365512495989716473331818714316710055654119727328532407752918486220628549098485331968443234754400938307745356420121730609534429183196118394433 wb
)
29 if ( atomic_fetch_add_explicit (& v
, count
, memory_order_acquire
)
30 != 32989948702316232480335285257522007651797921361911553051336846941838746033267838132787142126234600390460896864515266515948244982922814218638834004898720831836147048500614762 wb
)
33 if ( atomic_fetch_add_explicit (& v
, 6958312589905983216078981134518695082538588883298046610645489916662738759809700053844918067866491080683973037493524864531300139437943661326918145212620326291059845453630984 wb
,
35 != 54839273229019773390060802548084583373940026251066174072341285778382345527070867450447336773104055432754410960346593765287308525126693487663083551897467750902746428531795736 wb
)
38 if ( atomic_fetch_add_explicit (& v
, count
, memory_order_acq_rel
)
39 != 61797585818925756606139783682603278456478615134364220682986775695045084286880567504292254840970546513438383997840118629818608664564637148990001697110088077193806273985426720 wb
)
42 if ( atomic_fetch_add_explicit (& v
, - 40070085597220253007443375012839311464160438432662764715171645999337062215395237625623334979615599652975898123428005079853660189572782012739700306191422569739682093304494995 wb
,
44 != - 40018290390922969514385959536657740838944954527087078253040313514859928772582336763205751042781520939066937619336623790518010310384859186969521833442111587697897732057741874 wb
)
47 if ( atomic_fetch_add (& v
, 7196090098608011755205055682070541953902689411792805630101863619558545582022760829169235622333653743217332966939875542415224317593660770300818700993340012969018217868600175 wb
)
48 != 43576824748409044508421925960326542714460281590856076988819568532251621565288359196329114508224401902755999970243440799304012017195734405274550937917412426520723560712112699 wb
)
51 if ( atomic_load (& v
) != 50772914847017056263626981642397084668362971002648882618921432151810167147311120025498350130558055645973332937183316341719236334789395175575369638910752439489741778580712874 wb
)
58 atomic_store_explicit (& v
, - 24875491091433158113922205635657739252057730543056417031972993454853665637813018617125143194799847437263037065304695383952916979113678037118532311779822859742705294727822376 wb
,
59 memory_order_release
);
60 count
= 6813702694653136917886567607003795360731391695538381923575500076220746287948057449348609672603971831069550813465757196210073636056135824219022209113495061317682354090030599 wb
;
62 if ( atomic_fetch_sub_explicit (& v
, count
, memory_order_relaxed
)
63 != - 24875491091433158113922205635657739252057730543056417031972993454853665637813018617125143194799847437263037065304695383952916979113678037118532311779822859742705294727822376 wb
)
66 if ( atomic_fetch_sub_explicit (& v
, 8502925336737158389204618905966437550402192530184998378452912098895816391400915282714213521081597588768568861040471642522181200007537708168290327879425612502090295717806034 wb
,
68 != - 31689193786086295031808773242661534612789122238594798955548493531074411925761076066473752867403819268332587878770452580162990615169813861337554520893317921060387648817852975 wb
)
71 if ( atomic_fetch_sub_explicit (& v
, count
, memory_order_acquire
)
72 != - 40192119122823453421013392148627972163191314768779797334001405629970228317161991349187966388485416857101156739810924222685171815177351569505844848772743533562477944535659009 wb
)
75 if ( atomic_fetch_sub_explicit (& v
, - 14654459030451169455889477114198307761108411115104251375487725308584250511764953921137486025925617622862411621191578047606524662379041353882420330350079004108508600686109553 wb
,
77 != - 47005821817476590338899959755631767523922706464318179257576905706190974605110048798536576061089388688170707553276681418895245451233487393724867057886238594880160298625689608 wb
)
80 if ( atomic_fetch_sub_explicit (& v
, count
, memory_order_acq_rel
)
81 != - 32351362787025420883010482641433459762814295349213927882089180397606724093345094877399090035163771065308295932085103371288720788854446039842446727536159590771651697939580055 wb
)
84 if ( atomic_fetch_sub_explicit (& v
, 22886836433700729148520267039236396292049781709943309196356241086882444816631218673962641435859436811686812355905147988710440709035301495069683757516099446883747069843672565 wb
,
86 != - 39165065481678557800897050248437255123545687044752309805664680473827470381293152326747699707767742896377846745550860567498794424910581864061468936649654652089334052029610654 wb
)
89 if ( atomic_fetch_sub (& v
, 49406467535448986167225179068150076098092817730200780462287871488076089290458383699602612866098591282427581289588523598202726797161439183859560135056424525356253246480887928 wb
)
90 != 61613298821172980080833943222149943601970205795910300955010606485738697355341562584447859386994342786734176611552061113466447383207492245852620383385192484985222264201066349 wb
)
93 if ( atomic_load_explicit (& v
, memory_order_acquire
)
94 != 12206831285723993913608764153999867503877388065709520492722734997662608064883178884845246520895751504306595321963537515263720586046053061993060248328767959628969017720178421 wb
)
101 atomic_store (& v
, init
);
103 if ( atomic_fetch_and_explicit (& v
, 0 , memory_order_relaxed
) != init
)
106 if ( atomic_fetch_and_explicit (& v
, init
, memory_order_consume
) != 0 )
109 if ( atomic_fetch_and_explicit (& v
, 0 , memory_order_acquire
) != 0 )
113 if ( atomic_fetch_and_explicit (& v
, init
, memory_order_release
) != init
)
116 if ( atomic_fetch_and_explicit (& v
, 0 , memory_order_acq_rel
) != init
)
119 if ( atomic_fetch_and_explicit (& v
, 0 , memory_order_seq_cst
) != 0 )
122 if ( atomic_fetch_and (& v
, 0 ) != 0 )
132 if ( atomic_fetch_xor_explicit (& v
, count
, memory_order_relaxed
) != init
)
135 if ( atomic_fetch_xor_explicit (& v
, ~ count
, memory_order_consume
) != init
)
138 if ( atomic_fetch_xor_explicit (& v
, 0 , memory_order_acquire
) != 0 )
141 if ( atomic_fetch_xor_explicit (& v
, ~ count
, memory_order_release
) != 0 )
144 if ( atomic_fetch_xor_explicit (& v
, 0 , memory_order_acq_rel
) != init
)
147 if ( atomic_fetch_xor_explicit (& v
, ~ count
, memory_order_seq_cst
) != init
)
150 if ( atomic_fetch_xor (& v
, ~ count
) != 0 )
158 count
= 28269553036454149273332760011886696253239742350009903329945699220681916416 wb
;
160 if ( atomic_fetch_or_explicit (& v
, count
, memory_order_relaxed
) != 0 wb
)
164 if ( atomic_fetch_or_explicit (& v
, 56539106072908298546665520023773392506479484700019806659891398441363832832 wb
,
165 memory_order_consume
)
166 != 28269553036454149273332760011886696253239742350009903329945699220681916416 wb
)
170 if ( atomic_fetch_or_explicit (& v
, count
, memory_order_acquire
)
171 != 84808659109362447819998280035660088759719227050029709989837097662045749248 wb
)
175 if ( atomic_fetch_or_explicit (& v
, 226156424291633194186662080095093570025917938800079226639565593765455331328 wb
,
176 memory_order_release
)
177 != 197886871255179044913329320083206873772678196450069323309619894544773414912 wb
)
181 if ( atomic_fetch_or_explicit (& v
, count
, memory_order_acq_rel
)
182 != 424043295546812239099991400178300443798596135250148549949185488310228746240 wb
)
186 if ( atomic_fetch_or_explicit (& v
, count
, memory_order_seq_cst
)
187 != 876356144130078627473315560368487583850432012850307003228316675841139408896 wb
)
191 if ( atomic_fetch_or (& v
, count
) != 1780981841296611404219963880748861863954103768050623909786579050902960734208 wb
)
196 /* Test the OP routines with a result which isn't used. */
202 count
= 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677 wb
;
204 atomic_fetch_add (& v
, count
);
205 if ( v
!= 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677 wb
)
208 atomic_fetch_add_explicit (& v
, count
, memory_order_consume
);
209 if ( v
!= 2973685811219503388667991961246738269772721288963776813759793504178074130510359140173115930589534699106813779098200501348725870508374254508706949645221709435224795354 wb
)
212 atomic_fetch_add (& v
, 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677 wb
);
213 if ( v
!= 4460528716829255083001987941870107404659081933445665220639690256267111195765538710259673895884302048660220668647300752023088805762561381763060424467832564152837193031 wb
)
216 atomic_fetch_add_explicit (& v
, 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677 wb
,
217 memory_order_release
);
218 if ( v
!= 5947371622439006777335983922493476539545442577927553627519587008356148261020718280346231861179069398213627558196401002697451741016748509017413899290443418870449590708 wb
)
221 atomic_fetch_add (& v
, 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677 wb
);
222 if ( v
!= 7434214528048758471669979903116845674431803222409442034399483760445185326275897850432789826473836747767034447745501253371814676270935636271767374113054273588061988385 wb
)
225 atomic_fetch_add_explicit (& v
, count
, memory_order_seq_cst
);
226 if ( v
!= 8921057433658510166003975883740214809318163866891330441279380512534222391531077420519347791768604097320441337294601504046177611525122763526120848935665128305674386062 wb
)
233 v
= res
= 55339930658115792138308584702507715233391812567721958037499562620485942364609138719919541704955047331226014242859673113345829202990143617633801993282898070230404539826267403 wb
;
236 atomic_fetch_sub (& v
, count
+ 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
);
237 res
-= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
;
241 atomic_fetch_sub_explicit (& v
, count
+ 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
, memory_order_consume
);
242 res
-= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
;
246 atomic_fetch_sub (& v
, 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
);
247 res
-= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
;
251 atomic_fetch_sub_explicit (& v
, 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
, memory_order_release
);
252 res
-= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
;
256 atomic_fetch_sub (& v
, count
+ 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
);
257 res
-= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
;
261 atomic_fetch_sub_explicit (& v
, count
+ 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
, memory_order_seq_cst
);
262 res
-= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057 wb
;
272 atomic_fetch_and (& v
, 0 );
277 atomic_fetch_and_explicit (& v
, init
, memory_order_consume
);
281 atomic_fetch_and (& v
, 0 );
286 atomic_fetch_and_explicit (& v
, init
, memory_order_release
);
290 atomic_fetch_and (& v
, 0 );
295 atomic_fetch_and_explicit (& v
, 0 , memory_order_seq_cst
);
306 atomic_fetch_xor (& v
, count
);
310 atomic_fetch_xor_explicit (& v
, ~ count
, memory_order_consume
);
314 atomic_fetch_xor (& v
, 0 );
318 atomic_fetch_xor_explicit (& v
, ~ count
, memory_order_release
);
322 atomic_fetch_xor_explicit (& v
, 0 , memory_order_acq_rel
);
326 atomic_fetch_xor (& v
, ~ count
);
335 count
= 19342813113834066795298816 wb
;
337 atomic_fetch_or (& v
, count
);
338 if ( v
!= 19342813113834066795298816 wb
)
342 atomic_fetch_or_explicit (& v
, count
, memory_order_consume
);
343 if ( v
!= 58028439341502200385896448 wb
)
347 atomic_fetch_or (& v
, 77371252455336267181195264 wb
);
348 if ( v
!= 135399691796838467567091712 wb
)
352 atomic_fetch_or_explicit (& v
, 154742504910672534362390528 wb
,
353 memory_order_release
);
354 if ( v
!= 290142196707511001929482240 wb
)
358 atomic_fetch_or (& v
, count
);
359 if ( v
!= 599627206528856070654263296 wb
)
363 atomic_fetch_or_explicit (& v
, count
, memory_order_seq_cst
);
364 if ( v
!= 1218597226171546208103825408 wb
)
371 atomic_store (& v
, - 285679222948993342888321238830899996788334328454283006589115162661816862491992700267590986826514460282130796141107636816730207482542791159837024986802592659048696136633096 wb
);
372 if ( atomic_exchange (& v
, 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601 wb
)
373 != - 285679222948993342888321238830899996788334328454283006589115162661816862491992700267590986826514460282130796141107636816730207482542791159837024986802592659048696136633096 wb
374 || atomic_load (& v
) != 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601 wb
)
376 if ( atomic_exchange_explicit (& v
, - 4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649 wb
,
377 memory_order_relaxed
)
378 != 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601 wb
379 || ( atomic_load_explicit (& v
, memory_order_acquire
)
380 != - 4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649 wb
))
383 count
= 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601 wb
;
384 if ( atomic_compare_exchange_strong (& v
, & count
,
385 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707 wb
))
387 if ( count
!= - 4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649 wb
388 || atomic_load (& v
) != - 4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649 wb
)
390 if (! atomic_compare_exchange_strong (& v
, & count
,
391 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707 wb
))
393 if ( count
!= - 4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649 wb
394 || atomic_load (& v
) != 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707 wb
)
397 count
= 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601 wb
;
398 if ( atomic_compare_exchange_strong_explicit (& v
, & count
,
399 - 20263258027145541347005514871938569231358927704236809883668741851321168433670480594273940614283839738125120292424689828120954658857299483460682957837178666219043928324493674 wb
,
400 memory_order_seq_cst
,
401 memory_order_relaxed
))
403 if ( count
!= 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707 wb
404 || atomic_load (& v
) != 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707 wb
)
406 if (! atomic_compare_exchange_strong_explicit (& v
, & count
,
407 - 20263258027145541347005514871938569231358927704236809883668741851321168433670480594273940614283839738125120292424689828120954658857299483460682957837178666219043928324493674 wb
,
408 memory_order_seq_cst
,
409 memory_order_seq_cst
))
411 if ( count
!= 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707 wb
412 || atomic_load (& v
) != - 20263258027145541347005514871938569231358927704236809883668741851321168433670480594273940614283839738125120292424689828120954658857299483460682957837178666219043928324493674 wb
)
415 count
= atomic_load (& v
);
417 res
= count
+ 3438682542819842029328613486899299339199839206022263296398180581126218550036955367421469273900216774711772362599086182416923053671263751262393559525082445581168420546542404 wb
;
418 while (! atomic_compare_exchange_weak (& v
, & count
, res
));
419 if ( atomic_load (& v
) != - 16824575484325699317676901385039269892159088498214546587270561270194949883633525226852471340383622963413347929825603645704031605186035732198289398312096220637875507777951270 wb
)
422 count
= atomic_load_explicit (& v
, memory_order_acquire
);
424 res
= count
+ 55351299008567209999272942257960316150846002020561006740901388462123844029522178721330031429855007927083338249659817829635668878607777961512926342979905691183772323299904096 wb
;
425 while (! atomic_compare_exchange_weak_explicit (& v
, & count
, res
,
426 memory_order_relaxed
,
427 memory_order_relaxed
));
428 if ( atomic_load (& v
) != 38526723524241510681596040872921046258686913522346460153630827191928894145888653494477560089471384963669990319834214183931637273421742229314636944667809470545896815521952826 wb
)
436 #if __BITINT_MAXWIDTH__ >= 575