generic-arithm.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*
  2. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  3. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  4. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  5. *
  6. *
  7. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  8. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  9. *
  10. * Permission is hereby granted to use or copy this program
  11. * for any purpose, provided the above notices are retained on all copies.
  12. * Permission to modify the code and to distribute modified code is granted,
  13. * provided the above notices are retained, and a notice that the code was
  14. * modified is included with the above copyright notice.
  15. *
  16. */
  17. AO_INLINE unsigned/**/char
  18. AO_char_fetch_and_add(volatile unsigned/**/char *addr, unsigned/**/char incr)
  19. {
  20. return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED);
  21. }
  22. #define AO_HAVE_char_fetch_and_add
  23. AO_INLINE void
  24. AO_char_and(volatile unsigned/**/char *addr, unsigned/**/char value)
  25. {
  26. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED);
  27. }
  28. #define AO_HAVE_char_and
  29. AO_INLINE void
  30. AO_char_or(volatile unsigned/**/char *addr, unsigned/**/char value)
  31. {
  32. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED);
  33. }
  34. #define AO_HAVE_char_or
  35. AO_INLINE void
  36. AO_char_xor(volatile unsigned/**/char *addr, unsigned/**/char value)
  37. {
  38. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED);
  39. }
  40. #define AO_HAVE_char_xor
  41. /*
  42. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  43. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  44. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  45. *
  46. *
  47. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  48. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  49. *
  50. * Permission is hereby granted to use or copy this program
  51. * for any purpose, provided the above notices are retained on all copies.
  52. * Permission to modify the code and to distribute modified code is granted,
  53. * provided the above notices are retained, and a notice that the code was
  54. * modified is included with the above copyright notice.
  55. *
  56. */
  57. AO_INLINE unsigned/**/short
  58. AO_short_fetch_and_add(volatile unsigned/**/short *addr, unsigned/**/short incr)
  59. {
  60. return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED);
  61. }
  62. #define AO_HAVE_short_fetch_and_add
  63. AO_INLINE void
  64. AO_short_and(volatile unsigned/**/short *addr, unsigned/**/short value)
  65. {
  66. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED);
  67. }
  68. #define AO_HAVE_short_and
  69. AO_INLINE void
  70. AO_short_or(volatile unsigned/**/short *addr, unsigned/**/short value)
  71. {
  72. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED);
  73. }
  74. #define AO_HAVE_short_or
  75. AO_INLINE void
  76. AO_short_xor(volatile unsigned/**/short *addr, unsigned/**/short value)
  77. {
  78. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED);
  79. }
  80. #define AO_HAVE_short_xor
  81. /*
  82. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  83. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  84. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  85. *
  86. *
  87. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  88. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  89. *
  90. * Permission is hereby granted to use or copy this program
  91. * for any purpose, provided the above notices are retained on all copies.
  92. * Permission to modify the code and to distribute modified code is granted,
  93. * provided the above notices are retained, and a notice that the code was
  94. * modified is included with the above copyright notice.
  95. *
  96. */
  97. AO_INLINE unsigned
  98. AO_int_fetch_and_add(volatile unsigned *addr, unsigned incr)
  99. {
  100. return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED);
  101. }
  102. #define AO_HAVE_int_fetch_and_add
  103. AO_INLINE void
  104. AO_int_and(volatile unsigned *addr, unsigned value)
  105. {
  106. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED);
  107. }
  108. #define AO_HAVE_int_and
  109. AO_INLINE void
  110. AO_int_or(volatile unsigned *addr, unsigned value)
  111. {
  112. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED);
  113. }
  114. #define AO_HAVE_int_or
  115. AO_INLINE void
  116. AO_int_xor(volatile unsigned *addr, unsigned value)
  117. {
  118. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED);
  119. }
  120. #define AO_HAVE_int_xor
  121. /*
  122. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  123. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  124. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  125. *
  126. *
  127. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  128. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  129. *
  130. * Permission is hereby granted to use or copy this program
  131. * for any purpose, provided the above notices are retained on all copies.
  132. * Permission to modify the code and to distribute modified code is granted,
  133. * provided the above notices are retained, and a notice that the code was
  134. * modified is included with the above copyright notice.
  135. *
  136. */
  137. AO_INLINE AO_t
  138. AO_fetch_and_add(volatile AO_t *addr, AO_t incr)
  139. {
  140. return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED);
  141. }
  142. #define AO_HAVE_fetch_and_add
  143. AO_INLINE void
  144. AO_and(volatile AO_t *addr, AO_t value)
  145. {
  146. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED);
  147. }
  148. #define AO_HAVE_and
  149. AO_INLINE void
  150. AO_or(volatile AO_t *addr, AO_t value)
  151. {
  152. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED);
  153. }
  154. #define AO_HAVE_or
  155. AO_INLINE void
  156. AO_xor(volatile AO_t *addr, AO_t value)
  157. {
  158. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED);
  159. }
  160. #define AO_HAVE_xor
  161. /*
  162. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  163. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  164. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  165. *
  166. *
  167. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  168. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  169. *
  170. * Permission is hereby granted to use or copy this program
  171. * for any purpose, provided the above notices are retained on all copies.
  172. * Permission to modify the code and to distribute modified code is granted,
  173. * provided the above notices are retained, and a notice that the code was
  174. * modified is included with the above copyright notice.
  175. *
  176. */
  177. AO_INLINE unsigned/**/char
  178. AO_char_fetch_and_add_acquire(volatile unsigned/**/char *addr, unsigned/**/char incr)
  179. {
  180. return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE);
  181. }
  182. #define AO_HAVE_char_fetch_and_add_acquire
  183. AO_INLINE void
  184. AO_char_and_acquire(volatile unsigned/**/char *addr, unsigned/**/char value)
  185. {
  186. (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE);
  187. }
  188. #define AO_HAVE_char_and_acquire
  189. AO_INLINE void
  190. AO_char_or_acquire(volatile unsigned/**/char *addr, unsigned/**/char value)
  191. {
  192. (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE);
  193. }
  194. #define AO_HAVE_char_or_acquire
  195. AO_INLINE void
  196. AO_char_xor_acquire(volatile unsigned/**/char *addr, unsigned/**/char value)
  197. {
  198. (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE);
  199. }
  200. #define AO_HAVE_char_xor_acquire
  201. /*
  202. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  203. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  204. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  205. *
  206. *
  207. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  208. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  209. *
  210. * Permission is hereby granted to use or copy this program
  211. * for any purpose, provided the above notices are retained on all copies.
  212. * Permission to modify the code and to distribute modified code is granted,
  213. * provided the above notices are retained, and a notice that the code was
  214. * modified is included with the above copyright notice.
  215. *
  216. */
  217. AO_INLINE unsigned/**/short
  218. AO_short_fetch_and_add_acquire(volatile unsigned/**/short *addr, unsigned/**/short incr)
  219. {
  220. return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE);
  221. }
  222. #define AO_HAVE_short_fetch_and_add_acquire
  223. AO_INLINE void
  224. AO_short_and_acquire(volatile unsigned/**/short *addr, unsigned/**/short value)
  225. {
  226. (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE);
  227. }
  228. #define AO_HAVE_short_and_acquire
  229. AO_INLINE void
  230. AO_short_or_acquire(volatile unsigned/**/short *addr, unsigned/**/short value)
  231. {
  232. (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE);
  233. }
  234. #define AO_HAVE_short_or_acquire
  235. AO_INLINE void
  236. AO_short_xor_acquire(volatile unsigned/**/short *addr, unsigned/**/short value)
  237. {
  238. (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE);
  239. }
  240. #define AO_HAVE_short_xor_acquire
  241. /*
  242. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  243. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  244. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  245. *
  246. *
  247. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  248. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  249. *
  250. * Permission is hereby granted to use or copy this program
  251. * for any purpose, provided the above notices are retained on all copies.
  252. * Permission to modify the code and to distribute modified code is granted,
  253. * provided the above notices are retained, and a notice that the code was
  254. * modified is included with the above copyright notice.
  255. *
  256. */
  257. AO_INLINE unsigned
  258. AO_int_fetch_and_add_acquire(volatile unsigned *addr, unsigned incr)
  259. {
  260. return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE);
  261. }
  262. #define AO_HAVE_int_fetch_and_add_acquire
  263. AO_INLINE void
  264. AO_int_and_acquire(volatile unsigned *addr, unsigned value)
  265. {
  266. (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE);
  267. }
  268. #define AO_HAVE_int_and_acquire
  269. AO_INLINE void
  270. AO_int_or_acquire(volatile unsigned *addr, unsigned value)
  271. {
  272. (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE);
  273. }
  274. #define AO_HAVE_int_or_acquire
  275. AO_INLINE void
  276. AO_int_xor_acquire(volatile unsigned *addr, unsigned value)
  277. {
  278. (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE);
  279. }
  280. #define AO_HAVE_int_xor_acquire
  281. /*
  282. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  283. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  284. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  285. *
  286. *
  287. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  288. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  289. *
  290. * Permission is hereby granted to use or copy this program
  291. * for any purpose, provided the above notices are retained on all copies.
  292. * Permission to modify the code and to distribute modified code is granted,
  293. * provided the above notices are retained, and a notice that the code was
  294. * modified is included with the above copyright notice.
  295. *
  296. */
  297. AO_INLINE AO_t
  298. AO_fetch_and_add_acquire(volatile AO_t *addr, AO_t incr)
  299. {
  300. return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE);
  301. }
  302. #define AO_HAVE_fetch_and_add_acquire
  303. AO_INLINE void
  304. AO_and_acquire(volatile AO_t *addr, AO_t value)
  305. {
  306. (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE);
  307. }
  308. #define AO_HAVE_and_acquire
  309. AO_INLINE void
  310. AO_or_acquire(volatile AO_t *addr, AO_t value)
  311. {
  312. (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE);
  313. }
  314. #define AO_HAVE_or_acquire
  315. AO_INLINE void
  316. AO_xor_acquire(volatile AO_t *addr, AO_t value)
  317. {
  318. (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE);
  319. }
  320. #define AO_HAVE_xor_acquire
  321. /*
  322. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  323. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  324. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  325. *
  326. *
  327. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  328. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  329. *
  330. * Permission is hereby granted to use or copy this program
  331. * for any purpose, provided the above notices are retained on all copies.
  332. * Permission to modify the code and to distribute modified code is granted,
  333. * provided the above notices are retained, and a notice that the code was
  334. * modified is included with the above copyright notice.
  335. *
  336. */
  337. AO_INLINE unsigned/**/char
  338. AO_char_fetch_and_add_release(volatile unsigned/**/char *addr, unsigned/**/char incr)
  339. {
  340. return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE);
  341. }
  342. #define AO_HAVE_char_fetch_and_add_release
  343. AO_INLINE void
  344. AO_char_and_release(volatile unsigned/**/char *addr, unsigned/**/char value)
  345. {
  346. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE);
  347. }
  348. #define AO_HAVE_char_and_release
  349. AO_INLINE void
  350. AO_char_or_release(volatile unsigned/**/char *addr, unsigned/**/char value)
  351. {
  352. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE);
  353. }
  354. #define AO_HAVE_char_or_release
  355. AO_INLINE void
  356. AO_char_xor_release(volatile unsigned/**/char *addr, unsigned/**/char value)
  357. {
  358. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE);
  359. }
  360. #define AO_HAVE_char_xor_release
  361. /*
  362. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  363. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  364. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  365. *
  366. *
  367. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  368. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  369. *
  370. * Permission is hereby granted to use or copy this program
  371. * for any purpose, provided the above notices are retained on all copies.
  372. * Permission to modify the code and to distribute modified code is granted,
  373. * provided the above notices are retained, and a notice that the code was
  374. * modified is included with the above copyright notice.
  375. *
  376. */
  377. AO_INLINE unsigned/**/short
  378. AO_short_fetch_and_add_release(volatile unsigned/**/short *addr, unsigned/**/short incr)
  379. {
  380. return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE);
  381. }
  382. #define AO_HAVE_short_fetch_and_add_release
  383. AO_INLINE void
  384. AO_short_and_release(volatile unsigned/**/short *addr, unsigned/**/short value)
  385. {
  386. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE);
  387. }
  388. #define AO_HAVE_short_and_release
  389. AO_INLINE void
  390. AO_short_or_release(volatile unsigned/**/short *addr, unsigned/**/short value)
  391. {
  392. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE);
  393. }
  394. #define AO_HAVE_short_or_release
  395. AO_INLINE void
  396. AO_short_xor_release(volatile unsigned/**/short *addr, unsigned/**/short value)
  397. {
  398. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE);
  399. }
  400. #define AO_HAVE_short_xor_release
  401. /*
  402. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  403. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  404. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  405. *
  406. *
  407. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  408. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  409. *
  410. * Permission is hereby granted to use or copy this program
  411. * for any purpose, provided the above notices are retained on all copies.
  412. * Permission to modify the code and to distribute modified code is granted,
  413. * provided the above notices are retained, and a notice that the code was
  414. * modified is included with the above copyright notice.
  415. *
  416. */
  417. AO_INLINE unsigned
  418. AO_int_fetch_and_add_release(volatile unsigned *addr, unsigned incr)
  419. {
  420. return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE);
  421. }
  422. #define AO_HAVE_int_fetch_and_add_release
  423. AO_INLINE void
  424. AO_int_and_release(volatile unsigned *addr, unsigned value)
  425. {
  426. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE);
  427. }
  428. #define AO_HAVE_int_and_release
  429. AO_INLINE void
  430. AO_int_or_release(volatile unsigned *addr, unsigned value)
  431. {
  432. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE);
  433. }
  434. #define AO_HAVE_int_or_release
  435. AO_INLINE void
  436. AO_int_xor_release(volatile unsigned *addr, unsigned value)
  437. {
  438. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE);
  439. }
  440. #define AO_HAVE_int_xor_release
  441. /*
  442. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  443. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  444. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  445. *
  446. *
  447. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  448. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  449. *
  450. * Permission is hereby granted to use or copy this program
  451. * for any purpose, provided the above notices are retained on all copies.
  452. * Permission to modify the code and to distribute modified code is granted,
  453. * provided the above notices are retained, and a notice that the code was
  454. * modified is included with the above copyright notice.
  455. *
  456. */
  457. AO_INLINE AO_t
  458. AO_fetch_and_add_release(volatile AO_t *addr, AO_t incr)
  459. {
  460. return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE);
  461. }
  462. #define AO_HAVE_fetch_and_add_release
  463. AO_INLINE void
  464. AO_and_release(volatile AO_t *addr, AO_t value)
  465. {
  466. (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE);
  467. }
  468. #define AO_HAVE_and_release
  469. AO_INLINE void
  470. AO_or_release(volatile AO_t *addr, AO_t value)
  471. {
  472. (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE);
  473. }
  474. #define AO_HAVE_or_release
  475. AO_INLINE void
  476. AO_xor_release(volatile AO_t *addr, AO_t value)
  477. {
  478. (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE);
  479. }
  480. #define AO_HAVE_xor_release
  481. /*
  482. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  483. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  484. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  485. *
  486. *
  487. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  488. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  489. *
  490. * Permission is hereby granted to use or copy this program
  491. * for any purpose, provided the above notices are retained on all copies.
  492. * Permission to modify the code and to distribute modified code is granted,
  493. * provided the above notices are retained, and a notice that the code was
  494. * modified is included with the above copyright notice.
  495. *
  496. */
  497. AO_INLINE unsigned/**/char
  498. AO_char_fetch_and_add_full(volatile unsigned/**/char *addr, unsigned/**/char incr)
  499. {
  500. return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST);
  501. }
  502. #define AO_HAVE_char_fetch_and_add_full
  503. AO_INLINE void
  504. AO_char_and_full(volatile unsigned/**/char *addr, unsigned/**/char value)
  505. {
  506. (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST);
  507. }
  508. #define AO_HAVE_char_and_full
  509. AO_INLINE void
  510. AO_char_or_full(volatile unsigned/**/char *addr, unsigned/**/char value)
  511. {
  512. (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST);
  513. }
  514. #define AO_HAVE_char_or_full
  515. AO_INLINE void
  516. AO_char_xor_full(volatile unsigned/**/char *addr, unsigned/**/char value)
  517. {
  518. (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST);
  519. }
  520. #define AO_HAVE_char_xor_full
  521. /*
  522. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  523. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  524. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  525. *
  526. *
  527. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  528. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  529. *
  530. * Permission is hereby granted to use or copy this program
  531. * for any purpose, provided the above notices are retained on all copies.
  532. * Permission to modify the code and to distribute modified code is granted,
  533. * provided the above notices are retained, and a notice that the code was
  534. * modified is included with the above copyright notice.
  535. *
  536. */
  537. AO_INLINE unsigned/**/short
  538. AO_short_fetch_and_add_full(volatile unsigned/**/short *addr, unsigned/**/short incr)
  539. {
  540. return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST);
  541. }
  542. #define AO_HAVE_short_fetch_and_add_full
  543. AO_INLINE void
  544. AO_short_and_full(volatile unsigned/**/short *addr, unsigned/**/short value)
  545. {
  546. (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST);
  547. }
  548. #define AO_HAVE_short_and_full
  549. AO_INLINE void
  550. AO_short_or_full(volatile unsigned/**/short *addr, unsigned/**/short value)
  551. {
  552. (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST);
  553. }
  554. #define AO_HAVE_short_or_full
  555. AO_INLINE void
  556. AO_short_xor_full(volatile unsigned/**/short *addr, unsigned/**/short value)
  557. {
  558. (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST);
  559. }
  560. #define AO_HAVE_short_xor_full
  561. /*
  562. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  563. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  564. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  565. *
  566. *
  567. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  568. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  569. *
  570. * Permission is hereby granted to use or copy this program
  571. * for any purpose, provided the above notices are retained on all copies.
  572. * Permission to modify the code and to distribute modified code is granted,
  573. * provided the above notices are retained, and a notice that the code was
  574. * modified is included with the above copyright notice.
  575. *
  576. */
  577. AO_INLINE unsigned
  578. AO_int_fetch_and_add_full(volatile unsigned *addr, unsigned incr)
  579. {
  580. return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST);
  581. }
  582. #define AO_HAVE_int_fetch_and_add_full
  583. AO_INLINE void
  584. AO_int_and_full(volatile unsigned *addr, unsigned value)
  585. {
  586. (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST);
  587. }
  588. #define AO_HAVE_int_and_full
  589. AO_INLINE void
  590. AO_int_or_full(volatile unsigned *addr, unsigned value)
  591. {
  592. (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST);
  593. }
  594. #define AO_HAVE_int_or_full
  595. AO_INLINE void
  596. AO_int_xor_full(volatile unsigned *addr, unsigned value)
  597. {
  598. (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST);
  599. }
  600. #define AO_HAVE_int_xor_full
  601. /*
  602. * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
  603. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
  604. * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
  605. *
  606. *
  607. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  608. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  609. *
  610. * Permission is hereby granted to use or copy this program
  611. * for any purpose, provided the above notices are retained on all copies.
  612. * Permission to modify the code and to distribute modified code is granted,
  613. * provided the above notices are retained, and a notice that the code was
  614. * modified is included with the above copyright notice.
  615. *
  616. */
  617. AO_INLINE AO_t
  618. AO_fetch_and_add_full(volatile AO_t *addr, AO_t incr)
  619. {
  620. return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST);
  621. }
  622. #define AO_HAVE_fetch_and_add_full
  623. AO_INLINE void
  624. AO_and_full(volatile AO_t *addr, AO_t value)
  625. {
  626. (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST);
  627. }
  628. #define AO_HAVE_and_full
  629. AO_INLINE void
  630. AO_or_full(volatile AO_t *addr, AO_t value)
  631. {
  632. (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST);
  633. }
  634. #define AO_HAVE_or_full
  635. AO_INLINE void
  636. AO_xor_full(volatile AO_t *addr, AO_t value)
  637. {
  638. (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST);
  639. }
  640. #define AO_HAVE_xor_full