aboutsummaryrefslogblamecommitdiffstats
path: root/erts/include/internal/ethr_atomics.h
blob: 612894b8c14bede4907cc71ae21ddeb4e172a4df (plain) (tree)
1
2
3
4
5
6
7
8
9
10
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
  








                                                         

                   
                                                        















                                                                         
                                       


                        
































                                                             
























                                                          



















































































                                                                      
 



                           
 


























                                                            
  
                                                  


                                      








                                           
 















                                                                                



                             





                                                              
                                             





                                                                
        
                                                          
                                             













                                                                
                                             
































































                                                                                      
       
                                    
        













                                                                

      




                                                                    
 































































































































































































                                                                                                    
                                                                                                     





                                                                                                     
                                                                         





                                                                         
                                                                          





                                                                          
                                                                          







                                                                                                        
                                                                                                             





                                                                                                             
                                                                                 





                                                                                 
                                                                                  





                                                                                  
                                                                                  















































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                             








                                                                                                                             









































































































































































































































































































































































































































































































                                                                                                                                                       








                                                                                                 







































































































































































































































































































































                                                                                                  








                                                                                                  









































































































































































































































































































                                                                                                  








                                                                                                  








                                                                                          
                                                                                               





                                                                                               
                                                                       





                                                                       
                                                               





                                                               
                                                                





                                                                      
                                                                           





                                                                           
                                                      





                                                      
                                                          





                                                          
                                                          





                                                          
                                                               





                                                               
                                              





                                              
                                              





                                                                       
                                                                            





                                                                            
                                                                           






























































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                       








                                                                                                                       

























































































































































































































































                                                                                                      








                                                                                               













































































































































                                                                                       








                                                                                       













































































































































                                                                                        








                                                                                        

























































































































































































































































                                                                                                       








                                                                                                   

























































































































































                                                                                                                            








                                                                              

























































































































































                                                                                  








                                                                                  

























































































































































                                                                                  








                                                                                  













































































































































                                                                                       








                                                                                       













































































































































                                                                             








                                                                      













































































































































                                                                             








                                                                      

























































































































































































































































                                                                                                       








                                                                                                    

























































































































































































































































                                                                                                       








                                                                                                   








                                                                                                    
                                                                                                         





                                                                                                         
                                                                               





                                                                               
                                                                     





                                                                     
                                                                      





                                                                              
                                                                                   





                                                                                   
                                                            





                                                            
                                                                





                                                                
                                                                





                                                                
                                                                     





                                                                     
                                                  





                                                  
                                                  





                                                                               
                                                                                    





                                                                                    
                                                                                   






























































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                 








                                                                                                                                 

























































































































































































































































                                                                                                          








                                                                                                       






















































































                                                                                             
     
                                                   
      
 
 



















                                                                                             
      
 
 























                                                                                           
      
 
 








                                                                                             
 
                    
 
 

















                                                                                         
 





















                                                                                            
 





















                                                                                            
 





















                                                                                              
 





















                                                                                              
 























                                                                                            
      
 
 








                                                                                              
 



                                                                                                      
 
























                                                                                                           
     
                                                            
      
               

 
                                                                                                         
 
































                                                                                                           
     
                                                               
      
               

 
                                                                                                         
 
































                                                                                                           
     
                                                               
      
               

 
                                                                                                           
 
































                                                                                                           
     
                                                                 
      
               

 
                                                                                                           
 
































                                                                                                           
     
                                                                 
      



                                                                                                         
 








































                                                                                                           
     
                                                               
      
               

 








                                                                                                           




                                                                               
 












                                                              
     
                                                                                                                                 
      
               

 
                                                                                  
 
















                                                              
     
                                                                                                                                    
      
               

 
                                                                                  
 
















                                                              
     

                                                                                                                                    
               






















                                                                                                                                      
      
               

 
                                                                                    
 
















                                                              
     

                                                                                                                                      
               


























                                                                                                                                    
      
               

 








                                                                                    




                                                                                   
 












                                                                    
     

                                                               
               






















                                                                                      
      
               

 
                                                                                      
 
















                                                                    
     

                                                                  
               






















                                                                                        
      
               

 
                                                                                        
 
















                                                                    
     

                                                                    
               


























                                                                                      
      
               

 








                                                                                        




                                                                                   
 












                                                                    
     

                                                                
               






















                                                                                      
      
               

 























                                                                                      
 
                                                                                        
 
















                                                                             
     
                                                                     
      
               

 
                                                                                        
 
















                                                                    
     
                                                                     
      
               

 
                                                                                      
 




















                                                                             
     
                                                                   
      
               

 








                                                                                        




                                                                                        
 











                                                               
     
                                                  


      
                                                                                           
 















                                                               
     
                                                     


      
                                                                                           
 















                                                               
     
                                                     


      
                                                                                             
 















                                                                             
     
                                                       


      





















                                                                                             
 
                                                                                           
 



















                                                                             
     
                                                     


      








                                                                                             




                                                                     
 











                                         
     
                                             


      
                                                                        
 















                                         
     
                                                


      
                                                                        
 















                                         
     
                                                


      
                                                                          
 















                                                                             
     
                                                  
      


                                                                          
 















                                              
     
                                                  


      
                                                                        
 

















                                                                             
                                  
                                                                             
     
                                                


      








                                                                          




                                                                     
 
                                  
                                  









                                         
     
                                             


      
                                                                        
 















                                         
     
                                                


      
                                                                        
 















                                         
     
                                                


      
                                                                          
 















                                                                             
     
                                                  


      
                                                                          
 















                                              
     
                                                  


      
                                                                        
 



















                                                                             
     
                                                


      








                                                                          




                                                                                                       
 
                      

























                                                                                                           
      
               

 







































                                                                                                           
 
                                                                                                          
 
































                                                                                                           
     
                                                                
      
               

 
                                                                                                            
 
































                                                                                                           
     
                                                                  
      
               

 
                                                                                                            
 
































                                                                                                           
     
                                                                  
      
               

 
                                                                                                          
 








































                                                                                                           
     
                                                                
      
               

 








                                                                                                            




                                                                                                      
 
























                                                                                                           
     
                                                            
      
               

 
                                                                                                         
 
































                                                                                                           
     
                                                               
      
               

 
                                                                                                         
 
































                                                                                                           
     
                                                               
      
               

 







































                                                                                                           
 







































                                                                                                           
 















































                                                                                                           
 








                                                                                                           
                                 
 
                             
/*
 * --------------- DO NOT EDIT THIS FILE! ---------------
 * This file was automatically generated by the
 * $ERL_TOP/erts/lib_src/utils/make_atomics_api script.
 * If you need to make changes, edit the script and
 * regenerate this file.
 * --------------- DO NOT EDIT THIS FILE! ---------------
 */

/*
 * %CopyrightBegin%
 *
 * Copyright Ericsson AB 2011-2012. All Rights Reserved.
 *
 * The contents of this file are subject to the Erlang Public License,
 * Version 1.1, (the "License"); you may not use this file except in
 * compliance with the License. You should have received a copy of the
 * Erlang Public License along with this software. If not, it can be
 * retrieved online at http://www.erlang.org/.
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * %CopyrightEnd%
 */

/*
 * Description: The ethread atomics API
 * Author: Rickard Green
 */

/*
 * This file maps native atomic implementations to ethread
 * API atomics. If no native atomic implementation
 * is available, a less efficient fallback is used instead.
 * The API consists of 32-bit size, word size (pointer size),
 * and double word size atomics.
 *
 * The following atomic operations are implemented for
 * 32-bit size, and word size atomics:
 * - cmpxchg
 * - xchg
 * - set
 * - init
 * - add_read
 * - read
 * - inc_read
 * - dec_read
 * - add
 * - inc
 * - dec
 * - read_band
 * - read_bor
 *
 * The following atomic operations are implemented for
 * double word size atomics:
 * - cmpxchg
 * - set
 * - read
 * - init
 *
 * Appart from a function implementing the atomic operation
 * with unspecified memory barrier semantics, there are
 * functions implementing each operation with the following
 * implied memory barrier semantics:
 * - mb   - Full memory barrier. Orders both loads, and
 *          stores before, and after the atomic operation.
 *          No load or store is allowed to be reordered
 *          over the atomic operation.
 * - relb - Release barrier. Orders both loads, and
 *          stores appearing *before* the atomic
 *          operation. These are not allowed to be
 *          reordered over the atomic operation.
 * - acqb - Acquire barrier. Orders both loads, and stores
 *          appearing *after* the atomic operation. These
 *          are not allowed to be reordered over the
 *          atomic operation.
 * - wb   - Write barrier. Orders *only* stores. These are
 *          not allowed to be reordered over the barrier.
 *          Store in atomic operation is ordered *after*
 *          the barrier.
 * - rb   - Read barrier. Orders *only* loads. These are
 *          not allowed to be reordered over the barrier.
 *          Load in atomic operation is ordered *before*
 *          the barrier. 
 * - ddrb - Data dependency read barrier. Orders *only*
 *          loads according to data dependency across the
 *          barrier. Load in atomic operation is ordered
 *          before the barrier.
 *
 * We implement all of these operation/barrier
 * combinations, regardless of whether they are useful
 * or not (some of them are useless).
 *
 * Double word size atomic functions are on the followning
 * form:
 *   ethr_dw_atomic_<OP>[_<BARRIER>]
 *
 * Word size atomic functions are on the followning
 * form:
 *   ethr_atomic_<OP>[_<BARRIER>]
 *
 * 32-bit size atomic functions are on the followning
 * form:
 *   ethr_atomic32_<OP>[_<BARRIER>]
 *
 * Apart from the operation/barrier functions
 * described above also 'addr' functions are implemented
 * which return the actual memory address used of the
 * atomic variable. The 'addr' functions have no barrier
 * versions.
 *
 * The native atomic implementation does not need to
 * implement all operation/barrier combinations.
 * Functions that have no native implementation will be
 * constructed from existing native functionality. These
 * functions will perform the wanted operation and will
 * produce sufficient memory barriers, but may
 * in some cases be less efficient than pure native
 * versions.
 *
 * When we create ethread API operation/barrier functions by
 * adding barriers before and after native operations it is
 * assumed that:
 * - A native read operation begins, and ends with a load.
 * - A native set operation begins, and ends with a store.
 * - An init operation begins with either a load, or a store,
 *   and ends with either a load, or a store.
 * - All other operations begins with a load, and ends with
 *   either a load, or a store.
 *
 * This is the minimum functionality that a native
 * implementation needs to provide:
 *
 * - Functions that need to be implemented:
 *
 *   - ethr_native_[dw_|su_dw_]atomic[BITS]_addr
 *   - ethr_native_[dw_|su_dw_]atomic[BITS]_cmpxchg[_<BARRIER>]
 *     (at least one cmpxchg of optional barrier)
 *
 * - Macros that needs to be defined:
 *
 *   A macro informing about the presence of the native
 *   implementation:
 *
 *   - ETHR_HAVE_NATIVE_[DW_|SU_DW_]ATOMIC[BITS]
 *
 *   A macro naming (a string constant) the implementation:
 *
 *   - ETHR_NATIVE_[DW_]ATOMIC[BITS]_IMPL
 *
 *   Each implemented native atomic function has to
 *   be accompanied by a defined macro on the following
 *   form informing about its presence:
 *
 *   - ETHR_HAVE_ETHR_NATIVE_[DW_|SU_DW_]ATOMIC[BITS]_<OP>[_<BARRIER>]
 *
 *   A (sparc-v9 style) membar macro:
 *
 *   - ETHR_MEMBAR(B)
 *
 *     Which takes a combination of the following macros
 *     or:ed (using |) together:
 *
 *     - ETHR_LoadLoad
 *     - ETHR_LoadStore
 *     - ETHR_StoreLoad
 *     - ETHR_StoreStore
 *
 */

#ifndef ETHR_ATOMICS_H__
#define ETHR_ATOMICS_H__

#undef ETHR_AMC_FALLBACK__
#undef ETHR_AMC_NO_ATMCS__
#undef ETHR_AMC_ATMC_T__
#undef ETHR_AMC_ATMC_FUNC__

/* -- 32-bit atomics -- */

#undef ETHR_NAINT32_T__
#undef ETHR_NATMC32_FUNC__
#undef ETHR_NATMC32_ADDR_FUNC__
#undef ETHR_NATMC32_BITS__
#if defined(ETHR_HAVE_NATIVE_ATOMIC32)
#    define ETHR_NEED_NATMC32_ADDR
#  define ETHR_NATMC32_ADDR_FUNC__ ethr_native_atomic32_addr
typedef ethr_native_atomic32_t ethr_atomic32_t;
#  define ETHR_NAINT32_T__ ethr_sint32_t
#  define ETHR_NATMC32_FUNC__(X) ethr_native_atomic32_ ## X
#  define ETHR_NATMC32_BITS__ 32
#elif defined(ETHR_HAVE_NATIVE_ATOMIC64)
#  define ETHR_NEED_NATMC64_ADDR
#ifdef ETHR_BIGENDIAN
#  define ETHR_NATMC32_ADDR_FUNC__(VAR) \
  (((ethr_sint32_t *) ethr_native_atomic64_addr((VAR))) + 1)
#else
#  define ETHR_NATMC32_ADDR_FUNC__(VAR) \
  ((ethr_sint32_t *) ethr_native_atomic64_addr((VAR)))
#endif
typedef ethr_native_atomic64_t ethr_atomic32_t;
#  define ETHR_NAINT32_T__ ethr_sint64_t
#  define ETHR_NATMC32_FUNC__(X) ethr_native_atomic64_ ## X
#  define ETHR_NATMC32_BITS__ 64
#else
/*
 * No native atomics usable for 32-bits atomics :(
 * Use fallback...
 */
typedef ethr_sint32_t ethr_atomic32_t;
#endif

#undef ETHR_ATMC32_INLINE__
#ifdef ETHR_NATMC32_BITS__
#  ifdef ETHR_TRY_INLINE_FUNCS
#    define ETHR_ATMC32_INLINE__
#  endif
#  define ETHR_HAVE_32BIT_NATIVE_ATOMIC_OPS
#endif

#if !defined(ETHR_ATMC32_INLINE__) || defined(ETHR_ATOMIC_IMPL__)
#  define ETHR_NEED_ATMC32_PROTOTYPES__
#endif

#ifndef ETHR_INLINE_ATMC32_FUNC_NAME_
#  define ETHR_INLINE_ATMC32_FUNC_NAME_(X) X
#endif

#undef ETHR_ATMC32_FUNC__
#define ETHR_ATMC32_FUNC__(X) ETHR_INLINE_ATMC32_FUNC_NAME_(ethr_atomic32_ ## X)


/* -- Word size atomics -- */

#undef ETHR_NEED_NATMC32_ADDR
#undef ETHR_NEED_NATMC64_ADDR

#undef ETHR_NAINT_T__
#undef ETHR_NATMC_FUNC__
#undef ETHR_NATMC_ADDR_FUNC__
#undef ETHR_NATMC_BITS__
#if ETHR_SIZEOF_PTR == 8 && defined(ETHR_HAVE_NATIVE_ATOMIC64)
#  ifndef ETHR_NEED_NATMC64_ADDR
#    define ETHR_NEED_NATMC64_ADDR
#  endif
#  define ETHR_NATMC_ADDR_FUNC__ ethr_native_atomic64_addr
typedef ethr_native_atomic64_t ethr_atomic_t;
#  define ETHR_NAINT_T__ ethr_sint64_t
#  define ETHR_NATMC_FUNC__(X) ethr_native_atomic64_ ## X
#  define ETHR_NATMC_BITS__ 64
#elif ETHR_SIZEOF_PTR == 4 && defined(ETHR_HAVE_NATIVE_ATOMIC32)
#  ifndef ETHR_NEED_NATMC64_ADDR
#    define ETHR_NEED_NATMC32_ADDR
#  endif
#  define ETHR_NATMC_ADDR_FUNC__ ethr_native_atomic32_addr
typedef ethr_native_atomic32_t ethr_atomic_t;
#  define ETHR_NAINT_T__ ethr_sint32_t
#  define ETHR_NATMC_FUNC__(X) ethr_native_atomic32_ ## X
#  define ETHR_NATMC_BITS__ 32
#elif ETHR_SIZEOF_PTR == 4 && defined(ETHR_HAVE_NATIVE_ATOMIC64)
#  ifndef ETHR_NEED_NATMC64_ADDR
#    define ETHR_NEED_NATMC64_ADDR
#  endif
#ifdef ETHR_BIGENDIAN
#  define ETHR_NATMC_ADDR_FUNC__(VAR) \
  (((ethr_sint32_t *) ethr_native_atomic64_addr((VAR))) + 1)
#else
#  define ETHR_NATMC_ADDR_FUNC__(VAR) \
  ((ethr_sint32_t *) ethr_native_atomic64_addr((VAR)))
#endif
typedef ethr_native_atomic64_t ethr_atomic_t;
#  define ETHR_NATMC_T__ ethr_native_atomic64_t
#  define ETHR_NAINT_T__ ethr_sint64_t
#  define ETHR_NATMC_FUNC__(X) ethr_native_atomic64_ ## X
#  define ETHR_NATMC_BITS__ 64
#else
/*
 * No native atomics usable for pointer size atomics :(
 * Use fallback...
 */

#  if defined(ETHR_HAVE_32BIT_NATIVE_ATOMIC_OPS)
#    define ETHR_AMC_FALLBACK__
#    define ETHR_AMC_NO_ATMCS__ 2
#    define ETHR_AMC_SINT_T__ ethr_sint32_t
#    define ETHR_AMC_ATMC_T__ ethr_atomic32_t
#    define ETHR_AMC_ATMC_FUNC__(X) ETHR_INLINE_ATMC32_FUNC_NAME_(ethr_atomic32_ ## X)
typedef struct {
    ETHR_AMC_ATMC_T__ atomic[ETHR_AMC_NO_ATMCS__];
} ethr_amc_t;
typedef struct {
    ethr_amc_t amc;
    ethr_sint_t sint;
} ethr_atomic_t;
#  else /* locked fallback */
typedef ethr_sint_t ethr_atomic_t;
#  endif
#endif

#undef ETHR_ATMC_INLINE__
#ifdef ETHR_NATMC_BITS__
#  ifdef ETHR_TRY_INLINE_FUNCS
#    define ETHR_ATMC_INLINE__
#  endif
#  define ETHR_HAVE_WORD_SZ_NATIVE_ATOMIC_OPS
#endif

#if !defined(ETHR_ATMC_INLINE__) || defined(ETHR_ATOMIC_IMPL__)
#  define ETHR_NEED_ATMC_PROTOTYPES__
#endif

#ifndef ETHR_INLINE_ATMC_FUNC_NAME_
#  define ETHR_INLINE_ATMC_FUNC_NAME_(X) X
#endif

#undef ETHR_ATMC_FUNC__
#define ETHR_ATMC_FUNC__(X) ETHR_INLINE_ATMC_FUNC_NAME_(ethr_atomic_ ## X)

/* -- Double word atomics -- */

#undef ETHR_SU_DW_NAINT_T__
#undef ETHR_SU_DW_NATMC_FUNC__
#undef ETHR_SU_DW_NATMC_ADDR_FUNC__
#undef ETHR_DW_NATMC_FUNC__
#undef ETHR_DW_NATMC_ADDR_FUNC__
#undef ETHR_DW_NATMC_BITS__
#if defined(ETHR_HAVE_NATIVE_DW_ATOMIC) || defined(ETHR_HAVE_NATIVE_SU_DW_ATOMIC)
#  define ETHR_NEED_DW_NATMC_ADDR
#  define ETHR_DW_NATMC_ADDR_FUNC__ ethr_native_dw_atomic_addr
#  define ETHR_NATIVE_DW_ATOMIC_T__ ethr_native_dw_atomic_t
#  define ETHR_DW_NATMC_FUNC__(X) ethr_native_dw_atomic_ ## X
#  define ETHR_SU_DW_NATMC_FUNC__(X) ethr_native_su_dw_atomic_ ## X
#  if ETHR_SIZEOF_PTR == 8
#    define ETHR_DW_NATMC_BITS__ 128
#  elif ETHR_SIZEOF_PTR == 4
#    define ETHR_DW_NATMC_BITS__ 64
#  else
#    error "Word size not supported"
#  endif
#  ifdef ETHR_NATIVE_SU_DW_SINT_T
#    define ETHR_SU_DW_NAINT_T__ ETHR_NATIVE_SU_DW_SINT_T
#  endif
#elif ETHR_SIZEOF_PTR == 4 && defined(ETHR_HAVE_NATIVE_ATOMIC64)
#  define ETHR_HAVE_NATIVE_SU_DW_ATOMIC
#  ifndef ETHR_NEED_NATMC64_ADDR
#    define ETHR_NEED_NATMC64_ADDR
#  endif
#  define ETHR_DW_NATMC_ADDR_FUNC__(VAR) \
  ((ethr_dw_sint_t *) ethr_native_atomic64_addr((VAR)))
#  define ETHR_NATIVE_DW_ATOMIC_T__ ethr_native_atomic64_t
#  define ETHR_SU_DW_NAINT_T__ ethr_sint64_t
#  define ETHR_SU_DW_NATMC_FUNC__(X) ethr_native_atomic64_ ## X
#  define ETHR_DW_NATMC_BITS__ 64
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
#define ETHR_DW_ATOMIC_FUNC__(X) ethr_dw_atomic_ ## X ## _fallback__
#else
#define ETHR_DW_ATOMIC_FUNC__(X) ethr_dw_atomic_ ## X
#endif

#if !defined(ETHR_DW_NATMC_BITS__) || defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
#  define ETHR_NEED_DW_FALLBACK__
#endif

#if defined(ETHR_NEED_DW_FALLBACK__)
/*
 * No native atomics usable for double word atomics :(
 * Use fallback...
 */

#  ifndef ETHR_AMC_FALLBACK__
#    if ETHR_SIZEOF_PTR == 8 && defined(ETHR_HAVE_WORD_SZ_NATIVE_ATOMIC_OPS)
#      define ETHR_AMC_FALLBACK__
#      define ETHR_AMC_NO_ATMCS__ 1
#      define ETHR_AMC_SINT_T__ ethr_sint_t
#      define ETHR_AMC_ATMC_T__ ethr_atomic_t
#      define ETHR_AMC_ATMC_FUNC__(X) ETHR_INLINE_ATMC_FUNC_NAME_(ethr_atomic_ ## X)
#    elif defined(ETHR_HAVE_32BIT_NATIVE_ATOMIC_OPS)
#      define ETHR_AMC_FALLBACK__
#      define ETHR_AMC_NO_ATMCS__ 2
#      define ETHR_AMC_SINT_T__ ethr_sint32_t
#      define ETHR_AMC_ATMC_T__ ethr_atomic32_t
#      define ETHR_AMC_ATMC_FUNC__(X) ETHR_INLINE_ATMC32_FUNC_NAME_(ethr_atomic32_ ## X)
#    endif
#    ifdef ETHR_AMC_FALLBACK__
typedef struct {
    ETHR_AMC_ATMC_T__ atomic[ETHR_AMC_NO_ATMCS__];
} ethr_amc_t;
#    endif
#  endif

typedef struct {
#ifdef ETHR_AMC_FALLBACK__
    ethr_amc_t amc;
#endif
    ethr_sint_t sint[2];
} ethr_dw_atomic_fallback_t;

#endif

typedef union {
#ifdef ETHR_NATIVE_DW_ATOMIC_T__
    ETHR_NATIVE_DW_ATOMIC_T__ native;
#endif
#ifdef ETHR_NEED_DW_FALLBACK__
    ethr_dw_atomic_fallback_t fallback;
#endif
    ethr_sint_t sint[2];
} ethr_dw_atomic_t;

typedef union {
#ifdef ETHR_SU_DW_NAINT_T__
    ETHR_SU_DW_NAINT_T__ dw_sint;
#endif
    ethr_sint_t sint[2];
} ethr_dw_sint_t;

#ifdef ETHR_BIGENDIAN
#  define ETHR_DW_SINT_LOW_WORD 1
#  define ETHR_DW_SINT_HIGH_WORD 0
#else
#  define ETHR_DW_SINT_LOW_WORD 0
#  define ETHR_DW_SINT_HIGH_WORD 1
#endif

#undef ETHR_DW_ATMC_INLINE__
#ifdef ETHR_DW_NATMC_BITS__
#  ifdef ETHR_TRY_INLINE_FUNCS
#    define ETHR_ATMC32_INLINE__
#  endif
#  define ETHR_HAVE_DOUBLE_WORD_SZ_NATIVE_ATOMIC_OPS
#endif

#if !defined(ETHR_DW_ATMC_INLINE__) || defined(ETHR_ATOMIC_IMPL__)
#  define ETHR_NEED_DW_ATMC_PROTOTYPES__
#endif

#ifndef ETHR_INLINE_DW_ATMC_FUNC_NAME_
#  define ETHR_INLINE_DW_ATMC_FUNC_NAME_(X) X
#endif

#undef ETHR_DW_ATMC_FUNC__
#define ETHR_DW_ATMC_FUNC__(X) ETHR_INLINE_DW_ATMC_FUNC_NAME_(ethr_dw_atomic_ ## X)

#if defined(ETHR_NEED_DW_ATMC_PROTOTYPES__)
int ethr_have_native_dw_atomic(void);
#endif
#if defined(ETHR_DW_ATMC_INLINE__) || defined(ETHR_ATOMIC_IMPL__)
static ETHR_INLINE int
ETHR_INLINE_DW_ATMC_FUNC_NAME_(ethr_have_native_dw_atomic)(void)
{
#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    return ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__;
#elif defined(ETHR_DW_NATMC_BITS__)
    return 1;
#else
    return 0;
#endif
}
#endif

/* -- Misc -- */

#if defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_ATOMIC_IMPL__)
/*
 * Unusual values are used by read() fallbacks implemented via cmpxchg().
 * We want to use an unusual value in hope that it is more efficient
 * not to match the value in memory.
 *
 * - Negative integer values are probably more unusual.
 * - Very large absolute integer values are probably more unusual.
 * - Odd pointers are probably more unusual (only char pointers can be odd).
 */
#  define ETHR_UNUSUAL_SINT32_VAL__ ((ethr_sint32_t) 0x81818181)
#  if ETHR_SIZEOF_PTR == 4
#    define ETHR_UNUSUAL_SINT_VAL__ ((ethr_sint_t) ETHR_UNUSUAL_SINT32_VAL__)
#  elif ETHR_SIZEOF_PTR == 8
#    define ETHR_UNUSUAL_SINT_VAL__ ((ethr_sint_t) 0x8181818181818181L)
#  else
#    error "Word size not supported"
#  endif
#  if defined(ETHR_NEED_DW_NATMC_ADDR) && !defined(ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_ADDR)
#    error "No ethr_native_dw_atomic_addr() available"
#  endif
#  if defined(ETHR_NEED_NATMC32_ADDR) && !defined(ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADDR)
#    error "No ethr_native_atomic32_addr() available"
#  endif
#  if defined(ETHR_NEED_NATMC64_ADDR) && !defined(ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADDR)
#    error "No ethr_native_atomic64_addr() available"
#  endif
#endif

#if defined(__GNUC__)
#  ifndef ETHR_COMPILER_BARRIER
#    define ETHR_COMPILER_BARRIER __asm__ __volatile__("" : : : "memory")
#  endif
#elif defined(ETHR_WIN32_THREADS)
#  ifndef ETHR_COMPILER_BARRIER
#    include <intrin.h>
#    pragma intrinsic(_ReadWriteBarrier)
#    define ETHR_COMPILER_BARRIER _ReadWriteBarrier()
#  endif
#endif

void ethr_compiler_barrier_fallback(void);
#ifndef ETHR_COMPILER_BARRIER
#  define ETHR_COMPILER_BARRIER ethr_compiler_barrier_fallback()
#endif

int ethr_init_atomics(void);

/* info */
char **ethr_native_atomic32_ops(void);
char **ethr_native_atomic64_ops(void);
char **ethr_native_dw_atomic_ops(void);
char **ethr_native_su_dw_atomic_ops(void);

#if !defined(ETHR_DW_NATMC_BITS__) && !defined(ETHR_NATMC_BITS__) && !defined(ETHR_NATMC32_BITS__)
/*
 * ETHR_*MEMORY_BARRIER orders between locked and atomic accesses only,
 * i.e. when no native atomic implementation exist and only our lock
 * based atomic fallback is used, a noop is sufficient.
 */
#  undef ETHR_MEMORY_BARRIER
#  undef ETHR_WRITE_MEMORY_BARRIER
#  undef ETHR_READ_MEMORY_BARRIER
#  undef ETHR_READ_DEPEND_MEMORY_BARRIER
#  undef ETHR_MEMBAR
#  define ETHR_MEMBAR(B) do { } while (0)
#endif

#ifndef ETHR_MEMBAR
#  error "No ETHR_MEMBAR defined"
#endif

#define ETHR_MEMORY_BARRIER ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore)
#define ETHR_WRITE_MEMORY_BARRIER ETHR_MEMBAR(ETHR_StoreStore)
#define ETHR_READ_MEMORY_BARRIER ETHR_MEMBAR(ETHR_LoadLoad)
#ifdef ETHR_READ_DEPEND_MEMORY_BARRIER
#  undef ETHR_ORDERED_READ_DEPEND
#else
#  define ETHR_READ_DEPEND_MEMORY_BARRIER ETHR_COMPILER_BARRIER
#  define ETHR_ORDERED_READ_DEPEND
#endif


/* ---------- Double word size atomic implementation ---------- */


#ifdef ETHR_NEED_DW_ATMC_PROTOTYPES__
ethr_sint_t *ethr_dw_atomic_addr(ethr_dw_atomic_t *var);
int ethr_dw_atomic_cmpxchg(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ethr_dw_atomic_cmpxchg_ddrb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ethr_dw_atomic_cmpxchg_rb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ethr_dw_atomic_cmpxchg_wb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ethr_dw_atomic_cmpxchg_acqb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ethr_dw_atomic_cmpxchg_relb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ethr_dw_atomic_cmpxchg_mb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
void ethr_dw_atomic_set(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_set_ddrb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_set_rb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_set_wb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_set_acqb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_set_relb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_set_mb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read_ddrb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read_rb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read_wb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read_acqb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read_relb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_read_mb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init_ddrb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init_rb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init_wb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init_acqb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init_relb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ethr_dw_atomic_init_mb(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
ethr_sint_t *ETHR_DW_ATOMIC_FUNC__(addr)(ethr_dw_atomic_t *var);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
int ETHR_DW_ATOMIC_FUNC__(cmpxchg_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val);
void ETHR_DW_ATOMIC_FUNC__(set)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(set_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(set_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(set_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(set_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(set_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(set_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(read_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
void ETHR_DW_ATOMIC_FUNC__(init_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val);
#endif
#endif /* ETHR_NEED_DW_ATMC_PROTOTYPES__ */

#if (defined(ETHR_HAVE_DOUBLE_WORD_SZ_NATIVE_ATOMIC_OPS) \
     && (defined(ETHR_DW_ATMC_INLINE__) || defined(ETHR_ATOMIC_IMPL__)))

#if !defined(ETHR_DW_NATMC_BITS__)
#  error "Missing native atomic implementation"
#elif defined(ETHR_HAVE_NATIVE_DW_ATOMIC)  || defined(ETHR_HAVE_NATIVE_SU_DW_ATOMIC)
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_CMPXCHG
#    define ETHR_HAVE_DW_NATMC_CMPXCHG 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_CMPXCHG
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_CMPXCHG_RB
#    define ETHR_HAVE_DW_NATMC_CMPXCHG_RB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_CMPXCHG_RB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_CMPXCHG_WB
#    define ETHR_HAVE_DW_NATMC_CMPXCHG_WB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_CMPXCHG_WB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_CMPXCHG_ACQB
#    define ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_CMPXCHG_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_CMPXCHG_RELB
#    define ETHR_HAVE_DW_NATMC_CMPXCHG_RELB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_CMPXCHG_RELB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_CMPXCHG_MB
#    define ETHR_HAVE_DW_NATMC_CMPXCHG_MB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_CMPXCHG_MB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_SET
#  undef ETHR_HAVE_DW_NATMC_SET
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_SET
#    define ETHR_HAVE_DW_NATMC_SET 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_SET
#    define ETHR_HAVE_SU_DW_NATMC_SET 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_SET_RB
#  undef ETHR_HAVE_DW_NATMC_SET_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_SET_RB
#    define ETHR_HAVE_DW_NATMC_SET_RB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_SET_RB
#    define ETHR_HAVE_SU_DW_NATMC_SET_RB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_SET_WB
#  undef ETHR_HAVE_DW_NATMC_SET_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_SET_WB
#    define ETHR_HAVE_DW_NATMC_SET_WB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_SET_WB
#    define ETHR_HAVE_SU_DW_NATMC_SET_WB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_SET_ACQB
#  undef ETHR_HAVE_DW_NATMC_SET_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_SET_ACQB
#    define ETHR_HAVE_DW_NATMC_SET_ACQB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_SET_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_SET_ACQB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_SET_RELB
#  undef ETHR_HAVE_DW_NATMC_SET_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_SET_RELB
#    define ETHR_HAVE_DW_NATMC_SET_RELB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_SET_RELB
#    define ETHR_HAVE_SU_DW_NATMC_SET_RELB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_SET_MB
#  undef ETHR_HAVE_DW_NATMC_SET_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_SET_MB
#    define ETHR_HAVE_DW_NATMC_SET_MB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_SET_MB
#    define ETHR_HAVE_SU_DW_NATMC_SET_MB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_READ
#  undef ETHR_HAVE_DW_NATMC_READ
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_READ
#    define ETHR_HAVE_DW_NATMC_READ 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_READ
#    define ETHR_HAVE_SU_DW_NATMC_READ 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_READ_RB
#  undef ETHR_HAVE_DW_NATMC_READ_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_READ_RB
#    define ETHR_HAVE_DW_NATMC_READ_RB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_READ_RB
#    define ETHR_HAVE_SU_DW_NATMC_READ_RB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_READ_WB
#  undef ETHR_HAVE_DW_NATMC_READ_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_READ_WB
#    define ETHR_HAVE_DW_NATMC_READ_WB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_READ_WB
#    define ETHR_HAVE_SU_DW_NATMC_READ_WB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_READ_ACQB
#  undef ETHR_HAVE_DW_NATMC_READ_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_READ_ACQB
#    define ETHR_HAVE_DW_NATMC_READ_ACQB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_READ_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_READ_ACQB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_READ_RELB
#  undef ETHR_HAVE_DW_NATMC_READ_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_READ_RELB
#    define ETHR_HAVE_DW_NATMC_READ_RELB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_READ_RELB
#    define ETHR_HAVE_SU_DW_NATMC_READ_RELB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_READ_MB
#  undef ETHR_HAVE_DW_NATMC_READ_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_READ_MB
#    define ETHR_HAVE_DW_NATMC_READ_MB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_READ_MB
#    define ETHR_HAVE_SU_DW_NATMC_READ_MB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_INIT
#  undef ETHR_HAVE_DW_NATMC_INIT
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_INIT
#    define ETHR_HAVE_DW_NATMC_INIT 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_INIT
#    define ETHR_HAVE_SU_DW_NATMC_INIT 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_RB
#  undef ETHR_HAVE_DW_NATMC_INIT_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_INIT_RB
#    define ETHR_HAVE_DW_NATMC_INIT_RB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_INIT_RB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_RB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_WB
#  undef ETHR_HAVE_DW_NATMC_INIT_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_INIT_WB
#    define ETHR_HAVE_DW_NATMC_INIT_WB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_INIT_WB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_WB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_ACQB
#  undef ETHR_HAVE_DW_NATMC_INIT_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_INIT_ACQB
#    define ETHR_HAVE_DW_NATMC_INIT_ACQB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_INIT_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_ACQB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_RELB
#  undef ETHR_HAVE_DW_NATMC_INIT_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_INIT_RELB
#    define ETHR_HAVE_DW_NATMC_INIT_RELB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_INIT_RELB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_RELB 1
#  endif
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_MB
#  undef ETHR_HAVE_DW_NATMC_INIT_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_DW_ATOMIC_INIT_MB
#    define ETHR_HAVE_DW_NATMC_INIT_MB 1
#  endif
#  ifdef ETHR_HAVE_ETHR_NATIVE_SU_DW_ATOMIC_INIT_MB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_MB 1
#  endif
#elif ETHR_DW_NATMC_BITS__ == 64
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_RB
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_RB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_WB
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_WB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_RELB
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_RELB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_CMPXCHG_MB
#  undef ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_MB
#    define ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_SET
#  undef ETHR_HAVE_SU_DW_NATMC_SET
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET
#    define ETHR_HAVE_SU_DW_NATMC_SET 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_SET_RB
#  undef ETHR_HAVE_SU_DW_NATMC_SET_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_RB
#    define ETHR_HAVE_SU_DW_NATMC_SET_RB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_SET_WB
#  undef ETHR_HAVE_SU_DW_NATMC_SET_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_WB
#    define ETHR_HAVE_SU_DW_NATMC_SET_WB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_SET_ACQB
#  undef ETHR_HAVE_SU_DW_NATMC_SET_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_SET_ACQB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_SET_RELB
#  undef ETHR_HAVE_SU_DW_NATMC_SET_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_RELB
#    define ETHR_HAVE_SU_DW_NATMC_SET_RELB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_SET_MB
#  undef ETHR_HAVE_SU_DW_NATMC_SET_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_MB
#    define ETHR_HAVE_SU_DW_NATMC_SET_MB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_READ
#  undef ETHR_HAVE_SU_DW_NATMC_READ
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ
#    define ETHR_HAVE_SU_DW_NATMC_READ 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_READ_RB
#  undef ETHR_HAVE_SU_DW_NATMC_READ_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_RB
#    define ETHR_HAVE_SU_DW_NATMC_READ_RB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_READ_WB
#  undef ETHR_HAVE_SU_DW_NATMC_READ_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_WB
#    define ETHR_HAVE_SU_DW_NATMC_READ_WB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_READ_ACQB
#  undef ETHR_HAVE_SU_DW_NATMC_READ_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_READ_ACQB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_READ_RELB
#  undef ETHR_HAVE_SU_DW_NATMC_READ_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_RELB
#    define ETHR_HAVE_SU_DW_NATMC_READ_RELB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_READ_MB
#  undef ETHR_HAVE_SU_DW_NATMC_READ_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_MB
#    define ETHR_HAVE_SU_DW_NATMC_READ_MB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_INIT
#  undef ETHR_HAVE_SU_DW_NATMC_INIT
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT
#    define ETHR_HAVE_SU_DW_NATMC_INIT 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_INIT_RB
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_RB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_RB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_INIT_WB
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_WB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_WB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_INIT_ACQB
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_ACQB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_ACQB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_INIT_RELB
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_RELB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_RELB 1
#  endif
#  undef ETHR_HAVE_DW_NATMC_INIT_MB
#  undef ETHR_HAVE_SU_DW_NATMC_INIT_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_MB
#    define ETHR_HAVE_SU_DW_NATMC_INIT_MB 1
#  endif
#else
#  error "Invalid native atomic size"
#endif


#if defined(ETHR_HAVE_NATIVE_DW_ATOMIC)

#if (!defined(ETHR_HAVE_DW_NATMC_CMPXCHG) \
     && !defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB) \
     && !defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB) \
     && !defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB) \
     && !defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB) \
     && !defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB))
#  error "No native cmpxchg() op available"
#endif


/*
 * Read op used together with cmpxchg() fallback when no native op present.
 */
#if defined(ETHR_HAVE_DW_NATMC_READ)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  ETHR_DW_NATMC_FUNC__(read)(VAR, VAL)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  VAL.dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(VAR)
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  ETHR_DW_NATMC_FUNC__(read_rb)(VAR, VAL)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  VAL.dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(VAR)
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  ETHR_DW_NATMC_FUNC__(read_wb)(VAR, VAL)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  VAL.dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(VAR)
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  ETHR_DW_NATMC_FUNC__(read_acqb)(VAR, VAL)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  VAL.dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(VAR)
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  ETHR_DW_NATMC_FUNC__(read_relb)(VAR, VAL)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  VAL.dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(VAR)
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  ETHR_DW_NATMC_FUNC__(read_mb)(VAR, VAL)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
  VAL.dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(VAR)
#else
/*
 * We have no native read() op; guess zero and then use the
 * the atomics actual value returned from cmpxchg().
 */
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, VAL) \
do { \
  VAL.sint[0] = (ethr_sint_t) 0; \
  VAL.sint[1] = (ethr_sint_t) 0; \
} while (0)
#endif

/*
 * Native cmpxchg() fallback used when no native op present.
 */
#define ETHR_DW_NATMC_CMPXCHG_FALLBACK__(CMPXCHG, VAR, AVAL, OPS) \
do { \
    int res__; \
    ethr_dw_sint_t AVAL, exp_act__; \
    ETHR_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR, exp_act__); \
    do { \
	AVAL.sint[0] = exp_act__.sint[0]; \
	AVAL.sint[1] = exp_act__.sint[1]; \
	{ OPS; } \
	res__ = CMPXCHG(VAR, AVAL.sint, exp_act__.sint); \
    } while (__builtin_expect(res__ == 0, 0)); \
} while (0)


#elif defined(ETHR_HAVE_NATIVE_SU_DW_ATOMIC)

#if (!defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG) \
     && !defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB) \
     && !defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB) \
     && !defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB) \
     && !defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB) \
     && !defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB))
#  error "No native cmpxchg() op available"
#endif


/*
 * Read op used together with cmpxchg() fallback when no native op present.
 */
#if defined(ETHR_HAVE_SU_DW_NATMC_READ)
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_SU_DW_NATMC_FUNC__(read)(VAR)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_SU_DW_NATMC_FUNC__(read_rb)(VAR)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_SU_DW_NATMC_FUNC__(read_wb)(VAR)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_SU_DW_NATMC_FUNC__(read_acqb)(VAR)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_SU_DW_NATMC_FUNC__(read_relb)(VAR)
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_SU_DW_NATMC_FUNC__(read_mb)(VAR)
#else
/*
 * We have no native read() op; guess zero and then use the
 * the atomics actual value returned from cmpxchg().
 */
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ((ETHR_SU_DW_NAINT_T__) 0)
#endif

/*
 * Native cmpxchg() fallback used when no native op present.
 */
#define ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(CMPXCHG, VAR, AVAL, OPS) \
do { \
    ETHR_SU_DW_NAINT_T__ AVAL; \
    ETHR_SU_DW_NAINT_T__ new__, act__, exp__; \
    act__ = ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK_READ__(VAR); \
    do { \
	exp__ = act__; \
	AVAL = (ETHR_SU_DW_NAINT_T__) act__; \
	{ OPS; } \
	new__ = (ETHR_SU_DW_NAINT_T__) AVAL; \
	act__ = CMPXCHG(VAR, new__, exp__); \
    } while (__builtin_expect(act__ != exp__, 0)); \
} while (0)


#else
#  error "?!?"
#endif



/* --- addr() --- */

static ETHR_INLINE ethr_sint_t *ETHR_DW_ATMC_FUNC__(addr)(ethr_dw_atomic_t *var)
{
#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

    return (ethr_sint_t *) ETHR_DW_NATMC_ADDR_FUNC__((&var->native));

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { return ETHR_DW_ATOMIC_FUNC__(addr)(var); }
#endif

}


/* --- cmpxchg() --- */


static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
    int res;

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->sint, old_val->sint);
#else
#error "Missing implementation of ethr_dw_atomic_cmpxchg()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { res = ETHR_DW_ATOMIC_FUNC__(cmpxchg)(var, val, old_val); }
#endif

    return res;
}

static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
    int res;

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_dw_atomic_cmpxchg_rb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { res = ETHR_DW_ATOMIC_FUNC__(cmpxchg_rb)(var, val, old_val); }
#endif

    return res;
}

static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
    int res;

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_StoreStore);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_StoreStore);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_StoreStore);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_StoreStore);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->sint, old_val->sint);
#else
#error "Missing implementation of ethr_dw_atomic_cmpxchg_wb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { res = ETHR_DW_ATOMIC_FUNC__(cmpxchg_wb)(var, val, old_val); }
#endif

    return res;
}

static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
    int res;

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_dw_atomic_cmpxchg_acqb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { res = ETHR_DW_ATOMIC_FUNC__(cmpxchg_acqb)(var, val, old_val); }
#endif

    return res;
}

static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
    int res;

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->sint, old_val->sint);
#else
#error "Missing implementation of ethr_dw_atomic_cmpxchg_relb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { res = ETHR_DW_ATOMIC_FUNC__(cmpxchg_relb)(var, val, old_val); }
#endif

    return res;
}

static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
    int res;

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NAINT_T__ act;
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->dw_sint, old_val->dw_sint);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NAINT_T__ act;
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    act = ETHR_SU_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->dw_sint, old_val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    res = (act == old_val->dw_sint);
    old_val->dw_sint = act;
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_mb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_relb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_acqb)(&var->native, val->sint, old_val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_wb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg_rb)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = ETHR_DW_NATMC_FUNC__(cmpxchg)(&var->native, val->sint, old_val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_dw_atomic_cmpxchg_mb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { res = ETHR_DW_ATOMIC_FUNC__(cmpxchg_mb)(var, val, old_val); }
#endif

    return res;
}

static ETHR_INLINE int ETHR_DW_ATMC_FUNC__(cmpxchg_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val, ethr_dw_sint_t *old_val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_DW_ATMC_FUNC__(cmpxchg)(var, val, old_val);
#else
    return ETHR_DW_ATMC_FUNC__(cmpxchg_rb)(var, val, old_val);
#endif
}


/* --- set() --- */


static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_SET)
    ETHR_SU_DW_NATMC_FUNC__(set)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RB)
    ETHR_SU_DW_NATMC_FUNC__(set_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_WB)
    ETHR_SU_DW_NATMC_FUNC__(set_wb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_ACQB)
    ETHR_SU_DW_NATMC_FUNC__(set_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RELB)
    ETHR_SU_DW_NATMC_FUNC__(set_relb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_MB)
    ETHR_SU_DW_NATMC_FUNC__(set_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET)
    ETHR_DW_NATMC_FUNC__(set)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RB)
    ETHR_DW_NATMC_FUNC__(set_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_WB)
    ETHR_DW_NATMC_FUNC__(set_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_ACQB)
    ETHR_DW_NATMC_FUNC__(set_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RELB)
    ETHR_DW_NATMC_FUNC__(set_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_MB)
    ETHR_DW_NATMC_FUNC__(set_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#else
#error "Missing implementation of ethr_dw_atomic_set()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(set)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_SET_RB)
    ETHR_SU_DW_NATMC_FUNC__(set_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET)
    ETHR_SU_DW_NATMC_FUNC__(set)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_MB)
    ETHR_SU_DW_NATMC_FUNC__(set_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_WB)
    ETHR_SU_DW_NATMC_FUNC__(set_wb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_ACQB)
    ETHR_SU_DW_NATMC_FUNC__(set_acqb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RELB)
    ETHR_SU_DW_NATMC_FUNC__(set_relb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RB)
    ETHR_DW_NATMC_FUNC__(set_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET)
    ETHR_DW_NATMC_FUNC__(set)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_SET_MB)
    ETHR_DW_NATMC_FUNC__(set_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_WB)
    ETHR_DW_NATMC_FUNC__(set_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_SET_ACQB)
    ETHR_DW_NATMC_FUNC__(set_acqb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RELB)
    ETHR_DW_NATMC_FUNC__(set_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_dw_atomic_set_rb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(set_rb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_SET_WB)
    ETHR_SU_DW_NATMC_FUNC__(set_wb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_MB)
    ETHR_SU_DW_NATMC_FUNC__(set_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_relb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_WB)
    ETHR_DW_NATMC_FUNC__(set_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_MB)
    ETHR_DW_NATMC_FUNC__(set_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#else
#error "Missing implementation of ethr_dw_atomic_set_wb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(set_wb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_SET_ACQB)
    ETHR_SU_DW_NATMC_FUNC__(set_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RB)
    ETHR_SU_DW_NATMC_FUNC__(set_rb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET)
    ETHR_SU_DW_NATMC_FUNC__(set)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_MB)
    ETHR_SU_DW_NATMC_FUNC__(set_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_WB)
    ETHR_SU_DW_NATMC_FUNC__(set_wb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RELB)
    ETHR_SU_DW_NATMC_FUNC__(set_relb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET_ACQB)
    ETHR_DW_NATMC_FUNC__(set_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RB)
    ETHR_DW_NATMC_FUNC__(set_rb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET)
    ETHR_DW_NATMC_FUNC__(set)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET_MB)
    ETHR_DW_NATMC_FUNC__(set_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_WB)
    ETHR_DW_NATMC_FUNC__(set_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RELB)
    ETHR_DW_NATMC_FUNC__(set_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_dw_atomic_set_acqb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(set_acqb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_SET_RELB)
    ETHR_SU_DW_NATMC_FUNC__(set_relb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_SU_DW_NATMC_FUNC__(set_wb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_MB)
    ETHR_SU_DW_NATMC_FUNC__(set_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RELB)
    ETHR_DW_NATMC_FUNC__(set_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_DW_NATMC_FUNC__(set_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_MB)
    ETHR_DW_NATMC_FUNC__(set_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#else
#error "Missing implementation of ethr_dw_atomic_set_relb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(set_relb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_SET_MB)
    ETHR_SU_DW_NATMC_FUNC__(set_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RELB)
    ETHR_SU_DW_NATMC_FUNC__(set_relb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_SU_DW_NATMC_FUNC__(set_wb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set_rb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(set)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET_MB)
    ETHR_DW_NATMC_FUNC__(set_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RELB)
    ETHR_DW_NATMC_FUNC__(set_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_DW_NATMC_FUNC__(set_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set_rb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(set)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_MB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RELB)
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval = val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_SU_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval = val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_MB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_mb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RELB)
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_relb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_acqb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_wb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg_rb), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_CMPXCHG_FALLBACK__(ETHR_DW_NATMC_FUNC__(cmpxchg), &var->native, aval, aval.sint[0] = val->sint[0]; aval.sint[1] = val->sint[1]);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_dw_atomic_set_mb()!"
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(set_mb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(set_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_DW_ATMC_FUNC__(set)(var, val);
#else
    ETHR_DW_ATMC_FUNC__(set_rb)(var, val);
#endif
}


/* --- read() --- */


static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_READ)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(&var->native);
#elif defined(ETHR_HAVE_DW_NATMC_READ)
    ETHR_DW_NATMC_FUNC__(read)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
    ETHR_DW_NATMC_FUNC__(read_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
    ETHR_DW_NATMC_FUNC__(read_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
    ETHR_DW_NATMC_FUNC__(read_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
    ETHR_DW_NATMC_FUNC__(read_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
    ETHR_DW_NATMC_FUNC__(read_mb)(&var->native, val->sint);
#else
    ethr_dw_sint_t tmp;
    tmp.sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    tmp.sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    (void) ETHR_DW_ATMC_FUNC__(cmpxchg)(var, &tmp, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(read)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
    ETHR_DW_NATMC_FUNC__(read_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ)
    ETHR_DW_NATMC_FUNC__(read)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
    ETHR_DW_NATMC_FUNC__(read_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
    ETHR_DW_NATMC_FUNC__(read_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
    ETHR_DW_NATMC_FUNC__(read_acqb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
    ETHR_DW_NATMC_FUNC__(read_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    ethr_dw_sint_t tmp;
    tmp.sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    tmp.sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    (void) ETHR_DW_ATMC_FUNC__(cmpxchg_rb)(var, &tmp, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(read_rb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ)
    ETHR_MEMBAR(ETHR_StoreStore);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(&var->native);
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
    ETHR_DW_NATMC_FUNC__(read_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(read)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
    ETHR_DW_NATMC_FUNC__(read_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(read_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(read_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(read_relb)(&var->native, val->sint);
#else
    ethr_dw_sint_t tmp;
    tmp.sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    tmp.sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    (void) ETHR_DW_ATMC_FUNC__(cmpxchg_wb)(var, &tmp, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(read_wb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
    ETHR_DW_NATMC_FUNC__(read_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
    ETHR_DW_NATMC_FUNC__(read_rb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ)
    ETHR_DW_NATMC_FUNC__(read)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
    ETHR_DW_NATMC_FUNC__(read_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
    ETHR_DW_NATMC_FUNC__(read_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
    ETHR_DW_NATMC_FUNC__(read_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#else
    ethr_dw_sint_t tmp;
    tmp.sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    tmp.sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    (void) ETHR_DW_ATMC_FUNC__(cmpxchg_acqb)(var, &tmp, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(read_acqb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(&var->native);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
    ETHR_DW_NATMC_FUNC__(read_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
    ETHR_DW_NATMC_FUNC__(read_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read_acqb)(&var->native, val->sint);
#else
    ethr_dw_sint_t tmp;
    tmp.sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    tmp.sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    (void) ETHR_DW_ATMC_FUNC__(cmpxchg_relb)(var, &tmp, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(read_relb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_READ_MB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_mb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RELB)
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_relb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_acqb)(&var->native);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_wb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read_rb)(&var->native);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    val->dw_sint = ETHR_SU_DW_NATMC_FUNC__(read)(&var->native);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ_MB)
    ETHR_DW_NATMC_FUNC__(read_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RELB)
    ETHR_DW_NATMC_FUNC__(read_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read_rb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_DW_NATMC_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(read)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#else
    ethr_dw_sint_t tmp;
    tmp.sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    tmp.sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[0] = ETHR_UNUSUAL_SINT_VAL__;
    val->sint[1] = ETHR_UNUSUAL_SINT_VAL__;
    (void) ETHR_DW_ATMC_FUNC__(cmpxchg_mb)(var, &tmp, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(read_mb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(read_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_DW_ATMC_FUNC__(read)(var, val);
#else
    ETHR_DW_ATMC_FUNC__(read_rb)(var, val);
#endif
}


/* --- init() --- */


static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_INIT)
    ETHR_SU_DW_NATMC_FUNC__(init)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RB)
    ETHR_SU_DW_NATMC_FUNC__(init_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_WB)
    ETHR_SU_DW_NATMC_FUNC__(init_wb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_ACQB)
    ETHR_SU_DW_NATMC_FUNC__(init_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RELB)
    ETHR_SU_DW_NATMC_FUNC__(init_relb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_MB)
    ETHR_SU_DW_NATMC_FUNC__(init_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT)
    ETHR_DW_NATMC_FUNC__(init)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RB)
    ETHR_DW_NATMC_FUNC__(init_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_WB)
    ETHR_DW_NATMC_FUNC__(init_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_ACQB)
    ETHR_DW_NATMC_FUNC__(init_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RELB)
    ETHR_DW_NATMC_FUNC__(init_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_MB)
    ETHR_DW_NATMC_FUNC__(init_mb)(&var->native, val->sint);
#else
    ETHR_DW_ATMC_FUNC__(set)(var, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(init)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init_rb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_INIT_RB)
    ETHR_SU_DW_NATMC_FUNC__(init_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT)
    ETHR_SU_DW_NATMC_FUNC__(init)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_MB)
    ETHR_SU_DW_NATMC_FUNC__(init_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_WB)
    ETHR_SU_DW_NATMC_FUNC__(init_wb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_ACQB)
    ETHR_SU_DW_NATMC_FUNC__(init_acqb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RELB)
    ETHR_SU_DW_NATMC_FUNC__(init_relb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RB)
    ETHR_DW_NATMC_FUNC__(init_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT)
    ETHR_DW_NATMC_FUNC__(init)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_MB)
    ETHR_DW_NATMC_FUNC__(init_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_WB)
    ETHR_DW_NATMC_FUNC__(init_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_ACQB)
    ETHR_DW_NATMC_FUNC__(init_acqb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RELB)
    ETHR_DW_NATMC_FUNC__(init_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    ETHR_DW_ATMC_FUNC__(set_rb)(var, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(init_rb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init_wb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_INIT_WB)
    ETHR_SU_DW_NATMC_FUNC__(init_wb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_MB)
    ETHR_SU_DW_NATMC_FUNC__(init_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_relb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_WB)
    ETHR_DW_NATMC_FUNC__(init_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_MB)
    ETHR_DW_NATMC_FUNC__(init_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_relb)(&var->native, val->sint);
#else
    ETHR_DW_ATMC_FUNC__(set_wb)(var, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(init_wb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init_acqb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_INIT_ACQB)
    ETHR_SU_DW_NATMC_FUNC__(init_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RB)
    ETHR_SU_DW_NATMC_FUNC__(init_rb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT)
    ETHR_SU_DW_NATMC_FUNC__(init)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_MB)
    ETHR_SU_DW_NATMC_FUNC__(init_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_WB)
    ETHR_SU_DW_NATMC_FUNC__(init_wb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RELB)
    ETHR_SU_DW_NATMC_FUNC__(init_relb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_ACQB)
    ETHR_DW_NATMC_FUNC__(init_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RB)
    ETHR_DW_NATMC_FUNC__(init_rb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT)
    ETHR_DW_NATMC_FUNC__(init)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_MB)
    ETHR_DW_NATMC_FUNC__(init_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_WB)
    ETHR_DW_NATMC_FUNC__(init_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RELB)
    ETHR_DW_NATMC_FUNC__(init_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    ETHR_DW_ATMC_FUNC__(set_acqb)(var, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(init_acqb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init_relb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_INIT_RELB)
    ETHR_SU_DW_NATMC_FUNC__(init_relb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_FUNC__(init_wb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_MB)
    ETHR_SU_DW_NATMC_FUNC__(init_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_rb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RELB)
    ETHR_DW_NATMC_FUNC__(init_relb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(init_wb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_MB)
    ETHR_DW_NATMC_FUNC__(init_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_rb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_acqb)(&var->native, val->sint);
#else
    ETHR_DW_ATMC_FUNC__(set_relb)(var, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(init_relb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init_mb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    if (ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__) {
#endif

#if defined(ETHR_HAVE_SU_DW_NATMC_INIT_MB)
    ETHR_SU_DW_NATMC_FUNC__(init_mb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RELB)
    ETHR_SU_DW_NATMC_FUNC__(init_relb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_acqb)(&var->native, val->dw_sint);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_SU_DW_NATMC_FUNC__(init_wb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init_rb)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_SU_DW_NATMC_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_SU_DW_NATMC_FUNC__(init)(&var->native, val->dw_sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_MB)
    ETHR_DW_NATMC_FUNC__(init_mb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RELB)
    ETHR_DW_NATMC_FUNC__(init_relb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_acqb)(&var->native, val->sint);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_DW_NATMC_FUNC__(init_wb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init_rb)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_DW_NATMC_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_DW_NATMC_FUNC__(init)(&var->native, val->sint);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    ETHR_DW_ATMC_FUNC__(set_mb)(var, val);
#endif

#if defined(ETHR_RTCHK_USE_NATIVE_DW_ATOMIC_IMPL__)
    } else { ETHR_DW_ATOMIC_FUNC__(init_mb)(var, val); }
#endif

}

static ETHR_INLINE void ETHR_DW_ATMC_FUNC__(init_ddrb)(ethr_dw_atomic_t *var, ethr_dw_sint_t *val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_DW_ATMC_FUNC__(init)(var, val);
#else
    ETHR_DW_ATMC_FUNC__(init_rb)(var, val);
#endif
}

#endif /* ETHR_DW_ATMC_INLINE__ */


/* ---------- Word size atomic implementation ---------- */


#ifdef ETHR_NEED_ATMC_PROTOTYPES__
ethr_sint_t *ethr_atomic_addr(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_cmpxchg(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_cmpxchg_ddrb(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_cmpxchg_rb(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_cmpxchg_wb(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_cmpxchg_acqb(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_cmpxchg_relb(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_cmpxchg_mb(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val);
ethr_sint_t ethr_atomic_xchg(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_xchg_ddrb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_xchg_rb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_xchg_wb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_xchg_acqb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_xchg_relb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_xchg_mb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set_ddrb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set_rb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set_wb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set_acqb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set_relb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_set_mb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init_ddrb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init_rb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init_wb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init_acqb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init_relb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_init_mb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read_ddrb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read_rb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read_wb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read_acqb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read_relb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_add_read_mb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_ddrb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_rb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_wb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_acqb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_relb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_mb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read_ddrb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read_rb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read_wb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read_acqb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read_relb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_inc_read_mb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read_ddrb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read_rb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read_wb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read_acqb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read_relb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_dec_read_mb(ethr_atomic_t *var);
void ethr_atomic_add(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_add_ddrb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_add_rb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_add_wb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_add_acqb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_add_relb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_add_mb(ethr_atomic_t *var, ethr_sint_t val);
void ethr_atomic_inc(ethr_atomic_t *var);
void ethr_atomic_inc_ddrb(ethr_atomic_t *var);
void ethr_atomic_inc_rb(ethr_atomic_t *var);
void ethr_atomic_inc_wb(ethr_atomic_t *var);
void ethr_atomic_inc_acqb(ethr_atomic_t *var);
void ethr_atomic_inc_relb(ethr_atomic_t *var);
void ethr_atomic_inc_mb(ethr_atomic_t *var);
void ethr_atomic_dec(ethr_atomic_t *var);
void ethr_atomic_dec_ddrb(ethr_atomic_t *var);
void ethr_atomic_dec_rb(ethr_atomic_t *var);
void ethr_atomic_dec_wb(ethr_atomic_t *var);
void ethr_atomic_dec_acqb(ethr_atomic_t *var);
void ethr_atomic_dec_relb(ethr_atomic_t *var);
void ethr_atomic_dec_mb(ethr_atomic_t *var);
ethr_sint_t ethr_atomic_read_band(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_band_ddrb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_band_rb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_band_wb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_band_acqb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_band_relb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_band_mb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor_ddrb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor_rb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor_wb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor_acqb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor_relb(ethr_atomic_t *var, ethr_sint_t val);
ethr_sint_t ethr_atomic_read_bor_mb(ethr_atomic_t *var, ethr_sint_t val);
#endif /* ETHR_NEED_ATMC_PROTOTYPES__ */

#if (defined(ETHR_HAVE_WORD_SZ_NATIVE_ATOMIC_OPS) \
     && (defined(ETHR_ATMC_INLINE__) || defined(ETHR_ATOMIC_IMPL__)))

#if !defined(ETHR_NATMC_BITS__)
#  error "Missing native atomic implementation"
#elif ETHR_NATMC_BITS__ == 64
#  undef ETHR_HAVE_NATMC_CMPXCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG
#    define ETHR_HAVE_NATMC_CMPXCHG 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_RB
#    define ETHR_HAVE_NATMC_CMPXCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_WB
#    define ETHR_HAVE_NATMC_CMPXCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_ACQB
#    define ETHR_HAVE_NATMC_CMPXCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_RELB
#    define ETHR_HAVE_NATMC_CMPXCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_MB
#    define ETHR_HAVE_NATMC_CMPXCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG
#    define ETHR_HAVE_NATMC_XCHG 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_RB
#    define ETHR_HAVE_NATMC_XCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_WB
#    define ETHR_HAVE_NATMC_XCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_ACQB
#    define ETHR_HAVE_NATMC_XCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_RELB
#    define ETHR_HAVE_NATMC_XCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_MB
#    define ETHR_HAVE_NATMC_XCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET
#    define ETHR_HAVE_NATMC_SET 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_RB
#    define ETHR_HAVE_NATMC_SET_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_WB
#    define ETHR_HAVE_NATMC_SET_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_ACQB
#    define ETHR_HAVE_NATMC_SET_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_RELB
#    define ETHR_HAVE_NATMC_SET_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_MB
#    define ETHR_HAVE_NATMC_SET_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT
#    define ETHR_HAVE_NATMC_INIT 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_RB
#    define ETHR_HAVE_NATMC_INIT_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_WB
#    define ETHR_HAVE_NATMC_INIT_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_ACQB
#    define ETHR_HAVE_NATMC_INIT_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_RELB
#    define ETHR_HAVE_NATMC_INIT_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_MB
#    define ETHR_HAVE_NATMC_INIT_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN
#    define ETHR_HAVE_NATMC_ADD_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_RB
#    define ETHR_HAVE_NATMC_ADD_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_WB
#    define ETHR_HAVE_NATMC_ADD_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_ACQB
#    define ETHR_HAVE_NATMC_ADD_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_RELB
#    define ETHR_HAVE_NATMC_ADD_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_MB
#    define ETHR_HAVE_NATMC_ADD_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ
#    define ETHR_HAVE_NATMC_READ 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_RB
#    define ETHR_HAVE_NATMC_READ_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_WB
#    define ETHR_HAVE_NATMC_READ_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_ACQB
#    define ETHR_HAVE_NATMC_READ_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_RELB
#    define ETHR_HAVE_NATMC_READ_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_MB
#    define ETHR_HAVE_NATMC_READ_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN
#    define ETHR_HAVE_NATMC_INC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_RB
#    define ETHR_HAVE_NATMC_INC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_WB
#    define ETHR_HAVE_NATMC_INC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_ACQB
#    define ETHR_HAVE_NATMC_INC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_RELB
#    define ETHR_HAVE_NATMC_INC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_MB
#    define ETHR_HAVE_NATMC_INC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN
#    define ETHR_HAVE_NATMC_DEC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_RB
#    define ETHR_HAVE_NATMC_DEC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_WB
#    define ETHR_HAVE_NATMC_DEC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_ACQB
#    define ETHR_HAVE_NATMC_DEC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_RELB
#    define ETHR_HAVE_NATMC_DEC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_MB
#    define ETHR_HAVE_NATMC_DEC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD
#    define ETHR_HAVE_NATMC_ADD 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RB
#    define ETHR_HAVE_NATMC_ADD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_WB
#    define ETHR_HAVE_NATMC_ADD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_ACQB
#    define ETHR_HAVE_NATMC_ADD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RELB
#    define ETHR_HAVE_NATMC_ADD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_MB
#    define ETHR_HAVE_NATMC_ADD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC
#    define ETHR_HAVE_NATMC_INC 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RB
#    define ETHR_HAVE_NATMC_INC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_WB
#    define ETHR_HAVE_NATMC_INC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_ACQB
#    define ETHR_HAVE_NATMC_INC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RELB
#    define ETHR_HAVE_NATMC_INC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_MB
#    define ETHR_HAVE_NATMC_INC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC
#    define ETHR_HAVE_NATMC_DEC 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RB
#    define ETHR_HAVE_NATMC_DEC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_WB
#    define ETHR_HAVE_NATMC_DEC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_ACQB
#    define ETHR_HAVE_NATMC_DEC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RELB
#    define ETHR_HAVE_NATMC_DEC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_MB
#    define ETHR_HAVE_NATMC_DEC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD
#    define ETHR_HAVE_NATMC_AND_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_RB
#    define ETHR_HAVE_NATMC_AND_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_WB
#    define ETHR_HAVE_NATMC_AND_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_ACQB
#    define ETHR_HAVE_NATMC_AND_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_RELB
#    define ETHR_HAVE_NATMC_AND_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_MB
#    define ETHR_HAVE_NATMC_AND_RETOLD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD
#    define ETHR_HAVE_NATMC_OR_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_RB
#    define ETHR_HAVE_NATMC_OR_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_WB
#    define ETHR_HAVE_NATMC_OR_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_ACQB
#    define ETHR_HAVE_NATMC_OR_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_RELB
#    define ETHR_HAVE_NATMC_OR_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_MB
#    define ETHR_HAVE_NATMC_OR_RETOLD_MB 1
#  endif
#elif ETHR_NATMC_BITS__ == 32
#  undef ETHR_HAVE_NATMC_CMPXCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG
#    define ETHR_HAVE_NATMC_CMPXCHG 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_RB
#    define ETHR_HAVE_NATMC_CMPXCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_WB
#    define ETHR_HAVE_NATMC_CMPXCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_ACQB
#    define ETHR_HAVE_NATMC_CMPXCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_RELB
#    define ETHR_HAVE_NATMC_CMPXCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_CMPXCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_MB
#    define ETHR_HAVE_NATMC_CMPXCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG
#    define ETHR_HAVE_NATMC_XCHG 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_RB
#    define ETHR_HAVE_NATMC_XCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_WB
#    define ETHR_HAVE_NATMC_XCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_ACQB
#    define ETHR_HAVE_NATMC_XCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_RELB
#    define ETHR_HAVE_NATMC_XCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_XCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_MB
#    define ETHR_HAVE_NATMC_XCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET
#    define ETHR_HAVE_NATMC_SET 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_RB
#    define ETHR_HAVE_NATMC_SET_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_WB
#    define ETHR_HAVE_NATMC_SET_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_ACQB
#    define ETHR_HAVE_NATMC_SET_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_RELB
#    define ETHR_HAVE_NATMC_SET_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_SET_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_MB
#    define ETHR_HAVE_NATMC_SET_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT
#    define ETHR_HAVE_NATMC_INIT 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_RB
#    define ETHR_HAVE_NATMC_INIT_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_WB
#    define ETHR_HAVE_NATMC_INIT_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_ACQB
#    define ETHR_HAVE_NATMC_INIT_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_RELB
#    define ETHR_HAVE_NATMC_INIT_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_INIT_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_MB
#    define ETHR_HAVE_NATMC_INIT_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN
#    define ETHR_HAVE_NATMC_ADD_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_RB
#    define ETHR_HAVE_NATMC_ADD_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_WB
#    define ETHR_HAVE_NATMC_ADD_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_ACQB
#    define ETHR_HAVE_NATMC_ADD_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_RELB
#    define ETHR_HAVE_NATMC_ADD_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_MB
#    define ETHR_HAVE_NATMC_ADD_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ
#    define ETHR_HAVE_NATMC_READ 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_RB
#    define ETHR_HAVE_NATMC_READ_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_WB
#    define ETHR_HAVE_NATMC_READ_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_ACQB
#    define ETHR_HAVE_NATMC_READ_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_RELB
#    define ETHR_HAVE_NATMC_READ_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_READ_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_MB
#    define ETHR_HAVE_NATMC_READ_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN
#    define ETHR_HAVE_NATMC_INC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_RB
#    define ETHR_HAVE_NATMC_INC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_WB
#    define ETHR_HAVE_NATMC_INC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_ACQB
#    define ETHR_HAVE_NATMC_INC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_RELB
#    define ETHR_HAVE_NATMC_INC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_MB
#    define ETHR_HAVE_NATMC_INC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN
#    define ETHR_HAVE_NATMC_DEC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_RB
#    define ETHR_HAVE_NATMC_DEC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_WB
#    define ETHR_HAVE_NATMC_DEC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_ACQB
#    define ETHR_HAVE_NATMC_DEC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_RELB
#    define ETHR_HAVE_NATMC_DEC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_MB
#    define ETHR_HAVE_NATMC_DEC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD
#    define ETHR_HAVE_NATMC_ADD 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RB
#    define ETHR_HAVE_NATMC_ADD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_WB
#    define ETHR_HAVE_NATMC_ADD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_ACQB
#    define ETHR_HAVE_NATMC_ADD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RELB
#    define ETHR_HAVE_NATMC_ADD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_ADD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_MB
#    define ETHR_HAVE_NATMC_ADD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC
#    define ETHR_HAVE_NATMC_INC 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RB
#    define ETHR_HAVE_NATMC_INC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_WB
#    define ETHR_HAVE_NATMC_INC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_ACQB
#    define ETHR_HAVE_NATMC_INC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RELB
#    define ETHR_HAVE_NATMC_INC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_INC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_MB
#    define ETHR_HAVE_NATMC_INC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC
#    define ETHR_HAVE_NATMC_DEC 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RB
#    define ETHR_HAVE_NATMC_DEC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_WB
#    define ETHR_HAVE_NATMC_DEC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_ACQB
#    define ETHR_HAVE_NATMC_DEC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RELB
#    define ETHR_HAVE_NATMC_DEC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_DEC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_MB
#    define ETHR_HAVE_NATMC_DEC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD
#    define ETHR_HAVE_NATMC_AND_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_RB
#    define ETHR_HAVE_NATMC_AND_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_WB
#    define ETHR_HAVE_NATMC_AND_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_ACQB
#    define ETHR_HAVE_NATMC_AND_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_RELB
#    define ETHR_HAVE_NATMC_AND_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_AND_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_MB
#    define ETHR_HAVE_NATMC_AND_RETOLD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD
#    define ETHR_HAVE_NATMC_OR_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_RB
#    define ETHR_HAVE_NATMC_OR_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_WB
#    define ETHR_HAVE_NATMC_OR_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_ACQB
#    define ETHR_HAVE_NATMC_OR_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_RELB
#    define ETHR_HAVE_NATMC_OR_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC_OR_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_MB
#    define ETHR_HAVE_NATMC_OR_RETOLD_MB 1
#  endif
#else
#  error "Invalid native atomic size"
#endif

#if (!defined(ETHR_HAVE_NATMC_CMPXCHG) \
     && !defined(ETHR_HAVE_NATMC_CMPXCHG_RB) \
     && !defined(ETHR_HAVE_NATMC_CMPXCHG_WB) \
     && !defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB) \
     && !defined(ETHR_HAVE_NATMC_CMPXCHG_RELB) \
     && !defined(ETHR_HAVE_NATMC_CMPXCHG_MB))
#  error "No native cmpxchg() op available"
#endif


/*
 * Read op used together with cmpxchg() fallback when no native op present.
 */
#if defined(ETHR_HAVE_NATMC_READ)
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC_FUNC__(read)(VAR)
#elif defined(ETHR_HAVE_NATMC_READ_RB)
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC_FUNC__(read_rb)(VAR)
#elif defined(ETHR_HAVE_NATMC_READ_WB)
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC_FUNC__(read_wb)(VAR)
#elif defined(ETHR_HAVE_NATMC_READ_ACQB)
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC_FUNC__(read_acqb)(VAR)
#elif defined(ETHR_HAVE_NATMC_READ_RELB)
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC_FUNC__(read_relb)(VAR)
#elif defined(ETHR_HAVE_NATMC_READ_MB)
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC_FUNC__(read_mb)(VAR)
#else
/*
 * We have no native read() op; guess zero and then use the
 * the atomics actual value returned from cmpxchg().
 */
#define ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR) \
  ((ETHR_NAINT_T__) 0)
#endif

/*
 * Native cmpxchg() fallback used when no native op present.
 */
#define ETHR_NATMC_CMPXCHG_FALLBACK__(CMPXCHG, VAR, AVAL, OPS) \
do { \
    ethr_sint_t AVAL; \
    ETHR_NAINT_T__ new__, act__, exp__; \
    act__ = ETHR_NATMC_CMPXCHG_FALLBACK_READ__(VAR); \
    do { \
	exp__ = act__; \
	AVAL = (ethr_sint_t) act__; \
	{ OPS; } \
	new__ = (ETHR_NAINT_T__) AVAL; \
	act__ = CMPXCHG(VAR, new__, exp__); \
    } while (__builtin_expect(act__ != exp__, 0)); \
} while (0)



/* --- addr() --- */

static ETHR_INLINE ethr_sint_t *ETHR_ATMC_FUNC__(addr)(ethr_atomic_t *var)
{
    return (ethr_sint_t *) ETHR_NATMC_ADDR_FUNC__(var);

}


/* --- cmpxchg() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_CMPXCHG)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#else
#error "Missing implementation of ethr_atomic_cmpxchg()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg_rb)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic_cmpxchg_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg_wb)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#else
#error "Missing implementation of ethr_atomic_cmpxchg_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg_acqb)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_cmpxchg_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg_relb)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#else
#error "Missing implementation of ethr_atomic_cmpxchg_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg_mb)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(cmpxchg)(var, (ETHR_NAINT_T__) val, (ETHR_NAINT_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_cmpxchg_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(cmpxchg_ddrb)(ethr_atomic_t *var, ethr_sint_t val, ethr_sint_t old_val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(cmpxchg)(var, val, old_val);
#else
    return ETHR_ATMC_FUNC__(cmpxchg_rb)(var, val, old_val);
#endif
}


/* --- xchg() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_XCHG)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#else
#error "Missing implementation of ethr_atomic_xchg()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_XCHG_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_XCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_XCHG_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_XCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic_xchg_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_XCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
#else
#error "Missing implementation of ethr_atomic_xchg_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_XCHG_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_XCHG)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_XCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_XCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_xchg_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_XCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#else
#error "Missing implementation of ethr_atomic_xchg_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_XCHG_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_XCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_XCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_XCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_XCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(xchg)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_xchg_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(xchg_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(xchg)(var, val);
#else
    return ETHR_ATMC_FUNC__(xchg_rb)(var, val);
#endif
}


/* --- set() --- */


static ETHR_INLINE void ETHR_ATMC_FUNC__(set)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_SET)
    ETHR_NATMC_FUNC__(set)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RB)
    ETHR_NATMC_FUNC__(set_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_WB)
    ETHR_NATMC_FUNC__(set_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_ACQB)
    ETHR_NATMC_FUNC__(set_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RELB)
    ETHR_NATMC_FUNC__(set_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_MB)
    ETHR_NATMC_FUNC__(set_mb)(var, (ETHR_NAINT_T__) val);
#else
    (void) ETHR_ATMC_FUNC__(xchg)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(set_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_SET_RB)
    ETHR_NATMC_FUNC__(set_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET)
    ETHR_NATMC_FUNC__(set)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_SET_MB)
    ETHR_NATMC_FUNC__(set_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_WB)
    ETHR_NATMC_FUNC__(set_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_SET_ACQB)
    ETHR_NATMC_FUNC__(set_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_SET_RELB)
    ETHR_NATMC_FUNC__(set_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC_FUNC__(xchg_rb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(set_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_SET_WB)
    ETHR_NATMC_FUNC__(set_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_MB)
    ETHR_NATMC_FUNC__(set_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_relb)(var, (ETHR_NAINT_T__) val);
#else
    (void) ETHR_ATMC_FUNC__(xchg_wb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(set_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_SET_ACQB)
    ETHR_NATMC_FUNC__(set_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RB)
    ETHR_NATMC_FUNC__(set_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_SET)
    ETHR_NATMC_FUNC__(set)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_SET_MB)
    ETHR_NATMC_FUNC__(set_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_WB)
    ETHR_NATMC_FUNC__(set_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_SET_RELB)
    ETHR_NATMC_FUNC__(set_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(xchg_acqb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(set_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_SET_RELB)
    ETHR_NATMC_FUNC__(set_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_NATMC_FUNC__(set_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_MB)
    ETHR_NATMC_FUNC__(set_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_acqb)(var, (ETHR_NAINT_T__) val);
#else
    (void) ETHR_ATMC_FUNC__(xchg_relb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(set_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_SET_MB)
    ETHR_NATMC_FUNC__(set_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_RELB)
    ETHR_NATMC_FUNC__(set_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_NATMC_FUNC__(set_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(set)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(xchg_mb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(set_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC_FUNC__(set)(var, val);
#else
    ETHR_ATMC_FUNC__(set_rb)(var, val);
#endif
}


/* --- init() --- */


static ETHR_INLINE void ETHR_ATMC_FUNC__(init)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_INIT)
    ETHR_NATMC_FUNC__(init)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RB)
    ETHR_NATMC_FUNC__(init_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_WB)
    ETHR_NATMC_FUNC__(init_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_ACQB)
    ETHR_NATMC_FUNC__(init_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RELB)
    ETHR_NATMC_FUNC__(init_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_MB)
    ETHR_NATMC_FUNC__(init_mb)(var, (ETHR_NAINT_T__) val);
#else
    ETHR_ATMC_FUNC__(set)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(init_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_INIT_RB)
    ETHR_NATMC_FUNC__(init_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT)
    ETHR_NATMC_FUNC__(init)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INIT_MB)
    ETHR_NATMC_FUNC__(init_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_WB)
    ETHR_NATMC_FUNC__(init_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INIT_ACQB)
    ETHR_NATMC_FUNC__(init_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INIT_RELB)
    ETHR_NATMC_FUNC__(init_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    ETHR_ATMC_FUNC__(set_rb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(init_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_INIT_WB)
    ETHR_NATMC_FUNC__(init_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_MB)
    ETHR_NATMC_FUNC__(init_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_relb)(var, (ETHR_NAINT_T__) val);
#else
    ETHR_ATMC_FUNC__(set_wb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(init_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_INIT_ACQB)
    ETHR_NATMC_FUNC__(init_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RB)
    ETHR_NATMC_FUNC__(init_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INIT)
    ETHR_NATMC_FUNC__(init)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INIT_MB)
    ETHR_NATMC_FUNC__(init_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_WB)
    ETHR_NATMC_FUNC__(init_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INIT_RELB)
    ETHR_NATMC_FUNC__(init_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    ETHR_ATMC_FUNC__(set_acqb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(init_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_INIT_RELB)
    ETHR_NATMC_FUNC__(init_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(init_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_MB)
    ETHR_NATMC_FUNC__(init_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_acqb)(var, (ETHR_NAINT_T__) val);
#else
    ETHR_ATMC_FUNC__(set_relb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(init_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_INIT_MB)
    ETHR_NATMC_FUNC__(init_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_RELB)
    ETHR_NATMC_FUNC__(init_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(init_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC_FUNC__(init)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    ETHR_ATMC_FUNC__(set_mb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(init_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC_FUNC__(init)(var, val);
#else
    ETHR_ATMC_FUNC__(init_rb)(var, val);
#endif
}


/* --- add_read() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_ADD_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#else
#error "Missing implementation of ethr_atomic_add_read()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_ADD_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic_add_read_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_ADD_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
#else
#error "Missing implementation of ethr_atomic_add_read_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_ADD_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_add_read_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_ADD_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#else
#error "Missing implementation of ethr_atomic_add_read_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_ADD_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(add_return)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_add_read_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(add_read_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(add_read)(var, val);
#else
    return ETHR_ATMC_FUNC__(add_read_rb)(var, val);
#endif
}


/* --- read() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_READ)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_wb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_relb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_mb)(var);
#else
    res = ETHR_ATMC_FUNC__(cmpxchg)(var, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_rb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_READ_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC_READ)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_READ_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_READ_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_READ_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    res = ETHR_ATMC_FUNC__(cmpxchg_rb)(var, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_wb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_READ_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_wb)(var);
#elif defined(ETHR_HAVE_NATMC_READ)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read)(var);
#elif defined(ETHR_HAVE_NATMC_READ_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_relb)(var);
#else
    res = ETHR_ATMC_FUNC__(cmpxchg_wb)(var, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_acqb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_READ_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC_READ)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC_READ_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC_READ_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#else
    res = ETHR_ATMC_FUNC__(cmpxchg_acqb)(var, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_relb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_READ_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_relb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_wb)(var);
#elif defined(ETHR_HAVE_NATMC_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read)(var);
#elif defined(ETHR_HAVE_NATMC_READ_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_acqb)(var);
#else
    res = ETHR_ATMC_FUNC__(cmpxchg_relb)(var, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_mb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_READ_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(read)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#else
    res = ETHR_ATMC_FUNC__(cmpxchg_mb)(var, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__, (ethr_sint_t) ETHR_UNUSUAL_SINT_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_ddrb)(ethr_atomic_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(read)(var);
#else
    return ETHR_ATMC_FUNC__(read_rb)(var);
#endif
}


/* --- inc_read() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_INC_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_mb)(var);
#else
    res = ETHR_ATMC_FUNC__(add_read)(var, (ethr_sint_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read_rb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_INC_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    res = ETHR_ATMC_FUNC__(add_read_rb)(var, (ethr_sint_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read_wb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_INC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_relb)(var);
#else
    res = ETHR_ATMC_FUNC__(add_read_wb)(var, (ethr_sint_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read_acqb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_INC_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC_FUNC__(add_read_acqb)(var, (ethr_sint_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read_relb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_INC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_acqb)(var);
#else
    res = ETHR_ATMC_FUNC__(add_read_relb)(var, (ethr_sint_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read_mb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_INC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(inc_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC_FUNC__(add_read_mb)(var, (ethr_sint_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(inc_read_ddrb)(ethr_atomic_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(inc_read)(var);
#else
    return ETHR_ATMC_FUNC__(inc_read_rb)(var);
#endif
}


/* --- dec_read() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_DEC_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_mb)(var);
#else
    res = ETHR_ATMC_FUNC__(add_read)(var, (ethr_sint_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read_rb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_DEC_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    res = ETHR_ATMC_FUNC__(add_read_rb)(var, (ethr_sint_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read_wb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_DEC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_relb)(var);
#else
    res = ETHR_ATMC_FUNC__(add_read_wb)(var, (ethr_sint_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read_acqb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_DEC_RETURN_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC_FUNC__(add_read_acqb)(var, (ethr_sint_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read_relb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_DEC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_acqb)(var);
#else
    res = ETHR_ATMC_FUNC__(add_read_relb)(var, (ethr_sint_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read_mb)(ethr_atomic_t *var)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_DEC_RETURN_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(dec_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC_FUNC__(add_read_mb)(var, (ethr_sint_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(dec_read_ddrb)(ethr_atomic_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(dec_read)(var);
#else
    return ETHR_ATMC_FUNC__(dec_read_rb)(var);
#endif
}


/* --- add() --- */


static ETHR_INLINE void ETHR_ATMC_FUNC__(add)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_ADD)
    ETHR_NATMC_FUNC__(add)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RB)
    ETHR_NATMC_FUNC__(add_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_WB)
    ETHR_NATMC_FUNC__(add_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_ACQB)
    ETHR_NATMC_FUNC__(add_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RELB)
    ETHR_NATMC_FUNC__(add_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_MB)
    ETHR_NATMC_FUNC__(add_mb)(var, (ETHR_NAINT_T__) val);
#else
    (void) ETHR_ATMC_FUNC__(add_read)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(add_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_ADD_RB)
    ETHR_NATMC_FUNC__(add_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD)
    ETHR_NATMC_FUNC__(add)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_ADD_MB)
    ETHR_NATMC_FUNC__(add_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_WB)
    ETHR_NATMC_FUNC__(add_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_ADD_ACQB)
    ETHR_NATMC_FUNC__(add_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_ADD_RELB)
    ETHR_NATMC_FUNC__(add_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC_FUNC__(add_read_rb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(add_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_ADD_WB)
    ETHR_NATMC_FUNC__(add_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(add)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_MB)
    ETHR_NATMC_FUNC__(add_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(add_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(add_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(add_relb)(var, (ETHR_NAINT_T__) val);
#else
    (void) ETHR_ATMC_FUNC__(add_read_wb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(add_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_ADD_ACQB)
    ETHR_NATMC_FUNC__(add_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RB)
    ETHR_NATMC_FUNC__(add_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD)
    ETHR_NATMC_FUNC__(add)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_MB)
    ETHR_NATMC_FUNC__(add_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_WB)
    ETHR_NATMC_FUNC__(add_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RELB)
    ETHR_NATMC_FUNC__(add_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(add_read_acqb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(add_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_ADD_RELB)
    ETHR_NATMC_FUNC__(add_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_MB)
    ETHR_NATMC_FUNC__(add_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add_acqb)(var, (ETHR_NAINT_T__) val);
#else
    (void) ETHR_ATMC_FUNC__(add_read_relb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(add_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
#if defined(ETHR_HAVE_NATMC_ADD_MB)
    ETHR_NATMC_FUNC__(add_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_RELB)
    ETHR_NATMC_FUNC__(add_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_ADD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_ADD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(add)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(add_read_mb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(add_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC_FUNC__(add)(var, val);
#else
    ETHR_ATMC_FUNC__(add_rb)(var, val);
#endif
}


/* --- inc() --- */


static ETHR_INLINE void ETHR_ATMC_FUNC__(inc)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_INC)
    ETHR_NATMC_FUNC__(inc)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RB)
    ETHR_NATMC_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_WB)
    ETHR_NATMC_FUNC__(inc_wb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_ACQB)
    ETHR_NATMC_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RELB)
    ETHR_NATMC_FUNC__(inc_relb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_MB)
    ETHR_NATMC_FUNC__(inc_mb)(var);
#else
    (void) ETHR_ATMC_FUNC__(inc_read)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(inc_rb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_INC_RB)
    ETHR_NATMC_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC)
    ETHR_NATMC_FUNC__(inc)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INC_MB)
    ETHR_NATMC_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_WB)
    ETHR_NATMC_FUNC__(inc_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INC_ACQB)
    ETHR_NATMC_FUNC__(inc_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_INC_RELB)
    ETHR_NATMC_FUNC__(inc_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC_FUNC__(inc_read_rb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(inc_wb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_INC_WB)
    ETHR_NATMC_FUNC__(inc_wb)(var);
#elif defined(ETHR_HAVE_NATMC_INC)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(inc)(var);
#elif defined(ETHR_HAVE_NATMC_INC_MB)
    ETHR_NATMC_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(inc_relb)(var);
#else
    (void) ETHR_ATMC_FUNC__(inc_read_wb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(inc_acqb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_INC_ACQB)
    ETHR_NATMC_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RB)
    ETHR_NATMC_FUNC__(inc_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC)
    ETHR_NATMC_FUNC__(inc)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_MB)
    ETHR_NATMC_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_WB)
    ETHR_NATMC_FUNC__(inc_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RELB)
    ETHR_NATMC_FUNC__(inc_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(inc_read_acqb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(inc_relb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_INC_RELB)
    ETHR_NATMC_FUNC__(inc_relb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc_wb)(var);
#elif defined(ETHR_HAVE_NATMC_INC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc)(var);
#elif defined(ETHR_HAVE_NATMC_INC_MB)
    ETHR_NATMC_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc_acqb)(var);
#else
    (void) ETHR_ATMC_FUNC__(inc_read_relb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(inc_mb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_INC_MB)
    ETHR_NATMC_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_RELB)
    ETHR_NATMC_FUNC__(inc_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_INC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_INC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(inc)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(inc_read_mb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(inc_ddrb)(ethr_atomic_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC_FUNC__(inc)(var);
#else
    ETHR_ATMC_FUNC__(inc_rb)(var);
#endif
}


/* --- dec() --- */


static ETHR_INLINE void ETHR_ATMC_FUNC__(dec)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_DEC)
    ETHR_NATMC_FUNC__(dec)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RB)
    ETHR_NATMC_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_WB)
    ETHR_NATMC_FUNC__(dec_wb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_ACQB)
    ETHR_NATMC_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RELB)
    ETHR_NATMC_FUNC__(dec_relb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_MB)
    ETHR_NATMC_FUNC__(dec_mb)(var);
#else
    (void) ETHR_ATMC_FUNC__(dec_read)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(dec_rb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_DEC_RB)
    ETHR_NATMC_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC)
    ETHR_NATMC_FUNC__(dec)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_DEC_MB)
    ETHR_NATMC_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_WB)
    ETHR_NATMC_FUNC__(dec_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_DEC_ACQB)
    ETHR_NATMC_FUNC__(dec_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_DEC_RELB)
    ETHR_NATMC_FUNC__(dec_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC_FUNC__(dec_read_rb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(dec_wb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_DEC_WB)
    ETHR_NATMC_FUNC__(dec_wb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(dec)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_MB)
    ETHR_NATMC_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_FUNC__(dec_relb)(var);
#else
    (void) ETHR_ATMC_FUNC__(dec_read_wb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(dec_acqb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_DEC_ACQB)
    ETHR_NATMC_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RB)
    ETHR_NATMC_FUNC__(dec_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC)
    ETHR_NATMC_FUNC__(dec)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_MB)
    ETHR_NATMC_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_WB)
    ETHR_NATMC_FUNC__(dec_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RELB)
    ETHR_NATMC_FUNC__(dec_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(dec_read_acqb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(dec_relb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_DEC_RELB)
    ETHR_NATMC_FUNC__(dec_relb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec_wb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_MB)
    ETHR_NATMC_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec_acqb)(var);
#else
    (void) ETHR_ATMC_FUNC__(dec_read_relb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(dec_mb)(ethr_atomic_t *var)
{
#if defined(ETHR_HAVE_NATMC_DEC_MB)
    ETHR_NATMC_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_RELB)
    ETHR_NATMC_FUNC__(dec_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC_DEC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_DEC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_FUNC__(dec)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC_FUNC__(dec_read_mb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC_FUNC__(dec_ddrb)(ethr_atomic_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC_FUNC__(dec)(var);
#else
    ETHR_ATMC_FUNC__(dec_rb)(var);
#endif
}


/* --- read_band() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_AND_RETOLD)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#else
#error "Missing implementation of ethr_atomic_read_band()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_AND_RETOLD_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic_read_band_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_AND_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
#else
#error "Missing implementation of ethr_atomic_read_band_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_AND_RETOLD_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_read_band_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_AND_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#else
#error "Missing implementation of ethr_atomic_read_band_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_AND_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_AND_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(and_retold)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_read_band_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_band_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(read_band)(var, val);
#else
    return ETHR_ATMC_FUNC__(read_band_rb)(var, val);
#endif
}


/* --- read_bor() --- */


static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_OR_RETOLD)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#else
#error "Missing implementation of ethr_atomic_read_bor()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor_rb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_OR_RETOLD_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_acqb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic_read_bor_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor_wb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_OR_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
#else
#error "Missing implementation of ethr_atomic_read_bor_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor_acqb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_OR_RETOLD_ACQB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_WB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_read_bor_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor_relb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_OR_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_relb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_wb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_rb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#else
#error "Missing implementation of ethr_atomic_read_bor_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor_mb)(ethr_atomic_t *var, ethr_sint_t val)
{
    ethr_sint_t res;
#if defined(ETHR_HAVE_NATMC_OR_RETOLD_MB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_mb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RELB)
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_relb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_acqb)(var, (ETHR_NAINT_T__) val);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_wb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold_rb)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_OR_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint_t) ETHR_NATMC_FUNC__(or_retold)(var, (ETHR_NAINT_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_MB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RELB)
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC_CMPXCHG_FALLBACK__(ETHR_NATMC_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic_read_bor_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint_t ETHR_ATMC_FUNC__(read_bor_ddrb)(ethr_atomic_t *var, ethr_sint_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC_FUNC__(read_bor)(var, val);
#else
    return ETHR_ATMC_FUNC__(read_bor_rb)(var, val);
#endif
}

#endif /* ETHR_ATMC_INLINE__ */


/* ---------- 32-bit atomic implementation ---------- */


#ifdef ETHR_NEED_ATMC32_PROTOTYPES__
ethr_sint32_t *ethr_atomic32_addr(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_cmpxchg(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_cmpxchg_ddrb(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_cmpxchg_rb(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_cmpxchg_wb(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_cmpxchg_acqb(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_cmpxchg_relb(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_cmpxchg_mb(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val);
ethr_sint32_t ethr_atomic32_xchg(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_xchg_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_xchg_rb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_xchg_wb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_xchg_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_xchg_relb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_xchg_mb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set_rb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set_wb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set_relb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_set_mb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init_rb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init_wb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init_relb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_init_mb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read_rb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read_wb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read_relb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_add_read_mb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_ddrb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_rb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_wb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_acqb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_relb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_mb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read_ddrb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read_rb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read_wb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read_acqb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read_relb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_inc_read_mb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read_ddrb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read_rb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read_wb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read_acqb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read_relb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_dec_read_mb(ethr_atomic32_t *var);
void ethr_atomic32_add(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_add_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_add_rb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_add_wb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_add_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_add_relb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_add_mb(ethr_atomic32_t *var, ethr_sint32_t val);
void ethr_atomic32_inc(ethr_atomic32_t *var);
void ethr_atomic32_inc_ddrb(ethr_atomic32_t *var);
void ethr_atomic32_inc_rb(ethr_atomic32_t *var);
void ethr_atomic32_inc_wb(ethr_atomic32_t *var);
void ethr_atomic32_inc_acqb(ethr_atomic32_t *var);
void ethr_atomic32_inc_relb(ethr_atomic32_t *var);
void ethr_atomic32_inc_mb(ethr_atomic32_t *var);
void ethr_atomic32_dec(ethr_atomic32_t *var);
void ethr_atomic32_dec_ddrb(ethr_atomic32_t *var);
void ethr_atomic32_dec_rb(ethr_atomic32_t *var);
void ethr_atomic32_dec_wb(ethr_atomic32_t *var);
void ethr_atomic32_dec_acqb(ethr_atomic32_t *var);
void ethr_atomic32_dec_relb(ethr_atomic32_t *var);
void ethr_atomic32_dec_mb(ethr_atomic32_t *var);
ethr_sint32_t ethr_atomic32_read_band(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_band_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_band_rb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_band_wb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_band_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_band_relb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_band_mb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor_ddrb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor_rb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor_wb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor_acqb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor_relb(ethr_atomic32_t *var, ethr_sint32_t val);
ethr_sint32_t ethr_atomic32_read_bor_mb(ethr_atomic32_t *var, ethr_sint32_t val);
#endif /* ETHR_NEED_ATMC32_PROTOTYPES__ */

#if (defined(ETHR_HAVE_32BIT_NATIVE_ATOMIC_OPS) \
     && (defined(ETHR_ATMC32_INLINE__) || defined(ETHR_ATOMIC_IMPL__)))

#if !defined(ETHR_NATMC32_BITS__)
#  error "Missing native atomic implementation"
#elif ETHR_NATMC32_BITS__ == 64
#  undef ETHR_HAVE_NATMC32_CMPXCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG
#    define ETHR_HAVE_NATMC32_CMPXCHG 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_RB
#    define ETHR_HAVE_NATMC32_CMPXCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_WB
#    define ETHR_HAVE_NATMC32_CMPXCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_ACQB
#    define ETHR_HAVE_NATMC32_CMPXCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_RELB
#    define ETHR_HAVE_NATMC32_CMPXCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_CMPXCHG_MB
#    define ETHR_HAVE_NATMC32_CMPXCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG
#    define ETHR_HAVE_NATMC32_XCHG 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_RB
#    define ETHR_HAVE_NATMC32_XCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_WB
#    define ETHR_HAVE_NATMC32_XCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_ACQB
#    define ETHR_HAVE_NATMC32_XCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_RELB
#    define ETHR_HAVE_NATMC32_XCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_XCHG_MB
#    define ETHR_HAVE_NATMC32_XCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET
#    define ETHR_HAVE_NATMC32_SET 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_RB
#    define ETHR_HAVE_NATMC32_SET_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_WB
#    define ETHR_HAVE_NATMC32_SET_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_ACQB
#    define ETHR_HAVE_NATMC32_SET_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_RELB
#    define ETHR_HAVE_NATMC32_SET_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_SET_MB
#    define ETHR_HAVE_NATMC32_SET_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT
#    define ETHR_HAVE_NATMC32_INIT 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_RB
#    define ETHR_HAVE_NATMC32_INIT_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_WB
#    define ETHR_HAVE_NATMC32_INIT_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_ACQB
#    define ETHR_HAVE_NATMC32_INIT_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_RELB
#    define ETHR_HAVE_NATMC32_INIT_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INIT_MB
#    define ETHR_HAVE_NATMC32_INIT_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN
#    define ETHR_HAVE_NATMC32_ADD_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_RB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_WB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_ACQB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_RELB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RETURN_MB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ
#    define ETHR_HAVE_NATMC32_READ 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_RB
#    define ETHR_HAVE_NATMC32_READ_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_WB
#    define ETHR_HAVE_NATMC32_READ_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_ACQB
#    define ETHR_HAVE_NATMC32_READ_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_RELB
#    define ETHR_HAVE_NATMC32_READ_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_READ_MB
#    define ETHR_HAVE_NATMC32_READ_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN
#    define ETHR_HAVE_NATMC32_INC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_RB
#    define ETHR_HAVE_NATMC32_INC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_WB
#    define ETHR_HAVE_NATMC32_INC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_ACQB
#    define ETHR_HAVE_NATMC32_INC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_RELB
#    define ETHR_HAVE_NATMC32_INC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RETURN_MB
#    define ETHR_HAVE_NATMC32_INC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN
#    define ETHR_HAVE_NATMC32_DEC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_RB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_WB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_ACQB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_RELB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RETURN_MB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD
#    define ETHR_HAVE_NATMC32_ADD 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RB
#    define ETHR_HAVE_NATMC32_ADD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_WB
#    define ETHR_HAVE_NATMC32_ADD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_ACQB
#    define ETHR_HAVE_NATMC32_ADD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_RELB
#    define ETHR_HAVE_NATMC32_ADD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_ADD_MB
#    define ETHR_HAVE_NATMC32_ADD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC
#    define ETHR_HAVE_NATMC32_INC 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RB
#    define ETHR_HAVE_NATMC32_INC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_WB
#    define ETHR_HAVE_NATMC32_INC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_ACQB
#    define ETHR_HAVE_NATMC32_INC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_RELB
#    define ETHR_HAVE_NATMC32_INC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_INC_MB
#    define ETHR_HAVE_NATMC32_INC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC
#    define ETHR_HAVE_NATMC32_DEC 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RB
#    define ETHR_HAVE_NATMC32_DEC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_WB
#    define ETHR_HAVE_NATMC32_DEC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_ACQB
#    define ETHR_HAVE_NATMC32_DEC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_RELB
#    define ETHR_HAVE_NATMC32_DEC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_DEC_MB
#    define ETHR_HAVE_NATMC32_DEC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD
#    define ETHR_HAVE_NATMC32_AND_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_RB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_WB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_ACQB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_RELB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_AND_RETOLD_MB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD
#    define ETHR_HAVE_NATMC32_OR_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_RB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_WB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_ACQB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_RELB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC64_OR_RETOLD_MB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_MB 1
#  endif
#elif ETHR_NATMC32_BITS__ == 32
#  undef ETHR_HAVE_NATMC32_CMPXCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG
#    define ETHR_HAVE_NATMC32_CMPXCHG 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_RB
#    define ETHR_HAVE_NATMC32_CMPXCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_WB
#    define ETHR_HAVE_NATMC32_CMPXCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_ACQB
#    define ETHR_HAVE_NATMC32_CMPXCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_RELB
#    define ETHR_HAVE_NATMC32_CMPXCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_CMPXCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_MB
#    define ETHR_HAVE_NATMC32_CMPXCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG
#    define ETHR_HAVE_NATMC32_XCHG 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_RB
#    define ETHR_HAVE_NATMC32_XCHG_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_WB
#    define ETHR_HAVE_NATMC32_XCHG_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_ACQB
#    define ETHR_HAVE_NATMC32_XCHG_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_RELB
#    define ETHR_HAVE_NATMC32_XCHG_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_XCHG_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_MB
#    define ETHR_HAVE_NATMC32_XCHG_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET
#    define ETHR_HAVE_NATMC32_SET 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_RB
#    define ETHR_HAVE_NATMC32_SET_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_WB
#    define ETHR_HAVE_NATMC32_SET_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_ACQB
#    define ETHR_HAVE_NATMC32_SET_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_RELB
#    define ETHR_HAVE_NATMC32_SET_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_SET_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET_MB
#    define ETHR_HAVE_NATMC32_SET_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT
#    define ETHR_HAVE_NATMC32_INIT 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_RB
#    define ETHR_HAVE_NATMC32_INIT_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_WB
#    define ETHR_HAVE_NATMC32_INIT_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_ACQB
#    define ETHR_HAVE_NATMC32_INIT_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_RELB
#    define ETHR_HAVE_NATMC32_INIT_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INIT_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INIT_MB
#    define ETHR_HAVE_NATMC32_INIT_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN
#    define ETHR_HAVE_NATMC32_ADD_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_RB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_WB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_ACQB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_RELB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_MB
#    define ETHR_HAVE_NATMC32_ADD_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ
#    define ETHR_HAVE_NATMC32_READ 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_RB
#    define ETHR_HAVE_NATMC32_READ_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_WB
#    define ETHR_HAVE_NATMC32_READ_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_ACQB
#    define ETHR_HAVE_NATMC32_READ_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_RELB
#    define ETHR_HAVE_NATMC32_READ_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_READ_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ_MB
#    define ETHR_HAVE_NATMC32_READ_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN
#    define ETHR_HAVE_NATMC32_INC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_RB
#    define ETHR_HAVE_NATMC32_INC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_WB
#    define ETHR_HAVE_NATMC32_INC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_ACQB
#    define ETHR_HAVE_NATMC32_INC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_RELB
#    define ETHR_HAVE_NATMC32_INC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_MB
#    define ETHR_HAVE_NATMC32_INC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN
#    define ETHR_HAVE_NATMC32_DEC_RETURN 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_RB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_WB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_ACQB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_RELB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RETURN_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_MB
#    define ETHR_HAVE_NATMC32_DEC_RETURN_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD
#    define ETHR_HAVE_NATMC32_ADD 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RB
#    define ETHR_HAVE_NATMC32_ADD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_WB
#    define ETHR_HAVE_NATMC32_ADD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_ACQB
#    define ETHR_HAVE_NATMC32_ADD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RELB
#    define ETHR_HAVE_NATMC32_ADD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_ADD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_MB
#    define ETHR_HAVE_NATMC32_ADD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC
#    define ETHR_HAVE_NATMC32_INC 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RB
#    define ETHR_HAVE_NATMC32_INC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_WB
#    define ETHR_HAVE_NATMC32_INC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_ACQB
#    define ETHR_HAVE_NATMC32_INC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RELB
#    define ETHR_HAVE_NATMC32_INC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_INC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_MB
#    define ETHR_HAVE_NATMC32_INC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC
#    define ETHR_HAVE_NATMC32_DEC 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RB
#    define ETHR_HAVE_NATMC32_DEC_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_WB
#    define ETHR_HAVE_NATMC32_DEC_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_ACQB
#    define ETHR_HAVE_NATMC32_DEC_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RELB
#    define ETHR_HAVE_NATMC32_DEC_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_DEC_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_MB
#    define ETHR_HAVE_NATMC32_DEC_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD
#    define ETHR_HAVE_NATMC32_AND_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_RB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_WB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_ACQB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_RELB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_AND_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_MB
#    define ETHR_HAVE_NATMC32_AND_RETOLD_MB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD
#    define ETHR_HAVE_NATMC32_OR_RETOLD 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_RB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_RB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_RB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_WB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_WB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_WB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_ACQB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_ACQB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_ACQB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_RELB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_RELB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_RELB 1
#  endif
#  undef ETHR_HAVE_NATMC32_OR_RETOLD_MB
#  ifdef ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_MB
#    define ETHR_HAVE_NATMC32_OR_RETOLD_MB 1
#  endif
#else
#  error "Invalid native atomic size"
#endif

#if (!defined(ETHR_HAVE_NATMC32_CMPXCHG) \
     && !defined(ETHR_HAVE_NATMC32_CMPXCHG_RB) \
     && !defined(ETHR_HAVE_NATMC32_CMPXCHG_WB) \
     && !defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB) \
     && !defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB) \
     && !defined(ETHR_HAVE_NATMC32_CMPXCHG_MB))
#  error "No native cmpxchg() op available"
#endif


/*
 * Read op used together with cmpxchg() fallback when no native op present.
 */
#if defined(ETHR_HAVE_NATMC32_READ)
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC32_FUNC__(read)(VAR)
#elif defined(ETHR_HAVE_NATMC32_READ_RB)
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC32_FUNC__(read_rb)(VAR)
#elif defined(ETHR_HAVE_NATMC32_READ_WB)
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC32_FUNC__(read_wb)(VAR)
#elif defined(ETHR_HAVE_NATMC32_READ_ACQB)
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC32_FUNC__(read_acqb)(VAR)
#elif defined(ETHR_HAVE_NATMC32_READ_RELB)
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC32_FUNC__(read_relb)(VAR)
#elif defined(ETHR_HAVE_NATMC32_READ_MB)
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ETHR_NATMC32_FUNC__(read_mb)(VAR)
#else
/*
 * We have no native read() op; guess zero and then use the
 * the atomics actual value returned from cmpxchg().
 */
#define ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR) \
  ((ETHR_NAINT32_T__) 0)
#endif

/*
 * Native cmpxchg() fallback used when no native op present.
 */
#define ETHR_NATMC32_CMPXCHG_FALLBACK__(CMPXCHG, VAR, AVAL, OPS) \
do { \
    ethr_sint32_t AVAL; \
    ETHR_NAINT32_T__ new__, act__, exp__; \
    act__ = ETHR_NATMC32_CMPXCHG_FALLBACK_READ__(VAR); \
    do { \
	exp__ = act__; \
	AVAL = (ethr_sint32_t) act__; \
	{ OPS; } \
	new__ = (ETHR_NAINT32_T__) AVAL; \
	act__ = CMPXCHG(VAR, new__, exp__); \
    } while (__builtin_expect(act__ != exp__, 0)); \
} while (0)



/* --- addr() --- */

static ETHR_INLINE ethr_sint32_t *ETHR_ATMC32_FUNC__(addr)(ethr_atomic32_t *var)
{
    return (ethr_sint32_t *) ETHR_NATMC32_ADDR_FUNC__(var);

}


/* --- cmpxchg() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_CMPXCHG)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#else
#error "Missing implementation of ethr_atomic32_cmpxchg()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg_rb)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic32_cmpxchg_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg_wb)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#else
#error "Missing implementation of ethr_atomic32_cmpxchg_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg_acqb)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_cmpxchg_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg_relb)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#else
#error "Missing implementation of ethr_atomic32_cmpxchg_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg_mb)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_mb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_relb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_acqb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_wb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg_rb)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(cmpxchg)(var, (ETHR_NAINT32_T__) val, (ETHR_NAINT32_T__) old_val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_cmpxchg_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(cmpxchg_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val, ethr_sint32_t old_val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(cmpxchg)(var, val, old_val);
#else
    return ETHR_ATMC32_FUNC__(cmpxchg_rb)(var, val, old_val);
#endif
}


/* --- xchg() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_XCHG)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#else
#error "Missing implementation of ethr_atomic32_xchg()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_XCHG_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_XCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_XCHG_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic32_xchg_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_XCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
#else
#error "Missing implementation of ethr_atomic32_xchg_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_XCHG_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_XCHG)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_XCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_xchg_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_XCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#else
#error "Missing implementation of ethr_atomic32_xchg_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_XCHG_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_XCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_XCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_XCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_XCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(xchg)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval = val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval = val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_xchg_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(xchg_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(xchg)(var, val);
#else
    return ETHR_ATMC32_FUNC__(xchg_rb)(var, val);
#endif
}


/* --- set() --- */


static ETHR_INLINE void ETHR_ATMC32_FUNC__(set)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_SET)
    ETHR_NATMC32_FUNC__(set)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RB)
    ETHR_NATMC32_FUNC__(set_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_WB)
    ETHR_NATMC32_FUNC__(set_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_ACQB)
    ETHR_NATMC32_FUNC__(set_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RELB)
    ETHR_NATMC32_FUNC__(set_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_MB)
    ETHR_NATMC32_FUNC__(set_mb)(var, (ETHR_NAINT32_T__) val);
#else
    (void) ETHR_ATMC32_FUNC__(xchg)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(set_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_SET_RB)
    ETHR_NATMC32_FUNC__(set_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET)
    ETHR_NATMC32_FUNC__(set)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_SET_MB)
    ETHR_NATMC32_FUNC__(set_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_WB)
    ETHR_NATMC32_FUNC__(set_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_SET_ACQB)
    ETHR_NATMC32_FUNC__(set_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_SET_RELB)
    ETHR_NATMC32_FUNC__(set_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC32_FUNC__(xchg_rb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(set_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_SET_WB)
    ETHR_NATMC32_FUNC__(set_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_MB)
    ETHR_NATMC32_FUNC__(set_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_relb)(var, (ETHR_NAINT32_T__) val);
#else
    (void) ETHR_ATMC32_FUNC__(xchg_wb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(set_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_SET_ACQB)
    ETHR_NATMC32_FUNC__(set_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RB)
    ETHR_NATMC32_FUNC__(set_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_SET)
    ETHR_NATMC32_FUNC__(set)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_SET_MB)
    ETHR_NATMC32_FUNC__(set_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_WB)
    ETHR_NATMC32_FUNC__(set_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_SET_RELB)
    ETHR_NATMC32_FUNC__(set_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(xchg_acqb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(set_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_SET_RELB)
    ETHR_NATMC32_FUNC__(set_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_NATMC32_FUNC__(set_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_MB)
    ETHR_NATMC32_FUNC__(set_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_acqb)(var, (ETHR_NAINT32_T__) val);
#else
    (void) ETHR_ATMC32_FUNC__(xchg_relb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(set_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_SET_MB)
    ETHR_NATMC32_FUNC__(set_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_RELB)
    ETHR_NATMC32_FUNC__(set_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_SET_ACQB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_SET_WB)
    ETHR_MEMBAR(ETHR_LoadStore);
    ETHR_NATMC32_FUNC__(set_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_SET_RB)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_SET)
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(set)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(xchg_mb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(set_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC32_FUNC__(set)(var, val);
#else
    ETHR_ATMC32_FUNC__(set_rb)(var, val);
#endif
}


/* --- init() --- */


static ETHR_INLINE void ETHR_ATMC32_FUNC__(init)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_INIT)
    ETHR_NATMC32_FUNC__(init)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RB)
    ETHR_NATMC32_FUNC__(init_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_WB)
    ETHR_NATMC32_FUNC__(init_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_ACQB)
    ETHR_NATMC32_FUNC__(init_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RELB)
    ETHR_NATMC32_FUNC__(init_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_MB)
    ETHR_NATMC32_FUNC__(init_mb)(var, (ETHR_NAINT32_T__) val);
#else
    ETHR_ATMC32_FUNC__(set)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(init_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_INIT_RB)
    ETHR_NATMC32_FUNC__(init_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT)
    ETHR_NATMC32_FUNC__(init)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INIT_MB)
    ETHR_NATMC32_FUNC__(init_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_WB)
    ETHR_NATMC32_FUNC__(init_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INIT_ACQB)
    ETHR_NATMC32_FUNC__(init_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INIT_RELB)
    ETHR_NATMC32_FUNC__(init_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    ETHR_ATMC32_FUNC__(set_rb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(init_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_INIT_WB)
    ETHR_NATMC32_FUNC__(init_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_MB)
    ETHR_NATMC32_FUNC__(init_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_relb)(var, (ETHR_NAINT32_T__) val);
#else
    ETHR_ATMC32_FUNC__(set_wb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(init_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_INIT_ACQB)
    ETHR_NATMC32_FUNC__(init_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RB)
    ETHR_NATMC32_FUNC__(init_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INIT)
    ETHR_NATMC32_FUNC__(init)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INIT_MB)
    ETHR_NATMC32_FUNC__(init_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_WB)
    ETHR_NATMC32_FUNC__(init_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INIT_RELB)
    ETHR_NATMC32_FUNC__(init_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    ETHR_ATMC32_FUNC__(set_acqb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(init_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_INIT_RELB)
    ETHR_NATMC32_FUNC__(init_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(init_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_MB)
    ETHR_NATMC32_FUNC__(init_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_acqb)(var, (ETHR_NAINT32_T__) val);
#else
    ETHR_ATMC32_FUNC__(set_relb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(init_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_INIT_MB)
    ETHR_NATMC32_FUNC__(init_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_RELB)
    ETHR_NATMC32_FUNC__(init_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INIT_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_INIT_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(init_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INIT_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INIT)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(init)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    ETHR_ATMC32_FUNC__(set_mb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(init_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC32_FUNC__(init)(var, val);
#else
    ETHR_ATMC32_FUNC__(init_rb)(var, val);
#endif
}


/* --- add_read() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_ADD_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#else
#error "Missing implementation of ethr_atomic32_add_read()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_ADD_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic32_add_read_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_ADD_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
#else
#error "Missing implementation of ethr_atomic32_add_read_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_ADD_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_add_read_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_ADD_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#else
#error "Missing implementation of ethr_atomic32_add_read_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_ADD_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(add_return)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, aval += val; res = aval);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, aval += val; res = aval);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_add_read_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(add_read_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(add_read)(var, val);
#else
    return ETHR_ATMC32_FUNC__(add_read_rb)(var, val);
#endif
}


/* --- read() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_READ)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_mb)(var);
#else
    res = ETHR_ATMC32_FUNC__(cmpxchg)(var, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_rb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_READ_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_READ_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_READ_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_READ_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    res = ETHR_ATMC32_FUNC__(cmpxchg_rb)(var, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_wb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_READ_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_relb)(var);
#else
    res = ETHR_ATMC32_FUNC__(cmpxchg_wb)(var, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_acqb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_READ_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC32_READ)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC32_READ_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC32_READ_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#else
    res = ETHR_ATMC32_FUNC__(cmpxchg_acqb)(var, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_relb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_READ_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_acqb)(var);
#else
    res = ETHR_ATMC32_FUNC__(cmpxchg_relb)(var, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_mb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_READ_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC32_READ_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_READ_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC32_READ_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore);
#elif defined(ETHR_HAVE_NATMC32_READ)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(read)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore);
#else
    res = ETHR_ATMC32_FUNC__(cmpxchg_mb)(var, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__, (ethr_sint32_t) ETHR_UNUSUAL_SINT32_VAL__);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_ddrb)(ethr_atomic32_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(read)(var);
#else
    return ETHR_ATMC32_FUNC__(read_rb)(var);
#endif
}


/* --- inc_read() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_INC_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_mb)(var);
#else
    res = ETHR_ATMC32_FUNC__(add_read)(var, (ethr_sint32_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read_rb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_INC_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    res = ETHR_ATMC32_FUNC__(add_read_rb)(var, (ethr_sint32_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read_wb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_INC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_relb)(var);
#else
    res = ETHR_ATMC32_FUNC__(add_read_wb)(var, (ethr_sint32_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read_acqb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_INC_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC32_FUNC__(add_read_acqb)(var, (ethr_sint32_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read_relb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_INC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_acqb)(var);
#else
    res = ETHR_ATMC32_FUNC__(add_read_relb)(var, (ethr_sint32_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read_mb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_INC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(inc_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC32_FUNC__(add_read_mb)(var, (ethr_sint32_t) 1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(inc_read_ddrb)(ethr_atomic32_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(inc_read)(var);
#else
    return ETHR_ATMC32_FUNC__(inc_read_rb)(var);
#endif
}


/* --- dec_read() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_DEC_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_mb)(var);
#else
    res = ETHR_ATMC32_FUNC__(add_read)(var, (ethr_sint32_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read_rb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_DEC_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    res = ETHR_ATMC32_FUNC__(add_read_rb)(var, (ethr_sint32_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read_wb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_DEC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_relb)(var);
#else
    res = ETHR_ATMC32_FUNC__(add_read_wb)(var, (ethr_sint32_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read_acqb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_DEC_RETURN_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC32_FUNC__(add_read_acqb)(var, (ethr_sint32_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read_relb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_DEC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_acqb)(var);
#else
    res = ETHR_ATMC32_FUNC__(add_read_relb)(var, (ethr_sint32_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read_mb)(ethr_atomic32_t *var)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_DEC_RETURN_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RETURN)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(dec_return)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    res = ETHR_ATMC32_FUNC__(add_read_mb)(var, (ethr_sint32_t) -1);
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(dec_read_ddrb)(ethr_atomic32_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(dec_read)(var);
#else
    return ETHR_ATMC32_FUNC__(dec_read_rb)(var);
#endif
}


/* --- add() --- */


static ETHR_INLINE void ETHR_ATMC32_FUNC__(add)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_ADD)
    ETHR_NATMC32_FUNC__(add)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RB)
    ETHR_NATMC32_FUNC__(add_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_WB)
    ETHR_NATMC32_FUNC__(add_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_ACQB)
    ETHR_NATMC32_FUNC__(add_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RELB)
    ETHR_NATMC32_FUNC__(add_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_MB)
    ETHR_NATMC32_FUNC__(add_mb)(var, (ETHR_NAINT32_T__) val);
#else
    (void) ETHR_ATMC32_FUNC__(add_read)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(add_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_ADD_RB)
    ETHR_NATMC32_FUNC__(add_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD)
    ETHR_NATMC32_FUNC__(add)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_ADD_MB)
    ETHR_NATMC32_FUNC__(add_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_WB)
    ETHR_NATMC32_FUNC__(add_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_ADD_ACQB)
    ETHR_NATMC32_FUNC__(add_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_ADD_RELB)
    ETHR_NATMC32_FUNC__(add_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC32_FUNC__(add_read_rb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(add_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_ADD_WB)
    ETHR_NATMC32_FUNC__(add_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(add)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_MB)
    ETHR_NATMC32_FUNC__(add_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(add_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(add_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(add_relb)(var, (ETHR_NAINT32_T__) val);
#else
    (void) ETHR_ATMC32_FUNC__(add_read_wb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(add_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_ADD_ACQB)
    ETHR_NATMC32_FUNC__(add_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RB)
    ETHR_NATMC32_FUNC__(add_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD)
    ETHR_NATMC32_FUNC__(add)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_MB)
    ETHR_NATMC32_FUNC__(add_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_WB)
    ETHR_NATMC32_FUNC__(add_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RELB)
    ETHR_NATMC32_FUNC__(add_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(add_read_acqb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(add_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_ADD_RELB)
    ETHR_NATMC32_FUNC__(add_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_MB)
    ETHR_NATMC32_FUNC__(add_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add_acqb)(var, (ETHR_NAINT32_T__) val);
#else
    (void) ETHR_ATMC32_FUNC__(add_read_relb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(add_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#if defined(ETHR_HAVE_NATMC32_ADD_MB)
    ETHR_NATMC32_FUNC__(add_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_RELB)
    ETHR_NATMC32_FUNC__(add_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_ADD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_ADD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(add)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(add_read_mb)(var, val);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(add_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC32_FUNC__(add)(var, val);
#else
    ETHR_ATMC32_FUNC__(add_rb)(var, val);
#endif
}


/* --- inc() --- */


static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_INC)
    ETHR_NATMC32_FUNC__(inc)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RB)
    ETHR_NATMC32_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_WB)
    ETHR_NATMC32_FUNC__(inc_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_ACQB)
    ETHR_NATMC32_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RELB)
    ETHR_NATMC32_FUNC__(inc_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_MB)
    ETHR_NATMC32_FUNC__(inc_mb)(var);
#else
    (void) ETHR_ATMC32_FUNC__(inc_read)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc_rb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_INC_RB)
    ETHR_NATMC32_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC)
    ETHR_NATMC32_FUNC__(inc)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INC_MB)
    ETHR_NATMC32_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_WB)
    ETHR_NATMC32_FUNC__(inc_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INC_ACQB)
    ETHR_NATMC32_FUNC__(inc_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_INC_RELB)
    ETHR_NATMC32_FUNC__(inc_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC32_FUNC__(inc_read_rb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc_wb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_INC_WB)
    ETHR_NATMC32_FUNC__(inc_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(inc)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_MB)
    ETHR_NATMC32_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(inc_relb)(var);
#else
    (void) ETHR_ATMC32_FUNC__(inc_read_wb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc_acqb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_INC_ACQB)
    ETHR_NATMC32_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RB)
    ETHR_NATMC32_FUNC__(inc_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC)
    ETHR_NATMC32_FUNC__(inc)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_MB)
    ETHR_NATMC32_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_WB)
    ETHR_NATMC32_FUNC__(inc_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RELB)
    ETHR_NATMC32_FUNC__(inc_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(inc_read_acqb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc_relb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_INC_RELB)
    ETHR_NATMC32_FUNC__(inc_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_MB)
    ETHR_NATMC32_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc_acqb)(var);
#else
    (void) ETHR_ATMC32_FUNC__(inc_read_relb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc_mb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_INC_MB)
    ETHR_NATMC32_FUNC__(inc_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_RELB)
    ETHR_NATMC32_FUNC__(inc_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_INC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_INC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(inc)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(inc_read_mb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(inc_ddrb)(ethr_atomic32_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC32_FUNC__(inc)(var);
#else
    ETHR_ATMC32_FUNC__(inc_rb)(var);
#endif
}


/* --- dec() --- */


static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_DEC)
    ETHR_NATMC32_FUNC__(dec)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RB)
    ETHR_NATMC32_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_WB)
    ETHR_NATMC32_FUNC__(dec_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_ACQB)
    ETHR_NATMC32_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RELB)
    ETHR_NATMC32_FUNC__(dec_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_MB)
    ETHR_NATMC32_FUNC__(dec_mb)(var);
#else
    (void) ETHR_ATMC32_FUNC__(dec_read)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec_rb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_DEC_RB)
    ETHR_NATMC32_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC)
    ETHR_NATMC32_FUNC__(dec)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_DEC_MB)
    ETHR_NATMC32_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_WB)
    ETHR_NATMC32_FUNC__(dec_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_DEC_ACQB)
    ETHR_NATMC32_FUNC__(dec_acqb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_DEC_RELB)
    ETHR_NATMC32_FUNC__(dec_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
    (void) ETHR_ATMC32_FUNC__(dec_read_rb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec_wb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_DEC_WB)
    ETHR_NATMC32_FUNC__(dec_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(dec)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_MB)
    ETHR_NATMC32_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_FUNC__(dec_relb)(var);
#else
    (void) ETHR_ATMC32_FUNC__(dec_read_wb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec_acqb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_DEC_ACQB)
    ETHR_NATMC32_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RB)
    ETHR_NATMC32_FUNC__(dec_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC)
    ETHR_NATMC32_FUNC__(dec)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_MB)
    ETHR_NATMC32_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_WB)
    ETHR_NATMC32_FUNC__(dec_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RELB)
    ETHR_NATMC32_FUNC__(dec_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(dec_read_acqb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec_relb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_DEC_RELB)
    ETHR_NATMC32_FUNC__(dec_relb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec_wb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_MB)
    ETHR_NATMC32_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec_rb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec_acqb)(var);
#else
    (void) ETHR_ATMC32_FUNC__(dec_read_relb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec_mb)(ethr_atomic32_t *var)
{
#if defined(ETHR_HAVE_NATMC32_DEC_MB)
    ETHR_NATMC32_FUNC__(dec_mb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_RELB)
    ETHR_NATMC32_FUNC__(dec_relb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec_acqb)(var);
#elif defined(ETHR_HAVE_NATMC32_DEC_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec_wb)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec_rb)(var);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_DEC)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_FUNC__(dec)(var);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
    (void) ETHR_ATMC32_FUNC__(dec_read_mb)(var);
#endif
}

static ETHR_INLINE void ETHR_ATMC32_FUNC__(dec_ddrb)(ethr_atomic32_t *var)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    ETHR_ATMC32_FUNC__(dec)(var);
#else
    ETHR_ATMC32_FUNC__(dec_rb)(var);
#endif
}


/* --- read_band() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_AND_RETOLD)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#else
#error "Missing implementation of ethr_atomic32_read_band()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_AND_RETOLD_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic32_read_band_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_AND_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
#else
#error "Missing implementation of ethr_atomic32_read_band_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_AND_RETOLD_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_read_band_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_AND_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#else
#error "Missing implementation of ethr_atomic32_read_band_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_AND_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_AND_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(and_retold)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval &= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval &= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_read_band_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_band_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(read_band)(var, val);
#else
    return ETHR_ATMC32_FUNC__(read_band_rb)(var, val);
#endif
}


/* --- read_bor() --- */


static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_OR_RETOLD)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#else
#error "Missing implementation of ethr_atomic32_read_bor()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor_rb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_OR_RETOLD_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_acqb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad);
#else
#error "Missing implementation of ethr_atomic32_read_bor_rb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor_wb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_OR_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_MEMBAR(ETHR_StoreStore);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
#else
#error "Missing implementation of ethr_atomic32_read_bor_wb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor_acqb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_OR_RETOLD_ACQB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_WB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_read_bor_acqb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor_relb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_OR_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_relb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_wb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_rb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#else
#error "Missing implementation of ethr_atomic32_read_bor_relb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor_mb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
    ethr_sint32_t res;
#if defined(ETHR_HAVE_NATMC32_OR_RETOLD_MB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_mb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RELB)
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_relb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_acqb)(var, (ETHR_NAINT32_T__) val);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_wb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold_rb)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_OR_RETOLD)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    res = (ethr_sint32_t) ETHR_NATMC32_FUNC__(or_retold)(var, (ETHR_NAINT32_T__) val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_MB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_mb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RELB)
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_relb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_ACQB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_acqb), var, aval, res = aval; aval |= val);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_WB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_wb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG_RB)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg_rb), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#elif defined(ETHR_HAVE_NATMC32_CMPXCHG)
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_StoreLoad);
    ETHR_NATMC32_CMPXCHG_FALLBACK__(ETHR_NATMC32_FUNC__(cmpxchg), var, aval, res = aval; aval |= val);
    ETHR_MEMBAR(ETHR_LoadLoad|ETHR_LoadStore|ETHR_StoreLoad|ETHR_StoreStore);
#else
#error "Missing implementation of ethr_atomic32_read_bor_mb()!"
#endif
    return res;
}

static ETHR_INLINE ethr_sint32_t ETHR_ATMC32_FUNC__(read_bor_ddrb)(ethr_atomic32_t *var, ethr_sint32_t val)
{
#ifdef ETHR_ORDERED_READ_DEPEND
    return ETHR_ATMC32_FUNC__(read_bor)(var, val);
#else
    return ETHR_ATMC32_FUNC__(read_bor_rb)(var, val);
#endif
}

#endif /* ETHR_ATMC32_INLINE__ */

#endif /* ETHR_ATOMICS_H__ */