test_atomic_include.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624
  1. /*
  2. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  3. *
  4. * This file is covered by the GNU general public license, version 2.
  5. * see doc/COPYING for details.
  6. */
  7. /* Some basic sanity tests. These do not test the barrier semantics. */
  8. #undef TA_assert
  9. #define TA_assert(e) \
  10. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: )\n", \
  11. __FILE__, __LINE__), exit(1); }
  12. #undef MISSING
  13. #define MISSING(name) \
  14. fprintf(stderr, "Missing: %s\n", #name "")
  15. void test_atomic(void)
  16. {
  17. AO_t x;
  18. unsigned char b;
  19. unsigned short s;
  20. unsigned int zz;
  21. # if defined(AO_HAVE_test_and_set)
  22. AO_TS_t z = AO_TS_INITIALIZER;
  23. # endif
  24. # if defined(AO_HAVE_double_t)
  25. AO_double_t w;
  26. w.AO_val1 = 0;
  27. w.AO_val2 = 0;
  28. # endif
  29. # if defined(AO_HAVE_nop)
  30. AO_nop();
  31. # else
  32. MISSING(AO_nop);
  33. # endif
  34. # if defined(AO_HAVE_store)
  35. AO_store(&x, 13);
  36. TA_assert (x == 13);
  37. # else
  38. MISSING(AO_store);
  39. x = 13;
  40. # endif
  41. # if defined(AO_HAVE_load)
  42. TA_assert(AO_load(&x) == 13);
  43. # else
  44. MISSING(AO_load);
  45. # endif
  46. # if defined(AO_HAVE_test_and_set)
  47. assert(AO_test_and_set(&z) == AO_TS_CLEAR);
  48. assert(AO_test_and_set(&z) == AO_TS_SET);
  49. assert(AO_test_and_set(&z) == AO_TS_SET);
  50. AO_CLEAR(&z);
  51. # else
  52. MISSING(AO_test_and_set);
  53. # endif
  54. # if defined(AO_HAVE_fetch_and_add)
  55. TA_assert(AO_fetch_and_add(&x, 42) == 13);
  56. TA_assert(AO_fetch_and_add(&x, -42) == 55);
  57. # else
  58. MISSING(AO_fetch_and_add);
  59. # endif
  60. # if defined(AO_HAVE_fetch_and_add1)
  61. TA_assert(AO_fetch_and_add1(&x) == 13);
  62. # else
  63. MISSING(AO_fetch_and_add1);
  64. ++x;
  65. # endif
  66. # if defined(AO_HAVE_fetch_and_sub1)
  67. TA_assert(AO_fetch_and_sub1(&x) == 14);
  68. # else
  69. MISSING(AO_fetch_and_sub1);
  70. --x;
  71. # endif
  72. # if defined(AO_HAVE_short_store)
  73. AO_short_store(&s, 13);
  74. # else
  75. MISSING(AO_short_store);
  76. s = 13;
  77. # endif
  78. # if defined(AO_HAVE_short_load)
  79. TA_assert(AO_short_load(&s) == 13);
  80. # else
  81. MISSING(AO_short_load);
  82. # endif
  83. # if defined(AO_HAVE_short_fetch_and_add)
  84. TA_assert(AO_short_fetch_and_add(&s, 42) == 13);
  85. TA_assert(AO_short_fetch_and_add(&s, -42) == 55);
  86. # else
  87. MISSING(AO_short_fetch_and_add);
  88. # endif
  89. # if defined(AO_HAVE_short_fetch_and_add1)
  90. TA_assert(AO_short_fetch_and_add1(&s) == 13);
  91. # else
  92. MISSING(AO_short_fetch_and_add1);
  93. ++s;
  94. # endif
  95. # if defined(AO_HAVE_short_fetch_and_sub1)
  96. TA_assert(AO_short_fetch_and_sub1(&s) == 14);
  97. # else
  98. MISSING(AO_short_fetch_and_sub1);
  99. --s;
  100. # endif
  101. # if defined(AO_HAVE_char_store)
  102. AO_char_store(&b, 13);
  103. # else
  104. MISSING(AO_char_store);
  105. b = 13;
  106. # endif
  107. # if defined(AO_HAVE_char_load)
  108. TA_assert(AO_char_load(&b) == 13);
  109. # else
  110. MISSING(AO_char_load);
  111. # endif
  112. # if defined(AO_HAVE_char_fetch_and_add)
  113. TA_assert(AO_char_fetch_and_add(&b, 42) == 13);
  114. TA_assert(AO_char_fetch_and_add(&b, -42) == 55);
  115. # else
  116. MISSING(AO_char_fetch_and_add);
  117. # endif
  118. # if defined(AO_HAVE_char_fetch_and_add1)
  119. TA_assert(AO_char_fetch_and_add1(&b) == 13);
  120. # else
  121. MISSING(AO_char_fetch_and_add1);
  122. ++b;
  123. # endif
  124. # if defined(AO_HAVE_char_fetch_and_sub1)
  125. TA_assert(AO_char_fetch_and_sub1(&b) == 14);
  126. # else
  127. MISSING(AO_char_fetch_and_sub1);
  128. --b;
  129. # endif
  130. # if defined(AO_HAVE_int_store)
  131. AO_int_store(&zz, 13);
  132. # else
  133. MISSING(AO_int_store);
  134. zz = 13;
  135. # endif
  136. # if defined(AO_HAVE_int_load)
  137. TA_assert(AO_int_load(&zz) == 13);
  138. # else
  139. MISSING(AO_int_load);
  140. # endif
  141. # if defined(AO_HAVE_int_fetch_and_add)
  142. TA_assert(AO_int_fetch_and_add(&zz, 42) == 13);
  143. TA_assert(AO_int_fetch_and_add(&zz, -42) == 55);
  144. # else
  145. MISSING(AO_int_fetch_and_add);
  146. # endif
  147. # if defined(AO_HAVE_int_fetch_and_add1)
  148. TA_assert(AO_int_fetch_and_add1(&zz) == 13);
  149. # else
  150. MISSING(AO_int_fetch_and_add1);
  151. ++zz;
  152. # endif
  153. # if defined(AO_HAVE_int_fetch_and_sub1)
  154. TA_assert(AO_int_fetch_and_sub1(&zz) == 14);
  155. # else
  156. MISSING(AO_int_fetch_and_sub1);
  157. --zz;
  158. # endif
  159. # if defined(AO_HAVE_compare_and_swap)
  160. TA_assert(!AO_compare_and_swap(&x, 14, 42));
  161. TA_assert(x == 13);
  162. TA_assert(AO_compare_and_swap(&x, 13, 42));
  163. TA_assert(x == 42);
  164. # else
  165. MISSING(AO_compare_and_swap);
  166. # endif
  167. # if defined(AO_HAVE_or)
  168. AO_or(&x, 66);
  169. TA_assert(x == 106);
  170. # else
  171. MISSING(AO_or);
  172. x |= 34;
  173. # endif
  174. # if defined(AO_HAVE_compare_double_and_swap_double)
  175. TA_assert(!AO_compare_double_and_swap_double(&w, 17, 42, 12, 13));
  176. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  177. TA_assert(AO_compare_double_and_swap_double(&w, 0, 0, 12, 13));
  178. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  179. TA_assert(AO_compare_double_and_swap_double(&w, 12, 13, 17, 42));
  180. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  181. w.AO_val1 = 0; w.AO_val2 = 0;
  182. # else
  183. MISSING(AO_compare_double_and_swap_double);
  184. # endif
  185. # if defined(AO_HAVE_compare_and_swap_double)
  186. TA_assert(!AO_compare_and_swap_double(&w, 17, 12, 13));
  187. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  188. TA_assert(AO_compare_and_swap_double(&w, 0, 12, 13));
  189. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  190. TA_assert(AO_compare_and_swap_double(&w, 12, 17, 42));
  191. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  192. # else
  193. MISSING(AO_compare_and_swap_double);
  194. # endif
  195. }
  196. /*
  197. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  198. *
  199. * This file is covered by the GNU general public license, version 2.
  200. * see doc/COPYING for details.
  201. */
  202. /* Some basic sanity tests. These do not test the barrier semantics. */
  203. #undef TA_assert
  204. #define TA_assert(e) \
  205. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _release)\n", \
  206. __FILE__, __LINE__), exit(1); }
  207. #undef MISSING
  208. #define MISSING(name) \
  209. fprintf(stderr, "Missing: %s\n", #name "_release")
  210. void test_atomic_release(void)
  211. {
  212. AO_t x;
  213. unsigned char b;
  214. unsigned short s;
  215. unsigned int zz;
  216. # if defined(AO_HAVE_test_and_set_release)
  217. AO_TS_t z = AO_TS_INITIALIZER;
  218. # endif
  219. # if defined(AO_HAVE_double_t)
  220. AO_double_t w;
  221. w.AO_val1 = 0;
  222. w.AO_val2 = 0;
  223. # endif
  224. # if defined(AO_HAVE_nop_release)
  225. AO_nop_release();
  226. # else
  227. MISSING(AO_nop);
  228. # endif
  229. # if defined(AO_HAVE_store_release)
  230. AO_store_release(&x, 13);
  231. TA_assert (x == 13);
  232. # else
  233. MISSING(AO_store);
  234. x = 13;
  235. # endif
  236. # if defined(AO_HAVE_load_release)
  237. TA_assert(AO_load_release(&x) == 13);
  238. # else
  239. MISSING(AO_load);
  240. # endif
  241. # if defined(AO_HAVE_test_and_set_release)
  242. assert(AO_test_and_set_release(&z) == AO_TS_CLEAR);
  243. assert(AO_test_and_set_release(&z) == AO_TS_SET);
  244. assert(AO_test_and_set_release(&z) == AO_TS_SET);
  245. AO_CLEAR(&z);
  246. # else
  247. MISSING(AO_test_and_set);
  248. # endif
  249. # if defined(AO_HAVE_fetch_and_add_release)
  250. TA_assert(AO_fetch_and_add_release(&x, 42) == 13);
  251. TA_assert(AO_fetch_and_add_release(&x, -42) == 55);
  252. # else
  253. MISSING(AO_fetch_and_add);
  254. # endif
  255. # if defined(AO_HAVE_fetch_and_add1_release)
  256. TA_assert(AO_fetch_and_add1_release(&x) == 13);
  257. # else
  258. MISSING(AO_fetch_and_add1);
  259. ++x;
  260. # endif
  261. # if defined(AO_HAVE_fetch_and_sub1_release)
  262. TA_assert(AO_fetch_and_sub1_release(&x) == 14);
  263. # else
  264. MISSING(AO_fetch_and_sub1);
  265. --x;
  266. # endif
  267. # if defined(AO_HAVE_short_store_release)
  268. AO_short_store_release(&s, 13);
  269. # else
  270. MISSING(AO_short_store);
  271. s = 13;
  272. # endif
  273. # if defined(AO_HAVE_short_load_release)
  274. TA_assert(AO_short_load(&s) == 13);
  275. # else
  276. MISSING(AO_short_load);
  277. # endif
  278. # if defined(AO_HAVE_short_fetch_and_add_release)
  279. TA_assert(AO_short_fetch_and_add_release(&s, 42) == 13);
  280. TA_assert(AO_short_fetch_and_add_release(&s, -42) == 55);
  281. # else
  282. MISSING(AO_short_fetch_and_add);
  283. # endif
  284. # if defined(AO_HAVE_short_fetch_and_add1_release)
  285. TA_assert(AO_short_fetch_and_add1_release(&s) == 13);
  286. # else
  287. MISSING(AO_short_fetch_and_add1);
  288. ++s;
  289. # endif
  290. # if defined(AO_HAVE_short_fetch_and_sub1_release)
  291. TA_assert(AO_short_fetch_and_sub1_release(&s) == 14);
  292. # else
  293. MISSING(AO_short_fetch_and_sub1);
  294. --s;
  295. # endif
  296. # if defined(AO_HAVE_char_store_release)
  297. AO_char_store_release(&b, 13);
  298. # else
  299. MISSING(AO_char_store);
  300. b = 13;
  301. # endif
  302. # if defined(AO_HAVE_char_load_release)
  303. TA_assert(AO_char_load(&b) == 13);
  304. # else
  305. MISSING(AO_char_load);
  306. # endif
  307. # if defined(AO_HAVE_char_fetch_and_add_release)
  308. TA_assert(AO_char_fetch_and_add_release(&b, 42) == 13);
  309. TA_assert(AO_char_fetch_and_add_release(&b, -42) == 55);
  310. # else
  311. MISSING(AO_char_fetch_and_add);
  312. # endif
  313. # if defined(AO_HAVE_char_fetch_and_add1_release)
  314. TA_assert(AO_char_fetch_and_add1_release(&b) == 13);
  315. # else
  316. MISSING(AO_char_fetch_and_add1);
  317. ++b;
  318. # endif
  319. # if defined(AO_HAVE_char_fetch_and_sub1_release)
  320. TA_assert(AO_char_fetch_and_sub1_release(&b) == 14);
  321. # else
  322. MISSING(AO_char_fetch_and_sub1);
  323. --b;
  324. # endif
  325. # if defined(AO_HAVE_int_store_release)
  326. AO_int_store_release(&zz, 13);
  327. # else
  328. MISSING(AO_int_store);
  329. zz = 13;
  330. # endif
  331. # if defined(AO_HAVE_int_load_release)
  332. TA_assert(AO_int_load(&zz) == 13);
  333. # else
  334. MISSING(AO_int_load);
  335. # endif
  336. # if defined(AO_HAVE_int_fetch_and_add_release)
  337. TA_assert(AO_int_fetch_and_add_release(&zz, 42) == 13);
  338. TA_assert(AO_int_fetch_and_add_release(&zz, -42) == 55);
  339. # else
  340. MISSING(AO_int_fetch_and_add);
  341. # endif
  342. # if defined(AO_HAVE_int_fetch_and_add1_release)
  343. TA_assert(AO_int_fetch_and_add1_release(&zz) == 13);
  344. # else
  345. MISSING(AO_int_fetch_and_add1);
  346. ++zz;
  347. # endif
  348. # if defined(AO_HAVE_int_fetch_and_sub1_release)
  349. TA_assert(AO_int_fetch_and_sub1_release(&zz) == 14);
  350. # else
  351. MISSING(AO_int_fetch_and_sub1);
  352. --zz;
  353. # endif
  354. # if defined(AO_HAVE_compare_and_swap_release)
  355. TA_assert(!AO_compare_and_swap_release(&x, 14, 42));
  356. TA_assert(x == 13);
  357. TA_assert(AO_compare_and_swap_release(&x, 13, 42));
  358. TA_assert(x == 42);
  359. # else
  360. MISSING(AO_compare_and_swap);
  361. # endif
  362. # if defined(AO_HAVE_or_release)
  363. AO_or_release(&x, 66);
  364. TA_assert(x == 106);
  365. # else
  366. MISSING(AO_or);
  367. x |= 34;
  368. # endif
  369. # if defined(AO_HAVE_compare_double_and_swap_double_release)
  370. TA_assert(!AO_compare_double_and_swap_double_release(&w, 17, 42, 12, 13));
  371. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  372. TA_assert(AO_compare_double_and_swap_double_release(&w, 0, 0, 12, 13));
  373. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  374. TA_assert(AO_compare_double_and_swap_double_release(&w, 12, 13, 17, 42));
  375. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  376. w.AO_val1 = 0; w.AO_val2 = 0;
  377. # else
  378. MISSING(AO_compare_double_and_swap_double);
  379. # endif
  380. # if defined(AO_HAVE_compare_and_swap_double_release)
  381. TA_assert(!AO_compare_and_swap_double_release(&w, 17, 12, 13));
  382. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  383. TA_assert(AO_compare_and_swap_double_release(&w, 0, 12, 13));
  384. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  385. TA_assert(AO_compare_and_swap_double_release(&w, 12, 17, 42));
  386. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  387. # else
  388. MISSING(AO_compare_and_swap_double);
  389. # endif
  390. }
  391. /*
  392. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  393. *
  394. * This file is covered by the GNU general public license, version 2.
  395. * see doc/COPYING for details.
  396. */
  397. /* Some basic sanity tests. These do not test the barrier semantics. */
  398. #undef TA_assert
  399. #define TA_assert(e) \
  400. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _acquire)\n", \
  401. __FILE__, __LINE__), exit(1); }
  402. #undef MISSING
  403. #define MISSING(name) \
  404. fprintf(stderr, "Missing: %s\n", #name "_acquire")
  405. void test_atomic_acquire(void)
  406. {
  407. AO_t x;
  408. unsigned char b;
  409. unsigned short s;
  410. unsigned int zz;
  411. # if defined(AO_HAVE_test_and_set_acquire)
  412. AO_TS_t z = AO_TS_INITIALIZER;
  413. # endif
  414. # if defined(AO_HAVE_double_t)
  415. AO_double_t w;
  416. w.AO_val1 = 0;
  417. w.AO_val2 = 0;
  418. # endif
  419. # if defined(AO_HAVE_nop_acquire)
  420. AO_nop_acquire();
  421. # else
  422. MISSING(AO_nop);
  423. # endif
  424. # if defined(AO_HAVE_store_acquire)
  425. AO_store_acquire(&x, 13);
  426. TA_assert (x == 13);
  427. # else
  428. MISSING(AO_store);
  429. x = 13;
  430. # endif
  431. # if defined(AO_HAVE_load_acquire)
  432. TA_assert(AO_load_acquire(&x) == 13);
  433. # else
  434. MISSING(AO_load);
  435. # endif
  436. # if defined(AO_HAVE_test_and_set_acquire)
  437. assert(AO_test_and_set_acquire(&z) == AO_TS_CLEAR);
  438. assert(AO_test_and_set_acquire(&z) == AO_TS_SET);
  439. assert(AO_test_and_set_acquire(&z) == AO_TS_SET);
  440. AO_CLEAR(&z);
  441. # else
  442. MISSING(AO_test_and_set);
  443. # endif
  444. # if defined(AO_HAVE_fetch_and_add_acquire)
  445. TA_assert(AO_fetch_and_add_acquire(&x, 42) == 13);
  446. TA_assert(AO_fetch_and_add_acquire(&x, -42) == 55);
  447. # else
  448. MISSING(AO_fetch_and_add);
  449. # endif
  450. # if defined(AO_HAVE_fetch_and_add1_acquire)
  451. TA_assert(AO_fetch_and_add1_acquire(&x) == 13);
  452. # else
  453. MISSING(AO_fetch_and_add1);
  454. ++x;
  455. # endif
  456. # if defined(AO_HAVE_fetch_and_sub1_acquire)
  457. TA_assert(AO_fetch_and_sub1_acquire(&x) == 14);
  458. # else
  459. MISSING(AO_fetch_and_sub1);
  460. --x;
  461. # endif
  462. # if defined(AO_HAVE_short_store_acquire)
  463. AO_short_store_acquire(&s, 13);
  464. # else
  465. MISSING(AO_short_store);
  466. s = 13;
  467. # endif
  468. # if defined(AO_HAVE_short_load_acquire)
  469. TA_assert(AO_short_load(&s) == 13);
  470. # else
  471. MISSING(AO_short_load);
  472. # endif
  473. # if defined(AO_HAVE_short_fetch_and_add_acquire)
  474. TA_assert(AO_short_fetch_and_add_acquire(&s, 42) == 13);
  475. TA_assert(AO_short_fetch_and_add_acquire(&s, -42) == 55);
  476. # else
  477. MISSING(AO_short_fetch_and_add);
  478. # endif
  479. # if defined(AO_HAVE_short_fetch_and_add1_acquire)
  480. TA_assert(AO_short_fetch_and_add1_acquire(&s) == 13);
  481. # else
  482. MISSING(AO_short_fetch_and_add1);
  483. ++s;
  484. # endif
  485. # if defined(AO_HAVE_short_fetch_and_sub1_acquire)
  486. TA_assert(AO_short_fetch_and_sub1_acquire(&s) == 14);
  487. # else
  488. MISSING(AO_short_fetch_and_sub1);
  489. --s;
  490. # endif
  491. # if defined(AO_HAVE_char_store_acquire)
  492. AO_char_store_acquire(&b, 13);
  493. # else
  494. MISSING(AO_char_store);
  495. b = 13;
  496. # endif
  497. # if defined(AO_HAVE_char_load_acquire)
  498. TA_assert(AO_char_load(&b) == 13);
  499. # else
  500. MISSING(AO_char_load);
  501. # endif
  502. # if defined(AO_HAVE_char_fetch_and_add_acquire)
  503. TA_assert(AO_char_fetch_and_add_acquire(&b, 42) == 13);
  504. TA_assert(AO_char_fetch_and_add_acquire(&b, -42) == 55);
  505. # else
  506. MISSING(AO_char_fetch_and_add);
  507. # endif
  508. # if defined(AO_HAVE_char_fetch_and_add1_acquire)
  509. TA_assert(AO_char_fetch_and_add1_acquire(&b) == 13);
  510. # else
  511. MISSING(AO_char_fetch_and_add1);
  512. ++b;
  513. # endif
  514. # if defined(AO_HAVE_char_fetch_and_sub1_acquire)
  515. TA_assert(AO_char_fetch_and_sub1_acquire(&b) == 14);
  516. # else
  517. MISSING(AO_char_fetch_and_sub1);
  518. --b;
  519. # endif
  520. # if defined(AO_HAVE_int_store_acquire)
  521. AO_int_store_acquire(&zz, 13);
  522. # else
  523. MISSING(AO_int_store);
  524. zz = 13;
  525. # endif
  526. # if defined(AO_HAVE_int_load_acquire)
  527. TA_assert(AO_int_load(&zz) == 13);
  528. # else
  529. MISSING(AO_int_load);
  530. # endif
  531. # if defined(AO_HAVE_int_fetch_and_add_acquire)
  532. TA_assert(AO_int_fetch_and_add_acquire(&zz, 42) == 13);
  533. TA_assert(AO_int_fetch_and_add_acquire(&zz, -42) == 55);
  534. # else
  535. MISSING(AO_int_fetch_and_add);
  536. # endif
  537. # if defined(AO_HAVE_int_fetch_and_add1_acquire)
  538. TA_assert(AO_int_fetch_and_add1_acquire(&zz) == 13);
  539. # else
  540. MISSING(AO_int_fetch_and_add1);
  541. ++zz;
  542. # endif
  543. # if defined(AO_HAVE_int_fetch_and_sub1_acquire)
  544. TA_assert(AO_int_fetch_and_sub1_acquire(&zz) == 14);
  545. # else
  546. MISSING(AO_int_fetch_and_sub1);
  547. --zz;
  548. # endif
  549. # if defined(AO_HAVE_compare_and_swap_acquire)
  550. TA_assert(!AO_compare_and_swap_acquire(&x, 14, 42));
  551. TA_assert(x == 13);
  552. TA_assert(AO_compare_and_swap_acquire(&x, 13, 42));
  553. TA_assert(x == 42);
  554. # else
  555. MISSING(AO_compare_and_swap);
  556. # endif
  557. # if defined(AO_HAVE_or_acquire)
  558. AO_or_acquire(&x, 66);
  559. TA_assert(x == 106);
  560. # else
  561. MISSING(AO_or);
  562. x |= 34;
  563. # endif
  564. # if defined(AO_HAVE_compare_double_and_swap_double_acquire)
  565. TA_assert(!AO_compare_double_and_swap_double_acquire(&w, 17, 42, 12, 13));
  566. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  567. TA_assert(AO_compare_double_and_swap_double_acquire(&w, 0, 0, 12, 13));
  568. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  569. TA_assert(AO_compare_double_and_swap_double_acquire(&w, 12, 13, 17, 42));
  570. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  571. w.AO_val1 = 0; w.AO_val2 = 0;
  572. # else
  573. MISSING(AO_compare_double_and_swap_double);
  574. # endif
  575. # if defined(AO_HAVE_compare_and_swap_double_acquire)
  576. TA_assert(!AO_compare_and_swap_double_acquire(&w, 17, 12, 13));
  577. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  578. TA_assert(AO_compare_and_swap_double_acquire(&w, 0, 12, 13));
  579. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  580. TA_assert(AO_compare_and_swap_double_acquire(&w, 12, 17, 42));
  581. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  582. # else
  583. MISSING(AO_compare_and_swap_double);
  584. # endif
  585. }
  586. /*
  587. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  588. *
  589. * This file is covered by the GNU general public license, version 2.
  590. * see doc/COPYING for details.
  591. */
  592. /* Some basic sanity tests. These do not test the barrier semantics. */
  593. #undef TA_assert
  594. #define TA_assert(e) \
  595. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _read)\n", \
  596. __FILE__, __LINE__), exit(1); }
  597. #undef MISSING
  598. #define MISSING(name) \
  599. fprintf(stderr, "Missing: %s\n", #name "_read")
  600. void test_atomic_read(void)
  601. {
  602. AO_t x;
  603. unsigned char b;
  604. unsigned short s;
  605. unsigned int zz;
  606. # if defined(AO_HAVE_test_and_set_read)
  607. AO_TS_t z = AO_TS_INITIALIZER;
  608. # endif
  609. # if defined(AO_HAVE_double_t)
  610. AO_double_t w;
  611. w.AO_val1 = 0;
  612. w.AO_val2 = 0;
  613. # endif
  614. # if defined(AO_HAVE_nop_read)
  615. AO_nop_read();
  616. # else
  617. MISSING(AO_nop);
  618. # endif
  619. # if defined(AO_HAVE_store_read)
  620. AO_store_read(&x, 13);
  621. TA_assert (x == 13);
  622. # else
  623. MISSING(AO_store);
  624. x = 13;
  625. # endif
  626. # if defined(AO_HAVE_load_read)
  627. TA_assert(AO_load_read(&x) == 13);
  628. # else
  629. MISSING(AO_load);
  630. # endif
  631. # if defined(AO_HAVE_test_and_set_read)
  632. assert(AO_test_and_set_read(&z) == AO_TS_CLEAR);
  633. assert(AO_test_and_set_read(&z) == AO_TS_SET);
  634. assert(AO_test_and_set_read(&z) == AO_TS_SET);
  635. AO_CLEAR(&z);
  636. # else
  637. MISSING(AO_test_and_set);
  638. # endif
  639. # if defined(AO_HAVE_fetch_and_add_read)
  640. TA_assert(AO_fetch_and_add_read(&x, 42) == 13);
  641. TA_assert(AO_fetch_and_add_read(&x, -42) == 55);
  642. # else
  643. MISSING(AO_fetch_and_add);
  644. # endif
  645. # if defined(AO_HAVE_fetch_and_add1_read)
  646. TA_assert(AO_fetch_and_add1_read(&x) == 13);
  647. # else
  648. MISSING(AO_fetch_and_add1);
  649. ++x;
  650. # endif
  651. # if defined(AO_HAVE_fetch_and_sub1_read)
  652. TA_assert(AO_fetch_and_sub1_read(&x) == 14);
  653. # else
  654. MISSING(AO_fetch_and_sub1);
  655. --x;
  656. # endif
  657. # if defined(AO_HAVE_short_store_read)
  658. AO_short_store_read(&s, 13);
  659. # else
  660. MISSING(AO_short_store);
  661. s = 13;
  662. # endif
  663. # if defined(AO_HAVE_short_load_read)
  664. TA_assert(AO_short_load(&s) == 13);
  665. # else
  666. MISSING(AO_short_load);
  667. # endif
  668. # if defined(AO_HAVE_short_fetch_and_add_read)
  669. TA_assert(AO_short_fetch_and_add_read(&s, 42) == 13);
  670. TA_assert(AO_short_fetch_and_add_read(&s, -42) == 55);
  671. # else
  672. MISSING(AO_short_fetch_and_add);
  673. # endif
  674. # if defined(AO_HAVE_short_fetch_and_add1_read)
  675. TA_assert(AO_short_fetch_and_add1_read(&s) == 13);
  676. # else
  677. MISSING(AO_short_fetch_and_add1);
  678. ++s;
  679. # endif
  680. # if defined(AO_HAVE_short_fetch_and_sub1_read)
  681. TA_assert(AO_short_fetch_and_sub1_read(&s) == 14);
  682. # else
  683. MISSING(AO_short_fetch_and_sub1);
  684. --s;
  685. # endif
  686. # if defined(AO_HAVE_char_store_read)
  687. AO_char_store_read(&b, 13);
  688. # else
  689. MISSING(AO_char_store);
  690. b = 13;
  691. # endif
  692. # if defined(AO_HAVE_char_load_read)
  693. TA_assert(AO_char_load(&b) == 13);
  694. # else
  695. MISSING(AO_char_load);
  696. # endif
  697. # if defined(AO_HAVE_char_fetch_and_add_read)
  698. TA_assert(AO_char_fetch_and_add_read(&b, 42) == 13);
  699. TA_assert(AO_char_fetch_and_add_read(&b, -42) == 55);
  700. # else
  701. MISSING(AO_char_fetch_and_add);
  702. # endif
  703. # if defined(AO_HAVE_char_fetch_and_add1_read)
  704. TA_assert(AO_char_fetch_and_add1_read(&b) == 13);
  705. # else
  706. MISSING(AO_char_fetch_and_add1);
  707. ++b;
  708. # endif
  709. # if defined(AO_HAVE_char_fetch_and_sub1_read)
  710. TA_assert(AO_char_fetch_and_sub1_read(&b) == 14);
  711. # else
  712. MISSING(AO_char_fetch_and_sub1);
  713. --b;
  714. # endif
  715. # if defined(AO_HAVE_int_store_read)
  716. AO_int_store_read(&zz, 13);
  717. # else
  718. MISSING(AO_int_store);
  719. zz = 13;
  720. # endif
  721. # if defined(AO_HAVE_int_load_read)
  722. TA_assert(AO_int_load(&zz) == 13);
  723. # else
  724. MISSING(AO_int_load);
  725. # endif
  726. # if defined(AO_HAVE_int_fetch_and_add_read)
  727. TA_assert(AO_int_fetch_and_add_read(&zz, 42) == 13);
  728. TA_assert(AO_int_fetch_and_add_read(&zz, -42) == 55);
  729. # else
  730. MISSING(AO_int_fetch_and_add);
  731. # endif
  732. # if defined(AO_HAVE_int_fetch_and_add1_read)
  733. TA_assert(AO_int_fetch_and_add1_read(&zz) == 13);
  734. # else
  735. MISSING(AO_int_fetch_and_add1);
  736. ++zz;
  737. # endif
  738. # if defined(AO_HAVE_int_fetch_and_sub1_read)
  739. TA_assert(AO_int_fetch_and_sub1_read(&zz) == 14);
  740. # else
  741. MISSING(AO_int_fetch_and_sub1);
  742. --zz;
  743. # endif
  744. # if defined(AO_HAVE_compare_and_swap_read)
  745. TA_assert(!AO_compare_and_swap_read(&x, 14, 42));
  746. TA_assert(x == 13);
  747. TA_assert(AO_compare_and_swap_read(&x, 13, 42));
  748. TA_assert(x == 42);
  749. # else
  750. MISSING(AO_compare_and_swap);
  751. # endif
  752. # if defined(AO_HAVE_or_read)
  753. AO_or_read(&x, 66);
  754. TA_assert(x == 106);
  755. # else
  756. MISSING(AO_or);
  757. x |= 34;
  758. # endif
  759. # if defined(AO_HAVE_compare_double_and_swap_double_read)
  760. TA_assert(!AO_compare_double_and_swap_double_read(&w, 17, 42, 12, 13));
  761. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  762. TA_assert(AO_compare_double_and_swap_double_read(&w, 0, 0, 12, 13));
  763. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  764. TA_assert(AO_compare_double_and_swap_double_read(&w, 12, 13, 17, 42));
  765. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  766. w.AO_val1 = 0; w.AO_val2 = 0;
  767. # else
  768. MISSING(AO_compare_double_and_swap_double);
  769. # endif
  770. # if defined(AO_HAVE_compare_and_swap_double_read)
  771. TA_assert(!AO_compare_and_swap_double_read(&w, 17, 12, 13));
  772. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  773. TA_assert(AO_compare_and_swap_double_read(&w, 0, 12, 13));
  774. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  775. TA_assert(AO_compare_and_swap_double_read(&w, 12, 17, 42));
  776. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  777. # else
  778. MISSING(AO_compare_and_swap_double);
  779. # endif
  780. }
  781. /*
  782. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  783. *
  784. * This file is covered by the GNU general public license, version 2.
  785. * see doc/COPYING for details.
  786. */
  787. /* Some basic sanity tests. These do not test the barrier semantics. */
  788. #undef TA_assert
  789. #define TA_assert(e) \
  790. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _write)\n", \
  791. __FILE__, __LINE__), exit(1); }
  792. #undef MISSING
  793. #define MISSING(name) \
  794. fprintf(stderr, "Missing: %s\n", #name "_write")
  795. void test_atomic_write(void)
  796. {
  797. AO_t x;
  798. unsigned char b;
  799. unsigned short s;
  800. unsigned int zz;
  801. # if defined(AO_HAVE_test_and_set_write)
  802. AO_TS_t z = AO_TS_INITIALIZER;
  803. # endif
  804. # if defined(AO_HAVE_double_t)
  805. AO_double_t w;
  806. w.AO_val1 = 0;
  807. w.AO_val2 = 0;
  808. # endif
  809. # if defined(AO_HAVE_nop_write)
  810. AO_nop_write();
  811. # else
  812. MISSING(AO_nop);
  813. # endif
  814. # if defined(AO_HAVE_store_write)
  815. AO_store_write(&x, 13);
  816. TA_assert (x == 13);
  817. # else
  818. MISSING(AO_store);
  819. x = 13;
  820. # endif
  821. # if defined(AO_HAVE_load_write)
  822. TA_assert(AO_load_write(&x) == 13);
  823. # else
  824. MISSING(AO_load);
  825. # endif
  826. # if defined(AO_HAVE_test_and_set_write)
  827. assert(AO_test_and_set_write(&z) == AO_TS_CLEAR);
  828. assert(AO_test_and_set_write(&z) == AO_TS_SET);
  829. assert(AO_test_and_set_write(&z) == AO_TS_SET);
  830. AO_CLEAR(&z);
  831. # else
  832. MISSING(AO_test_and_set);
  833. # endif
  834. # if defined(AO_HAVE_fetch_and_add_write)
  835. TA_assert(AO_fetch_and_add_write(&x, 42) == 13);
  836. TA_assert(AO_fetch_and_add_write(&x, -42) == 55);
  837. # else
  838. MISSING(AO_fetch_and_add);
  839. # endif
  840. # if defined(AO_HAVE_fetch_and_add1_write)
  841. TA_assert(AO_fetch_and_add1_write(&x) == 13);
  842. # else
  843. MISSING(AO_fetch_and_add1);
  844. ++x;
  845. # endif
  846. # if defined(AO_HAVE_fetch_and_sub1_write)
  847. TA_assert(AO_fetch_and_sub1_write(&x) == 14);
  848. # else
  849. MISSING(AO_fetch_and_sub1);
  850. --x;
  851. # endif
  852. # if defined(AO_HAVE_short_store_write)
  853. AO_short_store_write(&s, 13);
  854. # else
  855. MISSING(AO_short_store);
  856. s = 13;
  857. # endif
  858. # if defined(AO_HAVE_short_load_write)
  859. TA_assert(AO_short_load(&s) == 13);
  860. # else
  861. MISSING(AO_short_load);
  862. # endif
  863. # if defined(AO_HAVE_short_fetch_and_add_write)
  864. TA_assert(AO_short_fetch_and_add_write(&s, 42) == 13);
  865. TA_assert(AO_short_fetch_and_add_write(&s, -42) == 55);
  866. # else
  867. MISSING(AO_short_fetch_and_add);
  868. # endif
  869. # if defined(AO_HAVE_short_fetch_and_add1_write)
  870. TA_assert(AO_short_fetch_and_add1_write(&s) == 13);
  871. # else
  872. MISSING(AO_short_fetch_and_add1);
  873. ++s;
  874. # endif
  875. # if defined(AO_HAVE_short_fetch_and_sub1_write)
  876. TA_assert(AO_short_fetch_and_sub1_write(&s) == 14);
  877. # else
  878. MISSING(AO_short_fetch_and_sub1);
  879. --s;
  880. # endif
  881. # if defined(AO_HAVE_char_store_write)
  882. AO_char_store_write(&b, 13);
  883. # else
  884. MISSING(AO_char_store);
  885. b = 13;
  886. # endif
  887. # if defined(AO_HAVE_char_load_write)
  888. TA_assert(AO_char_load(&b) == 13);
  889. # else
  890. MISSING(AO_char_load);
  891. # endif
  892. # if defined(AO_HAVE_char_fetch_and_add_write)
  893. TA_assert(AO_char_fetch_and_add_write(&b, 42) == 13);
  894. TA_assert(AO_char_fetch_and_add_write(&b, -42) == 55);
  895. # else
  896. MISSING(AO_char_fetch_and_add);
  897. # endif
  898. # if defined(AO_HAVE_char_fetch_and_add1_write)
  899. TA_assert(AO_char_fetch_and_add1_write(&b) == 13);
  900. # else
  901. MISSING(AO_char_fetch_and_add1);
  902. ++b;
  903. # endif
  904. # if defined(AO_HAVE_char_fetch_and_sub1_write)
  905. TA_assert(AO_char_fetch_and_sub1_write(&b) == 14);
  906. # else
  907. MISSING(AO_char_fetch_and_sub1);
  908. --b;
  909. # endif
  910. # if defined(AO_HAVE_int_store_write)
  911. AO_int_store_write(&zz, 13);
  912. # else
  913. MISSING(AO_int_store);
  914. zz = 13;
  915. # endif
  916. # if defined(AO_HAVE_int_load_write)
  917. TA_assert(AO_int_load(&zz) == 13);
  918. # else
  919. MISSING(AO_int_load);
  920. # endif
  921. # if defined(AO_HAVE_int_fetch_and_add_write)
  922. TA_assert(AO_int_fetch_and_add_write(&zz, 42) == 13);
  923. TA_assert(AO_int_fetch_and_add_write(&zz, -42) == 55);
  924. # else
  925. MISSING(AO_int_fetch_and_add);
  926. # endif
  927. # if defined(AO_HAVE_int_fetch_and_add1_write)
  928. TA_assert(AO_int_fetch_and_add1_write(&zz) == 13);
  929. # else
  930. MISSING(AO_int_fetch_and_add1);
  931. ++zz;
  932. # endif
  933. # if defined(AO_HAVE_int_fetch_and_sub1_write)
  934. TA_assert(AO_int_fetch_and_sub1_write(&zz) == 14);
  935. # else
  936. MISSING(AO_int_fetch_and_sub1);
  937. --zz;
  938. # endif
  939. # if defined(AO_HAVE_compare_and_swap_write)
  940. TA_assert(!AO_compare_and_swap_write(&x, 14, 42));
  941. TA_assert(x == 13);
  942. TA_assert(AO_compare_and_swap_write(&x, 13, 42));
  943. TA_assert(x == 42);
  944. # else
  945. MISSING(AO_compare_and_swap);
  946. # endif
  947. # if defined(AO_HAVE_or_write)
  948. AO_or_write(&x, 66);
  949. TA_assert(x == 106);
  950. # else
  951. MISSING(AO_or);
  952. x |= 34;
  953. # endif
  954. # if defined(AO_HAVE_compare_double_and_swap_double_write)
  955. TA_assert(!AO_compare_double_and_swap_double_write(&w, 17, 42, 12, 13));
  956. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  957. TA_assert(AO_compare_double_and_swap_double_write(&w, 0, 0, 12, 13));
  958. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  959. TA_assert(AO_compare_double_and_swap_double_write(&w, 12, 13, 17, 42));
  960. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  961. w.AO_val1 = 0; w.AO_val2 = 0;
  962. # else
  963. MISSING(AO_compare_double_and_swap_double);
  964. # endif
  965. # if defined(AO_HAVE_compare_and_swap_double_write)
  966. TA_assert(!AO_compare_and_swap_double_write(&w, 17, 12, 13));
  967. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  968. TA_assert(AO_compare_and_swap_double_write(&w, 0, 12, 13));
  969. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  970. TA_assert(AO_compare_and_swap_double_write(&w, 12, 17, 42));
  971. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  972. # else
  973. MISSING(AO_compare_and_swap_double);
  974. # endif
  975. }
  976. /*
  977. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  978. *
  979. * This file is covered by the GNU general public license, version 2.
  980. * see doc/COPYING for details.
  981. */
  982. /* Some basic sanity tests. These do not test the barrier semantics. */
  983. #undef TA_assert
  984. #define TA_assert(e) \
  985. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _full)\n", \
  986. __FILE__, __LINE__), exit(1); }
  987. #undef MISSING
  988. #define MISSING(name) \
  989. fprintf(stderr, "Missing: %s\n", #name "_full")
  990. void test_atomic_full(void)
  991. {
  992. AO_t x;
  993. unsigned char b;
  994. unsigned short s;
  995. unsigned int zz;
  996. # if defined(AO_HAVE_test_and_set_full)
  997. AO_TS_t z = AO_TS_INITIALIZER;
  998. # endif
  999. # if defined(AO_HAVE_double_t)
  1000. AO_double_t w;
  1001. w.AO_val1 = 0;
  1002. w.AO_val2 = 0;
  1003. # endif
  1004. # if defined(AO_HAVE_nop_full)
  1005. AO_nop_full();
  1006. # else
  1007. MISSING(AO_nop);
  1008. # endif
  1009. # if defined(AO_HAVE_store_full)
  1010. AO_store_full(&x, 13);
  1011. TA_assert (x == 13);
  1012. # else
  1013. MISSING(AO_store);
  1014. x = 13;
  1015. # endif
  1016. # if defined(AO_HAVE_load_full)
  1017. TA_assert(AO_load_full(&x) == 13);
  1018. # else
  1019. MISSING(AO_load);
  1020. # endif
  1021. # if defined(AO_HAVE_test_and_set_full)
  1022. assert(AO_test_and_set_full(&z) == AO_TS_CLEAR);
  1023. assert(AO_test_and_set_full(&z) == AO_TS_SET);
  1024. assert(AO_test_and_set_full(&z) == AO_TS_SET);
  1025. AO_CLEAR(&z);
  1026. # else
  1027. MISSING(AO_test_and_set);
  1028. # endif
  1029. # if defined(AO_HAVE_fetch_and_add_full)
  1030. TA_assert(AO_fetch_and_add_full(&x, 42) == 13);
  1031. TA_assert(AO_fetch_and_add_full(&x, -42) == 55);
  1032. # else
  1033. MISSING(AO_fetch_and_add);
  1034. # endif
  1035. # if defined(AO_HAVE_fetch_and_add1_full)
  1036. TA_assert(AO_fetch_and_add1_full(&x) == 13);
  1037. # else
  1038. MISSING(AO_fetch_and_add1);
  1039. ++x;
  1040. # endif
  1041. # if defined(AO_HAVE_fetch_and_sub1_full)
  1042. TA_assert(AO_fetch_and_sub1_full(&x) == 14);
  1043. # else
  1044. MISSING(AO_fetch_and_sub1);
  1045. --x;
  1046. # endif
  1047. # if defined(AO_HAVE_short_store_full)
  1048. AO_short_store_full(&s, 13);
  1049. # else
  1050. MISSING(AO_short_store);
  1051. s = 13;
  1052. # endif
  1053. # if defined(AO_HAVE_short_load_full)
  1054. TA_assert(AO_short_load(&s) == 13);
  1055. # else
  1056. MISSING(AO_short_load);
  1057. # endif
  1058. # if defined(AO_HAVE_short_fetch_and_add_full)
  1059. TA_assert(AO_short_fetch_and_add_full(&s, 42) == 13);
  1060. TA_assert(AO_short_fetch_and_add_full(&s, -42) == 55);
  1061. # else
  1062. MISSING(AO_short_fetch_and_add);
  1063. # endif
  1064. # if defined(AO_HAVE_short_fetch_and_add1_full)
  1065. TA_assert(AO_short_fetch_and_add1_full(&s) == 13);
  1066. # else
  1067. MISSING(AO_short_fetch_and_add1);
  1068. ++s;
  1069. # endif
  1070. # if defined(AO_HAVE_short_fetch_and_sub1_full)
  1071. TA_assert(AO_short_fetch_and_sub1_full(&s) == 14);
  1072. # else
  1073. MISSING(AO_short_fetch_and_sub1);
  1074. --s;
  1075. # endif
  1076. # if defined(AO_HAVE_char_store_full)
  1077. AO_char_store_full(&b, 13);
  1078. # else
  1079. MISSING(AO_char_store);
  1080. b = 13;
  1081. # endif
  1082. # if defined(AO_HAVE_char_load_full)
  1083. TA_assert(AO_char_load(&b) == 13);
  1084. # else
  1085. MISSING(AO_char_load);
  1086. # endif
  1087. # if defined(AO_HAVE_char_fetch_and_add_full)
  1088. TA_assert(AO_char_fetch_and_add_full(&b, 42) == 13);
  1089. TA_assert(AO_char_fetch_and_add_full(&b, -42) == 55);
  1090. # else
  1091. MISSING(AO_char_fetch_and_add);
  1092. # endif
  1093. # if defined(AO_HAVE_char_fetch_and_add1_full)
  1094. TA_assert(AO_char_fetch_and_add1_full(&b) == 13);
  1095. # else
  1096. MISSING(AO_char_fetch_and_add1);
  1097. ++b;
  1098. # endif
  1099. # if defined(AO_HAVE_char_fetch_and_sub1_full)
  1100. TA_assert(AO_char_fetch_and_sub1_full(&b) == 14);
  1101. # else
  1102. MISSING(AO_char_fetch_and_sub1);
  1103. --b;
  1104. # endif
  1105. # if defined(AO_HAVE_int_store_full)
  1106. AO_int_store_full(&zz, 13);
  1107. # else
  1108. MISSING(AO_int_store);
  1109. zz = 13;
  1110. # endif
  1111. # if defined(AO_HAVE_int_load_full)
  1112. TA_assert(AO_int_load(&zz) == 13);
  1113. # else
  1114. MISSING(AO_int_load);
  1115. # endif
  1116. # if defined(AO_HAVE_int_fetch_and_add_full)
  1117. TA_assert(AO_int_fetch_and_add_full(&zz, 42) == 13);
  1118. TA_assert(AO_int_fetch_and_add_full(&zz, -42) == 55);
  1119. # else
  1120. MISSING(AO_int_fetch_and_add);
  1121. # endif
  1122. # if defined(AO_HAVE_int_fetch_and_add1_full)
  1123. TA_assert(AO_int_fetch_and_add1_full(&zz) == 13);
  1124. # else
  1125. MISSING(AO_int_fetch_and_add1);
  1126. ++zz;
  1127. # endif
  1128. # if defined(AO_HAVE_int_fetch_and_sub1_full)
  1129. TA_assert(AO_int_fetch_and_sub1_full(&zz) == 14);
  1130. # else
  1131. MISSING(AO_int_fetch_and_sub1);
  1132. --zz;
  1133. # endif
  1134. # if defined(AO_HAVE_compare_and_swap_full)
  1135. TA_assert(!AO_compare_and_swap_full(&x, 14, 42));
  1136. TA_assert(x == 13);
  1137. TA_assert(AO_compare_and_swap_full(&x, 13, 42));
  1138. TA_assert(x == 42);
  1139. # else
  1140. MISSING(AO_compare_and_swap);
  1141. # endif
  1142. # if defined(AO_HAVE_or_full)
  1143. AO_or_full(&x, 66);
  1144. TA_assert(x == 106);
  1145. # else
  1146. MISSING(AO_or);
  1147. x |= 34;
  1148. # endif
  1149. # if defined(AO_HAVE_compare_double_and_swap_double_full)
  1150. TA_assert(!AO_compare_double_and_swap_double_full(&w, 17, 42, 12, 13));
  1151. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  1152. TA_assert(AO_compare_double_and_swap_double_full(&w, 0, 0, 12, 13));
  1153. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  1154. TA_assert(AO_compare_double_and_swap_double_full(&w, 12, 13, 17, 42));
  1155. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  1156. w.AO_val1 = 0; w.AO_val2 = 0;
  1157. # else
  1158. MISSING(AO_compare_double_and_swap_double);
  1159. # endif
  1160. # if defined(AO_HAVE_compare_and_swap_double_full)
  1161. TA_assert(!AO_compare_and_swap_double_full(&w, 17, 12, 13));
  1162. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  1163. TA_assert(AO_compare_and_swap_double_full(&w, 0, 12, 13));
  1164. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  1165. TA_assert(AO_compare_and_swap_double_full(&w, 12, 17, 42));
  1166. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  1167. # else
  1168. MISSING(AO_compare_and_swap_double);
  1169. # endif
  1170. }
  1171. /*
  1172. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  1173. *
  1174. * This file is covered by the GNU general public license, version 2.
  1175. * see doc/COPYING for details.
  1176. */
  1177. /* Some basic sanity tests. These do not test the barrier semantics. */
  1178. #undef TA_assert
  1179. #define TA_assert(e) \
  1180. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _release_write)\n", \
  1181. __FILE__, __LINE__), exit(1); }
  1182. #undef MISSING
  1183. #define MISSING(name) \
  1184. fprintf(stderr, "Missing: %s\n", #name "_release_write")
  1185. void test_atomic_release_write(void)
  1186. {
  1187. AO_t x;
  1188. unsigned char b;
  1189. unsigned short s;
  1190. unsigned int zz;
  1191. # if defined(AO_HAVE_test_and_set_release_write)
  1192. AO_TS_t z = AO_TS_INITIALIZER;
  1193. # endif
  1194. # if defined(AO_HAVE_double_t)
  1195. AO_double_t w;
  1196. w.AO_val1 = 0;
  1197. w.AO_val2 = 0;
  1198. # endif
  1199. # if defined(AO_HAVE_nop_release_write)
  1200. AO_nop_release_write();
  1201. # else
  1202. MISSING(AO_nop);
  1203. # endif
  1204. # if defined(AO_HAVE_store_release_write)
  1205. AO_store_release_write(&x, 13);
  1206. TA_assert (x == 13);
  1207. # else
  1208. MISSING(AO_store);
  1209. x = 13;
  1210. # endif
  1211. # if defined(AO_HAVE_load_release_write)
  1212. TA_assert(AO_load_release_write(&x) == 13);
  1213. # else
  1214. MISSING(AO_load);
  1215. # endif
  1216. # if defined(AO_HAVE_test_and_set_release_write)
  1217. assert(AO_test_and_set_release_write(&z) == AO_TS_CLEAR);
  1218. assert(AO_test_and_set_release_write(&z) == AO_TS_SET);
  1219. assert(AO_test_and_set_release_write(&z) == AO_TS_SET);
  1220. AO_CLEAR(&z);
  1221. # else
  1222. MISSING(AO_test_and_set);
  1223. # endif
  1224. # if defined(AO_HAVE_fetch_and_add_release_write)
  1225. TA_assert(AO_fetch_and_add_release_write(&x, 42) == 13);
  1226. TA_assert(AO_fetch_and_add_release_write(&x, -42) == 55);
  1227. # else
  1228. MISSING(AO_fetch_and_add);
  1229. # endif
  1230. # if defined(AO_HAVE_fetch_and_add1_release_write)
  1231. TA_assert(AO_fetch_and_add1_release_write(&x) == 13);
  1232. # else
  1233. MISSING(AO_fetch_and_add1);
  1234. ++x;
  1235. # endif
  1236. # if defined(AO_HAVE_fetch_and_sub1_release_write)
  1237. TA_assert(AO_fetch_and_sub1_release_write(&x) == 14);
  1238. # else
  1239. MISSING(AO_fetch_and_sub1);
  1240. --x;
  1241. # endif
  1242. # if defined(AO_HAVE_short_store_release_write)
  1243. AO_short_store_release_write(&s, 13);
  1244. # else
  1245. MISSING(AO_short_store);
  1246. s = 13;
  1247. # endif
  1248. # if defined(AO_HAVE_short_load_release_write)
  1249. TA_assert(AO_short_load(&s) == 13);
  1250. # else
  1251. MISSING(AO_short_load);
  1252. # endif
  1253. # if defined(AO_HAVE_short_fetch_and_add_release_write)
  1254. TA_assert(AO_short_fetch_and_add_release_write(&s, 42) == 13);
  1255. TA_assert(AO_short_fetch_and_add_release_write(&s, -42) == 55);
  1256. # else
  1257. MISSING(AO_short_fetch_and_add);
  1258. # endif
  1259. # if defined(AO_HAVE_short_fetch_and_add1_release_write)
  1260. TA_assert(AO_short_fetch_and_add1_release_write(&s) == 13);
  1261. # else
  1262. MISSING(AO_short_fetch_and_add1);
  1263. ++s;
  1264. # endif
  1265. # if defined(AO_HAVE_short_fetch_and_sub1_release_write)
  1266. TA_assert(AO_short_fetch_and_sub1_release_write(&s) == 14);
  1267. # else
  1268. MISSING(AO_short_fetch_and_sub1);
  1269. --s;
  1270. # endif
  1271. # if defined(AO_HAVE_char_store_release_write)
  1272. AO_char_store_release_write(&b, 13);
  1273. # else
  1274. MISSING(AO_char_store);
  1275. b = 13;
  1276. # endif
  1277. # if defined(AO_HAVE_char_load_release_write)
  1278. TA_assert(AO_char_load(&b) == 13);
  1279. # else
  1280. MISSING(AO_char_load);
  1281. # endif
  1282. # if defined(AO_HAVE_char_fetch_and_add_release_write)
  1283. TA_assert(AO_char_fetch_and_add_release_write(&b, 42) == 13);
  1284. TA_assert(AO_char_fetch_and_add_release_write(&b, -42) == 55);
  1285. # else
  1286. MISSING(AO_char_fetch_and_add);
  1287. # endif
  1288. # if defined(AO_HAVE_char_fetch_and_add1_release_write)
  1289. TA_assert(AO_char_fetch_and_add1_release_write(&b) == 13);
  1290. # else
  1291. MISSING(AO_char_fetch_and_add1);
  1292. ++b;
  1293. # endif
  1294. # if defined(AO_HAVE_char_fetch_and_sub1_release_write)
  1295. TA_assert(AO_char_fetch_and_sub1_release_write(&b) == 14);
  1296. # else
  1297. MISSING(AO_char_fetch_and_sub1);
  1298. --b;
  1299. # endif
  1300. # if defined(AO_HAVE_int_store_release_write)
  1301. AO_int_store_release_write(&zz, 13);
  1302. # else
  1303. MISSING(AO_int_store);
  1304. zz = 13;
  1305. # endif
  1306. # if defined(AO_HAVE_int_load_release_write)
  1307. TA_assert(AO_int_load(&zz) == 13);
  1308. # else
  1309. MISSING(AO_int_load);
  1310. # endif
  1311. # if defined(AO_HAVE_int_fetch_and_add_release_write)
  1312. TA_assert(AO_int_fetch_and_add_release_write(&zz, 42) == 13);
  1313. TA_assert(AO_int_fetch_and_add_release_write(&zz, -42) == 55);
  1314. # else
  1315. MISSING(AO_int_fetch_and_add);
  1316. # endif
  1317. # if defined(AO_HAVE_int_fetch_and_add1_release_write)
  1318. TA_assert(AO_int_fetch_and_add1_release_write(&zz) == 13);
  1319. # else
  1320. MISSING(AO_int_fetch_and_add1);
  1321. ++zz;
  1322. # endif
  1323. # if defined(AO_HAVE_int_fetch_and_sub1_release_write)
  1324. TA_assert(AO_int_fetch_and_sub1_release_write(&zz) == 14);
  1325. # else
  1326. MISSING(AO_int_fetch_and_sub1);
  1327. --zz;
  1328. # endif
  1329. # if defined(AO_HAVE_compare_and_swap_release_write)
  1330. TA_assert(!AO_compare_and_swap_release_write(&x, 14, 42));
  1331. TA_assert(x == 13);
  1332. TA_assert(AO_compare_and_swap_release_write(&x, 13, 42));
  1333. TA_assert(x == 42);
  1334. # else
  1335. MISSING(AO_compare_and_swap);
  1336. # endif
  1337. # if defined(AO_HAVE_or_release_write)
  1338. AO_or_release_write(&x, 66);
  1339. TA_assert(x == 106);
  1340. # else
  1341. MISSING(AO_or);
  1342. x |= 34;
  1343. # endif
  1344. # if defined(AO_HAVE_compare_double_and_swap_double_release_write)
  1345. TA_assert(!AO_compare_double_and_swap_double_release_write(&w, 17, 42, 12, 13));
  1346. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  1347. TA_assert(AO_compare_double_and_swap_double_release_write(&w, 0, 0, 12, 13));
  1348. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  1349. TA_assert(AO_compare_double_and_swap_double_release_write(&w, 12, 13, 17, 42));
  1350. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  1351. w.AO_val1 = 0; w.AO_val2 = 0;
  1352. # else
  1353. MISSING(AO_compare_double_and_swap_double);
  1354. # endif
  1355. # if defined(AO_HAVE_compare_and_swap_double_release_write)
  1356. TA_assert(!AO_compare_and_swap_double_release_write(&w, 17, 12, 13));
  1357. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  1358. TA_assert(AO_compare_and_swap_double_release_write(&w, 0, 12, 13));
  1359. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  1360. TA_assert(AO_compare_and_swap_double_release_write(&w, 12, 17, 42));
  1361. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  1362. # else
  1363. MISSING(AO_compare_and_swap_double);
  1364. # endif
  1365. }
  1366. /*
  1367. * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
  1368. *
  1369. * This file is covered by the GNU general public license, version 2.
  1370. * see doc/COPYING for details.
  1371. */
  1372. /* Some basic sanity tests. These do not test the barrier semantics. */
  1373. #undef TA_assert
  1374. #define TA_assert(e) \
  1375. if (!(e)) { fprintf(stderr, "Assertion failed %s:%d (barrier: _acquire_read)\n", \
  1376. __FILE__, __LINE__), exit(1); }
  1377. #undef MISSING
  1378. #define MISSING(name) \
  1379. fprintf(stderr, "Missing: %s\n", #name "_acquire_read")
  1380. void test_atomic_acquire_read(void)
  1381. {
  1382. AO_t x;
  1383. unsigned char b;
  1384. unsigned short s;
  1385. unsigned int zz;
  1386. # if defined(AO_HAVE_test_and_set_acquire_read)
  1387. AO_TS_t z = AO_TS_INITIALIZER;
  1388. # endif
  1389. # if defined(AO_HAVE_double_t)
  1390. AO_double_t w;
  1391. w.AO_val1 = 0;
  1392. w.AO_val2 = 0;
  1393. # endif
  1394. # if defined(AO_HAVE_nop_acquire_read)
  1395. AO_nop_acquire_read();
  1396. # else
  1397. MISSING(AO_nop);
  1398. # endif
  1399. # if defined(AO_HAVE_store_acquire_read)
  1400. AO_store_acquire_read(&x, 13);
  1401. TA_assert (x == 13);
  1402. # else
  1403. MISSING(AO_store);
  1404. x = 13;
  1405. # endif
  1406. # if defined(AO_HAVE_load_acquire_read)
  1407. TA_assert(AO_load_acquire_read(&x) == 13);
  1408. # else
  1409. MISSING(AO_load);
  1410. # endif
  1411. # if defined(AO_HAVE_test_and_set_acquire_read)
  1412. assert(AO_test_and_set_acquire_read(&z) == AO_TS_CLEAR);
  1413. assert(AO_test_and_set_acquire_read(&z) == AO_TS_SET);
  1414. assert(AO_test_and_set_acquire_read(&z) == AO_TS_SET);
  1415. AO_CLEAR(&z);
  1416. # else
  1417. MISSING(AO_test_and_set);
  1418. # endif
  1419. # if defined(AO_HAVE_fetch_and_add_acquire_read)
  1420. TA_assert(AO_fetch_and_add_acquire_read(&x, 42) == 13);
  1421. TA_assert(AO_fetch_and_add_acquire_read(&x, -42) == 55);
  1422. # else
  1423. MISSING(AO_fetch_and_add);
  1424. # endif
  1425. # if defined(AO_HAVE_fetch_and_add1_acquire_read)
  1426. TA_assert(AO_fetch_and_add1_acquire_read(&x) == 13);
  1427. # else
  1428. MISSING(AO_fetch_and_add1);
  1429. ++x;
  1430. # endif
  1431. # if defined(AO_HAVE_fetch_and_sub1_acquire_read)
  1432. TA_assert(AO_fetch_and_sub1_acquire_read(&x) == 14);
  1433. # else
  1434. MISSING(AO_fetch_and_sub1);
  1435. --x;
  1436. # endif
  1437. # if defined(AO_HAVE_short_store_acquire_read)
  1438. AO_short_store_acquire_read(&s, 13);
  1439. # else
  1440. MISSING(AO_short_store);
  1441. s = 13;
  1442. # endif
  1443. # if defined(AO_HAVE_short_load_acquire_read)
  1444. TA_assert(AO_short_load(&s) == 13);
  1445. # else
  1446. MISSING(AO_short_load);
  1447. # endif
  1448. # if defined(AO_HAVE_short_fetch_and_add_acquire_read)
  1449. TA_assert(AO_short_fetch_and_add_acquire_read(&s, 42) == 13);
  1450. TA_assert(AO_short_fetch_and_add_acquire_read(&s, -42) == 55);
  1451. # else
  1452. MISSING(AO_short_fetch_and_add);
  1453. # endif
  1454. # if defined(AO_HAVE_short_fetch_and_add1_acquire_read)
  1455. TA_assert(AO_short_fetch_and_add1_acquire_read(&s) == 13);
  1456. # else
  1457. MISSING(AO_short_fetch_and_add1);
  1458. ++s;
  1459. # endif
  1460. # if defined(AO_HAVE_short_fetch_and_sub1_acquire_read)
  1461. TA_assert(AO_short_fetch_and_sub1_acquire_read(&s) == 14);
  1462. # else
  1463. MISSING(AO_short_fetch_and_sub1);
  1464. --s;
  1465. # endif
  1466. # if defined(AO_HAVE_char_store_acquire_read)
  1467. AO_char_store_acquire_read(&b, 13);
  1468. # else
  1469. MISSING(AO_char_store);
  1470. b = 13;
  1471. # endif
  1472. # if defined(AO_HAVE_char_load_acquire_read)
  1473. TA_assert(AO_char_load(&b) == 13);
  1474. # else
  1475. MISSING(AO_char_load);
  1476. # endif
  1477. # if defined(AO_HAVE_char_fetch_and_add_acquire_read)
  1478. TA_assert(AO_char_fetch_and_add_acquire_read(&b, 42) == 13);
  1479. TA_assert(AO_char_fetch_and_add_acquire_read(&b, -42) == 55);
  1480. # else
  1481. MISSING(AO_char_fetch_and_add);
  1482. # endif
  1483. # if defined(AO_HAVE_char_fetch_and_add1_acquire_read)
  1484. TA_assert(AO_char_fetch_and_add1_acquire_read(&b) == 13);
  1485. # else
  1486. MISSING(AO_char_fetch_and_add1);
  1487. ++b;
  1488. # endif
  1489. # if defined(AO_HAVE_char_fetch_and_sub1_acquire_read)
  1490. TA_assert(AO_char_fetch_and_sub1_acquire_read(&b) == 14);
  1491. # else
  1492. MISSING(AO_char_fetch_and_sub1);
  1493. --b;
  1494. # endif
  1495. # if defined(AO_HAVE_int_store_acquire_read)
  1496. AO_int_store_acquire_read(&zz, 13);
  1497. # else
  1498. MISSING(AO_int_store);
  1499. zz = 13;
  1500. # endif
  1501. # if defined(AO_HAVE_int_load_acquire_read)
  1502. TA_assert(AO_int_load(&zz) == 13);
  1503. # else
  1504. MISSING(AO_int_load);
  1505. # endif
  1506. # if defined(AO_HAVE_int_fetch_and_add_acquire_read)
  1507. TA_assert(AO_int_fetch_and_add_acquire_read(&zz, 42) == 13);
  1508. TA_assert(AO_int_fetch_and_add_acquire_read(&zz, -42) == 55);
  1509. # else
  1510. MISSING(AO_int_fetch_and_add);
  1511. # endif
  1512. # if defined(AO_HAVE_int_fetch_and_add1_acquire_read)
  1513. TA_assert(AO_int_fetch_and_add1_acquire_read(&zz) == 13);
  1514. # else
  1515. MISSING(AO_int_fetch_and_add1);
  1516. ++zz;
  1517. # endif
  1518. # if defined(AO_HAVE_int_fetch_and_sub1_acquire_read)
  1519. TA_assert(AO_int_fetch_and_sub1_acquire_read(&zz) == 14);
  1520. # else
  1521. MISSING(AO_int_fetch_and_sub1);
  1522. --zz;
  1523. # endif
  1524. # if defined(AO_HAVE_compare_and_swap_acquire_read)
  1525. TA_assert(!AO_compare_and_swap_acquire_read(&x, 14, 42));
  1526. TA_assert(x == 13);
  1527. TA_assert(AO_compare_and_swap_acquire_read(&x, 13, 42));
  1528. TA_assert(x == 42);
  1529. # else
  1530. MISSING(AO_compare_and_swap);
  1531. # endif
  1532. # if defined(AO_HAVE_or_acquire_read)
  1533. AO_or_acquire_read(&x, 66);
  1534. TA_assert(x == 106);
  1535. # else
  1536. MISSING(AO_or);
  1537. x |= 34;
  1538. # endif
  1539. # if defined(AO_HAVE_compare_double_and_swap_double_acquire_read)
  1540. TA_assert(!AO_compare_double_and_swap_double_acquire_read(&w, 17, 42, 12, 13));
  1541. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  1542. TA_assert(AO_compare_double_and_swap_double_acquire_read(&w, 0, 0, 12, 13));
  1543. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  1544. TA_assert(AO_compare_double_and_swap_double_acquire_read(&w, 12, 13, 17, 42));
  1545. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  1546. w.AO_val1 = 0; w.AO_val2 = 0;
  1547. # else
  1548. MISSING(AO_compare_double_and_swap_double);
  1549. # endif
  1550. # if defined(AO_HAVE_compare_and_swap_double_acquire_read)
  1551. TA_assert(!AO_compare_and_swap_double_acquire_read(&w, 17, 12, 13));
  1552. TA_assert(w.AO_val1 == 0 && w.AO_val2 == 0);
  1553. TA_assert(AO_compare_and_swap_double_acquire_read(&w, 0, 12, 13));
  1554. TA_assert(w.AO_val1 == 12 && w.AO_val2 == 13);
  1555. TA_assert(AO_compare_and_swap_double_acquire_read(&w, 12, 17, 42));
  1556. TA_assert(w.AO_val1 == 17 && w.AO_val2 == 42);
  1557. # else
  1558. MISSING(AO_compare_and_swap_double);
  1559. # endif
  1560. }