13#ifndef __xwos_lib_xwaop_h__
14#define __xwos_lib_xwaop_h__
25#include <xwos/ospl/soc/xwaop.h>
35#define xwmoaop(type, op, a, memorder, ...) \
36 xwaop__##type##__##op(a, memorder, ##__VA_ARGS__)
45#define xwaop_load(type, a, memorder) \
46 xwmoaop(type, load, (a), memorder)
56#define xwaop_store(type, a, memorder, v) \
57 xwmoaop(type, store, (a), memorder, (v))
66#define xwaop(type, op, a, ...) \
67 xwaop__##type##__##op(a, ##__VA_ARGS__)
77#define xwaop_read(type, a, ov) \
78 xwaop(type, read, (a), (ov))
91#define xwaop_write(type, a, v, ov) \
92 xwaop(type, write, (a), (v), (ov))
113#define xwaop_teq_then_write(type, a, t, v, ov) \
114 xwaop(type, teq_then_write, (a), (t), (v), (ov))
135#define xwaop_tne_then_write(type, a, t, v, ov) \
136 xwaop(type, tne_then_write, (a), (t), (v), (ov))
157#define xwaop_tgt_then_write(type, a, t, v, ov) \
158 xwaop(type, tgt_then_write, (a), (t), (v), (ov))
179#define xwaop_tge_then_write(type, a, t, v, ov) \
180 xwaop(type, tge_then_write, (a), (t), (v), (ov))
201#define xwaop_tlt_then_write(type, a, t, v, ov) \
202 xwaop(type, tlt_then_write, (a), (t), (v), (ov))
223#define xwaop_tle_then_write(type, a, t, v, ov) \
224 xwaop(type, tle_then_write, (a), (t), (v), (ov))
246#define xwaop_tgtlt_then_write(type, a, l, r, v, ov) \
247 xwaop(type, tgtlt_then_write, (a), (l), (r), (v), (ov))
269#define xwaop_tgelt_then_write(type, a, l, r, v, ov) \
270 xwaop(type, tgelt_then_write, (a), (l), (r), (v), (ov))
292#define xwaop_tgtle_then_write(type, a, l, r, v, ov) \
293 xwaop(type, tgtle_then_write, (a), (l), (r), (v), (ov))
315#define xwaop_tgele_then_write(type, a, l, r, v, ov) \
316 xwaop(type, tgele_then_write, (a), (l), (r), (v), (ov))
330#define xwaop_add(type, a, v, nv, ov) \
331 xwaop(type, add, (a), (v), (nv), (ov))
355#define xwaop_teq_then_add(type, a, t, v, nv, ov) \
356 xwaop(type, teq_then_add, (a), (t), (v), (nv), (ov))
380#define xwaop_tne_then_add(type, a, t, v, nv, ov) \
381 xwaop(type, tne_then_add, (a), (t), (v), (nv), (ov))
405#define xwaop_tgt_then_add(type, a, t, v, nv, ov) \
406 xwaop(type, tgt_then_add, (a), (t), (v), (nv), (ov))
430#define xwaop_tge_then_add(type, a, t, v, nv, ov) \
431 xwaop(type, tge_then_add, (a), (t), (v), (nv), (ov))
455#define xwaop_tlt_then_add(type, a, t, v, nv, ov) \
456 xwaop(type, tlt_then_add, (a), (t), (v), (nv), (ov))
480#define xwaop_tle_then_add(type, a, t, v, nv, ov) \
481 xwaop(type, tle_then_add, (a), (t), (v), (nv), (ov))
506#define xwaop_tgtlt_then_add(type, a, l, r, v, nv, ov) \
507 xwaop(type, tgtlt_then_add, (a), (l), (r), (v), (nv), (ov))
532#define xwaop_tgelt_then_add(type, a, l, r, v, nv, ov) \
533 xwaop(type, tgelt_then_add, (a), (l), (r), (v), (nv), (ov))
558#define xwaop_tgtle_then_add(type, a, l, r, v, nv, ov) \
559 xwaop(type, tgtle_then_add, (a), (l), (r), (v), (nv), (ov))
584#define xwaop_tgele_then_add(type, a, l, r, v, nv, ov) \
585 xwaop(type, tgele_then_add, (a), (l), (r), (v), (nv), (ov))
598#define xwaop_sub(type, a, v, nv, ov) \
599 xwaop(type, sub, (a), (v), (nv), (ov))
623#define xwaop_teq_then_sub(type, a, t, v, nv, ov) \
624 xwaop(type, teq_then_sub, (a), (t), (v), (nv), (ov))
648#define xwaop_tne_then_sub(type, a, t, v, nv, ov) \
649 xwaop(type, tne_then_sub, (a), (t), (v), (nv), (ov))
673#define xwaop_tgt_then_sub(type, a, t, v, nv, ov) \
674 xwaop(type, tgt_then_sub, (a), (t), (v), (nv), (ov))
698#define xwaop_tge_then_sub(type, a, t, v, nv, ov) \
699 xwaop(type, tge_then_sub, (a), (t), (v), (nv), (ov))
723#define xwaop_tlt_then_sub(type, a, t, v, nv, ov) \
724 xwaop(type, tlt_then_sub, (a), (t), (v), (nv), (ov))
748#define xwaop_tle_then_sub(type, a, t, v, nv, ov) \
749 xwaop(type, tle_then_sub, (a), (t), (v), (nv), (ov))
774#define xwaop_tgtlt_then_sub(type, a, l, r, v, nv, ov) \
775 xwaop(type, tgtlt_then_sub, (a), (l), (r), (v), (nv), (ov))
800#define xwaop_tgelt_then_sub(type, a, l, r, v, nv, ov) \
801 xwaop(type, tgelt_then_sub, (a), (l), (r), (v), (nv), (ov))
826#define xwaop_tgtle_then_sub(type, a, l, r, v, nv, ov) \
827 xwaop(type, tgtle_then_sub, (a), (l), (r), (v), (nv), (ov))
852#define xwaop_tgele_then_sub(type, a, l, r, v, nv, ov) \
853 xwaop(type, tgele_then_sub, (a), (l), (r), (v), (nv), (ov))
866#define xwaop_rsb(type, a, v, nv, ov) \
867 xwaop(type, rsb, (a), (v), (nv), (ov))
891#define xwaop_teq_then_rsb(type, a, t, v, nv, ov) \
892 xwaop(type, teq_then_rsb, (a), (t), (v), (nv), (ov))
916#define xwaop_tne_then_rsb(type, a, t, v, nv, ov) \
917 xwaop(type, tne_then_rsb, (a), (t), (v), (nv), (ov))
941#define xwaop_tgt_then_rsb(type, a, t, v, nv, ov) \
942 xwaop(type, tgt_then_rsb, (a), (t), (v), (nv), (ov))
966#define xwaop_tge_then_rsb(type, a, t, v, nv, ov) \
967 xwaop(type, tge_then_rsb, (a), (t), (v), (nv), (ov))
991#define xwaop_tlt_then_rsb(type, a, t, v, nv, ov) \
992 xwaop(type, tlt_then_rsb, (a), (t), (v), (nv), (ov))
1016#define xwaop_tle_then_rsb(type, a, t, v, nv, ov) \
1017 xwaop(type, tle_then_rsb, (a), (t), (v), (nv), (ov))
1042#define xwaop_tgtlt_then_rsb(type, a, l, r, v, nv, ov) \
1043 xwaop(type, tgtlt_then_rsb, (a), (l), (r), (v), (nv), (ov))
1068#define xwaop_tgelt_then_rsb(type, a, l, r, v, nv, ov) \
1069 xwaop(type, tgelt_then_rsb, (a), (l), (r), (v), (nv), (ov))
1094#define xwaop_tgtle_then_rsb(type, a, l, r, v, nv, ov) \
1095 xwaop(type, tgtle_then_rsb, (a), (l), (r), (v), (nv), (ov))
1120#define xwaop_tgele_then_rsb(type, a, l, r, v, nv, ov) \
1121 xwaop(type, tgele_then_rsb, (a), (l), (r), (v), (nv), (ov))
1134#define xwaop_and(type, a, v, nv, ov) \
1135 xwaop(type, and, (a), (v), (nv), (ov))
1148#define xwaop_or(type, a, v, nv, ov) \
1149 xwaop(type, or, (a), (v), (nv), (ov))
1162#define xwaop_xor(type, a, v, nv, ov) \
1163 xwaop(type, xor, (a), (v), (nv), (ov))
1176#define xwaop_s1m(type, a, m, nv, ov) \
1177 xwaop(type, or, (a), (m), (nv), (ov))
1190#define xwaop_c0m(type, a, m, nv, ov) \
1191 xwaop(type, c0m, (a), (m), (nv), (ov))
1204#define xwaop_x1m(type, a, m, nv, ov) \
1205 xwaop(type, xor, (a), (m), (nv), (ov))
1229#define xwaop_t1ma_then_c0m(type, a, m, nv, ov) \
1230 xwaop(type, t1ma_then_c0m, (a), (m), (nv), (ov))
1253#define xwaop_t1mo_then_c0m(type, a, m, nv, ov) \
1254 xwaop(type, t1mo_then_c0m, (a), (m), (nv), (ov))
1277#define xwaop_t0ma_then_s1m(type, a, m, nv, ov) \
1278 xwaop(type, t0ma_then_s1m, (a), (m), (nv), (ov))
1301#define xwaop_t0mo_then_s1m(type, a, m, nv, ov) \
1302 xwaop(type, t0mo_then_s1m, (a), (m), (nv), (ov))
1328#define xwaop_tst_then_op(type, a, tf, tfarg, of, ofarg, nv, ov) \
1329 xwaop(type, tst_then_op, (a), (tf), (tfarg), (of), (ofarg), (nv), (ov))
1337#define DEFINE_XWAOP_LOAD(type, btype) \
1338static __xwlib_inline \
1339type xwaop__##type##__load(atomic_##type * a, \
1340 const enum xwaop_memory_order_em mo) \
1342 return (type)xwaop__##btype##__load((atomic_##btype *)a, mo); \
1351#define DEFINE_XWAOP_STORE(type, btype) \
1352static __xwlib_inline \
1353type xwaop__##type##__store(atomic_##type * a, \
1354 const enum xwaop_memory_order_em mo, \
1357 return (type)xwaop__##btype##__store((atomic_##btype *)a, mo, (btype)v); \
1366#define DEFINE_XWAOP_READ(type, btype) \
1367static __xwlib_inline \
1368void xwaop__##type##__read(atomic_##type * a, type * ov) \
1370 xwaop__##btype##__read((atomic_##btype *)a, \
1380#define DEFINE_XWAOP_WRITE(type, btype) \
1381static __xwlib_inline \
1382void xwaop__##type##__write(atomic_##type * a, type v, type * ov) \
1384 xwaop__##btype##__write((atomic_##btype *)a, \
1394#define DEFINE_XWAOP_TEQ_THEN_WRITE(type, btype) \
1395static __xwlib_inline \
1396xwer_t xwaop__##type##__teq_then_write(atomic_##type * a, type t, type v, type * ov) \
1398 return xwaop__##btype##__teq_then_write((atomic_##btype *)a, \
1409#define DEFINE_XWAOP_TNE_THEN_WRITE(type, btype) \
1410static __xwlib_inline \
1411xwer_t xwaop__##type##__tne_then_write(atomic_##type * a, \
1416 return xwaop__##btype##__tne_then_write((atomic_##btype *)a, \
1427#define DEFINE_XWAOP_TGT_THEN_WRITE(type, btype) \
1428static __xwlib_inline \
1429xwer_t xwaop__##type##__tgt_then_write(atomic_##type * a, \
1434 return xwaop__##btype##__tgt_then_write((atomic_##btype *)a, \
1445#define DEFINE_XWAOP_TGE_THEN_WRITE(type, btype) \
1446static __xwlib_inline \
1447xwer_t xwaop__##type##__tge_then_write(atomic_##type * a, \
1452 return xwaop__##btype##__tge_then_write((atomic_##btype *)a, \
1463#define DEFINE_XWAOP_TLT_THEN_WRITE(type, btype) \
1464static __xwlib_inline \
1465xwer_t xwaop__##type##__tlt_then_write(atomic_##type * a, \
1470 return xwaop__##btype##__tlt_then_write((atomic_##btype *)a, \
1481#define DEFINE_XWAOP_TLE_THEN_WRITE(type, btype) \
1482static __xwlib_inline \
1483xwer_t xwaop__##type##__tle_then_write(atomic_##type * a, \
1488 return xwaop__##btype##__tle_then_write((atomic_##btype *)a, \
1499#define DEFINE_XWAOP_TGTLT_THEN_WRITE(type, btype) \
1500static __xwlib_inline \
1501xwer_t xwaop__##type##__tgtlt_then_write(atomic_##type * a, \
1506 return xwaop__##btype##__tgtlt_then_write((atomic_##btype *)a, \
1507 (btype)l, (btype)r, \
1517#define DEFINE_XWAOP_TGELT_THEN_WRITE(type, btype) \
1518static __xwlib_inline \
1519xwer_t xwaop__##type##__tgelt_then_write(atomic_##type * a, \
1524 return xwaop__##btype##__tgelt_then_write((atomic_##btype *)a, \
1525 (btype)l, (btype)r, \
1535#define DEFINE_XWAOP_TGTLE_THEN_WRITE(type, btype) \
1536static __xwlib_inline \
1537xwer_t xwaop__##type##__tgtle_then_write(atomic_##type * a, \
1542 return xwaop__##btype##__tgtle_then_write((atomic_##btype *)a, \
1543 (btype)l, (btype)r, \
1553#define DEFINE_XWAOP_TGELE_THEN_WRITE(type, btype) \
1554static __xwlib_inline \
1555xwer_t xwaop__##type##__tgele_then_write(atomic_##type * a, \
1560 return xwaop__##btype##__tgele_then_write((atomic_##btype *)a, \
1561 (btype)l, (btype)r, \
1572#define DEFINE_XWAOP_ADD(type, btype) \
1573static __xwlib_inline \
1574void xwaop__##type##__add(atomic_##type * a, \
1576 type * nv, type * ov) \
1578 xwaop__##btype##__add((atomic_##btype *)a, \
1580 (btype *)nv, (btype *)ov); \
1588#define DEFINE_XWAOP_TEQ_THEN_ADD(type, btype) \
1589static __xwlib_inline \
1590xwer_t xwaop__##type##__teq_then_add(atomic_##type * a, \
1593 type * nv, type * ov) \
1595 return xwaop__##btype##__teq_then_add((atomic_##btype *)a, \
1596 (btype)t, (btype)v, \
1597 (btype *)nv, (btype *)ov); \
1605#define DEFINE_XWAOP_TNE_THEN_ADD(type, btype) \
1606static __xwlib_inline \
1607xwer_t xwaop__##type##__tne_then_add(atomic_##type * a, \
1610 type * nv, type * ov) \
1612 return xwaop__##btype##__tne_then_add((atomic_##btype *)a, \
1615 (btype *)nv, (btype *)ov); \
1623#define DEFINE_XWAOP_TGT_THEN_ADD(type, btype) \
1624static __xwlib_inline \
1625xwer_t xwaop__##type##__tgt_then_add(atomic_##type * a, \
1628 type * nv, type * ov) \
1630 return xwaop__##btype##__tgt_then_add((atomic_##btype *)a, \
1633 (btype *)nv, (btype *)ov); \
1641#define DEFINE_XWAOP_TGE_THEN_ADD(type, btype) \
1642static __xwlib_inline \
1643xwer_t xwaop__##type##__tge_then_add(atomic_##type * a, \
1646 type * nv, type * ov) \
1648 return xwaop__##btype##__tge_then_add((atomic_##btype *)a, \
1651 (btype *)nv, (btype *)ov); \
1659#define DEFINE_XWAOP_TLT_THEN_ADD(type, btype) \
1660static __xwlib_inline \
1661xwer_t xwaop__##type##__tlt_then_add(atomic_##type * a, \
1664 type * nv, type * ov) \
1666 return xwaop__##btype##__tlt_then_add((atomic_##btype *)a, \
1669 (btype *)nv, (btype *)ov); \
1677#define DEFINE_XWAOP_TLE_THEN_ADD(type, btype) \
1678static __xwlib_inline \
1679xwer_t xwaop__##type##__tle_then_add(atomic_##type * a, \
1682 type * nv, type * ov) \
1684 return xwaop__##btype##__tle_then_add((atomic_##btype *)a, \
1687 (btype *)nv, (btype *)ov); \
1695#define DEFINE_XWAOP_TGTLT_THEN_ADD(type, btype) \
1696static __xwlib_inline \
1697xwer_t xwaop__##type##__tgtlt_then_add(atomic_##type * a, \
1700 type * nv, type * ov) \
1702 return xwaop__##btype##__tgtlt_then_add((atomic_##btype *)a, \
1703 (btype)l, (btype)r, \
1705 (btype *)nv, (btype *)ov); \
1713#define DEFINE_XWAOP_TGELT_THEN_ADD(type, btype) \
1714static __xwlib_inline \
1715xwer_t xwaop__##type##__tgelt_then_add(atomic_##type * a, \
1718 type * nv, type * ov) \
1720 return xwaop__##btype##__tgelt_then_add((atomic_##btype *)a, \
1721 (btype)l, (btype)r, \
1723 (btype *)nv, (btype *)ov); \
1731#define DEFINE_XWAOP_TGTLE_THEN_ADD(type, btype) \
1732static __xwlib_inline \
1733xwer_t xwaop__##type##__tgtle_then_add(atomic_##type * a, \
1736 type * nv, type * ov) \
1738 return xwaop__##btype##__tgtle_then_add((atomic_##btype *)a, \
1739 (btype)l, (btype)r, \
1741 (btype *)nv, (btype *)ov); \
1749#define DEFINE_XWAOP_TGELE_THEN_ADD(type, btype) \
1750static __xwlib_inline \
1751xwer_t xwaop__##type##__tgele_then_add(atomic_##type * a, \
1754 type * nv, type * ov) \
1756 return xwaop__##btype##__tgele_then_add((atomic_##btype *)a, \
1757 (btype)l, (btype)r, \
1759 (btype *)nv, (btype *)ov); \
1768#define DEFINE_XWAOP_SUB(type, btype) \
1769static __xwlib_inline \
1770void xwaop__##type##__sub(atomic_##type * a, \
1772 type * nv, type * ov) \
1774 xwaop__##btype##__sub((atomic_##btype *)a, \
1776 (btype *)nv, (btype *)ov); \
1784#define DEFINE_XWAOP_TEQ_THEN_SUB(type, btype) \
1785static __xwlib_inline \
1786xwer_t xwaop__##type##__teq_then_sub(atomic_##type * a, \
1789 type * nv, type * ov) \
1791 return xwaop__##btype##__teq_then_sub((atomic_##btype *)a, \
1794 (btype *)nv, (btype *)ov); \
1802#define DEFINE_XWAOP_TNE_THEN_SUB(type, btype) \
1803static __xwlib_inline \
1804xwer_t xwaop__##type##__tne_then_sub(atomic_##type * a, \
1807 type * nv, type * ov) \
1809 return xwaop__##btype##__tne_then_sub((atomic_##btype *)a, \
1812 (btype *)nv, (btype *)ov); \
1820#define DEFINE_XWAOP_TGT_THEN_SUB(type, btype) \
1821static __xwlib_inline \
1822xwer_t xwaop__##type##__tgt_then_sub(atomic_##type * a, \
1825 type * nv, type * ov) \
1827 return xwaop__##btype##__tgt_then_sub((atomic_##btype *)a, \
1830 (btype *)nv, (btype *)ov); \
1838#define DEFINE_XWAOP_TGE_THEN_SUB(type, btype) \
1839static __xwlib_inline \
1840xwer_t xwaop__##type##__tge_then_sub(atomic_##type * a, \
1843 type * nv, type * ov) \
1845 return xwaop__##btype##__tge_then_sub((atomic_##btype *)a, \
1848 (btype *)nv, (btype *)ov); \
1856#define DEFINE_XWAOP_TLT_THEN_SUB(type, btype) \
1857static __xwlib_inline \
1858xwer_t xwaop__##type##__tlt_then_sub(atomic_##type * a, \
1861 type * nv, type * ov) \
1863 return xwaop__##btype##__tlt_then_sub((atomic_##btype *)a, \
1866 (btype *)nv, (btype *)ov); \
1874#define DEFINE_XWAOP_TLE_THEN_SUB(type, btype) \
1875static __xwlib_inline \
1876xwer_t xwaop__##type##__tle_then_sub(atomic_##type * a, \
1879 type * nv, type * ov) \
1881 return xwaop__##btype##__tle_then_sub((atomic_##btype *)a, \
1884 (btype *)nv, (btype *)ov); \
1892#define DEFINE_XWAOP_TGTLT_THEN_SUB(type, btype) \
1893static __xwlib_inline \
1894xwer_t xwaop__##type##__tgtlt_then_sub(atomic_##type * a, \
1897 type * nv, type * ov) \
1899 return xwaop__##btype##__tgtlt_then_sub((atomic_##btype *)a, \
1900 (btype)l, (btype)r, \
1902 (btype *)nv, (btype *)ov); \
1910#define DEFINE_XWAOP_TGELT_THEN_SUB(type, btype) \
1911static __xwlib_inline \
1912xwer_t xwaop__##type##__tgelt_then_sub(atomic_##type * a, \
1915 type * nv, type * ov) \
1917 return xwaop__##btype##__tgelt_then_sub((atomic_##btype *)a, \
1918 (btype)l, (btype)r, \
1920 (btype *)nv, (btype *)ov); \
1928#define DEFINE_XWAOP_TGTLE_THEN_SUB(type, btype) \
1929static __xwlib_inline \
1930xwer_t xwaop__##type##__tgtle_then_sub(atomic_##type * a, \
1933 type * nv, type * ov) \
1935 return xwaop__##btype##__tgtle_then_sub((atomic_##btype *)a, \
1936 (btype)l, (btype)r, \
1938 (btype *)nv, (btype *)ov); \
1946#define DEFINE_XWAOP_TGELE_THEN_SUB(type, btype) \
1947static __xwlib_inline \
1948xwer_t xwaop__##type##__tgele_then_sub(atomic_##type * a, \
1951 type * nv, type * ov) \
1953 return xwaop__##btype##__tgele_then_sub((atomic_##btype *)a, \
1954 (btype)l, (btype)r, \
1956 (btype *)nv, (btype *)ov); \
1965#define DEFINE_XWAOP_RSB(type, btype) \
1966static __xwlib_inline \
1967void xwaop__##type##__rsb(atomic_##type * a, \
1969 type * nv, type * ov) \
1971 xwaop__##btype##__rsb((atomic_##btype *)a, \
1973 (btype *)nv, (btype *)ov); \
1981#define DEFINE_XWAOP_TEQ_THEN_RSB(type, btype) \
1982static __xwlib_inline \
1983xwer_t xwaop__##type##__teq_then_rsb(atomic_##type * a, \
1986 type * nv, type * ov) \
1988 return xwaop__##btype##__teq_then_rsb((atomic_##btype *)a, \
1991 (btype *)nv, (btype *)ov); \
1999#define DEFINE_XWAOP_TNE_THEN_RSB(type, btype) \
2000static __xwlib_inline \
2001xwer_t xwaop__##type##__tne_then_rsb(atomic_##type * a, \
2004 type * nv, type * ov) \
2006 return xwaop__##btype##__tne_then_rsb((atomic_##btype *)a, \
2009 (btype *)nv, (btype *)ov); \
2017#define DEFINE_XWAOP_TGT_THEN_RSB(type, btype) \
2018static __xwlib_inline \
2019xwer_t xwaop__##type##__tgt_then_rsb(atomic_##type * a, \
2022 type * nv, type * ov) \
2024 return xwaop__##btype##__tgt_then_rsb((atomic_##btype *)a, \
2027 (btype *)nv, (btype *)ov); \
2035#define DEFINE_XWAOP_TGE_THEN_RSB(type, btype) \
2036static __xwlib_inline \
2037xwer_t xwaop__##type##__tge_then_rsb(atomic_##type * a, \
2040 type * nv, type * ov) \
2042 return xwaop__##btype##__tge_then_rsb((atomic_##btype *)a, \
2045 (btype *)nv, (btype *)ov); \
2053#define DEFINE_XWAOP_TLT_THEN_RSB(type, btype) \
2054static __xwlib_inline \
2055xwer_t xwaop__##type##__tlt_then_rsb(atomic_##type * a, \
2058 type * nv, type * ov) \
2060 return xwaop__##btype##__tlt_then_rsb((atomic_##btype *)a, \
2063 (btype *)nv, (btype *)ov); \
2071#define DEFINE_XWAOP_TLE_THEN_RSB(type, btype) \
2072static __xwlib_inline \
2073xwer_t xwaop__##type##__tle_then_rsb(atomic_##type * a, \
2076 type * nv, type * ov) \
2078 return xwaop__##btype##__tle_then_rsb((atomic_##btype *)a, \
2081 (btype *)nv, (btype *)ov); \
2089#define DEFINE_XWAOP_TGTLT_THEN_RSB(type, btype) \
2090static __xwlib_inline \
2091xwer_t xwaop__##type##__tgtlt_then_rsb(atomic_##type * a, \
2094 type * nv, type * ov) \
2096 return xwaop__##btype##__tgtlt_then_rsb((atomic_##btype *)a, \
2097 (btype)l, (btype)r, \
2099 (btype *)nv, (btype *)ov); \
2107#define DEFINE_XWAOP_TGELT_THEN_RSB(type, btype) \
2108static __xwlib_inline \
2109xwer_t xwaop__##type##__tgelt_then_rsb(atomic_##type * a, \
2112 type * nv, type * ov) \
2114 return xwaop__##btype##__tgelt_then_rsb((atomic_##btype *)a, \
2115 (btype)l, (btype)r, \
2117 (btype *)nv, (btype *)ov); \
2125#define DEFINE_XWAOP_TGTLE_THEN_RSB(type, btype) \
2126static __xwlib_inline \
2127xwer_t xwaop__##type##__tgtle_then_rsb(atomic_##type * a, \
2130 type * nv, type * ov) \
2132 return xwaop__##btype##__tgtle_then_rsb((atomic_##btype *)a, \
2133 (btype)l, (btype)r, \
2135 (btype *)nv, (btype *)ov); \
2143#define DEFINE_XWAOP_TGELE_THEN_RSB(type, btype) \
2144static __xwlib_inline \
2145xwer_t xwaop__##type##__tgele_then_rsb(atomic_##type * a, \
2148 type * nv, type * ov) \
2150 return xwaop__##btype##__tgele_then_rsb((atomic_##btype *)a, \
2151 (btype)l, (btype)r, \
2153 (btype *)nv, (btype *)ov); \
2162#define DEFINE_XWAOP_OR(type, btype) \
2163static __xwlib_inline \
2164void xwaop__##type##__or(atomic_##type * a, \
2166 type * nv, type * ov) \
2168 xwaop__##btype##__or((atomic_##btype *)a, \
2170 (btype *)nv, (btype *)ov); \
2178#define DEFINE_XWAOP_AND(type, btype) \
2179static __xwlib_inline \
2180void xwaop__##type##__and(atomic_##type * a, \
2182 type * nv, type * ov) \
2184 xwaop__##btype##__and((atomic_##btype *)a, \
2186 (btype *)nv, (btype *)ov); \
2194#define DEFINE_XWAOP_XOR(type, btype) \
2195static __xwlib_inline \
2196void xwaop__##type##__xor(atomic_##type * a, \
2198 type * nv, type * ov) \
2200 xwaop__##btype##__xor((atomic_##btype *)a, \
2202 (btype *)nv, (btype *)ov); \
2210#define DEFINE_XWAOP_C0M(type, btype) \
2211static __xwlib_inline \
2212void xwaop__##type##__c0m(atomic_##type * a, \
2214 type * nv, type * ov) \
2216 xwaop__##btype##__c0m((atomic_##btype *)a, \
2218 (btype *)nv, (btype *)ov); \
2226#define DEFINE_XWAOP_T1MA_THEN_C0M(type, btype) \
2227static __xwlib_inline \
2228xwer_t xwaop__##type##__t1ma_then_c0m(atomic_##type * a, \
2230 type * nv, type * ov) \
2232 return xwaop__##btype##__t1ma_then_c0m((atomic_##btype *)a, \
2234 (btype *)nv, (btype *)ov); \
2242#define DEFINE_XWAOP_T1MO_THEN_C0M(type, btype) \
2243static __xwlib_inline \
2244xwer_t xwaop__##type##__t1mo_then_c0m(atomic_##type * a, \
2246 type * nv, type * ov) \
2248 return xwaop__##btype##__t1mo_then_c0m((atomic_##btype *)a, \
2250 (btype *)nv, (btype *)ov); \
2258#define DEFINE_XWAOP_T0MA_THEN_S1M(type, btype) \
2259static __xwlib_inline \
2260xwer_t xwaop__##type##__t0ma_then_s1m(atomic_##type * a, \
2262 type * nv, type * ov) \
2264 return xwaop__##btype##__t0ma_then_s1m((atomic_##btype *)a, \
2266 (btype *)nv, (btype *)ov); \
2274#define DEFINE_XWAOP_T0MO_THEN_S1M(type, btype) \
2275static __xwlib_inline \
2276xwer_t xwaop__##type##__t0mo_then_s1m(atomic_##type * a, \
2278 type * nv, type * ov) \
2280 return xwaop__##btype##__t0mo_then_s1m((atomic_##btype *)a, \
2282 (btype *)nv, (btype *)ov); \
2291#define DEFINE_XWAOP_TST_THEN_OP(type, btype) \
2292static __xwlib_inline \
2293xwer_t xwaop__##type##__tst_then_op(atomic_##type * a, \
2294 xwaop_tst_f tst, void * tst_args, \
2295 xwaop_op_f op, void * op_args, \
2296 type * nv, type * ov) \
2298 return xwaop__##btype##__tst_then_op((atomic_##btype *)a, \
2301 (btype *)nv, (btype *)ov); \
2309#define DEFINE_XWAOP(type, btype) \
2310 DEFINE_XWAOP_LOAD(type, btype) \
2311 DEFINE_XWAOP_STORE(type, btype) \
2312 DEFINE_XWAOP_READ(type, btype) \
2313 DEFINE_XWAOP_WRITE(type, btype) \
2314 DEFINE_XWAOP_TEQ_THEN_WRITE(type, btype) \
2315 DEFINE_XWAOP_TNE_THEN_WRITE(type, btype) \
2316 DEFINE_XWAOP_TGT_THEN_WRITE(type, btype) \
2317 DEFINE_XWAOP_TGE_THEN_WRITE(type, btype) \
2318 DEFINE_XWAOP_TLT_THEN_WRITE(type, btype) \
2319 DEFINE_XWAOP_TLE_THEN_WRITE(type, btype) \
2320 DEFINE_XWAOP_TGTLT_THEN_WRITE(type, btype) \
2321 DEFINE_XWAOP_TGELT_THEN_WRITE(type, btype) \
2322 DEFINE_XWAOP_TGTLE_THEN_WRITE(type, btype) \
2323 DEFINE_XWAOP_TGELE_THEN_WRITE(type, btype) \
2324 DEFINE_XWAOP_ADD(type, btype) \
2325 DEFINE_XWAOP_TEQ_THEN_ADD(type, btype) \
2326 DEFINE_XWAOP_TNE_THEN_ADD(type, btype) \
2327 DEFINE_XWAOP_TGT_THEN_ADD(type, btype) \
2328 DEFINE_XWAOP_TGE_THEN_ADD(type, btype) \
2329 DEFINE_XWAOP_TLT_THEN_ADD(type, btype) \
2330 DEFINE_XWAOP_TLE_THEN_ADD(type, btype) \
2331 DEFINE_XWAOP_TGTLT_THEN_ADD(type, btype) \
2332 DEFINE_XWAOP_TGELT_THEN_ADD(type, btype) \
2333 DEFINE_XWAOP_TGTLE_THEN_ADD(type, btype) \
2334 DEFINE_XWAOP_TGELE_THEN_ADD(type, btype) \
2335 DEFINE_XWAOP_SUB(type, btype) \
2336 DEFINE_XWAOP_TEQ_THEN_SUB(type, btype) \
2337 DEFINE_XWAOP_TNE_THEN_SUB(type, btype) \
2338 DEFINE_XWAOP_TGT_THEN_SUB(type, btype) \
2339 DEFINE_XWAOP_TGE_THEN_SUB(type, btype) \
2340 DEFINE_XWAOP_TLT_THEN_SUB(type, btype) \
2341 DEFINE_XWAOP_TLE_THEN_SUB(type, btype) \
2342 DEFINE_XWAOP_TGTLT_THEN_SUB(type, btype) \
2343 DEFINE_XWAOP_TGELT_THEN_SUB(type, btype) \
2344 DEFINE_XWAOP_TGTLE_THEN_SUB(type, btype) \
2345 DEFINE_XWAOP_TGELE_THEN_SUB(type, btype) \
2346 DEFINE_XWAOP_RSB(type, btype) \
2347 DEFINE_XWAOP_TEQ_THEN_RSB(type, btype) \
2348 DEFINE_XWAOP_TNE_THEN_RSB(type, btype) \
2349 DEFINE_XWAOP_TGT_THEN_RSB(type, btype) \
2350 DEFINE_XWAOP_TGE_THEN_RSB(type, btype) \
2351 DEFINE_XWAOP_TLT_THEN_RSB(type, btype) \
2352 DEFINE_XWAOP_TLE_THEN_RSB(type, btype) \
2353 DEFINE_XWAOP_TGTLT_THEN_RSB(type, btype) \
2354 DEFINE_XWAOP_TGELT_THEN_RSB(type, btype) \
2355 DEFINE_XWAOP_TGTLE_THEN_RSB(type, btype) \
2356 DEFINE_XWAOP_TGELE_THEN_RSB(type, btype) \
2357 DEFINE_XWAOP_OR(type, btype) \
2358 DEFINE_XWAOP_AND(type, btype) \
2359 DEFINE_XWAOP_XOR(type, btype) \
2360 DEFINE_XWAOP_C0M(type, btype) \
2361 DEFINE_XWAOP_T1MA_THEN_C0M(type, btype) \
2362 DEFINE_XWAOP_T1MO_THEN_C0M(type, btype) \
2363 DEFINE_XWAOP_T0MA_THEN_S1M(type, btype) \
2364 DEFINE_XWAOP_T0MO_THEN_S1M(type, btype) \
2365 DEFINE_XWAOP_TST_THEN_OP(type, btype)
2368#if (16 == BITS_PER_XWSZ_T)
2370#elif (32 == BITS_PER_XWSZ_T)
2372#elif (64 == BITS_PER_XWSZ_T)
2376#if (16 == BITS_PER_XWSSZ_T)
2378#elif (32 == BITS_PER_XWSSZ_T)
2380#elif (64 == BITS_PER_XWSSZ_T)
2384#if (16 == BITS_PER_XWPTR_T)
2387#elif (32 == BITS_PER_XWPTR_T)
2390#elif (64 == BITS_PER_XWPTR_T)
2395#if (16 == BITS_PER_XWER_T)
2397#elif (32 == BITS_PER_XWER_T)
2399#elif (64 == BITS_PER_XWER_T)
2403#if (8 == BITS_PER_XWID_T)
2405#elif (16 == BITS_PER_XWID_T)
2407#elif (32 == BITS_PER_XWID_T)
2409#elif (64 == BITS_PER_XWID_T)
2413#if (8 == BITS_PER_XWSID_T)
2415#elif (16 == BITS_PER_XWSID_T)
2417#elif (32 == BITS_PER_XWSID_T)
2419#elif (64 == BITS_PER_XWSID_T)
2423#if (16 == BITS_PER_XWREG_T)
2425#elif (32 == BITS_PER_XWREG_T)
2427#elif (64 == BITS_PER_XWREG_T)
2431#if (16 == BITS_PER_XWSREG_T)
2433#elif (32 == BITS_PER_XWSREG_T)
2435#elif (64 == BITS_PER_XWSREG_T)
2439#if (16 == BITS_PER_XWSQ_T)
2441#elif (32 == BITS_PER_XWSQ_T)
2443#elif (64 == BITS_PER_XWSQ_T)
2447#if (16 == BITS_PER_XWSSQ_T)
2449#elif (32 == BITS_PER_XWSSQ_T)
2451#elif (64 == BITS_PER_XWSSQ_T)
2455#if (8 == BITS_PER_XWBMP_T)
2457#elif (16 == BITS_PER_XWBMP_T)
2459#elif (32 == BITS_PER_XWBMP_T)
2461#elif (64 == BITS_PER_XWBMP_T)
2484#define xwbmpaop_define(name, bits) atomic_xwbmp_t name[BITS_TO_XWBMP_T(bits)]
2610 for (i = 0; i < n; i++) {
2628 for (i = 0; i < n; i++) {
xws64_t xwtm_t
XWOS系统时间 (有符号)
xwu64_t xwtk_t
XWOS系统滴答计数 (无符号)
__xwcc_atomic xwbmp_t atomic_xwbmp_t
#define xwaop_c0m(type, a, m, nv, ov)
对原子变量进行原子操作:读取-位清0操作-回写
#define xwaop_s1m(type, a, m, nv, ov)
对原子变量进行原子操作:读取-位置1操作-回写
#define DEFINE_XWAOP(type, btype)
使用模板为某一类型定义原子操作函数集合
void xwbmpaop_x1i(atomic_xwbmp_t *bmp, xwsq_t idx)
XWOS AOPLIB:将位图中某位翻转
static void xwbmpaop_c0all(atomic_xwbmp_t *bmp, xwsq_t num)
XWOS AOPLIB:将位图所有位清0
xwssq_t xwbmpaop_ffz_then_s1i(atomic_xwbmp_t *bmp, xwsz_t num)
XWOS AOPLIB:从最低位起查找位图中第一个为0的位并将它置1
xwssq_t xwbmpaop_fls_then_c0i(atomic_xwbmp_t *bmp, xwsz_t num)
XWOS AOPLIB:从最高位起查找位图中第一个为1的位并将它清0
xwssq_t xwbmpaop_ffs_then_c0i(atomic_xwbmp_t *bmp, xwsz_t num)
XWOS AOPLIB:从最低位起查找位图中第一个为1的位并将它清0
bool xwbmpaop_t1i(atomic_xwbmp_t *bmp, xwsq_t idx)
XWOS AOPLIB:测试位图中的某位是否被置1
xwer_t xwbmpaop_t1i_then_c0i(atomic_xwbmp_t *bmp, xwsq_t idx)
XWOS AOPLIB:测试位图中某位是否为1,如果是,就将它清0
static void xwbmpaop_s1all(atomic_xwbmp_t *bmp, xwsq_t num)
XWOS AOPLIB:将位图所有位置1
xwssq_t xwbmpaop_flz_then_s1i(atomic_xwbmp_t *bmp, xwsz_t num)
XWOS AOPLIB:从最高位起查找位图中第一个为0的位并将它置1
void xwbmpaop_c0i(atomic_xwbmp_t *bmp, xwsq_t idx)
XWOS AOPLIB:将位图中某位清0
xwer_t xwbmpaop_t0i_then_s1i(atomic_xwbmp_t *bmp, xwsq_t idx)
XWOS AOPLIB:测试位图中某位是否为0,如果是,就将它置1
void xwbmpaop_s1i(atomic_xwbmp_t *bmp, xwsq_t idx)
XWOS AOPLIB:将位图中某位置1
#define BITS_TO_XWBMP_T(n)