1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 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 1521 1522 1523 1524 1525 1526 1527 1528 1529 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 2020 2021 2022 2023 2024 2025 2026 2027 2028 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 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 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 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 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 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962
|
GIT update of git://sourceware.org/git/glibc.git/release/2.24/master from glibc-2.24
diff --git a/ChangeLog b/ChangeLog
index c44c926094..9be47cd9ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,747 @@
+2017-10-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21265]
+ * sysdeps/x86/cpu-features-offsets.sym (XSAVE_STATE_SIZE_OFFSET):
+ New.
+ * sysdeps/x86/cpu-features.c: Include <libc-internal.h>.
+ (get_common_indeces): Set xsave_state_size and
+ bit_arch_XSAVEC_Usable if needed.
+ (init_cpu_features): Remove bit_arch_Use_dl_runtime_resolve_slow
+ and bit_arch_Use_dl_runtime_resolve_opt.
+ * sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
+ Removed.
+ (bit_arch_Use_dl_runtime_resolve_slow): Likewise.
+ (bit_arch_Prefer_No_AVX512): Updated.
+ (bit_arch_MathVec_Prefer_No_AVX512): Likewise.
+ (bit_arch_XSAVEC_Usable): New.
+ (STATE_SAVE_OFFSET): Likewise.
+ (STATE_SAVE_MASK): Likewise.
+ [__ASSEMBLER__]: Include <cpu-features-offsets.h>.
+ (cpu_features): Add xsave_state_size.
+ (index_arch_Use_dl_runtime_resolve_opt): Removed.
+ (index_arch_Use_dl_runtime_resolve_slow): Likewise.
+ (index_arch_XSAVEC_Usable): New.
+ * sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
+ Replace _dl_runtime_resolve_sse, _dl_runtime_resolve_avx,
+ _dl_runtime_resolve_avx_slow, _dl_runtime_resolve_avx_opt,
+ _dl_runtime_resolve_avx512 and _dl_runtime_resolve_avx512_opt
+ with _dl_runtime_resolve_fxsave, _dl_runtime_resolve_xsave and
+ _dl_runtime_resolve_xsavec.
+ * sysdeps/x86_64/dl-trampoline.S (DL_RUNTIME_UNALIGNED_VEC_SIZE):
+ Removed.
+ (DL_RUNTIME_RESOLVE_REALIGN_STACK): Check STATE_SAVE_ALIGNMENT
+ instead of VEC_SIZE.
+ (REGISTER_SAVE_BND0): Removed.
+ (REGISTER_SAVE_BND1): Likewise.
+ (REGISTER_SAVE_BND3): Likewise.
+ (REGISTER_SAVE_RAX): Always defined to 0.
+ (VMOV): Removed.
+ (_dl_runtime_resolve_avx): Likewise.
+ (_dl_runtime_resolve_avx_slow): Likewise.
+ (_dl_runtime_resolve_avx_opt): Likewise.
+ (_dl_runtime_resolve_avx512): Likewise.
+ (_dl_runtime_resolve_avx512_opt): Likewise.
+ (_dl_runtime_resolve_sse): Likewise.
+ (_dl_runtime_resolve_sse_vex): Likewise.
+ (USE_FXSAVE): New.
+ (_dl_runtime_resolve_fxsave): Likewise.
+ (USE_XSAVE): Likewise.
+ (_dl_runtime_resolve_xsave): Likewise.
+ (USE_XSAVEC): Likewise.
+ (_dl_runtime_resolve_xsavec): Likewise.
+ * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx512):
+ Removed.
+ (_dl_runtime_resolve_avx512_opt): Likewise.
+ (_dl_runtime_resolve_avx): Likewise.
+ (_dl_runtime_resolve_avx_opt): Likewise.
+ (_dl_runtime_resolve_sse): Likewise.
+ (_dl_runtime_resolve_sse_vex): Likewise.
+ (_dl_runtime_resolve_fxsave): New.
+ (_dl_runtime_resolve_xsave): Likewise.
+ (_dl_runtime_resolve_xsavec): Likewise.
+
+2017-10-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/x86_64/Makefile (tests): Add tst-sse, tst-avx and
+ tst-avx512.
+ (test-extras): Add tst-avx-aux and tst-avx512-aux.
+ (extra-test-objs): Add tst-avx-aux.o and tst-avx512-aux.o.
+ (modules-names): Add tst-ssemod, tst-avxmod and tst-avx512mod.
+ ($(objpfx)tst-sse): New rule.
+ ($(objpfx)tst-avx): Likewise.
+ ($(objpfx)tst-avx512): Likewise.
+ (CFLAGS-tst-avx-aux.c): New.
+ (CFLAGS-tst-avxmod.c): Likewise.
+ (CFLAGS-tst-avx512-aux.c): Likewise.
+ (CFLAGS-tst-avx512mod.c): Likewise.
+ * sysdeps/x86_64/tst-avx-aux.c: New file.
+ * sysdeps/x86_64/tst-avx.c: Likewise.
+ * sysdeps/x86_64/tst-avx512-aux.c: Likewise.
+ * sysdeps/x86_64/tst-avx512.c: Likewise.
+ * sysdeps/x86_64/tst-avx512mod.c: Likewise.
+ * sysdeps/x86_64/tst-avxmod.c: Likewise.
+ * sysdeps/x86_64/tst-sse.c: Likewise.
+ * sysdeps/x86_64/tst-ssemod.c: Likewise.
+
+2017-10-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Don't
+ adjust CFA when allocating register save area on re-aligned
+ stack.
+
+2016-12-21 Joseph Myers <joseph@codesourcery.com>
+
+ [BZ #20978]
+ * nis/nss_nisplus/nisplus-alias.c (_nss_nisplus_getaliasbyname_r):
+ Compare name == NULL, not name != NULL.
+
+2016-11-08 Joseph Myers <joseph@codesourcery.com>
+
+ [BZ #20790]
+ * sunrpc/rpc_parse.c (get_prog_declaration): Increase buffer size
+ to MAXLINESIZE.
+ * sunrpc/bug20790.x: New file.
+ * sunrpc/Makefile [$(run-built-tests) = yes] (rpcgen-tests): New
+ variable.
+ [$(run-built-tests) = yes] (tests-special): Add $(rpcgen-tests).
+ [$(run-built-tests) = yes] ($(rpcgen-tests)): New rule.
+
+2016-10-14 Steve Ellcey <sellcey@caviumnetworks.com>
+
+ * sysdeps/ieee754/dbl-64/e_pow.c (checkint) Make conditions explicitly
+ boolean.
+
+2017-07-19 DJ Delorie <dj@delorie.com>
+
+ [BZ #21654]
+ * grp/grp-merge.c (libc_hidden_def): Fix cast-after-dereference.
+
+2017-07-14 DJ Delorie <dj@redhat.com>
+
+ [BZ #21654]
+ * grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
+ alignment not char alignment.
+ (__merge_grp): Likewise.
+
+2017-08-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21871]
+ * sysdeps/x86/cpu-features.c (init_cpu_features): Set
+ bit_arch_Use_dl_runtime_resolve_opt only with AVX512F.
+
+2017-02-27 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #21115]
+ * sunrpc/clnt_udp.c (clntudp_call): Free ancillary data later.
+ * sunrpc/Makefile (tests): Add tst-udp-error.
+ (tst-udp-error): Link against libc.so explicitly.
+ * sunrpc/tst-udp-error: New file.
+
+2017-01-24 James Clarke <jrtc27@jrtc27.com>
+
+ * sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym: Use new REG_R*
+ constants instead of the old R* ones.
+ * sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGPREG): Rename...
+ (NGREG): ... to this, to fit in with other architectures.
+ (gpregset_t): Use new NGREG macro.
+ [__USE_GNU]: Remove condition; all architectures other than tile
+ are unconditional.
+ (R*): Rename to REG_R*.
+
+2017-07-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21666]
+ * misc/regexp.c (loc1): Add __attribute__ ((nocommon));
+ (loc2): Likewise.
+ (locs): Likewise.
+
+2017-07-12 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * sysdeps/aarch64/dl-machine.h (RTLD_START_1): Change _dl_argv to the
+ hidden __GI__dl_argv symbol.
+
+2016-09-05 Aurelien Jarno <aurelien@aurel32.net>
+
+ * conform/Makefile (conformtest-header-tests): Pass -I. to $(PERL).
+ (linknamespace-symlists-tests): Likewise.
+ (linknamespace-header-tests): Likewise.
+
+2017-07-06 Florian Weimer <fweimer@redhat.com>
+ H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21609]
+ * sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
+ (gen-as-const-headers): Add rtld-offsets.sym.
+ * sysdeps/x86_64/dl-tls.c: New file.
+ * sysdeps/x86_64/rtld-offsets.sym: Likwise.
+ * sysdeps/x86_64/tls_get_addr.S: Likewise.
+ * sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
+ * sysdeps/x86_64/tlsdesc.sym (TI_MODULE_OFFSET): New.
+ (TI_OFFSET_OFFSET): Likwise.
+
+2017-06-14 Florian Weimer <fweimer@redhat.com>
+
+ * sysdeps/i386/i686/multiarch/strcspn-c.c: Add IS_IN (libc) guard.
+ * sysdeps/i386/i686/multiarch/varshift.c: Likewise.
+
+2017-03-07 Siddhesh Poyarekar <siddhesh@sourceware.org>
+
+ [BZ #21209]
+ * elf/rtld.c (process_envvars): Ignore LD_HWCAP_MASK for
+ AT_SECURE processes.
+ * sysdeps/generic/unsecvars.h: Add LD_HWCAP_MASK.
+
+2017-06-19 Florian Weimer <fweimer@redhat.com>
+
+ * elf/rtld.c (audit_list_string): New variable.
+ (audit_list): Update comment.
+ (struct audit_list_iter): Define.
+ (audit_list_iter_init, audit_list_iter_next): New function.
+ (dl_main): Use struct audit_list_iter to process audit modules.
+ (process_dl_audit): Call dso_name_valid_for_suid.
+ (process_envvars): Set audit_list_string instead of calling
+ process_dl_audit.
+
+2017-06-19 Florian Weimer <fweimer@redhat.com>
+
+ * elf/rtld.c (SECURE_NAME_LIMIT, SECURE_PATH_LIMIT): Define.
+ (dso_name_valid_for_suid): New function.
+ (handle_ld_preload): Likewise.
+ (dl_main): Call it. Remove alloca.
+
+2017-06-19 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #21624]
+ CVE-2017-1000366
+ * elf/rtld.c (process_envvars): Ignore LD_LIBRARY_PATH for
+ __libc_enable_secure.
+
+2017-02-01 Andreas Schwab <schwab@linux-m68k.org>
+
+ * sysdeps/m68k/m680x0/m68020/atomic-machine.h
+ (__arch_compare_and_exchange_val_64_acq, atomic_exchange_acq)
+ (atomic_exchange_and_add, atomic_add): Add casts to 64 bit asm
+ operands.
+
+2017-05-12 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #21386]
+ * sysdeps/nptl/fork.c (__libc_fork): Remove assertions on the
+ parent PID. The assertion in the child is incorrect with PID
+ namespaces.
+
+2017-06-07 Arjun Shankar <arjun.is@lostca.se>
+
+ * sysdeps/unix/sysv/linux/tst-clone2.c: Do not
+ include test-skeleton.c.
+ Include support/check.h and support/test-driver.c.
+
+2016-11-24 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ * sysdeps/nptl/fork.c (__libc_fork): Remove pid cache setting.
+ * nptl/allocatestack.c (allocate_stack): Likewise.
+ (__reclaim_stacks): Likewise.
+ (setxid_signal_thread): Obtain pid through syscall.
+ * nptl/nptl-init.c (sigcancel_handler): Likewise.
+ (sighandle_setxid): Likewise.
+ * nptl/pthread_cancel.c (pthread_cancel): Likewise.
+ * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise.
+ * sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
+ Likewise.
+ * sysdeps/unix/sysv/linux/createthread.c (create_thread): Likewise.
+ * sysdeps/unix/sysv/linux/raise.c (raise): Remove old behaviour
+ comment.
+ * sysdeps/unix/sysv/linux/getpid.c: Remove file.
+ * nptl/descr.h (struct pthread): Change comment about pid value.
+ * nptl/pthread_getattr_np.c (pthread_getattr_np): Remove thread
+ pid assert.
+ * sysdeps/unix/sysv/linux/pthread-pids.h (__pthread_initialize_pids):
+ Do not set pid value.
+ * nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove thread
+ pid cache check.
+ * nptl_db/td_thr_validate.c (td_thr_validate): Likewise.
+ * sysdeps/aarch64/nptl/tcb-offsets.sym: Remove pid offset.
+ * sysdeps/alpha/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/arm/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/hppa/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/i386/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/ia64/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/m68k/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/microblaze/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/mips/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/nios2/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/powerpc/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/s390/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/sh/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/sparc/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/tile/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/x86_64/nptl/tcb-offsets.sym: Likewise.
+ * sysdeps/unix/sysv/linux/aarch64/clone.S: Remove pid and tid caching.
+ * sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/nios2/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/tile/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/aarch64/vfork.S: Remove pid set and reset.
+ * sysdeps/unix/sysv/linux/alpha/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/arm/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/nios2/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/tile/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/pt-vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/tst-clone2.c (f): Remove direct pthread
+ struct access.
+ (clone_test): Remove function.
+ (do_test): Rewrite to take in consideration pid is not cached anymore.
+
+2016-09-26 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ * sysdeps/unix/sysdep.h (__INTERNAL_SYSCALL0): New macro.
+ (__INTERNAL_SYSCALL1): Likewise.
+ (__INTERNAL_SYSCALL2): Likewise.
+ (__INTERNAL_SYSCALL3): Likewise.
+ (__INTERNAL_SYSCALL4): Likewise.
+ (__INTERNAL_SYSCALL5): Likewise.
+ (__INTERNAL_SYSCALL6): Likewise.
+ (__INTERNAL_SYSCALL7): Likewise.
+ (__INTERNAL_SYSCALL_NARGS_X): Likewise.
+ (__INTERNAL_SYSCALL_NARGS): Likewise.
+ (__INTERNAL_SYSCALL_DISP): Likewise.
+ (INTERNAL_SYSCALL_CALL): Likewise.
+ (__SYSCALL0): Rename to __INLINE_SYSCALL0.
+ (__SYSCALL1): Rename to __INLINE_SYSCALL1.
+ (__SYSCALL2): Rename to __INLINE_SYSCALL2.
+ (__SYSCALL3): Rename to __INLINE_SYSCALL3.
+ (__SYSCALL4): Rename to __INLINE_SYSCALL4.
+ (__SYSCALL5): Rename to __INLINE_SYSCALL5.
+ (__SYSCALL6): Rename to __INLINE_SYSCALL6.
+ (__SYSCALL7): Rename to __INLINE_SYSCALL7.
+ (__SYSCALL_NARGS_X): Rename to __INLINE_SYSCALL_NARGS_X.
+ (__SYSCALL_NARGS): Rename to __INLINE_SYSCALL_NARGS.
+ (__SYSCALL_DISP): Rename to __INLINE_SYSCALL_DISP.
+ (__SYSCALL_CALL): Rename to INLINE_SYSCALL_CALL.
+ (SYSCALL_CANCEL): Replace __SYSCALL_CALL with INLINE_SYSCALL_CALL.
+
+2017-04-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21396]
+ * sysdeps/x86/cpu-features.c (init_cpu_features): Set
+ Prefer_No_AVX512 if AVX512ER isn't available.
+ * sysdeps/x86/cpu-features.h (bit_arch_Prefer_No_AVX512): New.
+ (index_arch_Prefer_No_AVX512): Likewise.
+ * sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Don't use
+ AVX512 version if Prefer_No_AVX512 is set.
+ * sysdeps/x86_64/multiarch/memcpy_chk.S (__memcpy_chk):
+ Likewise.
+ * sysdeps/x86_64/multiarch/memmove.S (__libc_memmove): Likewise.
+ * sysdeps/x86_64/multiarch/memmove_chk.S (__memmove_chk):
+ Likewise.
+ * sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Likewise.
+ * sysdeps/x86_64/multiarch/mempcpy_chk.S (__mempcpy_chk):
+ Likewise.
+ * sysdeps/x86_64/multiarch/memset.S (memset): Likewise.
+ * sysdeps/x86_64/multiarch/memset_chk.S (__memset_chk):
+ Likewise.
+
+2017-04-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/x86/cpu-features.c (init_cpu_features): Set
+ Prefer_No_VZEROUPPER if AVX512ER is available.
+ * sysdeps/x86/cpu-features.h
+ (bit_cpu_AVX512PF): New.
+ (bit_cpu_AVX512ER): Likewise.
+ (bit_cpu_AVX512CD): Likewise.
+ (bit_cpu_AVX512BW): Likewise.
+ (bit_cpu_AVX512VL): Likewise.
+ (index_cpu_AVX512PF): Likewise.
+ (index_cpu_AVX512ER): Likewise.
+ (index_cpu_AVX512CD): Likewise.
+ (index_cpu_AVX512BW): Likewise.
+ (index_cpu_AVX512VL): Likewise.
+ (reg_AVX512PF): Likewise.
+ (reg_AVX512ER): Likewise.
+ (reg_AVX512CD): Likewise.
+ (reg_AVX512BW): Likewise.
+ (reg_AVX512VL): Likewise.
+
+2017-01-05 Joseph Myers <joseph@codesourcery.com>
+
+ [BZ #21026]
+ * sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+ (readahead): New syscall entry.
+
+2017-04-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21258]
+ * sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve_opt):
+ Define only if _dl_runtime_resolve is defined to
+ _dl_runtime_resolve_sse_vex.
+ * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_opt):
+ Fallthrough to _dl_runtime_resolve_sse_vex.
+
+2017-04-03 Mike Frysinger <vapier@gentoo.org>
+
+ [BZ #21253]
+ * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Increase argv_size
+ slack space by 32KiB.
+
+2017-03-31 Slava Barinov <v.barinov@samsung.com>
+
+ [BZ #21289]
+ * io/fts.h (fts_set): Replace __REDIRECT with __REDIRECT_NTH.
+
+2017-03-20 Mike Frysinger <vapier@gentoo.org>
+
+ [BZ #21275]
+ * sysdeps/unix/sysv/linux/spawni.c [__ia64__] (CLONE): Rename
+ __stack to __stackbase.
+ (STACK): Invert _STACK_GROWS_DOWN and _STACK_GROWS_UP order of
+ checks so we can include defined(__ia64__) first.
+
+2017-03-15 John David Anglin <danglin@gcc.gnu.org>
+
+ * sysdeps/hppa/dl-machine.h (DL_STACK_END): Define.
+ (RTLD_START): Don't record stack end address in _dl_start_user.
+
+2017-01-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21081]
+ * sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
+ (L(stosb)): Add VZEROUPPER before ret.
+
+2016-11-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #20750]
+ * sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
+ of PIC.
+
+2016-12-31 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #18784]
+ CVE-2015-5180
+ * include/arpa/nameser_compat.h (T_QUERY_A_AND_AAAA): Rename from
+ T_UNSPEC. Adjust value.
+ * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname4_r): Use it.
+ * resolv/res_query.c (__libc_res_nquery): Likewise.
+ * resolv/res_mkquery.c (res_nmkquery): Check for out-of-range
+ QTYPEs.
+ * resolv/tst-resolv-qtypes.c: New file.
+ * resolv/Makefile (xtests): Add tst-resolv-qtypes.
+ (tst-resolv-qtypes): Link against libresolv and libpthread.
+
+2017-02-02 Siddhesh Poyarekar <siddhesh@sourceware.org>
+
+ * sysdeps/generic/unsecvars.h: Add GLIBC_TUNABLES.
+
+2017-01-23 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
+ Steven Munroe <sjmunroe@us.ibm.com>
+ Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
+
+ [BZ #20822]
+ * sysdeps/unix/sysv/linux/powerpc/elision-lock.c
+ (__lll_lock_elision): Access adapt_count via C11 atomics.
+ * sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
+ (__lll_trylock_elision): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
+ (__lll_unlock_elision): Update adapt_count variable inside the
+ critical section using C11 atomics.
+
+2016-12-24 Carlos O'Donell <carlos@redhat.com>
+
+ [BZ #11941]
+ * elf/dl-close.c (_dl_close): Take dl_load_lock to examine map.
+ Remove assert (map->l_init_called); if DF_1_NODELETE is set.
+ * elf/Makefile [ifeq (yes,$(build-shared))] (tests): Add
+ tst-nodelete-dlclose.
+ (modules-names): Add tst-nodelete-dlclose-dso and
+ tst-nodelete-dlclose-plugin.
+ ($(objpfx)tst-nodelete-dlclose-dso.so): Define.
+ ($(objpfx)tst-nodelete-dlclose-plugin.so): Define.
+ ($(objpfx)tst-nodelete-dlclose): Define.
+ ($(objpfx)tst-nodelete-dlclose.out): Define.
+
+2016-08-02 Aurelien Jarno <aurelien@aurel32.net>
+
+2016-08-02 Aurelien Jarno <aurelien@aurel32.net>
+
+ * sysdeps/alpha/fpu/s_ceil.c (__ceil): Add argument with itself
+ when it is a NaN.
+ [_IEEE_FP_INEXACT] Remove.
+ * sysdeps/alpha/fpu/s_ceilf.c (__ceilf): Likewise.
+ * sysdeps/alpha/fpu/s_floor.c (__floor): Add argument with itself
+ when it is a NaN.
+ [_IEEE_FP_INEXACT] Remove.
+ * sysdeps/alpha/fpu/s_floorf.c (__floorf): Likewise.
+ * sysdeps/alpha/fpu/s_rint.c (__rint): Add argument with itself
+ when it is a NaN.
+ * sysdeps/alpha/fpu/s_rintf.c (__rintf): Likewise.
+ * sysdeps/alpha/fpu/s_trunc.c (__trunc): Return the input value
+ when its absolute value is greater than 0x1.0p52.
+ [_IEEE_FP_INEXACT] Remove.
+ * sysdeps/alpha/fpu/s_truncf.c (__truncf): Return the input value
+ when its absolute value is greater than 0x1.0p23.
+ [_IEEE_FP_INEXACT] Remove.
+
+2016-11-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #20495]
+ [BZ #20508]
+ * sysdeps/x86/cpu-features.c (init_cpu_features): For Intel
+ processors, set Use_dl_runtime_resolve_slow and set
+ Use_dl_runtime_resolve_opt if XGETBV suports ECX == 1.
+ * sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
+ New.
+ (bit_arch_Use_dl_runtime_resolve_slow): Likewise.
+ (index_arch_Use_dl_runtime_resolve_opt): Likewise.
+ (index_arch_Use_dl_runtime_resolve_slow): Likewise.
+ * sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup): Use
+ _dl_runtime_resolve_avx512_opt and _dl_runtime_resolve_avx_opt
+ if Use_dl_runtime_resolve_opt is set. Use
+ _dl_runtime_resolve_slow if Use_dl_runtime_resolve_slow is set.
+ * sysdeps/x86_64/dl-trampoline.S: Include <cpu-features.h>.
+ (_dl_runtime_resolve_opt): New. Defined for AVX and AVX512.
+ (_dl_runtime_resolve): Add one for _dl_runtime_resolve_sse_vex.
+ * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx_slow):
+ New.
+ (_dl_runtime_resolve_opt): Likewise.
+ (_dl_runtime_profile): Define only if _dl_runtime_profile is
+ defined.
+
+2016-11-24 Aurelien Jarno <aurelien@aurel32.net>
+
+ * sysdeps/x86_64/memcpy_chk.S (__memcpy_chk): Check for SHARED
+ instead of PIC.
+
+2016-11-23 Matthew Fortune <Matthew.Fortune@imgtec.com>
+ Maciej W. Rozycki <macro@imgtec.com>
+
+ * sysdeps/mips/mips32/crti.S (_init): Add `.insn' pseudo-op at
+ `.Lno_weak_fn' label.
+ * sysdeps/mips/mips64/n32/crti.S (_init): Likewise.
+ * sysdeps/mips/mips64/n64/crti.S (_init): Likewise.
+
+2016-11-22 Adhemerval Zanella <adhemerva.zanella@linaro.org>
+
+ [BZ #20847]
+ * posix/execvpe.c (maybe_script_execute): Remove write past allocated
+ array bounds.
+ (__execvpe): Likewise.
+
+2016-11-15 Denis Kaganovich <mahatma@eu.by>
+ Magnus Granberg <zorry@gentoo.org>
+ Mike Frysinger <vapier@gentoo.org>
+
+ [BZ #20662]
+ * configure.ac (libc_cv_predef_stack_protector): Also check for
+ __stack_chk_fail_local symbols.
+ * configure: Regenerated.
+
+2016-11-03 Joseph Myers <joseph@codesourcery.com>
+
+ * conform/Makefile ($(linknamespace-header-tests)): Also depend on
+ $(linknamespace-symlists-tests).
+
+2016-11-06 Aurelien Jarno <aurelien@aurel32.net>
+
+ * iconv/gconv.h (__gconv_info): Define __data element using a
+ zero-length array.
+
+2016-10-25 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/powerpc/powerpc32/power6/memset.S (memset): Use cmplwi
+ instead of cmpli.
+ * sysdeps/powerpc/powerpc64/power6/memset.S (memset): Use cmpldi
+ instead of cmpli.
+
+2016-10-24 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ * sysdeps/unix/sysv/linux/pread.c (__libc_pread): Use SYSCALL_LL_PRW.
+ * sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise.
+ * sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Use
+ SYSCALL_LL64_PRW.
+ * sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Likewise.
+ * sysdeps/unix/sysv/linux/sh/kernel-features.h: Define
+ __ASSUME_PRW_DUMMY_ARG.
+ * sysdeps/unix/sysv/linux/sh/pread.c: Remove file.
+ * sysdeps/unix/sysv/linux/sh/pread64.c: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise.
+ * sysdeps/unix/sysv/linux/sysdep.h: Define SYSCALL_LL_PRW and
+ SYSCALL_LL_PRW64 based on __ASSUME_PRW_DUMMY_ARG.
+
+2016-10-05 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
+
+ * sysdeps/powerpc/fpu/libm-test-ulps: Regenerated.
+
+2016-09-20 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ * sysdeps/unix/sysv/linux/spawni.c (__spawnix): Correctly block and unblock
+ all signals when executing the clone vfork child.
+ (SIGALL_SET): Remove macro.
+
+ * nptl/Makefile (tests): Add tst-exec5.
+ * nptl/tst-exec5.c: New file.
+ * sysdeps/unix/sysv/linux/spawni.c (__spawni): Correctly enable and disable
+ asynchronous cancellation.
+
+2016-09-19 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
+
+ [BZ #20615]
+ * sysdeps/powerpc/powerpc32/power9/multiarch/Implies: Replace
+ fpu directory by non-fpu.
+ * sysdeps/powerpc/powerpc64/power9/fpu/Implies: Remove dependency
+ on non-fpu directory from a fpu directory.
+
+2016-09-02 Roland McGrath <roland@hack.frob.com>
+
+ * sysdeps/arm/nacl/libc.abilist: Add GLIBC_2.24 A.
+
+ * sysdeps/nacl/dup.c: Add libc_hidden_def.
+
+2016-09-02 Roland McGrath <roland@hack.frob.com>
+
+ * sysdeps/posix/wait3.c: Don't treat STAT_LOC as a union, since it's
+ not any more.
+
+2016-09-02 Roland McGrath <roland@hack.frob.com>
+
+ * sysdeps/nacl/clock.c (clock): nacl_abi_clock_t -> nacl_irt_clock_t
+
+2016-08-17 Florian Weimer <fweimer@redhat.com>
+
+ Reduce time to expected nptl/tst-once5 failure.
+ * nptl/tst-once5.cc (TIMEOUT): Define.
+
+2016-08-18 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #16907]
+ * argp/argp.h: Switch to __BEGIN_DECLS and __END_DECLS.
+ (__THROW, __NTH, __attribute__, __restrict): Remove definitions.
+ * argp/argp-fmtstream.h: Add __BEGIN_DECLS and __END_DECLS.
+ (__attribute__): Remove definition.
+
+2016-08-15 Andreas Schwab <schwab@suse.de>
+
+ [BZ #20435]
+ * sysdeps/unix/sysv/linux/arm/setcontext.S (__startcontext): Mark
+ as .cantunwind.
+
+2016-08-17 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #20452]
+ Avoid additional copies of objects in libc.a in static libraries.
+ * sysdeps/ia64/nptl/Makefile (libpthread-shared-only-routines):
+ Add ptw-sysdep, ptw-sigblock, ptw-sigprocmask.
+ * sysdeps/mips/Makefile (librt-shared-only-routines): Add
+ rt-sysdep.
+ * sysdeps/mips/nptl/Makefile (libpthread-shared-only-routines):
+ Add nptl-sysdep.
+ * sysdeps/s390/nptl/Makefile (libpthread-shared-only-routines):
+ Add ptw-sysdep.
+ * sysdeps/unix/alpha/Makefile (librt-shared-only-routines): Add
+ rt-sysdep.
+ * sysdeps/unix/sysv/linux/alpha/Makefile
+ (libpthread-shared-only-routines): Add ptw-sysdep,
+ ptw-sigprocmask, ptw-rt_sigaction.
+ * sysdeps/unix/sysv/linux/ia64/Makefile
+ (librt-shared-only-routines): Add rt-sysdep.
+ * sysdeps/unix/sysv/linux/i386/Makefile
+ (libpthread-shared-only-routines): Add libc-do-syscall.
+ * sysdeps/unix/sysv/linux/microblaze/Makefile
+ (libpthread-shared-only-routines): Add sysdep.
+ * sysdeps/unix/sysv/linux/powerpc/Makefile
+ (librt-shared-only-routines): Add rt-sysdep.
+ (libpthread-shared-only-routines): Add sysdep.
+ * sysdeps/unix/sysv/linux/s390/Makefile
+ (librt-shared-only-routines): Add rt-sysdep.
+ * sysdeps/unix/sysv/linux/sparc/Makefile
+ (librt-shared-only-routines): Add rt-sysdep.
+ (libpthread-shared-only-routines): Add sysdep.
+ * sysdeps/unix/sysv/linux/tile/Makefile
+ (libpthread-shared-only-routines): Likewise.
+
+2016-08-05 Aurelien Jarno <aurelien@aurel32.net>
+
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
+ [$(subdir) = math && $(have-as-vis3) = yes] (libm-sysdep_routines):
+ Remove s_fdimf-vis3, s_fdim-vis3.
+ * sysdeps/sparc/sparc32/fpu/s_fdim.S: Delete file.
+ * sysdeps/sparc/sparc32/fpu/s_fdimf.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf-vis3.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/s_fdim.S: Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/s_fdimf.S: Likewise.
+ * sysdeps/sparc/sparc64/fpu/s_fdim.S: Likewise.
+ * sysdeps/sparc/sparc64/fpu/s_fdimf.S: Likewise.
+
+2016-08-02 David S. Miller <davem@davemloft.net>
+
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
+ (__nearbyint_vis3): Don't check for sNaN before float register is
+ loaded with the incoming argument.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
+ (__nearbyintf_vis3): Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S (__nearbyint):
+ Likewise.
+ * sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S (__nearbyintf):
+ Likewise.
+
+2016-08-03 Aurelien Jarno <aurelien@aurel32.net>
+
+ * sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Replace beqlr instructions
+ by beq instructions jumping to the end of the function.
+ * sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Add "11", "12", "cr0" to the
+ clobber list. Use "i" constraint instead of "X".
+ (ifunc_one): Add "12" to the clobber list. Use "i" constraint instead
+ of "X".
+
+2016-08-04 Carlos O'Donell <carlos@redhat.com>
+
+ * po/de.po: Update from Translation Project.
+ * po/fi.po: Likewise.
+ * po/sv.po: Likewise.
+
+2016-08-02 Florian Weimer <fweimer@redhat.com>
+
+ [BZ #20370]
+ * malloc/arena.c (get_free_list): Update comment. Assert that
+ arenas on the free list have no attached threads.
+ (remove_from_free_list): New function.
+ (reused_arena): Call it.
+
+2016-08-04 Florian Weimer <fweimer@redhat.com>
+
+ Use sysdep.o from libc.a in static libraries.
+ * sysdeps/unix/sysv/linux/i386/Makefile
+ (libpthread-shared-only-routines): Add sysdep.
+ (librt-shared-only-routines): Likewise.
+
2016-08-01 Carlos O'Donell <carlos@redhat.com>
* version.h (RELEASE): Set to "stable"
diff --git a/Makeconfig b/Makeconfig
index 03fd89c13e..ee379f5852 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -394,6 +394,9 @@ ifndef after-link
after-link =
endif
+# Additional libraries to link into every test.
+link-extra-libs-tests = $(libsupport)
+
# Command for linking PIE programs with the C library.
ifndef +link-pie
+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
@@ -503,7 +506,7 @@ link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib)
link-libc-tests = $(link-libc-tests-rpath-link) \
$(link-libc-before-gnulib) $(gnulib-tests)
# This is how to find at build-time things that will be installed there.
-rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec
+rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec support
rpath-link = \
$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
else
@@ -850,7 +853,7 @@ libio-include = -I$(..)libio
# List of non-library modules that we build.
built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
libSegFault libpcprofile librpcsvc locale-programs \
- memusagestat nonlib nscd extramodules libnldbl
+ memusagestat nonlib nscd extramodules libnldbl libsupport
in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
$(libof-$(<F)) \
@@ -1089,6 +1092,12 @@ libm = $(common-objpfx)math/libm.a
libmvec = $(common-objpfx)mathvec/libmvec.a
endif
+ifeq ($(build-shared),yes)
+libsupport = $(common-objpfx)support/libsupport_nonshared.a
+else
+libsupport = $(common-objpfx)support/libsupport.a
+endif
+
# These are the subdirectories containing the library source. The order
# is more or less arbitrary. The sorting step will take care of the
# dependencies.
@@ -1096,7 +1105,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
stdlib stdio-common libio malloc string wcsmbs time dirent \
grp pwd posix io termios resource misc socket sysvipc gmon \
gnulib iconv iconvdata wctype manual shadow gshadow po argp \
- crypt localedata timezone rt conform debug mathvec \
+ crypt localedata timezone rt conform debug mathvec support \
$(add-on-subdirs) dlfcn elf
ifndef avoid-generated
diff --git a/NEWS b/NEWS
index b0447e7169..9a9e487ee6 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,34 @@ See the end for copying conditions.
Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
using `glibc' in the "product" field.
+Version 2.24.1
+
+Security related changes:
+
+* On ARM EABI (32-bit), generating a backtrace for execution contexts which
+ have been created with makecontext could fail to terminate due to a
+ missing .cantunwind annotation. This has been observed to lead to a hang
+ (denial of service) in some Go applications compiled with gccgo. Reported
+ by Andreas Schwab. (CVE-2016-6323)
+
+* The DNS stub resolver functions would crash due to a NULL pointer
+ dereference when processing a query with a valid DNS question type which
+ was used internally in the implementation. The stub resolver now uses a
+ question type which is outside the range of valid question type values.
+ (CVE-2015-5180)
+
+The following bugs are resolved with this release:
+
+ [20790] Fix rpcgen buffer overrun
+ [20978] Fix strlen on null pointer in nss_nisplus
+ [21209] Ignore and remove LD_HWCAP_MASK for AT_SECURE programs
+ [21265] x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve
+ [21289] Fix symbol redirect for fts_set
+ [21386] Assertion in fork for distinct parent PID is incorrect
+ [21609] x86-64: Align the stack in __tls_get_addr
+ [21624] Unsafe alloca allows local attackers to alias stack and heap (CVE-2017-1000366)
+ [21654] nss: Fix invalid cast in group merging
+
Version 2.24
* The minimum Linux kernel version that this version of the GNU C Library
diff --git a/Rules b/Rules
index 8306d36a07..a981965d2b 100644
--- a/Rules
+++ b/Rules
@@ -149,6 +149,7 @@ endif
ifneq "$(strip $(binaries-shared-tests))" ""
$(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
+ $(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-tests)
@@ -156,6 +157,7 @@ endif
ifneq "$(strip $(binaries-pie-tests))" ""
$(addprefix $(objpfx),$(binaries-pie-tests)): %: %.o \
+ $(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-pie-tests)
@@ -177,6 +179,7 @@ endif
ifneq "$(strip $(binaries-static-tests))" ""
$(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
+ $(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc-static-tests))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-static-tests)
diff --git a/argp/argp-fmtstream.h b/argp/argp-fmtstream.h
index bdeaa54dc2..e8c5797f38 100644
--- a/argp/argp-fmtstream.h
+++ b/argp/argp-fmtstream.h
@@ -29,21 +29,6 @@
#include <string.h>
#include <unistd.h>
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \
- defined __STRICT_ANSI__
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
- defined __STRICT_ANSI__
-# define __format__ format
-# define __printf__ printf
-# endif
-#endif
-
#if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)
/* line_wrap_stream is available, so use that. */
#define ARGP_FMTSTREAM_USE_LINEWRAP
@@ -111,6 +96,8 @@ struct argp_fmtstream
typedef struct argp_fmtstream *argp_fmtstream_t;
+__BEGIN_DECLS
+
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
written on it with LMARGIN spaces and limits them to RMARGIN columns
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
@@ -297,6 +284,8 @@ __argp_fmtstream_point (argp_fmtstream_t __fs)
#endif /* __OPTIMIZE__ */
+__END_DECLS
+
#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
#endif /* argp-fmtstream.h */
diff --git a/argp/argp.h b/argp/argp.h
index e67bbef739..7cb5a69f08 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -28,48 +28,12 @@
#define __need_error_t
#include <errno.h>
-#ifndef __THROW
-# define __THROW
-#endif
-#ifndef __NTH
-# define __NTH(fct) fct __THROW
-#endif
-
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \
- defined __STRICT_ANSI__
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
- defined __STRICT_ANSI__
-# define __format__ format
-# define __printf__ printf
-# endif
-#endif
-
-/* GCC 2.95 and later have "__restrict"; C99 compilers have
- "restrict", and "configure" may have defined "restrict". */
-#ifndef __restrict
-# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
-# if defined restrict || 199901L <= __STDC_VERSION__
-# define __restrict restrict
-# else
-# define __restrict
-# endif
-# endif
-#endif
-
#ifndef __error_t_defined
typedef int error_t;
# define __error_t_defined
#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
/* A description of a particular option. A pointer to an array of
these is passed in the OPTIONS field of an argp structure. Each option
@@ -590,8 +554,6 @@ __NTH (__option_is_end (const struct argp_option *__opt))
# endif
#endif /* Use extern inlines. */
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
#endif /* argp.h */
diff --git a/configure b/configure
index 17625e1041..9b5a486048 100755
--- a/configure
+++ b/configure
@@ -6289,12 +6289,14 @@ echo >&5 "libc_undefs='$libc_undefs'"
# symbols (resolved by the linker), so filter out unknown symbols.
# This will fail to produce the correct result if the compiler
# defaults to -fstack-protector but this produces an undefined symbol
-# other than __stack_chk_fail. However, compilers like that have not
-# been encountered in practice.
-libc_undefs=`echo "$libc_undefs" | egrep '^(foobar|__stack_chk_fail)$'`
+# other than __stack_chk_fail or __stack_chk_fail_local. However,
+# compilers like that have not been encountered in practice.
+libc_undefs=`echo "$libc_undefs" | \
+ egrep '^(foobar|__stack_chk_fail|__stack_chk_fail_local)$'`
case "$libc_undefs" in
foobar) libc_cv_predef_stack_protector=no ;;
'__stack_chk_fail
+foobar'|'__stack_chk_fail_local
foobar') libc_cv_predef_stack_protector=yes ;;
*) as_fn_error $? "unexpected symbols in test: $libc_undefs" "$LINENO" 5 ;;
esac
diff --git a/configure.ac b/configure.ac
index 33bcd62180..8277d9f727 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1626,12 +1626,14 @@ echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
# symbols (resolved by the linker), so filter out unknown symbols.
# This will fail to produce the correct result if the compiler
# defaults to -fstack-protector but this produces an undefined symbol
-# other than __stack_chk_fail. However, compilers like that have not
-# been encountered in practice.
-libc_undefs=`echo "$libc_undefs" | egrep '^(foobar|__stack_chk_fail)$'`
+# other than __stack_chk_fail or __stack_chk_fail_local. However,
+# compilers like that have not been encountered in practice.
+libc_undefs=`echo "$libc_undefs" | \
+ egrep '^(foobar|__stack_chk_fail|__stack_chk_fail_local)$'`
case "$libc_undefs" in
foobar) libc_cv_predef_stack_protector=no ;;
'__stack_chk_fail
+foobar'|'__stack_chk_fail_local
foobar') libc_cv_predef_stack_protector=yes ;;
*) AC_MSG_ERROR([unexpected symbols in test: $libc_undefs]) ;;
esac],
diff --git a/conform/Makefile b/conform/Makefile
index 32a0937b06..7883624c81 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -196,13 +196,13 @@ $(conformtest-header-tests): $(objpfx)%/conform.out: \
conformtest.pl $(conformtest-headers-data)
(set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
mkdir -p $(@D)/scratch; \
- $(PERL) conformtest.pl --tmpdir=$(@D)/scratch --cc='$(CC)' \
+ $(PERL) -I. conformtest.pl --tmpdir=$(@D)/scratch --cc='$(CC)' \
--flags='$(conformtest-cc-flags)' --standard=$$std \
--headers=$$hdr > $@); \
$(evaluate-test)
$(linknamespace-symlists-tests): $(objpfx)symlist-%: list-header-symbols.pl
- $(PERL) -w $< --tmpdir=$(objpfx) --cc='$(CC)' \
+ $(PERL) -I. -w $< --tmpdir=$(objpfx) --cc='$(CC)' \
--flags='$(conformtest-cc-flags)' --standard=$* \
--headers="$(strip $(conformtest-headers-$*))" \
> $@ 2> $@.err; \
@@ -229,10 +229,11 @@ $(linknamespace-symlist-stdlibs-tests): $(objpfx)symlist-stdlibs-%: \
$(linknamespace-header-tests): $(objpfx)%/linknamespace.out: \
linknamespace.pl \
+ $(linknamespace-symlists-tests) \
$(linknamespace-symlist-stdlibs-tests)
(set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
mkdir -p $(@D)/scratch; \
- $(PERL) -w $< --tmpdir=$(@D)/scratch --cc='$(CC)' \
+ $(PERL) -I. -w $< --tmpdir=$(@D)/scratch --cc='$(CC)' \
--flags='$(conformtest-cc-flags)' --standard=$$std \
--stdsyms=$(objpfx)symlist-$$std --header=$$hdr \
--libsyms=$(objpfx)symlist-stdlibs-$$std \
diff --git a/elf/Makefile b/elf/Makefile
index 593403c640..847a012f84 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -149,7 +149,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
tst-nodelete) \
tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
- tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error
+ tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error \
+ tst-nodelete-dlclose
# reldep9
ifeq ($(build-hardcoded-path-in-tests),yes)
tests += tst-dlopen-aout
@@ -223,7 +224,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
tst-array5dep tst-null-argv-lib \
tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod \
tst-audit11mod1 tst-audit11mod2 tst-auditmod11 \
- tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12
+ tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12 \
+ tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin
ifeq (yes,$(have-mtls-dialect-gnu2))
tests += tst-gnu2-tls1
modules-names += tst-gnu2-tls1mod
@@ -1267,3 +1269,12 @@ $(objpfx)tst-ldconfig-X.out : tst-ldconfig-X.sh $(objpfx)ldconfig
$(evaluate-test)
$(objpfx)tst-dlsym-error: $(libdl)
+
+# The application depends on the DSO, and the DSO loads the plugin.
+# The plugin also depends on the DSO. This creates the circular
+# dependency via dlopen that we're testing to make sure works.
+$(objpfx)tst-nodelete-dlclose-dso.so: $(libdl)
+$(objpfx)tst-nodelete-dlclose-plugin.so: $(objpfx)tst-nodelete-dlclose-dso.so
+$(objpfx)tst-nodelete-dlclose: $(objpfx)tst-nodelete-dlclose-dso.so
+$(objpfx)tst-nodelete-dlclose.out: $(objpfx)tst-nodelete-dlclose-dso.so \
+ $(objpfx)tst-nodelete-dlclose-plugin.so
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 687d7de874..9f93ab7628 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -805,19 +805,37 @@ _dl_close (void *_map)
{
struct link_map *map = _map;
- /* First see whether we can remove the object at all. */
+ /* We must take the lock to examine the contents of map and avoid
+ concurrent dlopens. */
+ __rtld_lock_lock_recursive (GL(dl_load_lock));
+
+ /* At this point we are guaranteed nobody else is touching the list of
+ loaded maps, but a concurrent dlclose might have freed our map
+ before we took the lock. There is no way to detect this (see below)
+ so we proceed assuming this isn't the case. First see whether we
+ can remove the object at all. */
if (__glibc_unlikely (map->l_flags_1 & DF_1_NODELETE))
{
- assert (map->l_init_called);
/* Nope. Do nothing. */
+ __rtld_lock_unlock_recursive (GL(dl_load_lock));
return;
}
+ /* At present this is an unreliable check except in the case where the
+ caller has recursively called dlclose and we are sure the link map
+ has not been freed. In a non-recursive dlclose the map itself
+ might have been freed and this access is potentially a data race
+ with whatever other use this memory might have now, or worse we
+ might silently corrupt memory if it looks enough like a link map.
+ POSIX has language in dlclose that appears to guarantee that this
+ should be a detectable case and given that dlclose should be threadsafe
+ we need this to be a reliable detection.
+ This is bug 20990. */
if (__builtin_expect (map->l_direct_opencount, 1) == 0)
- GLRO(dl_signal_error) (0, map->l_name, NULL, N_("shared object not open"));
-
- /* Acquire the lock. */
- __rtld_lock_lock_recursive (GL(dl_load_lock));
+ {
+ __rtld_lock_unlock_recursive (GL(dl_load_lock));
+ _dl_signal_error (0, map->l_name, NULL, N_("shared object not open"));
+ }
_dl_close_worker (map, false);
diff --git a/elf/rtld.c b/elf/rtld.c
index 647661ca45..8f56d6edd3 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -99,14 +99,121 @@ uintptr_t __pointer_chk_guard_local
strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
#endif
+/* Length limits for names and paths, to protect the dynamic linker,
+ particularly when __libc_enable_secure is active. */
+#ifdef NAME_MAX
+# define SECURE_NAME_LIMIT NAME_MAX
+#else
+# define SECURE_NAME_LIMIT 255
+#endif
+#ifdef PATH_MAX
+# define SECURE_PATH_LIMIT PATH_MAX
+#else
+# define SECURE_PATH_LIMIT 1024
+#endif
+
+/* Check that AT_SECURE=0, or that the passed name does not contain
+ directories and is not overly long. Reject empty names
+ unconditionally. */
+static bool
+dso_name_valid_for_suid (const char *p)
+{
+ if (__glibc_unlikely (__libc_enable_secure))
+ {
+ /* Ignore pathnames with directories for AT_SECURE=1
+ programs, and also skip overlong names. */
+ size_t len = strlen (p);
+ if (len >= SECURE_NAME_LIMIT || memchr (p, '/', len) != NULL)
+ return false;
+ }
+ return *p != '\0';
+}
-/* List of auditing DSOs. */
+/* LD_AUDIT variable contents. Must be processed before the
+ audit_list below. */
+const char *audit_list_string;
+
+/* Cyclic list of auditing DSOs. audit_list->next is the first
+ element. */
static struct audit_list
{
const char *name;
struct audit_list *next;
} *audit_list;
+/* Iterator for audit_list_string followed by audit_list. */
+struct audit_list_iter
+{
+ /* Tail of audit_list_string still needing processing, or NULL. */
+ const char *audit_list_tail;
+
+ /* The list element returned in the previous iteration. NULL before
+ the first element. */
+ struct audit_list *previous;
+
+ /* Scratch buffer for returning a name which is part of
+ audit_list_string. */
+ char fname[SECURE_NAME_LIMIT];
+};
+
+/* Initialize an audit list iterator. */
+static void
+audit_list_iter_init (struct audit_list_iter *iter)
+{
+ iter->audit_list_tail = audit_list_string;
+ iter->previous = NULL;
+}
+
+/* Iterate through both audit_list_string and audit_list. */
+static const char *
+audit_list_iter_next (struct audit_list_iter *iter)
+{
+ if (iter->audit_list_tail != NULL)
+ {
+ /* First iterate over audit_list_string. */
+ while (*iter->audit_list_tail != '\0')
+ {
+ /* Split audit list at colon. */
+ size_t len = strcspn (iter->audit_list_tail, ":");
+ if (len > 0 && len < sizeof (iter->fname))
+ {
+ memcpy (iter->fname, iter->audit_list_tail, len);
+ iter->fname[len] = '\0';
+ }
+ else
+ /* Do not return this name to the caller. */
+ iter->fname[0] = '\0';
+
+ /* Skip over the substring and the following delimiter. */
+ iter->audit_list_tail += len;
+ if (*iter->audit_list_tail == ':')
+ ++iter->audit_list_tail;
+
+ /* If the name is valid, return it. */
+ if (dso_name_valid_for_suid (iter->fname))
+ return iter->fname;
+ /* Otherwise, wrap around and try the next name. */
+ }
+ /* Fall through to the procesing of audit_list. */
+ }
+
+ if (iter->previous == NULL)
+ {
+ if (audit_list == NULL)
+ /* No pre-parsed audit list. */
+ return NULL;
+ /* Start of audit list. The first list element is at
+ audit_list->next (cyclic list). */
+ iter->previous = audit_list->next;
+ return iter->previous->name;
+ }
+ if (iter->previous == audit_list)
+ /* Cyclic list wrap-around. */
+ return NULL;
+ iter->previous = iter->previous->next;
+ return iter->previous->name;
+}
+
#ifndef HAVE_INLINED_SYSCALLS
/* Set nonzero during loading and initialization of executable and
libraries, cleared before the executable's entry point runs. This
@@ -730,6 +837,42 @@ static const char *preloadlist attribute_relro;
/* Nonzero if information about versions has to be printed. */
static int version_info attribute_relro;
+/* The LD_PRELOAD environment variable gives list of libraries
+ separated by white space or colons that are loaded before the
+ executable's dependencies and prepended to the global scope list.
+ (If the binary is running setuid all elements containing a '/' are
+ ignored since it is insecure.) Return the number of preloads
+ performed. */
+unsigned int
+handle_ld_preload (const char *preloadlist, struct link_map *main_map)
+{
+ unsigned int npreloads = 0;
+ const char *p = preloadlist;
+ char fname[SECURE_PATH_LIMIT];
+
+ while (*p != '\0')
+ {
+ /* Split preload list at space/colon. */
+ size_t len = strcspn (p, " :");
+ if (len > 0 && len < sizeof (fname))
+ {
+ memcpy (fname, p, len);
+ fname[len] = '\0';
+ }
+ else
+ fname[0] = '\0';
+
+ /* Skip over the substring and the following delimiter. */
+ p += len;
+ if (*p != '\0')
+ ++p;
+
+ if (dso_name_valid_for_suid (fname))
+ npreloads += do_preload (fname, main_map, "LD_PRELOAD");
+ }
+ return npreloads;
+}
+
static void
dl_main (const ElfW(Phdr) *phdr,
ElfW(Word) phnum,
@@ -1257,11 +1400,13 @@ of this helper program; chances are you did not intend to run this program.\n\
GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid ();
/* If we have auditing DSOs to load, do it now. */
- if (__glibc_unlikely (audit_list != NULL))
+ bool need_security_init = true;
+ if (__glibc_unlikely (audit_list != NULL)
+ || __glibc_unlikely (audit_list_string != NULL))
{
- /* Iterate over all entries in the list. The order is important. */
struct audit_ifaces *last_audit = NULL;
- struct audit_list *al = audit_list->next;
+ struct audit_list_iter al_iter;
+ audit_list_iter_init (&al_iter);
/* Since we start using the auditing DSOs right away we need to
initialize the data structures now. */
@@ -1272,9 +1417,14 @@ of this helper program; chances are you did not intend to run this program.\n\
use different values (especially the pointer guard) and will
fail later on. */
security_init ();
+ need_security_init = false;
- do
+ while (true)
{
+ const char *name = audit_list_iter_next (&al_iter);
+ if (name == NULL)
+ break;
+
int tls_idx = GL(dl_tls_max_dtv_idx);
/* Now it is time to determine the layout of the static TLS
@@ -1283,7 +1433,7 @@ of this helper program; chances are you did not intend to run this program.\n\
no DF_STATIC_TLS bit is set. The reason is that we know
glibc will use the static model. */
struct dlmopen_args dlmargs;
- dlmargs.fname = al->name;
+ dlmargs.fname = name;
dlmargs.map = NULL;
const char *objname;
@@ -1296,7 +1446,7 @@ of this helper program; chances are you did not intend to run this program.\n\
not_loaded:
_dl_error_printf ("\
ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
- al->name, err_str);
+ name, err_str);
if (malloced)
free ((char *) err_str);
}
@@ -1400,10 +1550,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
goto not_loaded;
}
}
-
- al = al->next;
}
- while (al != audit_list->next);
/* If we have any auditing modules, announce that we already
have two objects loaded. */
@@ -1481,23 +1628,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
if (__glibc_unlikely (preloadlist != NULL))
{
- /* The LD_PRELOAD environment variable gives list of libraries
- separated by white space or colons that are loaded before the
- executable's dependencies and prepended to the global scope
- list. If the binary is running setuid all elements
- containing a '/' are ignored since it is insecure. */
- char *list = strdupa (preloadlist);
- char *p;
-
HP_TIMING_NOW (start);
-
- /* Prevent optimizing strsep. Speed is not important here. */
- while ((p = (strsep) (&list, " :")) != NULL)
- if (p[0] != '\0'
- && (__builtin_expect (! __libc_enable_secure, 1)
- || strchr (p, '/') == NULL))
- npreloads += do_preload (p, main_map, "LD_PRELOAD");
-
+ npreloads += handle_ld_preload (preloadlist, main_map);
HP_TIMING_NOW (stop);
HP_TIMING_DIFF (diff, start, stop);
HP_TIMING_ACCUM_NT (load_time, diff);
@@ -1682,7 +1814,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
if (tcbp == NULL)
tcbp = init_tls ();
- if (__glibc_likely (audit_list == NULL))
+ if (__glibc_likely (need_security_init))
/* Initialize security features. But only if we have not done it
earlier. */
security_init ();
@@ -2313,9 +2445,7 @@ process_dl_audit (char *str)
char *p;
while ((p = (strsep) (&str, ":")) != NULL)
- if (p[0] != '\0'
- && (__builtin_expect (! __libc_enable_secure, 1)
- || strchr (p, '/') == NULL))
+ if (dso_name_valid_for_suid (p))
{
/* This is using the local malloc, not the system malloc. The
memory can never be freed. */
@@ -2379,7 +2509,7 @@ process_envvars (enum mode *modep)
break;
}
if (memcmp (envline, "AUDIT", 5) == 0)
- process_dl_audit (&envline[6]);
+ audit_list_string = &envline[6];
break;
case 7:
@@ -2423,7 +2553,8 @@ process_envvars (enum mode *modep)
case 10:
/* Mask for the important hardware capabilities. */
- if (memcmp (envline, "HWCAP_MASK", 10) == 0)
+ if (!__libc_enable_secure
+ && memcmp (envline, "HWCAP_MASK", 10) == 0)
GLRO(dl_hwcap_mask) = __strtoul_internal (&envline[11], NULL,
0, 0);
break;
@@ -2437,7 +2568,8 @@ process_envvars (enum mode *modep)
case 12:
/* The library search path. */
- if (memcmp (envline, "LIBRARY_PATH", 12) == 0)
+ if (!__libc_enable_secure
+ && memcmp (envline, "LIBRARY_PATH", 12) == 0)
{
library_path = &envline[13];
break;
diff --git a/elf/tst-nodelete-dlclose-dso.c b/elf/tst-nodelete-dlclose-dso.c
new file mode 100644
index 0000000000..dd930f99cc
--- /dev/null
+++ b/elf/tst-nodelete-dlclose-dso.c
@@ -0,0 +1,90 @@
+/* Bug 11941: Improper assert map->l_init_called in dlclose.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This is the primary DSO that is loaded by the appliation. This DSO
+ then loads a plugin with RTLD_NODELETE. This plugin depends on this
+ DSO. This dependency chain means that at application shutdown the
+ plugin will be destructed first. Thus by the time this DSO is
+ destructed we will be calling dlclose on an object that has already
+ been destructed. It is allowed to call dlclose in this way and
+ should not assert. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+/* Plugin to load. */
+static void *plugin_lib = NULL;
+/* Plugin function. */
+static void (*plugin_func) (void);
+#define LIB_PLUGIN "tst-nodelete-dlclose-plugin.so"
+
+/* This function is never called but the plugin references it.
+ We do this to avoid any future --as-needed from removing the
+ plugin's DT_NEEDED on this DSO (required for the test). */
+void
+primary_reference (void)
+{
+ printf ("INFO: Called primary_reference function.\n");
+}
+
+void
+primary (void)
+{
+ char *error;
+
+ plugin_lib = dlopen (LIB_PLUGIN, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
+ if (plugin_lib == NULL)
+ {
+ printf ("ERROR: Unable to load plugin library.\n");
+ exit (EXIT_FAILURE);
+ }
+ dlerror ();
+
+ plugin_func = (void (*) (void)) dlsym (plugin_lib, "plugin_func");
+ error = dlerror ();
+ if (error != NULL)
+ {
+ printf ("ERROR: Unable to find symbol with error \"%s\".",
+ error);
+ exit (EXIT_FAILURE);
+ }
+
+ return;
+}
+
+__attribute__ ((destructor))
+static void
+primary_dtor (void)
+{
+ int ret;
+
+ printf ("INFO: Calling primary destructor.\n");
+
+ /* The destructor runs in the test driver also, which
+ hasn't called primary, in that case do nothing. */
+ if (plugin_lib == NULL)
+ return;
+
+ ret = dlclose (plugin_lib);
+ if (ret != 0)
+ {
+ printf ("ERROR: Calling dlclose failed with \"%s\"\n",
+ dlerror ());
+ exit (EXIT_FAILURE);
+ }
+}
diff --git a/elf/tst-nodelete-dlclose-plugin.c b/elf/tst-nodelete-dlclose-plugin.c
new file mode 100644
index 0000000000..8b295c1718
--- /dev/null
+++ b/elf/tst-nodelete-dlclose-plugin.c
@@ -0,0 +1,40 @@
+/* Bug 11941: Improper assert map->l_init_called in dlclose.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This DSO simulates a plugin with a dependency on the
+ primary DSO loaded by the appliation. */
+#include <stdio.h>
+
+extern void primary_reference (void);
+
+void
+plugin_func (void)
+{
+ printf ("INFO: Calling plugin function.\n");
+ /* Need a reference to the DSO to ensure that a potential --as-needed
+ doesn't remove the DT_NEEDED entry which we rely upon to ensure
+ destruction ordering. */
+ primary_reference ();
+}
+
+__attribute__ ((destructor))
+static void
+plugin_dtor (void)
+{
+ printf ("INFO: Calling plugin destructor.\n");
+}
diff --git a/elf/tst-nodelete-dlclose.c b/elf/tst-nodelete-dlclose.c
new file mode 100644
index 0000000000..b3d07e1849
--- /dev/null
+++ b/elf/tst-nodelete-dlclose.c
@@ -0,0 +1,36 @@
+/* Bug 11941: Improper assert map->l_init_called in dlclose.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This simulates an application using the primary DSO which loads the
+ plugin DSO. */
+#include <stdio.h>
+#include <stdlib.h>
+
+extern void primary (void);
+
+static int
+do_test (void)
+{
+ printf ("INFO: Starting application.\n");
+ primary ();
+ printf ("INFO: Exiting application.\n");
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/extra-lib.mk b/extra-lib.mk
index b10748d185..2552049135 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -5,6 +5,9 @@
# The variable $($(lib)-routines) defines the list of modules
# to be included in that library. A sysdep Makefile can add to
# $(lib)-sysdep_routines to include additional modules.
+#
+# Libraries listed in $(extra-libs-noinstall) are built, but not
+# installed.
lib := $(firstword $(extra-libs-left))
extra-libs-left := $(filter-out $(lib),$(extra-libs-left))
@@ -28,7 +31,9 @@ extra-objs := $(extra-objs)
all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
# Add each flavor of library to the lists of things to build and install.
+ifeq (,$(filter $(lib), $(extra-libs-noinstall)))
install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
+endif
extra-objs += $(foreach o,$(filter-out .os .oS,$(object-suffixes-$(lib))),\
$(patsubst %,%$o,$(filter-out \
$($(lib)-shared-only-routines),\
diff --git a/grp/grp-merge.c b/grp/grp-merge.c
index 0a1eb38d2c..5f79755798 100644
--- a/grp/grp-merge.c
+++ b/grp/grp-merge.c
@@ -85,6 +85,14 @@ __copy_grp (const struct group srcgrp, const size_t buflen,
}
members[i] = NULL;
+ /* Align for pointers. We can't simply align C because we need to
+ align destbuf[c]. */
+ if ((((uintptr_t)destbuf + c) & (__alignof__(char **) - 1)) != 0)
+ {
+ uintptr_t mis_align = ((uintptr_t)destbuf + c) & (__alignof__(char **) - 1);
+ c += __alignof__(char **) - mis_align;
+ }
+
/* Copy the pointers from the members array into the buffer and assign them
to the gr_mem member of destgrp. */
destgrp->gr_mem = (char **) &destbuf[c];
@@ -129,7 +137,7 @@ __merge_grp (struct group *savedgrp, char *savedbuf, char *savedend,
/* Get the count of group members from the last sizeof (size_t) bytes in the
mergegrp buffer. */
- savedmemcount = (size_t) *(savedend - sizeof (size_t));
+ savedmemcount = *(size_t *) (savedend - sizeof (size_t));
/* Get the count of new members to add. */
for (memcount = 0; mergegrp->gr_mem[memcount]; memcount++)
@@ -168,6 +176,14 @@ __merge_grp (struct group *savedgrp, char *savedbuf, char *savedend,
/* Add the NULL-terminator. */
members[savedmemcount + memcount] = NULL;
+ /* Align for pointers. We can't simply align C because we need to
+ align savedbuf[c]. */
+ if ((((uintptr_t)savedbuf + c) & (__alignof__(char **) - 1)) != 0)
+ {
+ uintptr_t mis_align = ((uintptr_t)savedbuf + c) & (__alignof__(char **) - 1);
+ c += __alignof__(char **) - mis_align;
+ }
+
/* Copy the member array back into the buffer after the member list and free
the member array. */
savedgrp->gr_mem = (char **) &savedbuf[c];
diff --git a/iconv/gconv.h b/iconv/gconv.h
index 8d8ce5813b..a87028047b 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -139,7 +139,7 @@ typedef struct __gconv_info
{
size_t __nsteps;
struct __gconv_step *__steps;
- __extension__ struct __gconv_step_data __data __flexarr;
+ __extension__ struct __gconv_step_data __data[0];
} *__gconv_t;
/* Transliteration using the locale's data. */
diff --git a/include/arpa/nameser_compat.h b/include/arpa/nameser_compat.h
index 2e735ede4c..7c0deed9ae 100644
--- a/include/arpa/nameser_compat.h
+++ b/include/arpa/nameser_compat.h
@@ -1,8 +1,8 @@
#ifndef _ARPA_NAMESER_COMPAT_
#include <resolv/arpa/nameser_compat.h>
-/* Picksome unused number to represent lookups of IPv4 and IPv6 (i.e.,
- T_A and T_AAAA). */
-#define T_UNSPEC 62321
+/* The number is outside the 16-bit RR type range and is used
+ internally by the implementation. */
+#define T_QUERY_A_AND_AAAA 439963904
#endif
diff --git a/io/fts.h b/io/fts.h
index 127a0d2721..b6b45206c8 100644
--- a/io/fts.h
+++ b/io/fts.h
@@ -193,7 +193,7 @@ FTS *__REDIRECT (fts_open, (char * const *, int,
int (*)(const FTSENT **, const FTSENT **)),
fts64_open);
FTSENT *__REDIRECT (fts_read, (FTS *), fts64_read);
-int __REDIRECT (fts_set, (FTS *, FTSENT *, int), fts64_set) __THROW;
+int __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), fts64_set);
# else
# define fts_children fts64_children
# define fts_close fts64_close
diff --git a/localedata/ChangeLog b/localedata/ChangeLog
index 4be8afc110..a7688e3df6 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,3 +1,17 @@
+2017-06-11 Santhosh Thottingal <santhosh.thottingal@gmail.com>
+
+ [BZ #19922]
+ * locales/iso14651_t1_common: Add collation rules for U+07DA to U+07DF.
+
+ [BZ #19919]
+ * locales/iso14651_t1_common: Correct collation of U+0D36 and U+0D37.
+
+2016-12-30 Mike Frysinger <vapier@gentoo.org>
+
+ [BZ #20974]
+ * localedata/bs_BA (LC_MESSAGES): Delete "*." from the end of
+ yesexpr and noexpr.
+
2016-07-07 Aurelien Jarno <aurelien@aurel32.net>
* locales/de_LI (postal_fmt): Fix indentation.
diff --git a/localedata/locales/bs_BA b/localedata/locales/bs_BA
index a47f87eb37..68c2f9471a 100644
--- a/localedata/locales/bs_BA
+++ b/localedata/locales/bs_BA
@@ -148,8 +148,8 @@ copy "en_DK"
END LC_CTYPE
LC_MESSAGES
-yesexpr "<U005E><U005B><U002B><U0031><U0064><U0044><U0079><U0059><U005D><U002A><U002E>"
-noexpr "<U005E><U005B><U002D><U0030><U006E><U004E><U005D><U002A><U002E>"
+yesexpr "<U005E><U005B><U002B><U0031><U0064><U0044><U0079><U0059><U005D>"
+noexpr "<U005E><U005B><U002D><U0030><U006E><U004E><U005D>"
yesstr "<U0064><U0061>"
nostr "<U006E><U0065>"
END LC_MESSAGES
diff --git a/localedata/locales/iso14651_t1_common b/localedata/locales/iso14651_t1_common
index eef75ba65e..0e64f26a12 100644
--- a/localedata/locales/iso14651_t1_common
+++ b/localedata/locales/iso14651_t1_common
@@ -1042,9 +1042,9 @@ collating-element <ml-bh> from "<U0D2D><U0D4D>"
collating-element <ml-m> from "<U0D2E><U0D4D>"
collating-element <ml-y> from "<U0D2F><U0D4D>"
collating-element <ml-v> from "<U0D35><U0D4D>"
-collating-element <ml-s> from "<U0D38><U0D4D>"
collating-element <ml-ss> from "<U0D36><U0D4D>"
collating-element <ml-sh> from "<U0D37><U0D4D>"
+collating-element <ml-s> from "<U0D38><U0D4D>"
collating-element <ml-h> from "<U0D39><U0D4D>"
collating-element <ml-zh> from "<U0D34><U0D4D>"
collating-element <ml-rr> from "<U0D31><U0D4D>"
@@ -1103,8 +1103,8 @@ collating-symbol <ml-rra>
collating-symbol <ml-la>
collating-symbol <ml-lla>
collating-symbol <ml-va>
-collating-symbol <ml-sha>
collating-symbol <ml-ssa>
+collating-symbol <ml-sha>
collating-symbol <ml-sa>
collating-symbol <ml-ha>
collating-symbol <ml-avagrah>
@@ -1126,6 +1126,12 @@ collating-symbol <mlvs-o>
collating-symbol <mlvs-au>
collating-symbol <ml-visarga>
collating-symbol <ml-virama>
+collating-symbol <ml-atomic-chillu-k>
+collating-symbol <ml-atomic-chillu-n>
+collating-symbol <ml-atomic-chillu-nn>
+collating-symbol <ml-atomic-chillu-l>
+collating-symbol <ml-atomic-chillu-ll>
+collating-symbol <ml-atomic-chillu-r>
#
# <BENGALI>
#
@@ -4552,6 +4558,12 @@ collating-symbol <TIB-subA>
<mlvs-o>
<mlvs-au>
<ml-visarga>
+<ml-atomic-chillu-k>
+<ml-atomic-chillu-n>
+<ml-atomic-chillu-nn>
+<ml-atomic-chillu-l>
+<ml-atomic-chillu-ll>
+<ml-atomic-chillu-r>
#
# <BENGALI>
#
@@ -7252,6 +7264,7 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<U0D13> <mlvw-o>;<BAS>;<MIN>;IGNORE
<U0D14> <mlvw-au>;<BAS>;<MIN>;IGNORE
<ml-chillu-k> "<ml-ka><ml-virama>";<BAS>;<MIN>;IGNORE
+<U0D7F> "<ml-ka><ml-virama>";<ml-atomic-chillu-k>;<MIN>;IGNORE
<U0D15> "<ml-ka><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-kh> "<ml-kha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D16> "<ml-kha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
@@ -7280,6 +7293,7 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<ml-dh> "<ml-dha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D22> "<ml-dha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-nn> "<ml-nna><ml-virama>";<BAS>;<MIN>;IGNORE # ണ് = ണ + ് + zwj
+<U0D7A> "<ml-nna><ml-virama>";<ml-atomic-chillu-nn>;<MIN>;IGNORE
<U0D23> "<ml-nna><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ണ = ണ + ് + അ
<ml-th> "<ml-tha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D24> "<ml-tha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
@@ -7290,6 +7304,7 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<ml-ddh> "<ml-ddha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D27> "<ml-ddha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-n> "<ml-na><ml-virama>";<BAS>;<MIN>;IGNORE # ന്= ന + ് + zwj
+<U0D7B> "<ml-na><ml-virama>";<ml-atomic-chillu-n>;<MIN>;IGNORE
<U0D28> "<ml-na><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE #ന = ന + ് + അ
<ml-p> "<ml-pa><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D2A> "<ml-pa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
@@ -7305,20 +7320,23 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<ml-y> "<ml-ya><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D2F> "<ml-ya><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-r> "<ml-ra><ml-virama>";<BAS>;<MIN>;IGNORE # ര = ര + ് + zwj
+<U0D7C> "<ml-ra><ml-virama>";<ml-atomic-chillu-r>;<MIN>;IGNORE
<U0D30> "<ml-ra><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ര = ര + ് + അ
<ml-chillu-l> <ml-la>;<BAS>;<MIN>;IGNORE # ല് = ല + ് + zwj
+<U0D7D> "<ml-la><ml-virama>";<ml-atomic-chillu-l>;<MIN>;IGNORE
<U0D32> "<ml-la><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ല = ല + ് + അ
<ml-v> "<ml-va><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D35> "<ml-va><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-ss> "<ml-ssa><ml-virama>";<BAS>;<MIN>;IGNORE
-<U0D37> "<ml-ssa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
+<U0D36> "<ml-ssa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-sh> "<ml-sha><ml-virama>";<BAS>;<MIN>;IGNORE
-<U0D36> "<ml-sha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
+<U0D37> "<ml-sha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-s> "<ml-sa><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D38> "<ml-sa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-h> "<ml-ha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D39> "<ml-ha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-ll> "<ml-lla><ml-virama>";<BAS>;<MIN>;IGNORE # ള് = ള + ് + zwj
+<U0D7E> "<ml-lla><ml-virama>";<ml-atomic-chillu-ll>;<MIN>;IGNORE
<U0D33> "<ml-lla><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ള = ള + ് + അ
<ml-zh> "<ml-zha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D34> "<ml-zha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
diff --git a/malloc/arena.c b/malloc/arena.c
index 229783f3b7..4e16593d8b 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -702,8 +702,7 @@ _int_new_arena (size_t size)
}
-/* Remove an arena from free_list. The arena may be in use because it
- was attached concurrently to a thread by reused_arena below. */
+/* Remove an arena from free_list. */
static mstate
get_free_list (void)
{
@@ -718,7 +717,8 @@ get_free_list (void)
free_list = result->next_free;
/* The arena will be attached to this thread. */
- ++result->attached_threads;
+ assert (result->attached_threads == 0);
+ result->attached_threads = 1;
detach_arena (replaced_arena);
}
@@ -735,6 +735,26 @@ get_free_list (void)
return result;
}
+/* Remove the arena from the free list (if it is present).
+ free_list_lock must have been acquired by the caller. */
+static void
+remove_from_free_list (mstate arena)
+{
+ mstate *previous = &free_list;
+ for (mstate p = free_list; p != NULL; p = p->next_free)
+ {
+ assert (p->attached_threads == 0);
+ if (p == arena)
+ {
+ /* Remove the requested arena from the list. */
+ *previous = p->next_free;
+ break;
+ }
+ else
+ previous = &p->next_free;
+ }
+}
+
/* Lock and return an arena that can be reused for memory allocation.
Avoid AVOID_ARENA as we have already failed to allocate memory in
it and it is currently locked. */
@@ -782,14 +802,25 @@ reused_arena (mstate avoid_arena)
(void) mutex_lock (&result->mutex);
out:
- /* Attach the arena to the current thread. Note that we may have
- selected an arena which was on free_list. */
+ /* Attach the arena to the current thread. */
{
/* Update the arena thread attachment counters. */
mstate replaced_arena = thread_arena;
(void) mutex_lock (&free_list_lock);
detach_arena (replaced_arena);
+
+ /* We may have picked up an arena on the free list. We need to
+ preserve the invariant that no arena on the free list has a
+ positive attached_threads counter (otherwise,
+ arena_thread_freeres cannot use the counter to determine if the
+ arena needs to be put on the free list). We unconditionally
+ remove the selected arena from the free list. The caller of
+ reused_arena checked the free list and observed it to be empty,
+ so the list is very short. */
+ remove_from_free_list (result);
+
++result->attached_threads;
+
(void) mutex_unlock (&free_list_lock);
}
diff --git a/misc/regexp.c b/misc/regexp.c
index 3b3668272f..b2a2c6e636 100644
--- a/misc/regexp.c
+++ b/misc/regexp.c
@@ -29,14 +29,15 @@
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
-/* Define the variables used for the interface. */
-char *loc1;
-char *loc2;
+/* Define the variables used for the interface. Avoid .symver on common
+ symbol, which just creates a new common symbol, not an alias. */
+char *loc1 __attribute__ ((nocommon));
+char *loc2 __attribute__ ((nocommon));
compat_symbol (libc, loc1, loc1, GLIBC_2_0);
compat_symbol (libc, loc2, loc2, GLIBC_2_0);
/* Although we do not support the use we define this variable as well. */
-char *locs;
+char *locs __attribute__ ((nocommon));
compat_symbol (libc, locs, locs, GLIBC_2_0);
diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c
index 7f698b4e6d..cb5acce01d 100644
--- a/nis/nss_nisplus/nisplus-alias.c
+++ b/nis/nss_nisplus/nisplus-alias.c
@@ -291,7 +291,7 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias,
return status;
}
- if (name != NULL)
+ if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
diff --git a/nptl/Makefile b/nptl/Makefile
index 0d8aadebed..fa925819ca 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -268,7 +268,7 @@ tests = tst-typesizes \
tst-flock1 tst-flock2 \
tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
tst-signal6 tst-signal7 \
- tst-exec1 tst-exec2 tst-exec3 tst-exec4 \
+ tst-exec1 tst-exec2 tst-exec3 tst-exec4 tst-exec5 \
tst-exit1 tst-exit2 tst-exit3 \
tst-stdio1 tst-stdio2 \
tst-stack1 tst-stack2 tst-stack3 tst-stack4 tst-pthread-getattr \
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 6b42b11d5a..7365ca606b 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -440,9 +440,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
SETUP_THREAD_SYSINFO (pd);
#endif
- /* The process ID is also the same as that of the caller. */
- pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
-
/* Don't allow setxid until cloned. */
pd->setxid_futex = -1;
@@ -579,9 +576,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
/* Don't allow setxid until cloned. */
pd->setxid_futex = -1;
- /* The process ID is also the same as that of the caller. */
- pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
-
/* Allocate the DTV for this thread. */
if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
{
@@ -875,9 +869,6 @@ __reclaim_stacks (void)
/* This marks the stack as free. */
curp->tid = 0;
- /* The PID field must be initialized for the new process. */
- curp->pid = self->pid;
-
/* Account for the size of the stack. */
stack_cache_actsize += curp->stackblock_size;
@@ -903,13 +894,6 @@ __reclaim_stacks (void)
}
}
- /* Reset the PIDs in any cached stacks. */
- list_for_each (runp, &stack_cache)
- {
- struct pthread *curp = list_entry (runp, struct pthread, list);
- curp->pid = self->pid;
- }
-
/* Add the stack of all running threads to the cache. */
list_splice (&stack_used, &stack_cache);
@@ -1054,9 +1038,9 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
return 0;
int val;
+ pid_t pid = __getpid ();
INTERNAL_SYSCALL_DECL (err);
- val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
+ val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, t->tid, SIGSETXID);
/* If this failed, it must have had not started yet or else exited. */
if (!INTERNAL_SYSCALL_ERROR_P (val, err))
diff --git a/nptl/descr.h b/nptl/descr.h
index 8e4938deb5..bc92abf010 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -167,8 +167,8 @@ struct pthread
therefore stack) used' flag. */
pid_t tid;
- /* Process ID - thread group ID in kernel speak. */
- pid_t pid;
+ /* Ununsed. */
+ pid_t pid_ununsed;
/* List of robust mutexes the thread is holding. */
#ifdef __PTHREAD_MUTEX_HAVE_PREV
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index bdbdfedcef..48fab50c4e 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -184,18 +184,12 @@ __nptl_set_robust (struct pthread *self)
static void
sigcancel_handler (int sig, siginfo_t *si, void *ctx)
{
- /* Determine the process ID. It might be negative if the thread is
- in the middle of a fork() call. */
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
- if (__glibc_unlikely (pid < 0))
- pid = -pid;
-
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGCANCEL
- || si->si_pid != pid
+ || si->si_pid != __getpid()
|| si->si_code != SI_TKILL)
return;
@@ -243,19 +237,14 @@ struct xid_command *__xidcmd attribute_hidden;
static void
sighandler_setxid (int sig, siginfo_t *si, void *ctx)
{
- /* Determine the process ID. It might be negative if the thread is
- in the middle of a fork() call. */
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
int result;
- if (__glibc_unlikely (pid < 0))
- pid = -pid;
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGSETXID
- || si->si_pid != pid
+ || si->si_pid != __getpid ()
|| si->si_code != SI_TKILL)
return;
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 1419baf988..89d02e1741 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -22,7 +22,7 @@
#include "pthreadP.h"
#include <atomic.h>
#include <sysdep.h>
-
+#include <unistd.h>
int
pthread_cancel (pthread_t th)
@@ -66,19 +66,11 @@ pthread_cancel (pthread_t th)
#ifdef SIGCANCEL
/* The cancellation handler will take care of marking the
thread as canceled. */
- INTERNAL_SYSCALL_DECL (err);
-
- /* One comment: The PID field in the TCB can temporarily be
- changed (in fork). But this must not affect this code
- here. Since this function would have to be called while
- the thread is executing fork, it would have to happen in
- a signal handler. But this is no allowed, pthread_cancel
- is not guaranteed to be async-safe. */
- int val;
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid), pd->tid,
- SIGCANCEL);
+ pid_t pid = getpid ();
+ INTERNAL_SYSCALL_DECL (err);
+ int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, pd->tid,
+ SIGCANCEL);
if (INTERNAL_SYSCALL_ERROR_P (val, err))
result = INTERNAL_SYSCALL_ERRNO (val, err);
#else
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index fb906f0484..32d7484bf8 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -68,7 +68,6 @@ pthread_getattr_np (pthread_t thread_id, pthread_attr_t *attr)
{
/* No stack information available. This must be for the initial
thread. Get the info in some magical way. */
- assert (abs (thread->pid) == thread->tid);
/* Stack size limit. */
struct rlimit rl;
diff --git a/nptl/tst-exec5.c b/nptl/tst-exec5.c
new file mode 100644
index 0000000000..4327d8d41c
--- /dev/null
+++ b/nptl/tst-exec5.c
@@ -0,0 +1,196 @@
+/* Check if posix_spawn does not act as a cancellation entrypoint.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <paths.h>
+#include <pthread.h>
+#include <signal.h>
+#include <spawn.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static pthread_barrier_t b;
+
+static pid_t pid;
+static int pipefd[2];
+
+static void *
+tf (void *arg)
+{
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("error: pthread_barrier_wait failed");
+ exit (1);
+ }
+
+ posix_spawn_file_actions_t a;
+ if (posix_spawn_file_actions_init (&a) != 0)
+ {
+ puts ("error: spawn_file_actions_init failed");
+ exit (1);
+ }
+
+ if (posix_spawn_file_actions_adddup2 (&a, pipefd[1], STDOUT_FILENO) != 0)
+ {
+ puts ("error: spawn_file_actions_adddup2 failed");
+ exit (1);
+ }
+
+ if (posix_spawn_file_actions_addclose (&a, pipefd[0]) != 0)
+ {
+ puts ("error: spawn_file_actions_addclose");
+ exit (1);
+ }
+
+ char *argv[] = { (char *) _PATH_BSHELL, (char *) "-c", (char *) "echo $$",
+ NULL };
+ if (posix_spawn (&pid, _PATH_BSHELL, &a, NULL, argv, NULL) != 0)
+ {
+ puts ("error: spawn failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ /* The test basically pipe a 'echo $$' created by a thread with a
+ cancellation pending. It then checks if the thread is not cancelled,
+ the process is created and if the output is the expected one. */
+
+ if (pipe (pipefd) != 0)
+ {
+ puts ("error: pipe failed");
+ exit (1);
+ }
+
+ /* Not interested in knowing when the pipe is closed. */
+ if (sigignore (SIGPIPE) != 0)
+ {
+ puts ("error: sigignore failed");
+ exit (1);
+ }
+
+ /* To synchronize with the thread. */
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("error: pthread_barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, &tf, NULL) != 0)
+ {
+ puts ("error: pthread_create failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("error: pthread_cancel failed");
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("error: pthread_barrier_wait");
+ exit (1);
+ }
+
+ void *retval;
+ if (pthread_join (th, &retval) != 0)
+ {
+ puts ("error: pthread_join failed\n");
+ }
+ if (retval == PTHREAD_CANCELED)
+ {
+ puts ("error: thread cancelled");
+ exit (1);
+ }
+
+ close (pipefd[1]);
+
+ /* The global 'pid' should be set by thread posix_spawn calling. Check
+ below if it was executed correctly and with expected output. */
+
+ char buf[64];
+ ssize_t n;
+ bool seen_pid = false;
+ while (TEMP_FAILURE_RETRY ((n = read (pipefd[0], buf, sizeof (buf)))) > 0)
+ {
+ /* We only expect to read the PID. */
+ char *endp;
+ long int rpid = strtol (buf, &endp, 10);
+
+ if (*endp != '\n')
+ {
+ printf ("error: didn't parse whole line: \"%s\"\n", buf);
+ exit (1);
+ }
+ if (endp == buf)
+ {
+ puts ("error: read empty line");
+ exit (1);
+ }
+
+ if (rpid != pid)
+ {
+ printf ("error: found \"%s\", expected PID %ld\n", buf,
+ (long int) pid);
+ exit (1);
+ }
+
+ if (seen_pid)
+ {
+ puts ("error: found more than one PID line");
+ exit (1);
+ }
+
+ seen_pid = true;
+ }
+
+ close (pipefd[0]);
+
+ int status;
+ int err = waitpid (pid, &status, 0);
+ if (err != pid)
+ {
+ puts ("errnor: waitpid failed");
+ exit (1);
+ }
+
+ if (!seen_pid)
+ {
+ puts ("error: didn't get PID");
+ exit (1);
+ }
+
+ return 0;
+}
diff --git a/nptl/tst-once5.cc b/nptl/tst-once5.cc
index 978d8271bd..513ac53f6f 100644
--- a/nptl/tst-once5.cc
+++ b/nptl/tst-once5.cc
@@ -75,5 +75,7 @@ do_test (void)
return result;
}
+// The test currently hangs and is XFAILed. Reduce the timeout.
+#define TIMEOUT 1
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
diff --git a/nptl_db/structs.def b/nptl_db/structs.def
index a9b621b126..1cb6a46391 100644
--- a/nptl_db/structs.def
+++ b/nptl_db/structs.def
@@ -48,7 +48,6 @@ DB_STRUCT (pthread)
DB_STRUCT_FIELD (pthread, list)
DB_STRUCT_FIELD (pthread, report_events)
DB_STRUCT_FIELD (pthread, tid)
-DB_STRUCT_FIELD (pthread, pid)
DB_STRUCT_FIELD (pthread, start_routine)
DB_STRUCT_FIELD (pthread, cancelhandling)
DB_STRUCT_FIELD (pthread, schedpolicy)
diff --git a/nptl_db/td_ta_thr_iter.c b/nptl_db/td_ta_thr_iter.c
index a990fed150..9e5059956b 100644
--- a/nptl_db/td_ta_thr_iter.c
+++ b/nptl_db/td_ta_thr_iter.c
@@ -76,48 +76,28 @@ iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback,
if (ps_pdread (ta->ph, addr, copy, ta->ta_sizeof_pthread) != PS_OK)
return TD_ERR;
- /* Verify that this thread's pid field matches the child PID.
- If its pid field is negative, it's about to do a fork or it
- is the sole thread in a fork child. */
- psaddr_t pid;
- err = DB_GET_FIELD_LOCAL (pid, ta, copy, pthread, pid, 0);
- if (err == TD_OK && (pid_t) (uintptr_t) pid < 0)
- {
- if (-(pid_t) (uintptr_t) pid == match_pid)
- /* It is about to do a fork, but is really still the parent PID. */
- pid = (psaddr_t) (uintptr_t) match_pid;
- else
- /* It must be a fork child, whose new PID is in the tid field. */
- err = DB_GET_FIELD_LOCAL (pid, ta, copy, pthread, tid, 0);
- }
+ err = DB_GET_FIELD_LOCAL (schedpolicy, ta, copy, pthread,
+ schedpolicy, 0);
if (err != TD_OK)
break;
+ err = DB_GET_FIELD_LOCAL (schedprio, ta, copy, pthread,
+ schedparam_sched_priority, 0);
+ if (err != TD_OK)
+ break;
+
+ /* Now test whether this thread matches the specified conditions. */
- if ((pid_t) (uintptr_t) pid == match_pid)
+ /* Only if the priority level is as high or higher. */
+ int descr_pri = ((uintptr_t) schedpolicy == SCHED_OTHER
+ ? 0 : (uintptr_t) schedprio);
+ if (descr_pri >= ti_pri)
{
- err = DB_GET_FIELD_LOCAL (schedpolicy, ta, copy, pthread,
- schedpolicy, 0);
- if (err != TD_OK)
- break;
- err = DB_GET_FIELD_LOCAL (schedprio, ta, copy, pthread,
- schedparam_sched_priority, 0);
- if (err != TD_OK)
- break;
-
- /* Now test whether this thread matches the specified conditions. */
-
- /* Only if the priority level is as high or higher. */
- int descr_pri = ((uintptr_t) schedpolicy == SCHED_OTHER
- ? 0 : (uintptr_t) schedprio);
- if (descr_pri >= ti_pri)
- {
- /* Yep, it matches. Call the callback function. */
- td_thrhandle_t th;
- th.th_ta_p = (td_thragent_t *) ta;
- th.th_unique = addr;
- if (callback (&th, cbdata_p) != 0)
- return TD_DBERR;
- }
+ /* Yep, it matches. Call the callback function. */
+ td_thrhandle_t th;
+ th.th_ta_p = (td_thragent_t *) ta;
+ th.th_unique = addr;
+ if (callback (&th, cbdata_p) != 0)
+ return TD_DBERR;
}
/* Get the pointer to the next element. */
diff --git a/nptl_db/td_thr_validate.c b/nptl_db/td_thr_validate.c
index f3c8a7bed6..9b89fecad2 100644
--- a/nptl_db/td_thr_validate.c
+++ b/nptl_db/td_thr_validate.c
@@ -80,28 +80,5 @@ td_thr_validate (const td_thrhandle_t *th)
err = TD_OK;
}
- if (err == TD_OK)
- {
- /* Verify that this is not a stale element in a fork child. */
- pid_t match_pid = ps_getpid (th->th_ta_p->ph);
- psaddr_t pid;
- err = DB_GET_FIELD (pid, th->th_ta_p, th->th_unique, pthread, pid, 0);
- if (err == TD_OK && (pid_t) (uintptr_t) pid < 0)
- {
- /* This was a thread that was about to fork, or it is the new sole
- thread in a fork child. In the latter case, its tid was stored
- via CLONE_CHILD_SETTID and so is already the proper child PID. */
- if (-(pid_t) (uintptr_t) pid == match_pid)
- /* It is about to do a fork, but is really still the parent PID. */
- pid = (psaddr_t) (uintptr_t) match_pid;
- else
- /* It must be a fork child, whose new PID is in the tid field. */
- err = DB_GET_FIELD (pid, th->th_ta_p, th->th_unique,
- pthread, tid, 0);
- }
- if (err == TD_OK && (pid_t) (uintptr_t) pid != match_pid)
- err = TD_NOTHR;
- }
-
return err;
}
diff --git a/po/de.po b/po/de.po
index 1383e8c4a9..ca14c7e386 100644
--- a/po/de.po
+++ b/po/de.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GNU libc 2.22-pre1\n"
"POT-Creation-Date: 2015-07-31 00:10-0400\n"
-"PO-Revision-Date: 2015-08-31 18:30+0200\n"
+"PO-Revision-Date: 2016-04-22 18:44+0200\n"
"Last-Translator: Jochen Hein <jochen@jochen.org>\n"
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
"Language: de\n"
@@ -4479,13 +4479,13 @@ msgstr ""
"%15s Cache ist dauerhaft\n"
"%15s Cache wird gemeinsam verwendet\n"
"%15Zu vorgeschlagene Größe\n"
-"%15Zu Gesamtröße des Data-Pools\n"
+"%15Zu Gesamtgröße des Data-Pools\n"
"%15Zu Benutzter Speicher im Data-Pool\n"
"%15lu Time to Live für positive Einträge in Sekunden\n"
"%15lu Time to Live für negative Einträge in Sekunden\n"
"%15<PRIuMAX> Cache-Hits bei positiven Einträgen\n"
"%15<PRIuMAX> Cache-Hits bei positiven Einträgen\n"
-"%15<PRIuMAX> Cache-Misses bei positiven Einträgen\n"
+"%15<PRIuMAX> Cache-Misses bei positiven Einträgen\n"
"%15<PRIuMAX> Cache-Misses bei negativen Einträgen\n"
"%15lu%% Cache-Hit Verhältnis\n"
"%15zu aktuelle Anzahl der Werte im Cache\n"
diff --git a/po/fi.po b/po/fi.po
index 17cb3e3e1d..8a2ab8358c 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -24,16 +24,16 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: libc 2.21-pre1\n"
+"Project-Id-Version: libc 2.22-pre1\n"
"POT-Creation-Date: 2015-07-31 00:10-0400\n"
-"PO-Revision-Date: 2015-07-28 20:29+0300\n"
+"PO-Revision-Date: 2016-05-26 21:14+0300\n"
"Last-Translator: Lauri Nurmi <lanurmi@iki.fi>\n"
"Language-Team: Finnish <translation-team-fi@lists.sourceforge.net>\n"
"Language: fi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.8.3\n"
+"X-Generator: Poedit 1.8.7\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: argp/argp-help.c:227
@@ -126,7 +126,7 @@ msgid "%s%s%s:%u: %s%sUnexpected error: %s.\n"
msgstr "%s%s%s:%u: %s%sOdottamaton virhe: %s.\n"
#: assert/assert.c:101
-#, fuzzy, c-format
+#, c-format
msgid ""
"%s%s%s:%u: %s%sAssertion `%s' failed.\n"
"%n"
@@ -169,12 +169,12 @@ msgstr ""
#: malloc/memusagestat.c:563 nss/getent.c:973 nss/makedb.c:369
#: posix/getconf.c:486 sunrpc/rpcinfo.c:691
#: sysdeps/unix/sysv/linux/lddlibc4.c:61
-#, fuzzy, c-format
+#, c-format
msgid ""
"For bug reporting instructions, please see:\n"
"%s.\n"
msgstr ""
-"Ohjeet ohjelmistovioista ilmoittamiseen ovat osoitteessa\n"
+"Katso ohjeet vikailmoitusten tekemiseen osoitteesta:\n"
"%s.\n"
#: catgets/gencat.c:245 debug/pcprofiledump.c:225 debug/xtrace.sh:64
@@ -321,9 +321,8 @@ msgstr "Käyttö: xtrace [VALITSIN]... OHJELMA [OHJELMANVALITSIN]...\\n"
#: debug/xtrace.sh:32 elf/sotruss.sh:56 elf/sotruss.sh:67 elf/sotruss.sh:135
#: malloc/memusage.sh:26
-#, fuzzy
msgid "Try \\`%s --help' or \\`%s --usage' for more information.\\n"
-msgstr "Kokeile ”%s --help” tai ”%s --usage” saadaksesi lisää tietoa.\n"
+msgstr "Kokeile ”%s --help” tai ”%s --usage” saadaksesi lisää tietoa.\\n"
#: debug/xtrace.sh:38
#, fuzzy
@@ -594,9 +593,8 @@ msgid "cannot enable executable stack as shared object requires"
msgstr "jaettua objektikahvaa ei voi luoda"
#: elf/dl-load.c:1339
-#, fuzzy
msgid "cannot close file descriptor"
-msgstr "tiedostoa %s ei voi sulkea"
+msgstr "tiedostokahvaa ei voi sulkea"
#: elf/dl-load.c:1568
msgid "file too short"
@@ -796,9 +794,8 @@ msgid "Format to use: new, old or compat (default)"
msgstr "Käytettävä muoto: ”new”, ”old” tai ”compat” (oletus)"
#: elf/ldconfig.c:151
-#, fuzzy
msgid "Ignore auxiliary cache file"
-msgstr "Käytä CACHEa välimuistitiedostona"
+msgstr "Jätä huomiotta apuvälimuistitiedosto"
#: elf/ldconfig.c:159
msgid "Configure Dynamic Linker Run Time Bindings."
@@ -1087,9 +1084,9 @@ msgid "invalid process ID '%s'"
msgstr "virheellinen prosessi-ID ”%s”"
#: elf/pldd.c:120
-#, fuzzy, c-format
+#, c-format
msgid "cannot open %s"
-msgstr "laitetta %s ei voi avata"
+msgstr "tiedostoa %s ei voi avata"
#: elf/pldd.c:152
#, fuzzy, c-format
@@ -1102,24 +1099,24 @@ msgid "cannot prepare reading %s/task"
msgstr "ei voi avata laitetta %s lukutilaan"
#: elf/pldd.c:168
-#, fuzzy, c-format
+#, c-format
msgid "invalid thread ID '%s'"
-msgstr "virheellinen prosessi-ID ”%s”"
+msgstr "virheellinen säie-ID ”%s”"
#: elf/pldd.c:179
-#, fuzzy, c-format
+#, c-format
msgid "cannot attach to process %lu"
-msgstr "tiedostoa ”%s” ei voi avata"
+msgstr "ei voida kiinnittyä prosessiin %lu"
#: elf/pldd.c:294
#, c-format
msgid "cannot get information about process %lu"
-msgstr ""
+msgstr "tietojen saaminen prosessista %lu ei onnistu"
#: elf/pldd.c:307
-#, fuzzy, c-format
+#, c-format
msgid "process %lu is no ELF program"
-msgstr "ohjelma %lu ei ole käytettävissä\n"
+msgstr "prosessi %lu ei ole ELF-ohjelma"
#: elf/readelflib.c:34
#, c-format
@@ -1203,7 +1200,7 @@ msgstr "%s kohde ei saa olla hakemisto\n"
#: elf/sln.c:184
#, c-format
msgid "%s: failed to remove the old destination\n"
-msgstr ""
+msgstr "%s: vanhan kohteen poistaminen epäonnistui\n"
#: elf/sln.c:192
#, c-format
@@ -1237,9 +1234,8 @@ msgid "Mandatory arguments to long options are also mandatory for any correspond
msgstr "Pakolliset argumentit pitkille valitsimille ovat pakollisia kaikille vastaaville lyhyille valitsimille.\\n"
#: elf/sotruss.sh:55
-#, fuzzy
msgid "%s: option requires an argument -- '%s'\\n"
-msgstr "%s: valitsin ”%s” vaatii argumentin\n"
+msgstr "%s: valitsin vaatii argumentin -- ”%c”\\n"
#: elf/sotruss.sh:61
msgid "%s: option is ambiguous; possibilities:"
@@ -1507,7 +1503,6 @@ msgid "unknown iconv() error %d"
msgstr "tuntematon iconv()-virhe %d"
#: iconv/iconv_prog.c:791
-#, fuzzy
msgid ""
"The following list contains all the coded character sets known. This does\n"
"not necessarily mean that all combinations of these names can be used for\n"
@@ -1516,9 +1511,9 @@ msgid ""
"\n"
" "
msgstr ""
-"Seuraavassa listassa ovat kaikki tunnetut koodatut merkistöt. Se ei\n"
+"Seuraavassa listassa ovat kaikki tunnetut koodatut merkistöt. Tämä ei\n"
"kuitenkaan välttämättä tarkoita sitä, että kaikkia näiden nimien\n"
-"yhdistelmiä voidaan käyttää FROM- ja TO-komentoriviparametreina. Yksi\n"
+"yhdistelmiä voisi käyttää FROM- ja TO-komentoriviparametreina. Yksi\n"
"koodattu merkistö voi olla listalla useilla eri nimillä (aliaksilla).\n"
"\n"
" "
@@ -2733,14 +2728,12 @@ msgid "locale.alias file to consult when making archive"
msgstr "Arkistoa luotaessa käytettävä locale.alias-tiedosto"
#: locale/programs/localedef.c:150
-#, fuzzy
msgid "Generate little-endian output"
-msgstr "Tuota little-endian-koodia"
+msgstr "Tuota little-endian-muotoa"
#: locale/programs/localedef.c:152
-#, fuzzy
msgid "Generate big-endian output"
-msgstr "Tuota big-endian-koodia"
+msgstr "Tuota big-endian-muotoa"
#: locale/programs/localedef.c:157
msgid "Compile locale specification"
@@ -4275,10 +4268,9 @@ msgid ""
msgstr ""
#: nscd/nscd.c:635
-#, fuzzy, c-format
-#| msgid "lstat failed"
+#, c-format
msgid "'wait' failed\n"
-msgstr "tiedoston tilan luku epäonnistui"
+msgstr "”wait” epäonnistui\n"
#: nscd/nscd.c:642
#, c-format
@@ -4670,9 +4662,9 @@ msgid "cannot create temporary file"
msgstr "tilapäistä tiedostoa ei voi luoda"
#: nss/makedb.c:304
-#, fuzzy, c-format
+#, c-format
msgid "cannot stat newly created file"
-msgstr "tiedoston ”%s” tilaa ei voi lukea: %s"
+msgstr "juuri luodun tiedoston tilaa ei voi lukea"
#: nss/makedb.c:315
#, c-format
@@ -4680,9 +4672,9 @@ msgid "cannot rename temporary file"
msgstr "tilapäistä tiedostoa ei voi nimetä uudelleen"
#: nss/makedb.c:531 nss/makedb.c:554
-#, fuzzy, c-format
+#, c-format
msgid "cannot create search tree"
-msgstr "hakupolulle ei voi luoda välimuistia"
+msgstr "hakupuuta ei voi luoda"
#: nss/makedb.c:560
msgid "duplicate key"
@@ -4699,9 +4691,9 @@ msgid "failed to write new database file"
msgstr "uuden tietokantatiedoston kirjoittaminen epäonnistui"
#: nss/makedb.c:812
-#, fuzzy, c-format
+#, c-format
msgid "cannot stat database file"
-msgstr "tiedoston ”%s” tilaa ei voi lukea: %s"
+msgstr "tietokantatiedoston tilaa ei voi lukea"
#: nss/makedb.c:817
#, fuzzy, c-format
@@ -4709,9 +4701,9 @@ msgid "cannot map database file"
msgstr "Karttatietokannassa ei ole enempää tietueita"
#: nss/makedb.c:820
-#, fuzzy, c-format
+#, c-format
msgid "file not a database file"
-msgstr "luettaessa profilointidatatiedoston tilaa"
+msgstr "tiedosto ei ole tietokantatiedosto"
#: nss/makedb.c:871
#, fuzzy, c-format
@@ -4726,7 +4718,7 @@ msgstr "Käyttö: %s [-v määrittely] muuttujanimi [polku]\n"
#: posix/getconf.c:403
#, c-format
msgid " %s -a [pathname]\n"
-msgstr ""
+msgstr " %s -a [polku]\n"
#: posix/getconf.c:479
#, c-format
@@ -5094,11 +5086,11 @@ msgstr "Laitetta irrotettu"
#: stdio-common/psiginfo.c:139
msgid "Signal sent by kill()"
-msgstr ""
+msgstr "Signaalin lähetti kill()"
#: stdio-common/psiginfo.c:142
msgid "Signal sent by sigqueue()"
-msgstr ""
+msgstr "Signaalin lähetti sigqueue()"
#: stdio-common/psiginfo.c:145
msgid "Signal generated by the expiration of a timer"
@@ -5114,7 +5106,7 @@ msgstr ""
#: stdio-common/psiginfo.c:157
msgid "Signal sent by tkill()"
-msgstr ""
+msgstr "Signaalin lähetti tkill()"
#: stdio-common/psiginfo.c:162
msgid "Signal generated by the completion of an asynchronous name lookup request"
@@ -5296,9 +5288,8 @@ msgid "Failed (unspecified error)"
msgstr "Epäonnistui (määrittelemätön virhe)"
#: sunrpc/clnt_raw.c:115
-#, fuzzy
msgid "clnt_raw.c: fatal header serialization error"
-msgstr "clnt_raw.c: vakava otsikon serialisointivirhe"
+msgstr "clnt_raw.c: vakava otsikon sarjallistamisvirhe"
#: sunrpc/pm_getmaps.c:77
msgid "pmap_getmaps.c: rpc problem"
@@ -6825,9 +6816,8 @@ msgid "Interrupted by a signal"
msgstr "Signaalin keskeyttämä"
#: sysdeps/posix/gai_strerror-strs.h:17
-#, fuzzy
msgid "Parameter string not correctly encoded"
-msgstr "Parametrimerkkijono on väärin koodattu"
+msgstr "Parametrimerkkijono ei ole koodattu oikein"
#: sysdeps/unix/sysv/linux/i386/readelflib.c:65
#, c-format
diff --git a/po/sv.po b/po/sv.po
index 49d1f23904..e046577b08 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -1,13 +1,17 @@
# GNU libc message catalog for Swedish
-# Copyright © 1996, 1998, 2001, 2002, 2003, 2006, 2008, 2009, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
+# Copyright © 1996, 1998, 2001, 2002, 2003, 2006, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
# This file is distributed under the same license as the glibc package.
-# Jan Djärv <jan.h.d@swipnet.se>, 1996, 1998, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015
+#
+# Jan Djärv <jan.h.d@swipnet.se>, 1996, 1998, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015.
+# Göran Uddeborg <goeran@uddeborg.se>, 2016.
+#
+# $Revision: 1.3 $
msgid ""
msgstr ""
-"Project-Id-Version: libc 2.21-pre1\n"
+"Project-Id-Version: libc 2.22-pre1\n"
"POT-Creation-Date: 2015-07-31 00:10-0400\n"
-"PO-Revision-Date: 2015-01-24 10:35+0100\n"
-"Last-Translator: Jan Djärv <jan.h.d@swipnet.se>\n"
+"PO-Revision-Date: 2016-08-02 17:17+0200\n"
+"Last-Translator: Göran Uddeborg <goeran@uddeborg.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
@@ -48,7 +52,7 @@ msgstr " [FLAGGA...]"
#: argp/argp-help.c:1643
#, c-format
msgid "Try `%s --help' or `%s --usage' for more information.\n"
-msgstr "Försök med \"%s --help\" eller \"%s --usage\" för mer information\n"
+msgstr "Försök med ”%s --help” eller ”%s --usage” för mer information.\n"
#: argp/argp-help.c:1671
#, c-format
@@ -304,11 +308,11 @@ msgstr "Användning: xtrace [FLAGGA]... PROGRAM [PROGRAMFLAGGA}...\\n"
#: debug/xtrace.sh:32 elf/sotruss.sh:56 elf/sotruss.sh:67 elf/sotruss.sh:135
#: malloc/memusage.sh:26
msgid "Try \\`%s --help' or \\`%s --usage' for more information.\\n"
-msgstr "Försök med \\\"%s --help\\\" eller \\\"%s --usage\\\" för mer information\\n"
+msgstr "Försök med ”%s --help” eller ”%s --usage” för mer information\\n"
#: debug/xtrace.sh:38
msgid "%s: option '%s' requires an argument.\\n"
-msgstr "%s: flaggan \\\"%s\\\" kräver ett argument\\n"
+msgstr "%s: flaggan ”%s” kräver ett argument.\\n"
#: debug/xtrace.sh:45
msgid ""
@@ -332,19 +336,17 @@ msgstr ""
" --usage Visa en kort hjälptext\n"
" -V,--version Visa versionsinformation och avsluta\n"
"\n"
-"Obligatoriska argument för långa flaggor är obligatoriska även för\n"
+"Obligatoriska argument för långa flaggor är obligatoriska även för\n"
"motsvarande korta.\n"
#: debug/xtrace.sh:57 elf/ldd.bash.in:55 elf/sotruss.sh:49
#: malloc/memusage.sh:64
msgid "For bug reporting instructions, please see:\\\\n%s.\\\\n"
-msgstr ""
-"För felrapporteringsinstruktioner, se:\\\\n%s.\\\\n\n"
-"Rapportera fel eller synpunkter på översättningen till <tp-sv@listor.tp-sv.se>.\\\\n"
+msgstr "För felrapporteringsinstruktioner, se:\\\\n%s.\\\\nRapportera fel eller synpunkter på översättningen till:\\\\n<tp-sv@listor.tp-sv.se>.\\\\n"
#: debug/xtrace.sh:125
msgid "xtrace: unrecognized option \\`$1'\\n"
-msgstr "xtrace: okänd flagga \"$1\"\\n"
+msgstr "xtrace: okänd flagga ”$1”\\n"
#: debug/xtrace.sh:138
msgid "No program name given\\n"
@@ -353,12 +355,12 @@ msgstr "Inget programnamn givet\\n"
#: debug/xtrace.sh:146
#, sh-format
msgid "executable \\`$program' not found\\n"
-msgstr "program \"$program\" hittades inte\\n"
+msgstr "program ”$program” hittades inte\\n"
#: debug/xtrace.sh:150
#, sh-format
msgid "\\`$program' is no executable\\n"
-msgstr "\"$program\" är inte en körbar binär\\n"
+msgstr "”$program” är inte en körbar binär\\n"
#: dlfcn/dlinfo.c:63
msgid "RTLD_SELF used in code not dynamically loaded"
@@ -396,7 +398,7 @@ msgstr ", OS ABI: %s %d.%d.%d"
#: elf/cache.c:157 elf/ldconfig.c:1340
#, c-format
msgid "Can't open cache file %s\n"
-msgstr "Kan inte öppna cache-fil \"%s\"\n"
+msgstr "Kan inte öppna cache-filen %s\n"
#: elf/cache.c:171
#, c-format
@@ -416,7 +418,7 @@ msgstr "%d bibliotek hittades i cache \"%s\"\n"
#: elf/cache.c:426
#, c-format
msgid "Can't create temporary cache file %s"
-msgstr "Kan inte skapa temporär cache-fil \"%s\""
+msgstr "Kan inte skapa en temporär cache-fil %s"
#: elf/cache.c:434 elf/cache.c:444 elf/cache.c:448 elf/cache.c:453
#, c-format
@@ -829,7 +831,7 @@ msgstr "Kan inte ta status (lstat) på %s"
#: elf/ldconfig.c:609
#, c-format
msgid "Ignored file %s since it is not a regular file."
-msgstr "Ignorerar fil %s eftersom den inte är en vanlig fil"
+msgstr "Ignorerar fil %s eftersom den inte är en vanlig fil."
#: elf/ldconfig.c:618
#, c-format
@@ -951,7 +953,7 @@ msgstr ""
#: elf/ldd.bash.in:80
msgid "ldd: option \\`$1' is ambiguous"
-msgstr "ldd: flaggan \"$1\" är tvetydig"
+msgstr "ldd: flaggan ”$1” är tvetydig"
#: elf/ldd.bash.in:87
msgid "unrecognized option"
@@ -959,7 +961,7 @@ msgstr "okänd flagga"
#: elf/ldd.bash.in:88 elf/ldd.bash.in:125
msgid "Try \\`ldd --help' for more information."
-msgstr "Försök med \"ldd --help\" för mer information"
+msgstr "Försök med \"ldd --help\" för mer information."
#: elf/ldd.bash.in:124
msgid "missing file arguments"
@@ -1028,10 +1030,9 @@ msgid "cannot read object name"
msgstr "kan inte läsa objektnamn"
#: elf/pldd-xx.c:219
-#, fuzzy, c-format
-#| msgid "cannot allocate memory for program header"
+#, c-format
msgid "cannot allocate buffer for object name"
-msgstr "kan inte allokera minne för programhuvud"
+msgstr "kan inte allokera en buffert för objektnamn"
#: elf/pldd.c:64
msgid "List dynamic shared objects loaded into process."
@@ -1212,11 +1213,11 @@ msgstr ""
#: elf/sotruss.sh:46
msgid "Mandatory arguments to long options are also mandatory for any corresponding\\nshort options.\\n"
-msgstr "Obligatoriska respektive valfria argument för långa flaggor är obligatoriska respektive\\nvalfria även för korta.\\n"
+msgstr "Obligatoriska respektive valfria argument för långa flaggor är obligatoriska\\nrespektive valfria även för korta.\\n"
#: elf/sotruss.sh:55
msgid "%s: option requires an argument -- '%s'\\n"
-msgstr "%s: flaggan kräver ett argument -- \\\"%s\\\"\\n"
+msgstr "%s: flaggan kräver ett argument — ”%s”\\n"
#: elf/sotruss.sh:61
msgid "%s: option is ambiguous; possibilities:"
@@ -1240,7 +1241,7 @@ msgstr ""
#: elf/sotruss.sh:134
msgid "%s: unrecognized option '%c%s'\\n"
-msgstr "%s: okänd flagga \\\"%c%s\\\"\\n"
+msgstr "%s: okänd flagga ”%c%s”\\n"
#: elf/sprof.c:77
msgid "Output selection:"
@@ -1260,7 +1261,7 @@ msgstr "generera anropsgraf"
#: elf/sprof.c:89
msgid "Read and display shared object profiling data."
-msgstr "Läs och visa profildata för delat objekt"
+msgstr "Läs och visa profildata för delat objekt."
#: elf/sprof.c:94
msgid "SHOBJ [PROFDATA]"
@@ -1622,7 +1623,7 @@ msgstr "Fel: .netrc kan läsas av andra."
#: inet/ruserpass.c:185
msgid "Remove password or make file unreadable by others."
-msgstr "Ta bort lösenord eller gör filen oläsbar för andra"
+msgstr "Ta bort lösenord eller gör filen oläsbar för andra."
#: inet/ruserpass.c:277
#, c-format
@@ -2182,12 +2183,12 @@ msgstr "Inget namn definierat i teckenuppsättning"
#: locale/programs/ld-ctype.c:479
#, c-format
msgid "character L'\\u%0*x' in class `%s' must be in class `%s'"
-msgstr "tecken L\"\\u%0*x\" i klass \"%s\" måste vara i klass \"%s\""
+msgstr "tecken L'\\u%0*x' i klassen ”%s” måste vara i klassen ”%s”"
#: locale/programs/ld-ctype.c:494
#, c-format
msgid "character L'\\u%0*x' in class `%s' must not be in class `%s'"
-msgstr "tecken L\"\\u%0*x\" i klass \"%s\" får inte vara i klass \"%s\""
+msgstr "tecken L'\\u%0*x' i klassen ”%s” får inte vara i klassen ”%s”"
#: locale/programs/ld-ctype.c:508 locale/programs/ld-ctype.c:566
#, c-format
@@ -2611,7 +2612,7 @@ msgstr "Skriv mer information"
#: locale/programs/locale.c:85
msgid "Get locale-specific information."
-msgstr "Hämta lokalspecifik information"
+msgstr "Hämta lokalspecifik information."
#: locale/programs/locale.c:88
msgid ""
@@ -3022,7 +3023,7 @@ msgstr "felaktig mcheck_status, biblioteket är felaktigt\n"
#: malloc/memusage.sh:32
msgid "%s: option '%s' requires an argument\\n"
-msgstr "%s: flaggan \\\"%s\\\" kräver ett argument\\n"
+msgstr "%s: flaggan ”%s” kräver ett argument\\n"
#: malloc/memusage.sh:38
msgid ""
@@ -3091,11 +3092,11 @@ msgstr ""
#: malloc/memusage.sh:191
msgid "memusage: option \\`${1##*=}' is ambiguous"
-msgstr "memusage: flaggan \"${1##*=}\" är tvetydig"
+msgstr "memusage: flaggan ”${1##*=}” är tvetydig"
#: malloc/memusage.sh:200
msgid "memusage: unrecognized option \\`$1'"
-msgstr "memusage: okänd flagga \"$1\""
+msgstr "memusage: okänd flagga ”$1”"
#: malloc/memusage.sh:213
msgid "No program name given"
@@ -3341,7 +3342,7 @@ msgstr "Kan inte skapa process hos server"
#: nis/nis_error.h:48
msgid "Master server busy, full dump rescheduled."
-msgstr "Huvudserver är upptagen, full dump åter schemalagd"
+msgstr "Huvudserver är upptagen, full dump åter schemalagd."
#: nis/nis_local_names.c:121
#, c-format
@@ -3511,7 +3512,7 @@ msgstr "\t\tRättigheter : "
#: nis/nis_print.c:290
msgid "Linked Object Type : "
-msgstr "Länkad objekttyp: "
+msgstr "Länkad objekttyp : "
#: nis/nis_print.c:292
#, c-format
@@ -3802,15 +3803,14 @@ msgid " (first)"
msgstr " (första)"
#: nscd/cache.c:288
-#, fuzzy, c-format
-#| msgid "cannot stat() file `%s': %s"
+#, c-format
msgid "checking for monitored file `%s': %s"
-msgstr "kan inte ta status på fil \"%s\": %s"
+msgstr "kontrollerar den övervakade filen ”%s”: %s"
#: nscd/cache.c:298
#, c-format
msgid "monitored file `%s` changed (mtime)"
-msgstr ""
+msgstr "den övervakade filen ”%s” ändrades (mtime)"
#: nscd/cache.c:341
#, c-format
@@ -3906,34 +3906,32 @@ msgstr "kan inte få uttag (socket) att acceptera förbindelser: %s"
#: nscd/connections.c:973
#, c-format
msgid "disabled inotify-based monitoring for file `%s': %s"
-msgstr ""
+msgstr "avaktiverade inotify-baserad övervakning för filen ”%s”: %s"
#: nscd/connections.c:977
#, c-format
msgid "monitoring file `%s` (%d)"
-msgstr ""
+msgstr "övervakar filen ”%s” (%d)"
#: nscd/connections.c:990
#, c-format
msgid "disabled inotify-based monitoring for directory `%s': %s"
-msgstr ""
+msgstr "avaktiverade inotify-baserad övervakning av katalogen ”%s”: %s"
#: nscd/connections.c:994
-#, fuzzy, c-format
-#| msgid "Can't open directory %s"
+#, c-format
msgid "monitoring directory `%s` (%d)"
-msgstr "Kan inte öppna katalog %s"
+msgstr "övervakar katalogen ”%s” (%d)"
#: nscd/connections.c:1022
-#, fuzzy, c-format
-#| msgid "register trace file %s for database %s"
+#, c-format
msgid "monitoring file %s for database %s"
-msgstr "registrera spårningsfil %s för databas %s"
+msgstr "övervakar filen %s för databas %s"
#: nscd/connections.c:1032
#, c-format
msgid "stat failed for file `%s'; will try again later: %s"
-msgstr ""
+msgstr "stat misslyckades för filen ”%s”; kommer försöka igen senare: %s"
#: nscd/connections.c:1151
#, c-format
@@ -4032,44 +4030,42 @@ msgstr "handle_request: begäran mottagen (Version = %d)"
#: nscd/connections.c:1963
#, c-format
msgid "ignored inotify event for `%s` (file exists)"
-msgstr ""
+msgstr "ignorerade inotify-händelse för ”%s” (filen finns)"
#: nscd/connections.c:1968
#, c-format
msgid "monitored file `%s` was %s, removing watch"
-msgstr ""
+msgstr "den övervakade filen ”%s” var %s, tar bort vakten"
#: nscd/connections.c:1976 nscd/connections.c:2018
#, c-format
msgid "failed to remove file watch `%s`: %s"
-msgstr ""
+msgstr "misslyckades att ta bort filvakt ”%s”: %s"
#: nscd/connections.c:1991
#, c-format
msgid "monitored file `%s` was written to"
-msgstr ""
+msgstr "den övervakade filen ”%s” skrevs till"
#: nscd/connections.c:2015
#, c-format
msgid "monitored parent directory `%s` was %s, removing watch on `%s`"
-msgstr ""
+msgstr "den övervakade föräldrakatalogen ”%s” var %s, tar bort vakten av ”%s”"
#: nscd/connections.c:2041
#, c-format
msgid "monitored file `%s` was %s, adding watch"
-msgstr ""
+msgstr "den övervakade filen ”%s” var %s, lägger till vakt"
#: nscd/connections.c:2053
-#, fuzzy, c-format
-#| msgid "failed to load shared object `%s'"
+#, c-format
msgid "failed to add file watch `%s`: %s"
-msgstr "misslyckades med att ladda delat objekt \"%s\""
+msgstr "misslyckades med att lägga till filvakt ”%s”: %s"
#: nscd/connections.c:2247 nscd/connections.c:2428
-#, fuzzy, c-format
-#| msgid "disabled inotify after read error %d"
+#, c-format
msgid "disabled inotify-based monitoring after read error %d"
-msgstr "inaktiverade inotify efter läsfel %d"
+msgstr "avaktiverade inotify-baserad övervakning efter läsfel %d"
#: nscd/connections.c:2543
msgid "could not initialize conditional variable"
@@ -4199,7 +4195,7 @@ msgstr "Använd separat cache för varje användare"
#: nscd/nscd.c:122
msgid "Name Service Cache Daemon."
-msgstr "Namntjänst cache-demon"
+msgstr "Cache-demon för namntjänsten."
#: nscd/nscd.c:155 nss/getent.c:1007 nss/makedb.c:206
#, c-format
@@ -4531,11 +4527,11 @@ msgstr "Access Vector Cache (AVC) startad"
#: nscd/selinux.c:368
msgid "Error querying policy for undefined object classes or permissions."
-msgstr "Fel när policy för odefinierade objektklasser eller rättigheter hämtades"
+msgstr "Fel när policy för odefinierade objektklasser eller rättigheter hämtades."
#: nscd/selinux.c:375
msgid "Error getting security class for nscd."
-msgstr "Fel när säkerhetsklass för nscd hämtades"
+msgstr "Fel när säkerhetsklass för nscd hämtades."
#: nscd/selinux.c:380
#, c-format
@@ -4609,7 +4605,7 @@ msgstr "inaktivera DIN-kodning"
#: nss/getent.c:64
msgid "Get entries from administrative database."
-msgstr "Hämta poster från den administrativa databasen"
+msgstr "Hämta poster från den administrativa databasen."
#: nss/getent.c:148 nss/getent.c:477 nss/getent.c:522
#, c-format
@@ -4652,7 +4648,7 @@ msgstr "Genererad rad som inte ingår i iterationen"
#: nss/makedb.c:131
msgid "Create simple database from textual input."
-msgstr "Skapa en enkel databas från textuell indata"
+msgstr "Skapa en enkel databas från textuell indata."
#: nss/makedb.c:134
msgid ""
@@ -5412,7 +5408,7 @@ msgstr "Kan inte ange netid-flaggan utan TIRPC!\n"
#: sunrpc/rpc_main.c:1374
#, c-format
msgid "Cannot use table flags with newstyle!\n"
-msgstr "Kan inte ange tabellflaggor med ny stil\n"
+msgstr "Kan inte ange tabellflaggor med ny stil!\n"
#: sunrpc/rpc_main.c:1393
#, c-format
@@ -7270,18 +7266,9 @@ msgstr "tidszonsförkortning skiljer sig från POSIX-standarden"
#: timezone/zic.c:2789
msgid "too many, or too long, time zone abbreviations"
-msgstr "för många eller för långa tidszonförkortningar"
+msgstr "för många eller för långa tidszonsförkortningar"
#: timezone/zic.c:2829
#, c-format
msgid "%s: Can't create directory %s: %s\n"
msgstr "%s: Kan inte skapa katalog %s: %s\n"
-
-#~ msgid "cannot load any more object with static TLS"
-#~ msgstr "kan inte ladda fler objekt med statiskt TLS"
-
-#~ msgid "%s: no PLTREL found in object %s\n"
-#~ msgstr "%s: hittade inga PLTREL i objekt %s\n"
-
-#~ msgid "cannot create internal descriptors"
-#~ msgstr "kan inte skapa interna deskriptorer"
diff --git a/posix/execvpe.c b/posix/execvpe.c
index d933f9c92a..7cdb06a611 100644
--- a/posix/execvpe.c
+++ b/posix/execvpe.c
@@ -48,12 +48,13 @@ maybe_script_execute (const char *file, char *const argv[], char *const envp[])
}
}
- /* Construct an argument list for the shell. */
+ /* Construct an argument list for the shell. It will contain at minimum 3
+ arguments (current shell, script, and an ending NULL. */
char *new_argv[argc + 1];
new_argv[0] = (char *) _PATH_BSHELL;
new_argv[1] = (char *) file;
if (argc > 1)
- memcpy (new_argv + 2, argv + 1, argc * sizeof(char *));
+ memcpy (new_argv + 2, argv + 1, (argc - 1) * sizeof(char *));
else
new_argv[2] = NULL;
@@ -91,10 +92,11 @@ __execvpe (const char *file, char *const argv[], char *const envp[])
/* Although GLIBC does not enforce NAME_MAX, we set it as the maximum
size to avoid unbounded stack allocation. Same applies for
PATH_MAX. */
- size_t file_len = __strnlen (file, NAME_MAX + 1);
+ size_t file_len = __strnlen (file, NAME_MAX) + 1;
size_t path_len = __strnlen (path, PATH_MAX - 1) + 1;
- if ((file_len > NAME_MAX)
+ /* NAME_MAX does not include the terminating null character. */
+ if (((file_len-1) > NAME_MAX)
|| !__libc_alloca_cutoff (path_len + file_len + 1))
{
errno = ENAMETOOLONG;
@@ -103,6 +105,9 @@ __execvpe (const char *file, char *const argv[], char *const envp[])
const char *subp;
bool got_eacces = false;
+ /* The resulting string maximum size would be potentially a entry
+ in PATH plus '/' (path_len + 1) and then the the resulting file name
+ plus '\0' (file_len since it already accounts for the '\0'). */
char buffer[path_len + file_len + 1];
for (const char *p = path; ; p = subp)
{
@@ -123,7 +128,7 @@ __execvpe (const char *file, char *const argv[], char *const envp[])
execute. */
char *pend = mempcpy (buffer, p, subp - p);
*pend = '/';
- memcpy (pend + (p < subp), file, file_len + 1);
+ memcpy (pend + (p < subp), file, file_len);
__execve (buffer, argv, envp);
diff --git a/resolv/Makefile b/resolv/Makefile
index 8be41d3ae1..a4c86b9762 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -40,6 +40,9 @@ ifeq ($(have-thread-library),yes)
extra-libs += libanl
routines += gai_sigqueue
tests += tst-res_hconf_reorder
+
+# This test sends millions of packets and is rather slow.
+xtests += tst-resolv-qtypes
endif
extra-libs-others = $(extra-libs)
libresolv-routines := gethnamaddr res_comp res_debug \
@@ -117,3 +120,5 @@ tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace
$(objpfx)mtrace-tst-leaks2.out: $(objpfx)tst-leaks2.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace > $@; \
$(evaluate-test)
+
+$(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library)
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 5f9e35701b..d16fa4b8ed 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -323,7 +323,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
int olderr = errno;
enum nss_status status;
- int n = __libc_res_nsearch (&_res, name, C_IN, T_UNSPEC,
+ int n = __libc_res_nsearch (&_res, name, C_IN, T_QUERY_A_AND_AAAA,
host_buffer.buf->buf, 2048, &host_buffer.ptr,
&ans2p, &nans2p, &resplen2, &ans2p_malloced);
if (n >= 0)
diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c
index 12f9730199..d80b5318e5 100644
--- a/resolv/res_mkquery.c
+++ b/resolv/res_mkquery.c
@@ -103,6 +103,10 @@ res_nmkquery(res_state statp,
int n;
u_char *dnptrs[20], **dpp, **lastdnptr;
+ if (class < 0 || class > 65535
+ || type < 0 || type > 65535)
+ return -1;
+
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_nmkquery(%s, %s, %s, %s)\n",
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 944d1a90f5..07dc6f6583 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -122,7 +122,7 @@ __libc_res_nquery(res_state statp,
int n, use_malloc = 0;
u_int oflags = statp->_flags;
- size_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;
+ size_t bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * QUERYSIZE;
u_char *buf = alloca (bufsize);
u_char *query1 = buf;
int nquery1 = -1;
@@ -137,7 +137,7 @@ __libc_res_nquery(res_state statp,
printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
- if (type == T_UNSPEC)
+ if (type == T_QUERY_A_AND_AAAA)
{
n = res_nmkquery(statp, QUERY, name, class, T_A, NULL, 0, NULL,
query1, bufsize);
@@ -190,7 +190,7 @@ __libc_res_nquery(res_state statp,
if (__builtin_expect (n <= 0, 0) && !use_malloc) {
/* Retry just in case res_nmkquery failed because of too
short buffer. Shouldn't happen. */
- bufsize = (type == T_UNSPEC ? 2 : 1) * MAXPACKET;
+ bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * MAXPACKET;
buf = malloc (bufsize);
if (buf != NULL) {
query1 = buf;
diff --git a/resolv/tst-resolv-qtypes.c b/resolv/tst-resolv-qtypes.c
new file mode 100644
index 0000000000..b3e60c693b
--- /dev/null
+++ b/resolv/tst-resolv-qtypes.c
@@ -0,0 +1,185 @@
+/* Exercise low-level query functions with different QTYPEs.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <resolv.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/check_nss.h>
+#include <support/resolv_test.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+#include <support/xmemstream.h>
+
+/* If ture, the response function will send the actual response packet
+ over TCP instead of UDP. */
+static volatile bool force_tcp;
+
+/* Send back a fake resource record matching the QTYPE. */
+static void
+response (const struct resolv_response_context *ctx,
+ struct resolv_response_builder *b,
+ const char *qname, uint16_t qclass, uint16_t qtype)
+{
+ if (force_tcp && ctx->tcp)
+ {
+ resolv_response_init (b, (struct resolv_response_flags) { .tc = 1 });
+ resolv_response_add_question (b, qname, qclass, qtype);
+ return;
+ }
+
+ resolv_response_init (b, (struct resolv_response_flags) { });
+ resolv_response_add_question (b, qname, qclass, qtype);
+ resolv_response_section (b, ns_s_an);
+ resolv_response_open_record (b, qname, qclass, qtype, 0);
+ resolv_response_add_data (b, &qtype, sizeof (qtype));
+ resolv_response_close_record (b);
+}
+
+static const const char *domain = "www.example.com";
+
+static int
+wrap_res_query (int type, unsigned char *answer, int answer_length)
+{
+ return res_query (domain, C_IN, type, answer, answer_length);
+}
+
+static int
+wrap_res_search (int type, unsigned char *answer, int answer_length)
+{
+ return res_query (domain, C_IN, type, answer, answer_length);
+}
+
+static int
+wrap_res_querydomain (int type, unsigned char *answer, int answer_length)
+{
+ return res_querydomain ("www", "example.com", C_IN, type,
+ answer, answer_length);
+}
+
+static int
+wrap_res_send (int type, unsigned char *answer, int answer_length)
+{
+ unsigned char buf[512];
+ int ret = res_mkquery (QUERY, domain, C_IN, type,
+ (const unsigned char *) "", 0, NULL,
+ buf, sizeof (buf));
+ if (type < 0 || type >= 65536)
+ {
+ /* res_mkquery fails for out-of-range record types. */
+ TEST_VERIFY_EXIT (ret == -1);
+ return -1;
+ }
+ TEST_VERIFY_EXIT (ret > 12); /* DNS header length. */
+ return res_send (buf, ret, answer, answer_length);
+}
+
+static int
+wrap_res_nquery (int type, unsigned char *answer, int answer_length)
+{
+ return res_nquery (&_res, domain, C_IN, type, answer, answer_length);
+}
+
+static int
+wrap_res_nsearch (int type, unsigned char *answer, int answer_length)
+{
+ return res_nquery (&_res, domain, C_IN, type, answer, answer_length);
+}
+
+static int
+wrap_res_nquerydomain (int type, unsigned char *answer, int answer_length)
+{
+ return res_nquerydomain (&_res, "www", "example.com", C_IN, type,
+ answer, answer_length);
+}
+
+static int
+wrap_res_nsend (int type, unsigned char *answer, int answer_length)
+{
+ unsigned char buf[512];
+ int ret = res_nmkquery (&_res, QUERY, domain, C_IN, type,
+ (const unsigned char *) "", 0, NULL,
+ buf, sizeof (buf));
+ if (type < 0 || type >= 65536)
+ {
+ /* res_mkquery fails for out-of-range record types. */
+ TEST_VERIFY_EXIT (ret == -1);
+ return -1;
+ }
+ TEST_VERIFY_EXIT (ret > 12); /* DNS header length. */
+ return res_nsend (&_res, buf, ret, answer, answer_length);
+}
+
+static void
+test_function (const char *fname,
+ int (*func) (int type,
+ unsigned char *answer, int answer_length))
+{
+ unsigned char buf[512];
+ for (int tcp = 0; tcp < 2; ++tcp)
+ {
+ force_tcp = tcp;
+ for (unsigned int type = 1; type <= 65535; ++type)
+ {
+ if (test_verbose)
+ printf ("info: sending QTYPE %d with %s (tcp=%d)\n",
+ type, fname, tcp);
+ int ret = func (type, buf, sizeof (buf));
+ if (ret != 47)
+ FAIL_EXIT1 ("%s tcp=%d qtype=%d return value %d",
+ fname,tcp, type, ret);
+ /* One question, one answer record. */
+ TEST_VERIFY (memcmp (buf + 4, "\0\1\0\1\0\0\0\0", 8) == 0);
+ /* Question section. */
+ static const char qname[] = "\3www\7example\3com";
+ size_t qname_length = sizeof (qname);
+ TEST_VERIFY (memcmp (buf + 12, qname, qname_length) == 0);
+ /* RDATA part of answer. */
+ uint16_t type16 = type;
+ TEST_VERIFY (memcmp (buf + ret - 2, &type16, sizeof (type16)) == 0);
+ }
+ }
+
+ TEST_VERIFY (func (-1, buf, sizeof (buf) == -1));
+ TEST_VERIFY (func (65536, buf, sizeof (buf) == -1));
+}
+
+static int
+do_test (void)
+{
+ struct resolv_redirect_config config =
+ {
+ .response_callback = response,
+ };
+ struct resolv_test *obj = resolv_test_start (config);
+
+ test_function ("res_query", &wrap_res_query);
+ test_function ("res_search", &wrap_res_search);
+ test_function ("res_querydomain", &wrap_res_querydomain);
+ test_function ("res_send", &wrap_res_send);
+
+ test_function ("res_nquery", &wrap_res_nquery);
+ test_function ("res_nsearch", &wrap_res_nsearch);
+ test_function ("res_nquerydomain", &wrap_res_nquerydomain);
+ test_function ("res_nsend", &wrap_res_nsend);
+
+ resolv_test_end (obj);
+ return 0;
+}
+
+#define TIMEOUT 300
+#include <support/test-driver.c>
diff --git a/scripts/backport-support.sh b/scripts/backport-support.sh
new file mode 100644
index 0000000000..2ece7ce575
--- /dev/null
+++ b/scripts/backport-support.sh
@@ -0,0 +1,110 @@
+#!/bin/bash
+# Create a patch which backports the support/ subdirectory.
+# Copyright (C) 2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+# This script does not backport the Makefile tweaks outside the
+# support/ directory (which need to be backported separately), or the
+# changes to test-skeleton.c (which should not be backported).
+
+set -e
+
+export LC_ALL=C
+export GIT_CONFIG=/dev/null
+export GTT_CONFIG_NOSYSTEM=0
+export GIT_PAGER=
+
+usage () {
+ cat >&2 <<EOF
+usage: $0 {patch|commit}
+EOF
+ exit 1
+}
+
+if test $# -ne 1 ; then
+ usage
+fi
+
+command="$1"
+
+case "$command" in
+ patch|commit)
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+# The upstream branch to work on.
+branch=origin/master
+
+# The commit which added the support/ directory.
+initial_commit=c23de0aacbeaa7a091609b35764bed931475a16d
+
+# We backport the support directory and this script. Directories need
+# to end in a /.
+patch_targets="support/ scripts/backport-support.sh"
+
+latest_commit="$(git log --max-count=1 --pretty=format:%H "$branch" -- \
+ $patch_targets)"
+
+# Simplify the branch name somewhat for reporting.
+branch_name="$(echo "$branch" | sed s,^origin/,,)"
+
+command_patch () {
+ cat <<EOF
+This patch creates the contents of the support/ directory up to this
+upstream commit on the $branch_name branch:
+
+EOF
+ git log --max-count=1 "$latest_commit"
+ echo
+ git diff "$initial_commit"^.."$latest_commit" $patch_targets
+ echo "# Before applying the patch, run this command:" >&2
+ echo "# rm -rf $patch_targets" >&2
+}
+
+command_commit () {
+ git status --porcelain | while read line ; do
+ echo "error: working copy is not clean, cannot commit" >&2
+ exit 1
+ done
+ for path in $patch_targets; do
+ echo "# Processing $path" >&2
+ case "$path" in
+ [a-zA-Z0-9]*/)
+ # Directory.
+ git rm --cached --ignore-unmatch -r "$path"
+ rm -rf "$path"
+ git read-tree --prefix="$path" "$latest_commit":"$path"
+ git checkout "$path"
+ ;;
+ *)
+ # File.
+ git show "$latest_commit":"$path" > "$path"
+ git add "$path"
+ esac
+ done
+ git commit -m "Synchronize support/ infrastructure with $branch_name
+
+This commit updates the support/ subdirectory to
+commit $latest_commit
+on the $branch_name branch.
+"
+}
+
+command_$command
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index 789ef423e5..1e91905011 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -96,13 +96,18 @@ rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
extra-objs = $(rpcgen-objs) $(addprefix cross-,$(rpcgen-objs))
others += rpcgen
-tests = tst-xdrmem tst-xdrmem2 test-rpcent
+tests = tst-xdrmem tst-xdrmem2 test-rpcent tst-udp-error
xtests := tst-getmyaddr
ifeq ($(have-thread-library),yes)
xtests += thrsvc
endif
+ifeq ($(run-built-tests),yes)
+rpcgen-tests := $(objpfx)bug20790.out
+tests-special += $(rpcgen-tests)
+endif
+
headers += $(rpcsvc:%.x=rpcsvc/%.h)
extra-libs := librpcsvc
extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
@@ -153,6 +158,7 @@ BUILD_CPPFLAGS += $(sunrpc-CPPFLAGS)
$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
+$(objpfx)tst-udp-error: $(common-objpfx)linkobj/libc.so
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
@@ -225,3 +231,9 @@ endif
endif
$(objpfx)thrsvc: $(common-objpfx)linkobj/libc.so $(shared-thread-library)
+
+ifeq ($(run-built-tests),yes)
+$(rpcgen-tests): $(objpfx)%.out: %.x $(objpfx)rpcgen
+ $(built-program-cmd) -c $< -o $@; \
+ $(evaluate-test)
+endif
diff --git a/sunrpc/bug20790.x b/sunrpc/bug20790.x
new file mode 100644
index 0000000000..a00c9b3830
--- /dev/null
+++ b/sunrpc/bug20790.x
@@ -0,0 +1 @@
+program TPROG { version TVERS { int FUNC(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) = 1; } = 1; } = 1;
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index 4d9acb1e6a..1de25cb771 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -421,9 +421,9 @@ send_again:
cmsg = CMSG_NXTHDR (&msg, cmsg))
if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
{
- free (cbuf);
e = (struct sock_extended_err *) CMSG_DATA(cmsg);
cu->cu_error.re_errno = e->ee_errno;
+ free (cbuf);
return (cu->cu_error.re_status = RPC_CANTRECV);
}
free (cbuf);
diff --git a/sunrpc/rpc_parse.c b/sunrpc/rpc_parse.c
index 1a1df6d8c2..505a6554cf 100644
--- a/sunrpc/rpc_parse.c
+++ b/sunrpc/rpc_parse.c
@@ -521,7 +521,7 @@ static void
get_prog_declaration (declaration * dec, defkind dkind, int num /* arg number */ )
{
token tok;
- char name[10]; /* argument name */
+ char name[MAXLINESIZE]; /* argument name */
if (dkind == DEF_PROGRAM)
{
diff --git a/sunrpc/tst-udp-error.c b/sunrpc/tst-udp-error.c
new file mode 100644
index 0000000000..1efc02f5c6
--- /dev/null
+++ b/sunrpc/tst-udp-error.c
@@ -0,0 +1,62 @@
+/* Check for use-after-free in clntudp_call (bug 21115).
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <netinet/in.h>
+#include <rpc/clnt.h>
+#include <rpc/svc.h>
+#include <support/check.h>
+#include <support/namespace.h>
+#include <support/xsocket.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+ support_become_root ();
+ support_enter_network_namespace ();
+
+ /* Obtain a likely-unused port number. */
+ struct sockaddr_in sin =
+ {
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = htonl (INADDR_LOOPBACK),
+ };
+ {
+ int fd = xsocket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ xbind (fd, (struct sockaddr *) &sin, sizeof (sin));
+ socklen_t sinlen = sizeof (sin);
+ xgetsockname (fd, (struct sockaddr *) &sin, &sinlen);
+ /* Close the socket, so that we will receive an error below. */
+ close (fd);
+ }
+
+ int sock = RPC_ANYSOCK;
+ CLIENT *clnt = clntudp_create
+ (&sin, 1, 2, (struct timeval) { 1, 0 }, &sock);
+ TEST_VERIFY_EXIT (clnt != NULL);
+ TEST_VERIFY (clnt_call (clnt, 3,
+ (xdrproc_t) xdr_void, NULL,
+ (xdrproc_t) xdr_void, NULL,
+ ((struct timeval) { 3, 0 }))
+ == RPC_CANTRECV);
+ clnt_destroy (clnt);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/Makefile b/support/Makefile
new file mode 100644
index 0000000000..20b0343ade
--- /dev/null
+++ b/support/Makefile
@@ -0,0 +1,146 @@
+# Makefile for support library, used only at build and test time
+# Copyright (C) 2016-2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+subdir := support
+
+include ../Makeconfig
+
+extra-libs := libsupport
+extra-libs-others = $(extra-libs)
+extra-libs-noinstall := $(extra-libs)
+
+libsupport-routines = \
+ check \
+ check_addrinfo \
+ check_dns_packet \
+ check_hostent \
+ check_netent \
+ delayed_exit \
+ ignore_stderr \
+ oom_error \
+ resolv_test \
+ set_fortify_handler \
+ support-xstat \
+ support_become_root \
+ support_can_chroot \
+ support_capture_subprocess \
+ support_capture_subprocess_check \
+ support_enter_network_namespace \
+ support_format_address_family \
+ support_format_addrinfo \
+ support_format_dns_packet \
+ support_format_herrno \
+ support_format_hostent \
+ support_format_netent \
+ support_isolate_in_subprocess \
+ support_record_failure \
+ support_run_diff \
+ support_shared_allocate \
+ support_write_file_string \
+ support_test_main \
+ support_test_verify_impl \
+ temp_file \
+ write_message \
+ xaccept \
+ xaccept4 \
+ xasprintf \
+ xbind \
+ xcalloc \
+ xchroot \
+ xclose \
+ xconnect \
+ xdup2 \
+ xfclose \
+ xfopen \
+ xfork \
+ xgetsockname \
+ xlisten \
+ xmalloc \
+ xmemstream \
+ xmkdir \
+ xmmap \
+ xmunmap \
+ xopen \
+ xpipe \
+ xpoll \
+ xpthread_attr_destroy \
+ xpthread_attr_init \
+ xpthread_attr_setdetachstate \
+ xpthread_attr_setstacksize \
+ xpthread_barrier_destroy \
+ xpthread_barrier_init \
+ xpthread_barrier_wait \
+ xpthread_cancel \
+ xpthread_check_return \
+ xpthread_cond_wait \
+ xpthread_create \
+ xpthread_detach \
+ xpthread_join \
+ xpthread_mutex_consistent \
+ xpthread_mutex_destroy \
+ xpthread_mutex_init \
+ xpthread_mutex_lock \
+ xpthread_mutex_unlock \
+ xpthread_mutexattr_destroy \
+ xpthread_mutexattr_init \
+ xpthread_mutexattr_setprotocol \
+ xpthread_mutexattr_setpshared \
+ xpthread_mutexattr_setrobust \
+ xpthread_mutexattr_settype \
+ xpthread_once \
+ xpthread_sigmask \
+ xpthread_spin_lock \
+ xpthread_spin_unlock \
+ xrealloc \
+ xrecvfrom \
+ xsendto \
+ xsetsockopt \
+ xsocket \
+ xstrdup \
+ xwaitpid \
+ xwrite \
+
+libsupport-static-only-routines := $(libsupport-routines)
+# Only build one variant of the library.
+libsupport-inhibit-o := .os
+ifeq ($(build-shared),yes)
+libsupport-inhibit-o += .o
+endif
+
+tests = \
+ README-testing \
+ tst-support-namespace \
+ tst-support_capture_subprocess \
+ tst-support_format_dns_packet \
+ tst-support_record_failure \
+
+ifeq ($(run-built-tests),yes)
+tests-special = \
+ $(objpfx)tst-support_record_failure-2.out
+
+$(objpfx)tst-support_record_failure-2.out: tst-support_record_failure-2.sh \
+ $(objpfx)tst-support_record_failure
+ $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
+ '$(run-program-env)' '$(test-program-prefix-after-env)' \
+ > $@; \
+ $(evaluate-test)
+endif
+
+$(objpfx)tst-support_format_dns_packet: $(common-objpfx)resolv/libresolv.so
+
+include ../Rules
diff --git a/support/README b/support/README
new file mode 100644
index 0000000000..476cfcda59
--- /dev/null
+++ b/support/README
@@ -0,0 +1,29 @@
+This subdirectory contains infrastructure which is not put into
+installed libraries, but may be linked into programs (installed or
+not) and tests.
+
+# Error-checking wrappers
+
+These wrappers test for error return codes an terminate the process on
+error. They are declared in these header files:
+
+* support.h
+* xsignal.h
+* xthread.h
+
+In general, new wrappers should be added to support.h if possible.
+However, support.h must remain fully compatible with C90 and therefore
+cannot include headers which use identifers not reserved in C90. If
+the wrappers need additional types, additional headers such as
+signal.h need to be introduced.
+
+# Test framework
+
+The test framework provides a main program for tests, including a
+timeout for hanging tests. See README-testing.c for a minimal
+example, and test-driver.c for details how to use it. The following
+header files provide related declarations:
+
+* check.h
+* temp_file.h
+* test-driver.h
diff --git a/support/README-testing.c b/support/README-testing.c
new file mode 100644
index 0000000000..9d289c3020
--- /dev/null
+++ b/support/README-testing.c
@@ -0,0 +1,19 @@
+/* This file contains an example test case which shows minimal use of
+ the test framework. Additional testing hooks are described in
+ <support/test-driver.c>. */
+
+/* This function will be called from the test driver. */
+static int
+do_test (void)
+{
+ if (3 == 5)
+ /* Indicate failure. */
+ return 1;
+ else
+ /* Indicate success. */
+ return 0;
+}
+
+/* This file references do_test above and contains the definition of
+ the main function. */
+#include <support/test-driver.c>
diff --git a/support/capture_subprocess.h b/support/capture_subprocess.h
new file mode 100644
index 0000000000..43caf9bce4
--- /dev/null
+++ b/support/capture_subprocess.h
@@ -0,0 +1,61 @@
+/* Capture output from a subprocess.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_CAPTURE_SUBPROCESS_H
+#define SUPPORT_CAPTURE_SUBPROCESS_H
+
+#include <support/xmemstream.h>
+
+struct support_capture_subprocess
+{
+ struct xmemstream out;
+ struct xmemstream err;
+ int status;
+};
+
+/* Invoke CALLBACK (CLOSURE) in a subprocess and capture standard
+ output, standard error, and the exit status. The out.buffer and
+ err.buffer members in the result are null-terminated strings which
+ can be examined by the caller (out.out and err.out are NULL). */
+struct support_capture_subprocess support_capture_subprocess
+ (void (*callback) (void *), void *closure);
+
+/* Deallocate the subprocess data captured by
+ support_capture_subprocess. */
+void support_capture_subprocess_free (struct support_capture_subprocess *);
+
+enum support_capture_allow
+{
+ /* No output is allowed. */
+ sc_allow_none = 0x01,
+ /* Output to stdout is permitted. */
+ sc_allow_stdout = 0x02,
+ /* Output to standard error is permitted. */
+ sc_allow_stderr = 0x04,
+};
+
+/* Check that the subprocess exited with STATUS and that only the
+ allowed outputs happened. ALLOWED is a combination of
+ support_capture_allow flags. Report errors under the CONTEXT
+ message. */
+void support_capture_subprocess_check (struct support_capture_subprocess *,
+ const char *context, int status,
+ int allowed)
+ __attribute__ ((nonnull (1, 2)));
+
+#endif /* SUPPORT_CAPTURE_SUBPROCESS_H */
diff --git a/support/check.c b/support/check.c
new file mode 100644
index 0000000000..592f2bc856
--- /dev/null
+++ b/support/check.c
@@ -0,0 +1,57 @@
+/* Support code for reporting test results.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/test-driver.h>
+
+static void
+print_failure (const char *file, int line, const char *format, va_list ap)
+{
+ printf ("error: %s:%d: ", file, line);
+ vprintf (format, ap);
+ puts ("");
+}
+
+int
+support_print_failure_impl (const char *file, int line,
+ const char *format, ...)
+{
+ support_record_failure ();
+ va_list ap;
+ va_start (ap, format);
+ print_failure (file, line, format, ap);
+ va_end (ap);
+ return 1;
+}
+
+void
+support_exit_failure_impl (int status, const char *file, int line,
+ const char *format, ...)
+{
+ if (status != EXIT_SUCCESS && status != EXIT_UNSUPPORTED)
+ support_record_failure ();
+ va_list ap;
+ va_start (ap, format);
+ print_failure (file, line, format, ap);
+ va_end (ap);
+ exit (status);
+}
diff --git a/support/check.h b/support/check.h
new file mode 100644
index 0000000000..1d244a3557
--- /dev/null
+++ b/support/check.h
@@ -0,0 +1,94 @@
+/* Functionality for reporting test results.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_CHECK_H
+#define SUPPORT_CHECK_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Record a test failure, print the failure message to standard output
+ and return 1. */
+#define FAIL_RET(...) \
+ return support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__)
+
+/* Print the failure message and terminate the process with STATUS.
+ Record a the process as failed if STATUS is neither EXIT_SUCCESS
+ nor EXIT_UNSUPPORTED. */
+#define FAIL_EXIT(status, ...) \
+ support_exit_failure_impl (status, __FILE__, __LINE__, __VA_ARGS__)
+
+/* Record a test failure, print the failure message and terminate with
+ exit status 1. */
+#define FAIL_EXIT1(...) \
+ support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__)
+
+/* Print failure message and terminate with as unsupported test (exit
+ status of 77). */
+#define FAIL_UNSUPPORTED(...) \
+ support_exit_failure_impl (77, __FILE__, __LINE__, __VA_ARGS__)
+
+/* Record a test failure (but continue executing) if EXPR evaluates to
+ false. */
+#define TEST_VERIFY(expr) \
+ ({ \
+ if (expr) \
+ ; \
+ else \
+ support_test_verify_impl (-1, __FILE__, __LINE__, #expr); \
+ })
+
+/* Record a test failure and exit if EXPR evaluates to false. */
+#define TEST_VERIFY_EXIT(expr) \
+ ({ \
+ if (expr) \
+ ; \
+ else \
+ support_test_verify_impl (1, __FILE__, __LINE__, #expr); \
+ })
+
+int support_print_failure_impl (const char *file, int line,
+ const char *format, ...)
+ __attribute__ ((nonnull (1), format (printf, 3, 4)));
+void support_exit_failure_impl (int exit_status,
+ const char *file, int line,
+ const char *format, ...)
+ __attribute__ ((noreturn, nonnull (2), format (printf, 4, 5)));
+void support_test_verify_impl (int status, const char *file, int line,
+ const char *expr);
+
+/* Record a test failure. This function returns and does not
+ terminate the process. The failure counter is stored in a shared
+ memory mapping, so that failures reported in child processes are
+ visible to the parent process and test driver. This function
+ depends on initialization by an ELF constructor, so it can only be
+ invoked after the test driver has run. Note that this function
+ does not support reporting failures from a DSO. */
+void support_record_failure (void);
+
+/* Internal function called by the test driver. */
+int support_report_failure (int status)
+ __attribute__ ((weak, warn_unused_result));
+
+/* Internal function used to test the failure recording framework. */
+void support_record_failure_reset (void);
+
+__END_DECLS
+
+#endif /* SUPPORT_CHECK_H */
diff --git a/support/check_addrinfo.c b/support/check_addrinfo.c
new file mode 100644
index 0000000000..55895ace3c
--- /dev/null
+++ b/support/check_addrinfo.c
@@ -0,0 +1,42 @@
+/* Compare struct addrinfo values against a formatted string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check_nss.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/format_nss.h>
+#include <support/run_diff.h>
+
+void
+check_addrinfo (const char *query_description, struct addrinfo *ai, int ret,
+ const char *expected)
+{
+ char *formatted = support_format_addrinfo (ai, ret);
+ if (strcmp (formatted, expected) != 0)
+ {
+ support_record_failure ();
+ printf ("error: addrinfo comparison failure\n");
+ if (query_description != NULL)
+ printf ("query: %s\n", query_description);
+ support_run_diff ("expected", expected,
+ "actual", formatted);
+ }
+ free (formatted);
+}
diff --git a/support/check_dns_packet.c b/support/check_dns_packet.c
new file mode 100644
index 0000000000..d2a31bed7b
--- /dev/null
+++ b/support/check_dns_packet.c
@@ -0,0 +1,42 @@
+/* Check that a DNS packet buffer has the expected contents.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check_nss.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/format_nss.h>
+#include <support/run_diff.h>
+
+void
+check_dns_packet (const char *query_description,
+ const unsigned char *buffer, size_t length,
+ const char *expected)
+{
+ char *formatted = support_format_dns_packet (buffer, length);
+ if (strcmp (formatted, expected) != 0)
+ {
+ support_record_failure ();
+ printf ("error: packet comparison failure\n");
+ if (query_description != NULL)
+ printf ("query: %s\n", query_description);
+ support_run_diff ("expected", expected, "actual", formatted);
+ }
+ free (formatted);
+}
diff --git a/support/check_hostent.c b/support/check_hostent.c
new file mode 100644
index 0000000000..890d672d50
--- /dev/null
+++ b/support/check_hostent.c
@@ -0,0 +1,42 @@
+/* Compare struct hostent values against a formatted string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check_nss.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/format_nss.h>
+#include <support/run_diff.h>
+
+void
+check_hostent (const char *query_description, struct hostent *h,
+ const char *expected)
+{
+ char *formatted = support_format_hostent (h);
+ if (strcmp (formatted, expected) != 0)
+ {
+ support_record_failure ();
+ printf ("error: hostent comparison failure\n");
+ if (query_description != NULL)
+ printf ("query: %s\n", query_description);
+ support_run_diff ("expected", expected,
+ "actual", formatted);
+ }
+ free (formatted);
+}
diff --git a/support/check_netent.c b/support/check_netent.c
new file mode 100644
index 0000000000..daa3083fd1
--- /dev/null
+++ b/support/check_netent.c
@@ -0,0 +1,42 @@
+/* Compare struct netent values against a formatted string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check_nss.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/format_nss.h>
+#include <support/run_diff.h>
+
+void
+check_netent (const char *query_description, struct netent *e,
+ const char *expected)
+{
+ char *formatted = support_format_netent (e);
+ if (strcmp (formatted, expected) != 0)
+ {
+ support_record_failure ();
+ printf ("error: netent comparison failure\n");
+ if (query_description != NULL)
+ printf ("query: %s\n", query_description);
+ support_run_diff ("expected", expected,
+ "actual", formatted);
+ }
+ free (formatted);
+}
diff --git a/support/check_nss.h b/support/check_nss.h
new file mode 100644
index 0000000000..2893f2c295
--- /dev/null
+++ b/support/check_nss.h
@@ -0,0 +1,42 @@
+/* Test verification functions for NSS- and DNS-related data.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_CHECK_NSS_H
+#define SUPPORT_CHECK_NSS_H
+
+#include <netdb.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Compare the data structures against the expected values (which have
+ to be formatted according to the support_format_* functions in
+ <support/format_nss.h>). If there is a difference, a delayed test
+ failure is recorded, and a diff is written to standard output. */
+void check_addrinfo (const char *query_description,
+ struct addrinfo *, int ret, const char *expected);
+void check_dns_packet (const char *query_description,
+ const unsigned char *, size_t, const char *expected);
+void check_hostent (const char *query_description,
+ struct hostent *, const char *expected);
+void check_netent (const char *query_description,
+ struct netent *, const char *expected);
+
+__END_DECLS
+
+#endif /* SUPPORT_CHECK_NSS_H */
diff --git a/support/delayed_exit.c b/support/delayed_exit.c
new file mode 100644
index 0000000000..67442f95df
--- /dev/null
+++ b/support/delayed_exit.c
@@ -0,0 +1,55 @@
+/* Time-triggered process termination.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+#include <support/xsignal.h>
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <time.h>
+
+static void *
+delayed_exit_thread (void *seconds_as_ptr)
+{
+ int seconds = (uintptr_t) seconds_as_ptr;
+ struct timespec delay = { seconds, 0 };
+ struct timespec remaining = { 0 };
+ if (nanosleep (&delay, &remaining) != 0)
+ FAIL_EXIT1 ("nanosleep: %m");
+ /* Exit the process sucessfully. */
+ exit (0);
+ return NULL;
+}
+
+void
+delayed_exit (int seconds)
+{
+ /* Create the new thread with all signals blocked. */
+ sigset_t all_blocked;
+ sigfillset (&all_blocked);
+ sigset_t old_set;
+ xpthread_sigmask (SIG_SETMASK, &all_blocked, &old_set);
+ /* Create a detached thread. */
+ pthread_t thr = xpthread_create
+ (NULL, delayed_exit_thread, (void *) (uintptr_t) seconds);
+ xpthread_detach (thr);
+ /* Restore the original signal mask. */
+ xpthread_sigmask (SIG_SETMASK, &old_set, NULL);
+}
diff --git a/support/format_nss.h b/support/format_nss.h
new file mode 100644
index 0000000000..fb4597c238
--- /dev/null
+++ b/support/format_nss.h
@@ -0,0 +1,41 @@
+/* String formatting functions for NSS- and DNS-related data.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_FORMAT_NSS_H
+#define SUPPORT_FORMAT_NSS_H
+
+#include <netdb.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* The following functions format their arguments as human-readable
+ strings (which can span multiple lines). The caller must free the
+ returned buffer. For NULL pointers or failure status arguments,
+ error variables such as h_errno and errno are included in the
+ result. */
+char *support_format_address_family (int);
+char *support_format_addrinfo (struct addrinfo *, int ret);
+char *support_format_dns_packet (const unsigned char *buffer, size_t length);
+char *support_format_herrno (int);
+char *support_format_hostent (struct hostent *);
+char *support_format_netent (struct netent *);
+
+__END_DECLS
+
+#endif /* SUPPORT_FORMAT_NSS_H */
diff --git a/support/ignore_stderr.c b/support/ignore_stderr.c
new file mode 100644
index 0000000000..7b77a2cd56
--- /dev/null
+++ b/support/ignore_stderr.c
@@ -0,0 +1,38 @@
+/* Avoid all the buffer overflow messages on stderr.
+ Copyright (C) 2015-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <fcntl.h>
+#include <paths.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void
+ignore_stderr (void)
+{
+ int fd = open (_PATH_DEVNULL, O_WRONLY);
+ if (fd == -1)
+ close (STDERR_FILENO);
+ else
+ {
+ dup2 (fd, STDERR_FILENO);
+ close (fd);
+ }
+ setenv ("LIBC_FATAL_STDERR_", "1", 1);
+}
diff --git a/support/namespace.h b/support/namespace.h
new file mode 100644
index 0000000000..e1ccaa1ef0
--- /dev/null
+++ b/support/namespace.h
@@ -0,0 +1,65 @@
+/* Entering namespaces for test case isolation.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_NAMESPACE_H
+#define SUPPORT_NAMESPACE_H
+
+#include <stdbool.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Attempts to become root (or acquire root-like privileges), possibly
+ with the help of user namespaces. Return true if (restricted) root
+ privileges could be attained in some way. Print diagnostics to
+ standard output.
+
+ Note that this function generally has to be called before a process
+ becomes multi-threaded, otherwise it may fail with insufficient
+ privileges on systems which would support this operation for
+ single-threaded processes. */
+bool support_become_root (void);
+
+/* Return true if this process can perform a chroot operation. In
+ general, this is only possible if support_become_root has been
+ called. Note that the actual test is performed in a subprocess,
+ after fork, so that the file system root of the original process is
+ not changed. */
+bool support_can_chroot (void);
+
+/* Enter a network namespace (and a UTS namespace if possible) and
+ configure the loopback interface. Return true if a network
+ namespace could be created. Print diagnostics to standard output.
+ If a network namespace could be created, but networking in it could
+ not be configured, terminate the process. It is recommended to
+ call support_become_root before this function so that the process
+ has sufficient privileges. */
+bool support_enter_network_namespace (void);
+
+/* Return true if support_enter_network_namespace managed to enter a
+ UTS namespace. */
+bool support_in_uts_namespace (void);
+
+/* Invoke CALLBACK (CLOSURE) in a subprocess created using fork.
+ Terminate the calling process if the subprocess exits with a
+ non-zero exit status. */
+void support_isolate_in_subprocess (void (*callback) (void *), void *closure);
+
+__END_DECLS
+
+#endif
diff --git a/support/oom_error.c b/support/oom_error.c
new file mode 100644
index 0000000000..7816978273
--- /dev/null
+++ b/support/oom_error.c
@@ -0,0 +1,29 @@
+/* Reporting out-of-memory errors.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+oom_error (const char *function, size_t size)
+{
+ printf ("%s: unable to allocate %zu bytes: %m\n", function, size);
+ exit (1);
+}
diff --git a/support/resolv_test.c b/support/resolv_test.c
new file mode 100644
index 0000000000..050cd7154b
--- /dev/null
+++ b/support/resolv_test.c
@@ -0,0 +1,1202 @@
+/* DNS test framework and libresolv redirection.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/resolv_test.h>
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <nss.h>
+#include <resolv.h>
+#include <search.h>
+#include <stdlib.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/namespace.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+#include <support/xsocket.h>
+#include <support/xthread.h>
+#include <support/xunistd.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+/* Response builder. */
+
+enum
+ {
+ max_response_length = 65536
+ };
+
+/* List of pointers to be freed. The hash table implementation
+ (struct hsearch_data) does not provide a way to deallocate all
+ objects, so this approach is used to avoid memory leaks. */
+struct to_be_freed
+{
+ struct to_be_freed *next;
+ void *ptr;
+};
+
+struct resolv_response_builder
+{
+ const unsigned char *query_buffer;
+ size_t query_length;
+
+ size_t offset; /* Bytes written so far in buffer. */
+ ns_sect section; /* Current section in the DNS packet. */
+ unsigned int truncate_bytes; /* Bytes to remove at end of response. */
+ bool drop; /* Discard generated response. */
+ bool close; /* Close TCP client connection. */
+
+ /* Offset of the two-byte RDATA length field in the currently
+ written RDATA sub-structure. 0 if no RDATA is being written. */
+ size_t current_rdata_offset;
+
+ /* Hash table for locating targets for label compression. */
+ struct hsearch_data compression_offsets;
+ /* List of pointers which need to be freed. Used for domain names
+ involved in label compression. */
+ struct to_be_freed *to_be_freed;
+
+ /* Must be last. Not zeroed for performance reasons. */
+ unsigned char buffer[max_response_length];
+};
+
+/* Response builder. */
+
+/* Add a pointer to the list of pointers to be freed when B is
+ deallocated. */
+static void
+response_push_pointer_to_free (struct resolv_response_builder *b, void *ptr)
+{
+ if (ptr == NULL)
+ return;
+ struct to_be_freed *e = xmalloc (sizeof (*e));
+ *e = (struct to_be_freed) {b->to_be_freed, ptr};
+ b->to_be_freed = e;
+}
+
+void
+resolv_response_init (struct resolv_response_builder *b,
+ struct resolv_response_flags flags)
+{
+ if (b->offset > 0)
+ FAIL_EXIT1 ("response_init: called at offset %zu", b->offset);
+ if (b->query_length < 12)
+ FAIL_EXIT1 ("response_init called for a query of size %zu",
+ b->query_length);
+ if (flags.rcode > 15)
+ FAIL_EXIT1 ("response_init: invalid RCODE %u", flags.rcode);
+
+ /* Copy the transaction ID. */
+ b->buffer[0] = b->query_buffer[0];
+ b->buffer[1] = b->query_buffer[1];
+
+ /* Initialize the flags. */
+ b->buffer[2] = 0x80; /* Mark as response. */
+ b->buffer[2] |= b->query_buffer[2] & 0x01; /* Copy the RD bit. */
+ if (flags.tc)
+ b->buffer[2] |= 0x02;
+ b->buffer[3] = 0x80 | flags.rcode; /* Always set RA. */
+
+ /* Fill in the initial section count values. */
+ b->buffer[4] = flags.qdcount >> 8;
+ b->buffer[5] = flags.qdcount;
+ b->buffer[6] = flags.ancount >> 8;
+ b->buffer[7] = flags.ancount;
+ b->buffer[8] = flags.nscount >> 8;
+ b->buffer[9] = flags.nscount;
+ b->buffer[10] = flags.adcount >> 8;
+ b->buffer[11] = flags.adcount;
+
+ b->offset = 12;
+}
+
+void
+resolv_response_section (struct resolv_response_builder *b, ns_sect section)
+{
+ if (b->offset == 0)
+ FAIL_EXIT1 ("resolv_response_section: response_init not called before");
+ if (section < b->section)
+ FAIL_EXIT1 ("resolv_response_section: cannot go back to previous section");
+ b->section = section;
+}
+
+/* Add a single byte to B. */
+static inline void
+response_add_byte (struct resolv_response_builder *b, unsigned char ch)
+{
+ if (b->offset == max_response_length)
+ FAIL_EXIT1 ("DNS response exceeds 64 KiB limit");
+ b->buffer[b->offset] = ch;
+ ++b->offset;
+}
+
+/* Add a 16-bit word VAL to B, in big-endian format. */
+static void
+response_add_16 (struct resolv_response_builder *b, uint16_t val)
+{
+ response_add_byte (b, val >> 8);
+ response_add_byte (b, val);
+}
+
+/* Increment the pers-section record counter in the packet header. */
+static void
+response_count_increment (struct resolv_response_builder *b)
+{
+ unsigned int offset = b->section;
+ offset = 4 + 2 * offset;
+ ++b->buffer[offset + 1];
+ if (b->buffer[offset + 1] == 0)
+ {
+ /* Carry. */
+ ++b->buffer[offset];
+ if (b->buffer[offset] == 0)
+ /* Overflow. */
+ FAIL_EXIT1 ("too many records in section");
+ }
+}
+
+void
+resolv_response_add_question (struct resolv_response_builder *b,
+ const char *name, uint16_t class, uint16_t type)
+{
+ if (b->offset == 0)
+ FAIL_EXIT1 ("resolv_response_add_question: "
+ "resolv_response_init not called");
+ if (b->section != ns_s_qd)
+ FAIL_EXIT1 ("resolv_response_add_question: "
+ "must be called in the question section");
+
+ resolv_response_add_name (b, name);
+ response_add_16 (b, type);
+ response_add_16 (b, class);
+
+ response_count_increment (b);
+}
+
+void
+resolv_response_add_name (struct resolv_response_builder *b,
+ const char *const origname)
+{
+ /* Normalized name. */
+ char *name;
+ /* Normalized name with case preserved. */
+ char *name_case;
+ {
+ size_t namelen = strlen (origname);
+ /* Remove trailing dots. FIXME: Handle trailing quoted dots. */
+ while (namelen > 0 && origname[namelen - 1] == '.')
+ --namelen;
+ name = xmalloc (namelen + 1);
+ name_case = xmalloc (namelen + 1);
+ /* Copy and convert to lowercase. FIXME: This needs to normalize
+ escaping as well. */
+ for (size_t i = 0; i < namelen; ++i)
+ {
+ char ch = origname[i];
+ name_case[i] = ch;
+ if ('A' <= ch && ch <= 'Z')
+ ch = ch - 'A' + 'a';
+ name[i] = ch;
+ }
+ name[namelen] = 0;
+ name_case[namelen] = 0;
+ }
+ char *name_start = name;
+ char *name_case_start = name_case;
+
+ bool compression = false;
+ while (*name)
+ {
+ /* Search for a previous name we can reference. */
+ ENTRY new_entry =
+ {
+ .key = name,
+ .data = (void *) (uintptr_t) b->offset,
+ };
+
+ /* If the label can be a compression target because it is at a
+ reachable offset, add it to the hash table. */
+ ACTION action;
+ if (b->offset < (1 << 12))
+ action = ENTER;
+ else
+ action = FIND;
+
+ /* Search for known compression offsets in the hash table. */
+ ENTRY *e;
+ if (hsearch_r (new_entry, action, &e, &b->compression_offsets) == 0)
+ {
+ if (action == FIND && errno == ESRCH)
+ /* Fall through. */
+ e = NULL;
+ else
+ FAIL_EXIT1 ("hsearch_r failure in name compression: %m");
+ }
+
+ /* The name is known. Reference the previous location. */
+ if (e != NULL && e->data != new_entry.data)
+ {
+ size_t old_offset = (uintptr_t) e->data;
+ response_add_byte (b, 0xC0 | (old_offset >> 8));
+ response_add_byte (b, old_offset);
+ compression = true;
+ break;
+ }
+
+ /* The name does not exist yet. Write one label. First, add
+ room for the label length. */
+ size_t buffer_label_offset = b->offset;
+ response_add_byte (b, 0);
+
+ /* Copy the label. */
+ while (true)
+ {
+ char ch = *name_case;
+ if (ch == '\0')
+ break;
+ ++name;
+ ++name_case;
+ if (ch == '.')
+ break;
+ /* FIXME: Handle escaping. */
+ response_add_byte (b, ch);
+ }
+
+ /* Patch in the label length. */
+ size_t label_length = b->offset - buffer_label_offset - 1;
+ if (label_length == 0)
+ FAIL_EXIT1 ("empty label in name compression: %s", origname);
+ if (label_length > 63)
+ FAIL_EXIT1 ("label too long in name compression: %s", origname);
+ b->buffer[buffer_label_offset] = label_length;
+
+ /* Continue with the tail of the name and the next label. */
+ }
+
+ if (compression)
+ {
+ /* If we found an immediate match for the name, we have not put
+ it into the hash table, and can free it immediately. */
+ if (name == name_start)
+ free (name_start);
+ else
+ response_push_pointer_to_free (b, name_start);
+ }
+ else
+ {
+ /* Terminate the sequence of labels. With compression, this is
+ implicit in the compression reference. */
+ response_add_byte (b, 0);
+ response_push_pointer_to_free (b, name_start);
+ }
+
+ free (name_case_start);
+}
+
+void
+resolv_response_open_record (struct resolv_response_builder *b,
+ const char *name,
+ uint16_t class, uint16_t type, uint32_t ttl)
+{
+ if (b->section == ns_s_qd)
+ FAIL_EXIT1 ("resolv_response_open_record called in question section");
+ if (b->current_rdata_offset != 0)
+ FAIL_EXIT1 ("resolv_response_open_record called with open record");
+
+ resolv_response_add_name (b, name);
+ response_add_16 (b, type);
+ response_add_16 (b, class);
+ response_add_16 (b, ttl >> 16);
+ response_add_16 (b, ttl);
+
+ b->current_rdata_offset = b->offset;
+ /* Add room for the RDATA length. */
+ response_add_16 (b, 0);
+}
+
+
+void
+resolv_response_close_record (struct resolv_response_builder *b)
+{
+ size_t rdata_offset = b->current_rdata_offset;
+ if (rdata_offset == 0)
+ FAIL_EXIT1 ("response_close_record called without open record");
+ size_t rdata_length = b->offset - rdata_offset - 2;
+ if (rdata_length > 65535)
+ FAIL_EXIT1 ("RDATA length %zu exceeds limit", rdata_length);
+ b->buffer[rdata_offset] = rdata_length >> 8;
+ b->buffer[rdata_offset + 1] = rdata_length;
+ response_count_increment (b);
+ b->current_rdata_offset = 0;
+}
+
+void
+resolv_response_add_data (struct resolv_response_builder *b,
+ const void *data, size_t length)
+{
+ size_t remaining = max_response_length - b->offset;
+ if (remaining < length)
+ FAIL_EXIT1 ("resolv_response_add_data: not enough room for %zu bytes",
+ length);
+ memcpy (b->buffer + b->offset, data, length);
+ b->offset += length;
+}
+
+void
+resolv_response_drop (struct resolv_response_builder *b)
+{
+ b->drop = true;
+}
+
+void
+resolv_response_close (struct resolv_response_builder *b)
+{
+ b->close = true;
+}
+
+void
+resolv_response_truncate_data (struct resolv_response_builder *b, size_t count)
+{
+ if (count > 65535)
+ FAIL_EXIT1 ("resolv_response_truncate_data: argument too large: %zu",
+ count);
+ b->truncate_bytes = count;
+}
+
+
+size_t
+resolv_response_length (const struct resolv_response_builder *b)
+{
+ return b->offset;
+}
+
+unsigned char *
+resolv_response_buffer (const struct resolv_response_builder *b)
+{
+ unsigned char *result = xmalloc (b->offset);
+ memcpy (result, b->buffer, b->offset);
+ return result;
+}
+
+static struct resolv_response_builder *
+response_builder_allocate
+ (const unsigned char *query_buffer, size_t query_length)
+{
+ struct resolv_response_builder *b = xmalloc (sizeof (*b));
+ memset (b, 0, offsetof (struct resolv_response_builder, buffer));
+ b->query_buffer = query_buffer;
+ b->query_length = query_length;
+ TEST_VERIFY_EXIT (hcreate_r (10000, &b->compression_offsets) != 0);
+ return b;
+}
+
+static void
+response_builder_free (struct resolv_response_builder *b)
+{
+ struct to_be_freed *current = b->to_be_freed;
+ while (current != NULL)
+ {
+ struct to_be_freed *next = current->next;
+ free (current->ptr);
+ free (current);
+ current = next;
+ }
+ hdestroy_r (&b->compression_offsets);
+ free (b);
+}
+
+/* DNS query processing. */
+
+/* Data extracted from the question section of a DNS packet. */
+struct query_info
+{
+ char qname[MAXDNAME];
+ uint16_t qclass;
+ uint16_t qtype;
+ struct resolv_edns_info edns;
+};
+
+/* Update *INFO from the specified DNS packet. */
+static void
+parse_query (struct query_info *info,
+ const unsigned char *buffer, size_t length)
+{
+ HEADER hd;
+ _Static_assert (sizeof (hd) == 12, "DNS header size");
+ if (length < sizeof (hd))
+ FAIL_EXIT1 ("malformed DNS query: too short: %zu bytes", length);
+ memcpy (&hd, buffer, sizeof (hd));
+
+ if (ntohs (hd.qdcount) != 1)
+ FAIL_EXIT1 ("malformed DNS query: wrong question count: %d",
+ (int) ntohs (hd.qdcount));
+ if (ntohs (hd.ancount) != 0)
+ FAIL_EXIT1 ("malformed DNS query: wrong answer count: %d",
+ (int) ntohs (hd.ancount));
+ if (ntohs (hd.nscount) != 0)
+ FAIL_EXIT1 ("malformed DNS query: wrong authority count: %d",
+ (int) ntohs (hd.nscount));
+ if (ntohs (hd.arcount) > 1)
+ FAIL_EXIT1 ("malformed DNS query: wrong additional count: %d",
+ (int) ntohs (hd.arcount));
+
+ int ret = dn_expand (buffer, buffer + length, buffer + sizeof (hd),
+ info->qname, sizeof (info->qname));
+ if (ret < 0)
+ FAIL_EXIT1 ("malformed DNS query: cannot uncompress QNAME");
+
+ /* Obtain QTYPE and QCLASS. */
+ size_t remaining = length - (12 + ret);
+ struct
+ {
+ uint16_t qtype;
+ uint16_t qclass;
+ } qtype_qclass;
+ if (remaining < sizeof (qtype_qclass))
+ FAIL_EXIT1 ("malformed DNS query: "
+ "query lacks QCLASS/QTYPE, QNAME: %s", info->qname);
+ memcpy (&qtype_qclass, buffer + 12 + ret, sizeof (qtype_qclass));
+ info->qclass = ntohs (qtype_qclass.qclass);
+ info->qtype = ntohs (qtype_qclass.qtype);
+
+ memset (&info->edns, 0, sizeof (info->edns));
+ if (ntohs (hd.arcount) > 0)
+ {
+ /* Parse EDNS record. */
+ struct __attribute__ ((packed, aligned (1)))
+ {
+ uint8_t root;
+ uint16_t rtype;
+ uint16_t payload;
+ uint8_t edns_extended_rcode;
+ uint8_t edns_version;
+ uint16_t flags;
+ uint16_t rdatalen;
+ } rr;
+ _Static_assert (sizeof (rr) == 11, "EDNS record size");
+
+ if (remaining < 4 + sizeof (rr))
+ FAIL_EXIT1 ("mailformed DNS query: no room for EDNS record");
+ memcpy (&rr, buffer + 12 + ret + 4, sizeof (rr));
+ if (rr.root != 0)
+ FAIL_EXIT1 ("malformed DNS query: invalid OPT RNAME: %d\n", rr.root);
+ if (rr.rtype != htons (41))
+ FAIL_EXIT1 ("malformed DNS query: invalid OPT type: %d\n",
+ ntohs (rr.rtype));
+ info->edns.active = true;
+ info->edns.extended_rcode = rr.edns_extended_rcode;
+ info->edns.version = rr.edns_version;
+ info->edns.flags = ntohs (rr.flags);
+ info->edns.payload_size = ntohs (rr.payload);
+ }
+}
+
+
+/* Main testing framework. */
+
+/* Per-server information. One struct is allocated for each test
+ server. */
+struct resolv_test_server
+{
+ /* Local address of the server. UDP and TCP use the same port. */
+ struct sockaddr_in address;
+
+ /* File descriptor of the UDP server, or -1 if this server is
+ disabled. */
+ int socket_udp;
+
+ /* File descriptor of the TCP server, or -1 if this server is
+ disabled. */
+ int socket_tcp;
+
+ /* Counter of the number of responses processed so far. */
+ size_t response_number;
+
+ /* Thread handles for the server threads (if not disabled in the
+ configuration). */
+ pthread_t thread_udp;
+ pthread_t thread_tcp;
+};
+
+/* Main struct for keeping track of libresolv redirection and
+ testing. */
+struct resolv_test
+{
+ /* After initialization, any access to the struct must be performed
+ while this lock is acquired. */
+ pthread_mutex_t lock;
+
+ /* Data for each test server. */
+ struct resolv_test_server servers[resolv_max_test_servers];
+
+ /* Used if config.single_thread_udp is true. */
+ pthread_t thread_udp_single;
+
+ struct resolv_redirect_config config;
+ bool termination_requested;
+};
+
+/* Function implementing a server thread. */
+typedef void (*thread_callback) (struct resolv_test *, int server_index);
+
+/* Storage for thread-specific data, for passing to the
+ thread_callback function. */
+struct thread_closure
+{
+ struct resolv_test *obj; /* Current test object. */
+ thread_callback callback; /* Function to call. */
+ int server_index; /* Index of the implemented server. */
+};
+
+/* Wrap response_callback as a function which can be passed to
+ pthread_create. */
+static void *
+thread_callback_wrapper (void *arg)
+{
+ struct thread_closure *closure = arg;
+ closure->callback (closure->obj, closure->server_index);
+ free (closure);
+ return NULL;
+}
+
+/* Start a server thread for the specified SERVER_INDEX, implemented
+ by CALLBACK. */
+static pthread_t
+start_server_thread (struct resolv_test *obj, int server_index,
+ thread_callback callback)
+{
+ struct thread_closure *closure = xmalloc (sizeof (*closure));
+ *closure = (struct thread_closure)
+ {
+ .obj = obj,
+ .callback = callback,
+ .server_index = server_index,
+ };
+ return xpthread_create (NULL, thread_callback_wrapper, closure);
+}
+
+/* Process one UDP query. Return false if a termination requested has
+ been detected. */
+static bool
+server_thread_udp_process_one (struct resolv_test *obj, int server_index)
+{
+ unsigned char query[512];
+ struct sockaddr_storage peer;
+ socklen_t peerlen = sizeof (peer);
+ size_t length = xrecvfrom (obj->servers[server_index].socket_udp,
+ query, sizeof (query), 0,
+ (struct sockaddr *) &peer, &peerlen);
+ /* Check for termination. */
+ {
+ bool termination_requested;
+ xpthread_mutex_lock (&obj->lock);
+ termination_requested = obj->termination_requested;
+ xpthread_mutex_unlock (&obj->lock);
+ if (termination_requested)
+ return false;
+ }
+
+
+ struct query_info qinfo;
+ parse_query (&qinfo, query, length);
+ if (test_verbose > 0)
+ {
+ if (test_verbose > 1)
+ printf ("info: UDP server %d: incoming query:"
+ " %zd bytes, %s/%u/%u, tnxid=0x%02x%02x\n",
+ server_index, length, qinfo.qname, qinfo.qclass, qinfo.qtype,
+ query[0], query[1]);
+ else
+ printf ("info: UDP server %d: incoming query:"
+ " %zd bytes, %s/%u/%u\n",
+ server_index, length, qinfo.qname, qinfo.qclass, qinfo.qtype);
+ }
+
+ struct resolv_response_context ctx =
+ {
+ .query_buffer = query,
+ .query_length = length,
+ .server_index = server_index,
+ .tcp = false,
+ .edns = qinfo.edns,
+ };
+ struct resolv_response_builder *b = response_builder_allocate (query, length);
+ obj->config.response_callback
+ (&ctx, b, qinfo.qname, qinfo.qclass, qinfo.qtype);
+
+ if (b->drop)
+ {
+ if (test_verbose)
+ printf ("info: UDP server %d: dropping response to %s/%u/%u\n",
+ server_index, qinfo.qname, qinfo.qclass, qinfo.qtype);
+ }
+ else
+ {
+ if (test_verbose)
+ {
+ if (b->offset >= 12)
+ printf ("info: UDP server %d: sending response:"
+ " %zu bytes, RCODE %d (for %s/%u/%u)\n",
+ server_index, b->offset, b->buffer[3] & 0x0f,
+ qinfo.qname, qinfo.qclass, qinfo.qtype);
+ else
+ printf ("info: UDP server %d: sending response: %zu bytes"
+ " (for %s/%u/%u)\n",
+ server_index, b->offset,
+ qinfo.qname, qinfo.qclass, qinfo.qtype);
+ if (b->truncate_bytes > 0)
+ printf ("info: truncated by %u bytes\n", b->truncate_bytes);
+ }
+ size_t to_send = b->offset;
+ if (to_send < b->truncate_bytes)
+ to_send = 0;
+ else
+ to_send -= b->truncate_bytes;
+
+ /* Ignore most errors here because the other end may have closed
+ the socket. */
+ if (sendto (obj->servers[server_index].socket_udp,
+ b->buffer, to_send, 0,
+ (struct sockaddr *) &peer, peerlen) < 0)
+ TEST_VERIFY_EXIT (errno != EBADF);
+ }
+ response_builder_free (b);
+ return true;
+}
+
+/* UDP thread_callback function. Variant for one thread per
+ server. */
+static void
+server_thread_udp (struct resolv_test *obj, int server_index)
+{
+ while (server_thread_udp_process_one (obj, server_index))
+ ;
+}
+
+/* Single-threaded UDP processing function, for the single_thread_udp
+ case. */
+static void *
+server_thread_udp_single (void *closure)
+{
+ struct resolv_test *obj = closure;
+
+ struct pollfd fds[resolv_max_test_servers];
+ for (int server_index = 0; server_index < resolv_max_test_servers;
+ ++server_index)
+ if (obj->config.servers[server_index].disable_udp)
+ fds[server_index] = (struct pollfd) {.fd = -1};
+ else
+ {
+ fds[server_index] = (struct pollfd)
+ {
+ .fd = obj->servers[server_index].socket_udp,
+ .events = POLLIN
+ };
+
+ /* Make the socket non-blocking. */
+ int flags = fcntl (obj->servers[server_index].socket_udp, F_GETFL, 0);
+ if (flags < 0)
+ FAIL_EXIT1 ("fcntl (F_GETFL): %m");
+ flags |= O_NONBLOCK;
+ if (fcntl (obj->servers[server_index].socket_udp, F_SETFL, flags) < 0)
+ FAIL_EXIT1 ("fcntl (F_SETFL): %m");
+ }
+
+ while (true)
+ {
+ xpoll (fds, resolv_max_test_servers, -1);
+ for (int server_index = 0; server_index < resolv_max_test_servers;
+ ++server_index)
+ if (fds[server_index].revents != 0)
+ {
+ if (!server_thread_udp_process_one (obj, server_index))
+ goto out;
+ fds[server_index].revents = 0;
+ }
+ }
+
+ out:
+ return NULL;
+}
+
+/* Start the single UDP handler thread (for the single_thread_udp
+ case). */
+static void
+start_server_thread_udp_single (struct resolv_test *obj)
+{
+ obj->thread_udp_single
+ = xpthread_create (NULL, server_thread_udp_single, obj);
+}
+
+/* Data describing a TCP client connect. */
+struct tcp_thread_closure
+{
+ struct resolv_test *obj;
+ int server_index;
+ int client_socket;
+};
+
+/* Read a complete DNS query packet. If EOF_OK, an immediate
+ end-of-file condition is acceptable. */
+static bool
+read_fully (int fd, void *buf, size_t len, bool eof_ok)
+{
+ const void *const end = buf + len;
+ while (buf < end)
+ {
+ ssize_t ret = read (fd, buf, end - buf);
+ if (ret == 0)
+ {
+ if (!eof_ok)
+ {
+ support_record_failure ();
+ printf ("error: unexpected EOF on TCP connection\n");
+ }
+ return false;
+ }
+ else if (ret < 0)
+ {
+ if (!eof_ok || errno != ECONNRESET)
+ {
+ support_record_failure ();
+ printf ("error: TCP read: %m\n");
+ }
+ return false;
+ }
+ buf += ret;
+ eof_ok = false;
+ }
+ return true;
+}
+
+/* Write an array of iovecs. Terminate the process on failure. */
+static void
+writev_fully (int fd, struct iovec *buffers, size_t count)
+{
+ while (count > 0)
+ {
+ /* Skip zero-length write requests. */
+ if (buffers->iov_len == 0)
+ {
+ ++buffers;
+ --count;
+ continue;
+ }
+ /* Try to rewrite the remaing buffers. */
+ ssize_t ret = writev (fd, buffers, count);
+ if (ret < 0)
+ FAIL_EXIT1 ("writev: %m");
+ if (ret == 0)
+ FAIL_EXIT1 ("writev: invalid return value zero");
+ /* Find the buffers that were successfully written. */
+ while (ret > 0)
+ {
+ if (count == 0)
+ FAIL_EXIT1 ("internal writev consistency failure");
+ /* Current buffer was partially written. */
+ if (buffers->iov_len > (size_t) ret)
+ {
+ buffers->iov_base += ret;
+ buffers->iov_len -= ret;
+ ret = 0;
+ }
+ else
+ {
+ ret -= buffers->iov_len;
+ buffers->iov_len = 0;
+ ++buffers;
+ --count;
+ }
+ }
+ }
+}
+
+/* Thread callback for handling a single established TCP connection to
+ a client. */
+static void *
+server_thread_tcp_client (void *arg)
+{
+ struct tcp_thread_closure *closure = arg;
+
+ while (true)
+ {
+ /* Read packet length. */
+ uint16_t query_length;
+ if (!read_fully (closure->client_socket,
+ &query_length, sizeof (query_length), true))
+ break;
+ query_length = ntohs (query_length);
+
+ /* Read the packet. */
+ unsigned char *query_buffer = xmalloc (query_length);
+ read_fully (closure->client_socket, query_buffer, query_length, false);
+
+ struct query_info qinfo;
+ parse_query (&qinfo, query_buffer, query_length);
+ if (test_verbose > 0)
+ {
+ if (test_verbose > 1)
+ printf ("info: UDP server %d: incoming query:"
+ " %d bytes, %s/%u/%u, tnxid=0x%02x%02x\n",
+ closure->server_index, query_length,
+ qinfo.qname, qinfo.qclass, qinfo.qtype,
+ query_buffer[0], query_buffer[1]);
+ else
+ printf ("info: TCP server %d: incoming query:"
+ " %u bytes, %s/%u/%u\n",
+ closure->server_index, query_length,
+ qinfo.qname, qinfo.qclass, qinfo.qtype);
+ }
+
+ struct resolv_response_context ctx =
+ {
+ .query_buffer = query_buffer,
+ .query_length = query_length,
+ .server_index = closure->server_index,
+ .tcp = true,
+ .edns = qinfo.edns,
+ };
+ struct resolv_response_builder *b = response_builder_allocate
+ (query_buffer, query_length);
+ closure->obj->config.response_callback
+ (&ctx, b, qinfo.qname, qinfo.qclass, qinfo.qtype);
+
+ if (b->drop)
+ {
+ if (test_verbose)
+ printf ("info: TCP server %d: dropping response to %s/%u/%u\n",
+ closure->server_index,
+ qinfo.qname, qinfo.qclass, qinfo.qtype);
+ }
+ else
+ {
+ if (test_verbose)
+ printf ("info: TCP server %d: sending response: %zu bytes"
+ " (for %s/%u/%u)\n",
+ closure->server_index, b->offset,
+ qinfo.qname, qinfo.qclass, qinfo.qtype);
+ uint16_t length = htons (b->offset);
+ size_t to_send = b->offset;
+ if (to_send < b->truncate_bytes)
+ to_send = 0;
+ else
+ to_send -= b->truncate_bytes;
+ struct iovec buffers[2] =
+ {
+ {&length, sizeof (length)},
+ {b->buffer, to_send}
+ };
+ writev_fully (closure->client_socket, buffers, 2);
+ }
+ bool close_flag = b->close;
+ response_builder_free (b);
+ free (query_buffer);
+ if (close_flag)
+ break;
+ }
+
+ xclose (closure->client_socket);
+ free (closure);
+ return NULL;
+}
+
+/* thread_callback for the TCP case. Accept connections and create a
+ new thread for each client. */
+static void
+server_thread_tcp (struct resolv_test *obj, int server_index)
+{
+ while (true)
+ {
+ /* Get the client conenction. */
+ int client_socket = xaccept
+ (obj->servers[server_index].socket_tcp, NULL, NULL);
+
+ /* Check for termination. */
+ xpthread_mutex_lock (&obj->lock);
+ if (obj->termination_requested)
+ {
+ xpthread_mutex_unlock (&obj->lock);
+ xclose (client_socket);
+ break;
+ }
+ xpthread_mutex_unlock (&obj->lock);
+
+ /* Spawn a new thread for handling this connection. */
+ struct tcp_thread_closure *closure = xmalloc (sizeof (*closure));
+ *closure = (struct tcp_thread_closure)
+ {
+ .obj = obj,
+ .server_index = server_index,
+ .client_socket = client_socket,
+ };
+
+ pthread_t thr
+ = xpthread_create (NULL, server_thread_tcp_client, closure);
+ /* TODO: We should keep track of this thread so that we can
+ block in resolv_test_end until it has exited. */
+ xpthread_detach (thr);
+ }
+}
+
+/* Create UDP and TCP server sockets. */
+static void
+make_server_sockets (struct resolv_test_server *server)
+{
+ while (true)
+ {
+ server->socket_udp = xsocket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ server->socket_tcp = xsocket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ /* Pick the address for the UDP socket. */
+ server->address = (struct sockaddr_in)
+ {
+ .sin_family = AF_INET,
+ .sin_addr = {.s_addr = htonl (INADDR_LOOPBACK)}
+ };
+ xbind (server->socket_udp,
+ (struct sockaddr *)&server->address, sizeof (server->address));
+
+ /* Retrieve the address. */
+ socklen_t addrlen = sizeof (server->address);
+ xgetsockname (server->socket_udp,
+ (struct sockaddr *)&server->address, &addrlen);
+
+ /* Bind the TCP socket to the same address. */
+ {
+ int on = 1;
+ xsetsockopt (server->socket_tcp, SOL_SOCKET, SO_REUSEADDR,
+ &on, sizeof (on));
+ }
+ if (bind (server->socket_tcp,
+ (struct sockaddr *)&server->address,
+ sizeof (server->address)) != 0)
+ {
+ /* Port collision. The UDP bind succeeded, but the TCP BIND
+ failed. We assume here that the kernel will pick the
+ next local UDP address randomly. */
+ if (errno == EADDRINUSE)
+ {
+ xclose (server->socket_udp);
+ xclose (server->socket_tcp);
+ continue;
+ }
+ FAIL_EXIT1 ("TCP bind: %m");
+ }
+ xlisten (server->socket_tcp, 5);
+ break;
+ }
+}
+
+/* One-time initialization of NSS. */
+static void
+resolv_redirect_once (void)
+{
+ /* Only use nss_dns. */
+ __nss_configure_lookup ("hosts", "dns");
+ __nss_configure_lookup ("networks", "dns");
+ /* Enter a network namespace for isolation and firewall state
+ cleanup. The tests will still work if these steps fail, but they
+ may be less reliable. */
+ support_become_root ();
+ support_enter_network_namespace ();
+}
+pthread_once_t resolv_redirect_once_var = PTHREAD_ONCE_INIT;
+
+void
+resolv_test_init (void)
+{
+ /* Perform one-time initialization of NSS. */
+ xpthread_once (&resolv_redirect_once_var, resolv_redirect_once);
+}
+
+/* Copy the search path from CONFIG.search to the _res object. */
+static void
+set_search_path (struct resolv_redirect_config config)
+{
+ memset (_res.defdname, 0, sizeof (_res.defdname));
+ memset (_res.dnsrch, 0, sizeof (_res.dnsrch));
+
+ char *current = _res.defdname;
+ char *end = current + sizeof (_res.defdname);
+
+ for (unsigned int i = 0;
+ i < sizeof (config.search) / sizeof (config.search[0]); ++i)
+ {
+ if (config.search[i] == NULL)
+ continue;
+
+ size_t length = strlen (config.search[i]) + 1;
+ size_t remaining = end - current;
+ TEST_VERIFY_EXIT (length <= remaining);
+ memcpy (current, config.search[i], length);
+ _res.dnsrch[i] = current;
+ current += length;
+ }
+}
+
+struct resolv_test *
+resolv_test_start (struct resolv_redirect_config config)
+{
+ /* Apply configuration defaults. */
+ if (config.nscount == 0)
+ config.nscount = resolv_max_test_servers;
+
+ struct resolv_test *obj = xmalloc (sizeof (*obj));
+ *obj = (struct resolv_test) {
+ .config = config,
+ .lock = PTHREAD_MUTEX_INITIALIZER,
+ };
+
+ resolv_test_init ();
+
+ /* Create all the servers, to reserve the necessary ports. */
+ for (int server_index = 0; server_index < config.nscount; ++server_index)
+ make_server_sockets (obj->servers + server_index);
+
+ /* Start server threads. Disable the server ports, as
+ requested. */
+ for (int server_index = 0; server_index < config.nscount; ++server_index)
+ {
+ struct resolv_test_server *server = obj->servers + server_index;
+ if (config.servers[server_index].disable_udp)
+ {
+ xclose (server->socket_udp);
+ server->socket_udp = -1;
+ }
+ else if (!config.single_thread_udp)
+ server->thread_udp = start_server_thread (obj, server_index,
+ server_thread_udp);
+ if (config.servers[server_index].disable_tcp)
+ {
+ xclose (server->socket_tcp);
+ server->socket_tcp = -1;
+ }
+ else
+ server->thread_tcp = start_server_thread (obj, server_index,
+ server_thread_tcp);
+ }
+ if (config.single_thread_udp)
+ start_server_thread_udp_single (obj);
+
+ int timeout = 1;
+
+ /* Initialize libresolv. */
+ TEST_VERIFY_EXIT (res_init () == 0);
+
+ /* Disable IPv6 name server addresses. The code below only
+ overrides the IPv4 addresses. */
+ __res_iclose (&_res, true);
+ _res._u._ext.nscount = 0;
+
+ /* Redirect queries to the server socket. */
+ if (test_verbose)
+ {
+ printf ("info: old timeout value: %d\n", _res.retrans);
+ printf ("info: old retry attempt value: %d\n", _res.retry);
+ printf ("info: old _res.options: 0x%lx\n", _res.options);
+ printf ("info: old _res.nscount value: %d\n", _res.nscount);
+ printf ("info: old _res.ndots value: %d\n", _res.ndots);
+ }
+ _res.retrans = timeout;
+ _res.retry = 4;
+ _res.nscount = config.nscount;
+ _res.options = RES_INIT | RES_RECURSE | RES_DEFNAMES | RES_DNSRCH;
+ _res.ndots = 1;
+ if (test_verbose)
+ {
+ printf ("info: new timeout value: %d\n", _res.retrans);
+ printf ("info: new retry attempt value: %d\n", _res.retry);
+ printf ("info: new _res.options: 0x%lx\n", _res.options);
+ printf ("info: new _res.nscount value: %d\n", _res.nscount);
+ printf ("info: new _res.ndots value: %d\n", _res.ndots);
+ }
+ for (int server_index = 0; server_index < config.nscount; ++server_index)
+ {
+ _res.nsaddr_list[server_index] = obj->servers[server_index].address;
+ if (test_verbose)
+ {
+ char buf[256];
+ TEST_VERIFY_EXIT
+ (inet_ntop (AF_INET, &obj->servers[server_index].address.sin_addr,
+ buf, sizeof (buf)) != NULL);
+ printf ("info: server %d: %s/%u\n",
+ server_index, buf,
+ htons (obj->servers[server_index].address.sin_port));
+ }
+ }
+
+ set_search_path (config);
+
+ return obj;
+}
+
+void
+resolv_test_end (struct resolv_test *obj)
+{
+ res_close ();
+
+ xpthread_mutex_lock (&obj->lock);
+ obj->termination_requested = true;
+ xpthread_mutex_unlock (&obj->lock);
+
+ /* Send trigger packets to unblock the server threads. */
+ for (int server_index = 0; server_index < obj->config.nscount;
+ ++server_index)
+ {
+ if (!obj->config.servers[server_index].disable_udp)
+ {
+ int sock = xsocket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ xsendto (sock, "", 1, 0,
+ (struct sockaddr *) &obj->servers[server_index].address,
+ sizeof (obj->servers[server_index].address));
+ xclose (sock);
+ }
+ if (!obj->config.servers[server_index].disable_tcp)
+ {
+ int sock = xsocket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ xconnect (sock,
+ (struct sockaddr *) &obj->servers[server_index].address,
+ sizeof (obj->servers[server_index].address));
+ xclose (sock);
+ }
+ }
+
+ if (obj->config.single_thread_udp)
+ xpthread_join (obj->thread_udp_single);
+
+ /* Wait for the server threads to terminate. */
+ for (int server_index = 0; server_index < obj->config.nscount;
+ ++server_index)
+ {
+ if (!obj->config.servers[server_index].disable_udp)
+ {
+ if (!obj->config.single_thread_udp)
+ xpthread_join (obj->servers[server_index].thread_udp);
+ xclose (obj->servers[server_index].socket_udp);
+ }
+ if (!obj->config.servers[server_index].disable_tcp)
+ {
+ xpthread_join (obj->servers[server_index].thread_tcp);
+ xclose (obj->servers[server_index].socket_tcp);
+ }
+ }
+
+ free (obj);
+}
diff --git a/support/resolv_test.h b/support/resolv_test.h
new file mode 100644
index 0000000000..6498751569
--- /dev/null
+++ b/support/resolv_test.h
@@ -0,0 +1,180 @@
+/* DNS test framework and libresolv redirection.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_RESOLV_TEST_H
+#define SUPPORT_RESOLV_TEST_H
+
+#include <arpa/nameser.h>
+#include <stdbool.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Information about EDNS properties of a DNS query. */
+struct resolv_edns_info
+{
+ bool active;
+ uint8_t extended_rcode;
+ uint8_t version;
+ uint16_t flags;
+ uint16_t payload_size;
+};
+
+/* This struct provides context information when the response callback
+ specified in struct resolv_redirect_config is invoked. */
+struct resolv_response_context
+{
+ const unsigned char *query_buffer;
+ size_t query_length;
+ int server_index;
+ bool tcp;
+ struct resolv_edns_info edns;
+};
+
+/* This opaque struct is used to construct responses from within the
+ response callback function. */
+struct resolv_response_builder;
+
+/* This opaque struct collects information about the resolver testing
+ currently in progress. */
+struct resolv_test;
+
+enum
+ {
+ /* Maximum number of test servers supported by the framework. */
+ resolv_max_test_servers = 3,
+ };
+
+/* Configuration settings specific to individual test servers. */
+struct resolv_redirect_server_config
+{
+ bool disable_tcp; /* If true, no TCP server is listening. */
+ bool disable_udp; /* If true, no UDP server is listening. */
+};
+
+/* Instructions for setting up the libresolv redirection. */
+struct resolv_redirect_config
+{
+ /* The response_callback function is called for every incoming DNS
+ packet, over UDP or TCP. It must be specified, the other
+ configuration settings are optional. */
+ void (*response_callback) (const struct resolv_response_context *,
+ struct resolv_response_builder *,
+ const char *qname,
+ uint16_t qclass, uint16_t qtype);
+
+ /* Per-server configuration. */
+ struct resolv_redirect_server_config servers[resolv_max_test_servers];
+
+ /* Search path entries. The first entry serves as the default
+ domain name as well. */
+ const char *search[7];
+
+ /* Number of servers to activate in resolv. 0 means the default,
+ resolv_max_test_servers. */
+ int nscount;
+
+ /* If true, use a single thread to process all UDP queries. This
+ may results in more predictable ordering of queries and
+ responses. */
+ bool single_thread_udp;
+};
+
+/* Configure NSS to use, nss_dns only for aplicable databases, and try
+ to put the process into a network namespace for better isolation.
+ This may have to be called before resolv_test_start, before the
+ process creates any threads. Otherwise, initialization is
+ performed by resolv_test_start implicitly. */
+void resolv_test_init (void);
+
+/* Initiate resolver testing. This updates the _res variable as
+ needed. As a side effect, NSS is reconfigured to use nss_dns only
+ for aplicable databases, and the process may enter a network
+ namespace for better isolation. */
+struct resolv_test *resolv_test_start (struct resolv_redirect_config);
+
+/* Call this function at the end of resolver testing, to free
+ resources and report pending errors (if any). */
+void resolv_test_end (struct resolv_test *);
+
+/* The remaining facilities in this file are used for constructing
+ response packets from the response_callback function. */
+
+/* Special settings for constructing responses from the callback. */
+struct resolv_response_flags
+{
+ /* 4-bit response code to incorporate into the response. */
+ unsigned char rcode;
+
+ /* If true, the TC (truncation) flag will be set. */
+ bool tc;
+
+ /* Initial section count values. Can be used to artificially
+ increase the counts, for malformed packet testing.*/
+ unsigned short qdcount;
+ unsigned short ancount;
+ unsigned short nscount;
+ unsigned short adcount;
+};
+
+/* Begin a new response with the requested flags. Must be called
+ first. */
+void resolv_response_init (struct resolv_response_builder *,
+ struct resolv_response_flags);
+
+/* Switches to the section in the response packet. Only forward
+ movement is supported. */
+void resolv_response_section (struct resolv_response_builder *, ns_sect);
+
+/* Add a question record to the question section. */
+void resolv_response_add_question (struct resolv_response_builder *,
+ const char *name, uint16_t class,
+ uint16_t type);
+/* Starts a new resource record with the specified owner name, class,
+ type, and TTL. Data is supplied with resolv_response_add_data or
+ resolv_response_add_name. */
+void resolv_response_open_record (struct resolv_response_builder *,
+ const char *name, uint16_t class,
+ uint16_t type, uint32_t ttl);
+
+/* Add unstructed bytes to the RDATA part of a resource record. */
+void resolv_response_add_data (struct resolv_response_builder *,
+ const void *, size_t);
+
+/* Add a compressed domain name to the RDATA part of a resource
+ record. */
+void resolv_response_add_name (struct resolv_response_builder *,
+ const char *name);
+
+/* Mark the end of the constructed record. Must be called last. */
+void resolv_response_close_record (struct resolv_response_builder *);
+
+/* Drop this query packet (that is, do not send a response, not even
+ an empty packet). */
+void resolv_response_drop (struct resolv_response_builder *);
+
+/* In TCP mode, close the connection after this packet (if a response
+ is sent). */
+void resolv_response_close (struct resolv_response_builder *);
+
+/* The size of the response packet built so far. */
+size_t resolv_response_length (const struct resolv_response_builder *);
+
+__END_DECLS
+
+#endif /* SUPPORT_RESOLV_TEST_H */
diff --git a/support/run_diff.h b/support/run_diff.h
new file mode 100644
index 0000000000..f65b5dd22c
--- /dev/null
+++ b/support/run_diff.h
@@ -0,0 +1,31 @@
+/* Invoke the system diff tool to compare two strings.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_RUN_DIFF_H
+#define SUPPORT_RUN_DIFF_H
+
+/* Compare the two NUL-terminated strings LEFT and RIGHT using the
+ diff tool. Label the sides of the diff with LEFT_LABEL and
+ RIGHT_LABEL, respectively.
+
+ This function assumes that LEFT and RIGHT are different
+ strings. */
+void support_run_diff (const char *left_label, const char *left,
+ const char *right_label, const char *right);
+
+#endif /* SUPPORT_RUN_DIFF_H */
diff --git a/support/set_fortify_handler.c b/support/set_fortify_handler.c
new file mode 100644
index 0000000000..f434a8082a
--- /dev/null
+++ b/support/set_fortify_handler.c
@@ -0,0 +1,34 @@
+/* Set signal handler for use in fortify tests.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <signal.h>
+
+void
+set_fortify_handler (void (*handler) (int sig))
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+
+ sigaction (SIGABRT, &sa, NULL);
+ ignore_stderr ();
+}
diff --git a/support/support-xstat.c b/support/support-xstat.c
new file mode 100644
index 0000000000..86a81ec601
--- /dev/null
+++ b/support/support-xstat.c
@@ -0,0 +1,30 @@
+/* stat64 with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* NB: Non-standard file name to avoid sysdeps override for xstat. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+void
+xstat (const char *path, struct stat64 *result)
+{
+ if (stat64 (path, result) != 0)
+ FAIL_EXIT1 ("stat64 (\"%s\"): %m", path);
+}
diff --git a/support/support.h b/support/support.h
new file mode 100644
index 0000000000..4b5f04c2cc
--- /dev/null
+++ b/support/support.h
@@ -0,0 +1,74 @@
+/* Common extra functions.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This header file should only contain definitions compatible with
+ C90. (Using __attribute__ is fine because <features.h> provides a
+ fallback.) */
+
+#ifndef SUPPORT_H
+#define SUPPORT_H
+
+#include <stddef.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Write a message to standard output. Can be used in signal
+ handlers. */
+void write_message (const char *message) __attribute__ ((nonnull (1)));
+
+/* Avoid all the buffer overflow messages on stderr. */
+void ignore_stderr (void);
+
+/* Set fortification error handler. Used when tests want to verify that bad
+ code is caught by the library. */
+void set_fortify_handler (void (*handler) (int sig));
+
+/* Report an out-of-memory error for the allocation of SIZE bytes in
+ FUNCTION, terminating the process. */
+void oom_error (const char *function, size_t size)
+ __attribute__ ((nonnull (1)));
+
+/* Return a pointer to a memory region of SIZE bytes. The memory is
+ initialized to zero and will be shared with subprocesses (across
+ fork). The returned pointer must be freed using
+ support_shared_free; it is not compatible with the malloc
+ functions. */
+void *support_shared_allocate (size_t size);
+
+/* Deallocate a pointer returned by support_shared_allocate. */
+void support_shared_free (void *);
+
+/* Write CONTENTS to the file PATH. Create or truncate the file as
+ needed. The file mode is 0666 masked by the umask. Terminate the
+ process on error. */
+void support_write_file_string (const char *path, const char *contents);
+
+/* Error-checking wrapper functions which terminate the process on
+ error. */
+
+void *xmalloc (size_t) __attribute__ ((malloc));
+void *xcalloc (size_t n, size_t s) __attribute__ ((malloc));
+void *xrealloc (void *p, size_t n);
+char *xasprintf (const char *format, ...)
+ __attribute__ ((format (printf, 1, 2), malloc));
+char *xstrdup (const char *);
+
+__END_DECLS
+
+#endif /* SUPPORT_H */
diff --git a/support/support_become_root.c b/support/support_become_root.c
new file mode 100644
index 0000000000..3fa0bd4ac0
--- /dev/null
+++ b/support/support_become_root.c
@@ -0,0 +1,40 @@
+/* Acquire root privileges.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/namespace.h>
+
+#include <sched.h>
+#include <stdio.h>
+#include <unistd.h>
+
+bool
+support_become_root (void)
+{
+#ifdef CLONE_NEWUSER
+ if (unshare (CLONE_NEWUSER | CLONE_NEWNS) == 0)
+ /* Even if we do not have UID zero, we have extended privileges at
+ this point. */
+ return true;
+#endif
+ if (setuid (0) != 0)
+ {
+ printf ("warning: could not become root outside namespace (%m)\n");
+ return false;
+ }
+ return true;
+}
diff --git a/support/support_can_chroot.c b/support/support_can_chroot.c
new file mode 100644
index 0000000000..0dfd2deb54
--- /dev/null
+++ b/support/support_can_chroot.c
@@ -0,0 +1,65 @@
+/* Return true if the process can perform a chroot operation.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdio.h>
+#include <support/check.h>
+#include <support/namespace.h>
+#include <support/support.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <xunistd.h>
+
+static void
+callback (void *closure)
+{
+ int *result = closure;
+ struct stat64 before;
+ xstat ("/dev", &before);
+ if (chroot ("/dev") != 0)
+ {
+ *result = errno;
+ return;
+ }
+ struct stat64 after;
+ xstat ("/", &after);
+ TEST_VERIFY (before.st_dev == after.st_dev);
+ TEST_VERIFY (before.st_ino == after.st_ino);
+ *result = 0;
+}
+
+bool
+support_can_chroot (void)
+{
+ int *result = support_shared_allocate (sizeof (*result));
+ *result = 0;
+ support_isolate_in_subprocess (callback, result);
+ bool ok = *result == 0;
+ if (!ok)
+ {
+ static bool already_warned;
+ if (!already_warned)
+ {
+ already_warned = true;
+ errno = *result;
+ printf ("warning: this process does not support chroot: %m\n");
+ }
+ }
+ support_shared_free (result);
+ return ok;
+}
diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
new file mode 100644
index 0000000000..030f124252
--- /dev/null
+++ b/support/support_capture_subprocess.c
@@ -0,0 +1,108 @@
+/* Capture output from a subprocess.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/capture_subprocess.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <support/xsocket.h>
+
+static void
+transfer (const char *what, struct pollfd *pfd, struct xmemstream *stream)
+{
+ if (pfd->revents != 0)
+ {
+ char buf[1024];
+ ssize_t ret = TEMP_FAILURE_RETRY (read (pfd->fd, buf, sizeof (buf)));
+ if (ret < 0)
+ {
+ support_record_failure ();
+ printf ("error: reading from subprocess %s: %m", what);
+ pfd->events = 0;
+ pfd->revents = 0;
+ }
+ else if (ret == 0)
+ {
+ /* EOF reached. Stop listening. */
+ pfd->events = 0;
+ pfd->revents = 0;
+ }
+ else
+ /* Store the data just read. */
+ TEST_VERIFY (fwrite (buf, ret, 1, stream->out) == 1);
+ }
+}
+
+struct support_capture_subprocess
+support_capture_subprocess (void (*callback) (void *), void *closure)
+{
+ struct support_capture_subprocess result;
+ xopen_memstream (&result.out);
+ xopen_memstream (&result.err);
+
+ int stdout_pipe[2];
+ xpipe (stdout_pipe);
+ int stderr_pipe[2];
+ xpipe (stderr_pipe);
+
+ TEST_VERIFY (fflush (stdout) == 0);
+ TEST_VERIFY (fflush (stderr) == 0);
+
+ pid_t pid = xfork ();
+ if (pid == 0)
+ {
+ xclose (stdout_pipe[0]);
+ xclose (stderr_pipe[0]);
+ xdup2 (stdout_pipe[1], STDOUT_FILENO);
+ xdup2 (stderr_pipe[1], STDERR_FILENO);
+ callback (closure);
+ _exit (0);
+ }
+ xclose (stdout_pipe[1]);
+ xclose (stderr_pipe[1]);
+
+ struct pollfd fds[2] =
+ {
+ { .fd = stdout_pipe[0], .events = POLLIN },
+ { .fd = stderr_pipe[0], .events = POLLIN },
+ };
+
+ do
+ {
+ xpoll (fds, 2, -1);
+ transfer ("stdout", &fds[0], &result.out);
+ transfer ("stderr", &fds[1], &result.err);
+ }
+ while (fds[0].events != 0 || fds[1].events != 0);
+ xclose (stdout_pipe[0]);
+ xclose (stderr_pipe[0]);
+
+ xfclose_memstream (&result.out);
+ xfclose_memstream (&result.err);
+ xwaitpid (pid, &result.status, 0);
+ return result;
+}
+
+void
+support_capture_subprocess_free (struct support_capture_subprocess *p)
+{
+ free (p->out.buffer);
+ free (p->err.buffer);
+}
diff --git a/support/support_capture_subprocess_check.c b/support/support_capture_subprocess_check.c
new file mode 100644
index 0000000000..708c89f331
--- /dev/null
+++ b/support/support_capture_subprocess_check.c
@@ -0,0 +1,67 @@
+/* Verify capture output from a subprocess.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+print_context (const char *context, bool *failed)
+{
+ if (*failed)
+ /* Do not duplicate message. */
+ return;
+ support_record_failure ();
+ printf ("error: subprocess failed: %s\n", context);
+}
+
+void
+support_capture_subprocess_check (struct support_capture_subprocess *proc,
+ const char *context, int status,
+ int allowed)
+{
+ TEST_VERIFY ((allowed & sc_allow_none)
+ || (allowed & sc_allow_stdout)
+ || (allowed & sc_allow_stderr));
+ TEST_VERIFY (!((allowed & sc_allow_none)
+ && ((allowed & sc_allow_stdout)
+ || (allowed & sc_allow_stderr))));
+
+ bool failed = false;
+ if (proc->status != status)
+ {
+ print_context (context, &failed);
+ printf ("error: expected exit status: %d\n", status);
+ printf ("error: actual exit status: %d\n", status);
+ }
+ if (!(allowed & sc_allow_stdout) && proc->out.length != 0)
+ {
+ print_context (context, &failed);
+ printf ("error: unexpected output from subprocess\n");
+ fwrite (proc->out.buffer, proc->out.length, 1, stdout);
+ puts ("\n");
+ }
+ if (!(allowed & sc_allow_stderr) && proc->err.length != 0)
+ {
+ print_context (context, &failed);
+ printf ("error: unexpected error output from subprocess\n");
+ fwrite (proc->err.buffer, proc->err.length, 1, stdout);
+ puts ("\n");
+ }
+}
diff --git a/support/support_enter_network_namespace.c b/support/support_enter_network_namespace.c
new file mode 100644
index 0000000000..28b0ee29cf
--- /dev/null
+++ b/support/support_enter_network_namespace.c
@@ -0,0 +1,75 @@
+/* Enter a network namespace.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/namespace.h>
+
+#include <net/if.h>
+#include <sched.h>
+#include <stdio.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/xsocket.h>
+#include <support/xunistd.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+static bool in_uts_namespace;
+
+bool
+support_enter_network_namespace (void)
+{
+#ifdef CLONE_NEWUTS
+ if (unshare (CLONE_NEWUTS) == 0)
+ in_uts_namespace = true;
+ else
+ printf ("warning: unshare (CLONE_NEWUTS) failed: %m\n");
+#endif
+
+#ifdef CLONE_NEWNET
+ if (unshare (CLONE_NEWNET) == 0)
+ {
+ /* Bring up the loopback interface. */
+ int fd = xsocket (AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ struct ifreq req;
+ strcpy (req.ifr_name, "lo");
+ TEST_VERIFY_EXIT (ioctl (fd, SIOCGIFFLAGS, &req) == 0);
+ bool already_up = req.ifr_flags & IFF_UP;
+ if (already_up)
+ /* This means that we likely have not achieved isolation from
+ the parent namespace. */
+ printf ("warning: loopback interface already exists"
+ " in new network namespace\n");
+ else
+ {
+ req.ifr_flags |= IFF_UP | IFF_RUNNING;
+ TEST_VERIFY_EXIT (ioctl (fd, SIOCSIFFLAGS, &req) == 0);
+ }
+ xclose (fd);
+
+ return !already_up;
+ }
+#endif
+ printf ("warning: could not enter network namespace\n");
+ return false;
+}
+
+bool
+support_in_uts_namespace (void)
+{
+ return in_uts_namespace;
+}
diff --git a/support/support_format_address_family.c b/support/support_format_address_family.c
new file mode 100644
index 0000000000..5d42c42a45
--- /dev/null
+++ b/support/support_format_address_family.c
@@ -0,0 +1,35 @@
+/* Convert an address family to a string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/format_nss.h>
+
+#include <support/support.h>
+
+char *
+support_format_address_family (int family)
+{
+ switch (family)
+ {
+ case AF_INET:
+ return xstrdup ("INET");
+ case AF_INET6:
+ return xstrdup ("INET6");
+ default:
+ return xasprintf ("<unknown address family %d>", family);
+ }
+}
diff --git a/support/support_format_addrinfo.c b/support/support_format_addrinfo.c
new file mode 100644
index 0000000000..eedb030591
--- /dev/null
+++ b/support/support_format_addrinfo.c
@@ -0,0 +1,239 @@
+/* Convert struct addrinfo values to a string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/format_nss.h>
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <stdio.h>
+#include <support/support.h>
+#include <support/xmemstream.h>
+
+static size_t
+socket_address_length (int family)
+{
+ switch (family)
+ {
+ case AF_INET:
+ return sizeof (struct sockaddr_in);
+ case AF_INET6:
+ return sizeof (struct sockaddr_in6);
+ default:
+ return -1;
+ }
+}
+
+static void
+format_ai_flags_1 (FILE *out, struct addrinfo *ai, int flag, const char *name,
+ int * flags_printed)
+{
+ if ((ai->ai_flags & flag) != 0)
+ fprintf (out, " %s", name);
+ *flags_printed |= flag;
+}
+
+static void
+format_ai_flags (FILE *out, struct addrinfo *ai)
+{
+ if (ai == NULL)
+ return;
+
+ if (ai->ai_flags != 0)
+ {
+ fprintf (out, "flags:");
+ int flags_printed = 0;
+#define FLAG(flag) format_ai_flags_1 (out, ai, flag, #flag, &flags_printed)
+ FLAG (AI_PASSIVE);
+ FLAG (AI_CANONNAME);
+ FLAG (AI_NUMERICHOST);
+ FLAG (AI_V4MAPPED);
+ FLAG (AI_ALL);
+ FLAG (AI_ADDRCONFIG);
+ FLAG (AI_IDN);
+ FLAG (AI_CANONIDN);
+ FLAG (AI_IDN_ALLOW_UNASSIGNED);
+ FLAG (AI_IDN_USE_STD3_ASCII_RULES);
+ FLAG (AI_NUMERICSERV);
+#undef FLAG
+ int remaining = ai->ai_flags & ~flags_printed;
+ if (remaining != 0)
+ fprintf (out, " %08x", remaining);
+ fprintf (out, "\n");
+ }
+
+ /* Report flag mismatches within the list. */
+ int flags = ai->ai_flags;
+ int index = 1;
+ ai = ai->ai_next;
+ while (ai != NULL)
+ {
+ if (ai->ai_flags != flags)
+ fprintf (out, "error: flags at %d: 0x%x expected, 0x%x actual\n",
+ index, flags, ai->ai_flags);
+ ai = ai->ai_next;
+ ++index;
+ }
+}
+
+static void
+format_ai_canonname (FILE *out, struct addrinfo *ai)
+{
+ if (ai == NULL)
+ return;
+ if (ai->ai_canonname != NULL)
+ fprintf (out, "canonname: %s\n", ai->ai_canonname);
+
+ /* Report incorrectly set ai_canonname fields on subsequent list
+ entries. */
+ int index = 1;
+ ai = ai->ai_next;
+ while (ai != NULL)
+ {
+ if (ai->ai_canonname != NULL)
+ fprintf (out, "error: canonname set at %d: %s\n",
+ index, ai->ai_canonname);
+ ai = ai->ai_next;
+ ++index;
+ }
+}
+
+static void
+format_ai_one (FILE *out, struct addrinfo *ai)
+{
+ {
+ char type_buf[32];
+ const char *type_str;
+ char proto_buf[32];
+ const char *proto_str;
+
+ /* ai_socktype */
+ switch (ai->ai_socktype)
+ {
+ case SOCK_RAW:
+ type_str = "RAW";
+ break;
+ case SOCK_DGRAM:
+ type_str = "DGRAM";
+ break;
+ case SOCK_STREAM:
+ type_str = "STREAM";
+ break;
+ default:
+ snprintf (type_buf, sizeof (type_buf), "%d", ai->ai_socktype);
+ type_str = type_buf;
+ }
+
+ /* ai_protocol */
+ switch (ai->ai_protocol)
+ {
+ case IPPROTO_IP:
+ proto_str = "IP";
+ break;
+ case IPPROTO_UDP:
+ proto_str = "UDP";
+ break;
+ case IPPROTO_TCP:
+ proto_str = "TCP";
+ break;
+ default:
+ snprintf (proto_buf, sizeof (proto_buf), "%d", ai->ai_protocol);
+ proto_str = proto_buf;
+ }
+ fprintf (out, "address: %s/%s", type_str, proto_str);
+ }
+
+ /* ai_addrlen */
+ if (ai->ai_addrlen != socket_address_length (ai->ai_family))
+ {
+ char *family = support_format_address_family (ai->ai_family);
+ fprintf (out, "error: invalid address length %d for %s\n",
+ ai->ai_addrlen, family);
+ free (family);
+ }
+
+ /* ai_addr */
+ {
+ char buf[128];
+ uint16_t port;
+ const char *ret;
+ switch (ai->ai_family)
+ {
+ case AF_INET:
+ {
+ struct sockaddr_in *sin = (struct sockaddr_in *) ai->ai_addr;
+ ret = inet_ntop (AF_INET, &sin->sin_addr, buf, sizeof (buf));
+ port = sin->sin_port;
+ }
+ break;
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *sin = (struct sockaddr_in6 *) ai->ai_addr;
+ ret = inet_ntop (AF_INET6, &sin->sin6_addr, buf, sizeof (buf));
+ port = sin->sin6_port;
+ }
+ break;
+ default:
+ errno = EAFNOSUPPORT;
+ ret = NULL;
+ }
+ if (ret == NULL)
+ fprintf (out, "error: inet_top failed: %m\n");
+ else
+ fprintf (out, " %s %u\n", buf, ntohs (port));
+ }
+}
+
+/* Format all the addresses in one address family. */
+static void
+format_ai_family (FILE *out, struct addrinfo *ai, int family)
+{
+ while (ai)
+ {
+ if (ai->ai_family == family)
+ format_ai_one (out, ai);
+ ai = ai->ai_next;
+ }
+}
+
+char *
+support_format_addrinfo (struct addrinfo *ai, int ret)
+{
+ int errno_copy = errno;
+
+ struct xmemstream mem;
+ xopen_memstream (&mem);
+ if (ret != 0)
+ {
+ fprintf (mem.out, "error: %s\n", gai_strerror (ret));
+ if (ret == EAI_SYSTEM)
+ {
+ errno = errno_copy;
+ fprintf (mem.out, "error: %m\n");
+ }
+ }
+ else
+ {
+ format_ai_flags (mem.out, ai);
+ format_ai_canonname (mem.out, ai);
+ format_ai_family (mem.out, ai, AF_INET);
+ format_ai_family (mem.out, ai, AF_INET6);
+ }
+
+ xfclose_memstream (&mem);
+ return mem.buffer;
+}
diff --git a/support/support_format_dns_packet.c b/support/support_format_dns_packet.c
new file mode 100644
index 0000000000..2992c57971
--- /dev/null
+++ b/support/support_format_dns_packet.c
@@ -0,0 +1,222 @@
+/* Convert a DNS packet to a human-readable representation.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/format_nss.h>
+
+#include <arpa/inet.h>
+#include <resolv.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/xmemstream.h>
+
+struct in_buffer
+{
+ const unsigned char *data;
+ size_t size;
+};
+
+static inline bool
+extract_8 (struct in_buffer *in, unsigned char *value)
+{
+ if (in->size == 0)
+ return false;
+ *value = in->data[0];
+ ++in->data;
+ --in->size;
+ return true;
+}
+
+static inline bool
+extract_16 (struct in_buffer *in, unsigned short *value)
+{
+ if (in->size < 2)
+ return false;
+ *value = (in->data[0] << 8) | in->data[1];
+ in->data += 2;
+ in->size -= 2;
+ return true;
+}
+
+static inline bool
+extract_32 (struct in_buffer *in, unsigned *value)
+{
+ if (in->size < 4)
+ return false;
+ unsigned a = in->data[0];
+ unsigned b = in->data[1];
+ unsigned c = in->data[2];
+ unsigned d = in->data[3];
+ *value = (a << 24) | (b << 16) | (c << 8) | d;
+ in->data += 4;
+ in->size -= 4;
+ return true;
+}
+
+static inline bool
+extract_bytes (struct in_buffer *in, size_t length, struct in_buffer *value)
+{
+ if (in->size < length)
+ return false;
+ *value = (struct in_buffer) {in->data, length};
+ in->data += length;
+ in->size -= length;
+ return true;
+}
+
+struct dname
+{
+ char name[MAXDNAME + 1];
+};
+
+static bool
+extract_name (struct in_buffer full, struct in_buffer *in, struct dname *value)
+{
+ const unsigned char *full_end = full.data + full.size;
+ /* Sanity checks; these indicate buffer misuse. */
+ TEST_VERIFY_EXIT
+ (!(in->data < full.data || in->data > full_end
+ || in->size > (size_t) (full_end - in->data)));
+ int ret = dn_expand (full.data, full_end, in->data,
+ value->name, sizeof (value->name));
+ if (ret < 0)
+ return false;
+ in->data += ret;
+ in->size -= ret;
+ return true;
+}
+
+char *
+support_format_dns_packet (const unsigned char *buffer, size_t length)
+{
+ struct in_buffer full = { buffer, length };
+ struct in_buffer in = full;
+ struct xmemstream mem;
+ xopen_memstream (&mem);
+
+ unsigned short txnid;
+ unsigned short flags;
+ unsigned short qdcount;
+ unsigned short ancount;
+ unsigned short nscount;
+ unsigned short adcount;
+ if (!(extract_16 (&in, &txnid)
+ && extract_16 (&in, &flags)
+ && extract_16 (&in, &qdcount)
+ && extract_16 (&in, &ancount)
+ && extract_16 (&in, &nscount)
+ && extract_16 (&in, &adcount)))
+ {
+ fprintf (mem.out, "error: could not parse DNS header\n");
+ goto out;
+ }
+ if (qdcount != 1)
+ {
+ fprintf (mem.out, "error: question count is %d, not 1\n", qdcount);
+ goto out;
+ }
+ struct dname qname;
+ if (!extract_name (full, &in, &qname))
+ {
+ fprintf (mem.out, "error: malformed QNAME\n");
+ goto out;
+ }
+ unsigned short qtype;
+ unsigned short qclass;
+ if (!(extract_16 (&in, &qtype)
+ && extract_16 (&in, &qclass)))
+ {
+ fprintf (mem.out, "error: malformed question\n");
+ goto out;
+ }
+ if (qtype != T_A && qtype != T_AAAA && qtype != T_PTR)
+ {
+ fprintf (mem.out, "error: unsupported QTYPE %d\n", qtype);
+ goto out;
+ }
+
+ fprintf (mem.out, "name: %s\n", qname.name);
+
+ for (int i = 0; i < ancount; ++i)
+ {
+ struct dname rname;
+ if (!extract_name (full, &in, &rname))
+ {
+ fprintf (mem.out, "error: malformed record name\n");
+ goto out;
+ }
+ unsigned short rtype;
+ unsigned short rclass;
+ unsigned ttl;
+ unsigned short rdlen;
+ struct in_buffer rdata;
+ if (!(extract_16 (&in, &rtype)
+ && extract_16 (&in, &rclass)
+ && extract_32 (&in, &ttl)
+ && extract_16 (&in, &rdlen)
+ && extract_bytes (&in, rdlen, &rdata)))
+ {
+ fprintf (mem.out, "error: malformed record header\n");
+ goto out;
+ }
+ /* Skip non-matching record types. */
+ if ((rtype != qtype && rtype != T_CNAME) || rclass != qclass)
+ continue;
+ switch (rtype)
+ {
+ case T_A:
+ if (rdlen == 4)
+ fprintf (mem.out, "address: %d.%d.%d.%d\n",
+ rdata.data[0],
+ rdata.data[1],
+ rdata.data[2],
+ rdata.data[3]);
+ else
+ fprintf (mem.out, "error: A record of size %d: %s\n",
+ rdlen, rname.name);
+ break;
+ case T_AAAA:
+ {
+ if (rdlen == 16)
+ {
+ char buf[100];
+ if (inet_ntop (AF_INET6, rdata.data, buf, sizeof (buf)) == NULL)
+ fprintf (mem.out, "error: AAAA record decoding failed: %m\n");
+ else
+ fprintf (mem.out, "address: %s\n", buf);
+ }
+ else
+ fprintf (mem.out, "error: AAAA record of size %d: %s\n",
+ rdlen, rname.name);
+ }
+ break;
+ case T_CNAME:
+ case T_PTR:
+ {
+ struct dname name;
+ if (extract_name (full, &rdata, &name))
+ fprintf (mem.out, "name: %s\n", name.name);
+ else
+ fprintf (mem.out, "error: malformed CNAME/PTR record\n");
+ }
+ }
+ }
+
+ out:
+ xfclose_memstream (&mem);
+ return mem.buffer;
+}
diff --git a/support/support_format_herrno.c b/support/support_format_herrno.c
new file mode 100644
index 0000000000..493d6ae962
--- /dev/null
+++ b/support/support_format_herrno.c
@@ -0,0 +1,45 @@
+/* Convert a h_errno error code to a string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/format_nss.h>
+
+#include <support/support.h>
+
+char *
+support_format_herrno (int code)
+{
+ const char *errstr;
+ switch (code)
+ {
+ case HOST_NOT_FOUND:
+ errstr = "HOST_NOT_FOUND";
+ break;
+ case NO_ADDRESS:
+ errstr = "NO_ADDRESS";
+ break;
+ case NO_RECOVERY:
+ errstr = "NO_RECOVERY";
+ break;
+ case TRY_AGAIN:
+ errstr = "TRY_AGAIN";
+ break;
+ default:
+ return xasprintf ("<invalid h_errno value %d>\n", code);
+ }
+ return xstrdup (errstr);
+}
diff --git a/support/support_format_hostent.c b/support/support_format_hostent.c
new file mode 100644
index 0000000000..5b5f26082e
--- /dev/null
+++ b/support/support_format_hostent.c
@@ -0,0 +1,75 @@
+/* Convert a struct hostent object to a string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/format_nss.h>
+
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <support/support.h>
+#include <support/xmemstream.h>
+
+static int
+address_length (int family)
+{
+ switch (family)
+ {
+ case AF_INET:
+ return 4;
+ case AF_INET6:
+ return 16;
+ }
+ return -1;
+}
+
+char *
+support_format_hostent (struct hostent *h)
+{
+ if (h == NULL)
+ {
+ char *value = support_format_herrno (h_errno);
+ char *result = xasprintf ("error: %s\n", value);
+ free (value);
+ return result;
+ }
+
+ struct xmemstream mem;
+ xopen_memstream (&mem);
+
+ fprintf (mem.out, "name: %s\n", h->h_name);
+ for (char **alias = h->h_aliases; *alias != NULL; ++alias)
+ fprintf (mem.out, "alias: %s\n", *alias);
+ for (unsigned i = 0; h->h_addr_list[i] != NULL; ++i)
+ {
+ char buf[128];
+ if (inet_ntop (h->h_addrtype, h->h_addr_list[i],
+ buf, sizeof (buf)) == NULL)
+ fprintf (mem.out, "error: inet_ntop failed: %m\n");
+ else
+ fprintf (mem.out, "address: %s\n", buf);
+ }
+ if (h->h_length != address_length (h->h_addrtype))
+ {
+ char *family = support_format_address_family (h->h_addrtype);
+ fprintf (mem.out, "error: invalid address length %d for %s\n",
+ h->h_length, family);
+ free (family);
+ }
+
+ xfclose_memstream (&mem);
+ return mem.buffer;
+}
diff --git a/support/support_format_netent.c b/support/support_format_netent.c
new file mode 100644
index 0000000000..020f5720d9
--- /dev/null
+++ b/support/support_format_netent.c
@@ -0,0 +1,52 @@
+/* Convert a struct netent object to a string.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/format_nss.h>
+
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <support/support.h>
+#include <support/xmemstream.h>
+
+char *
+support_format_netent (struct netent *e)
+{
+ if (e == NULL)
+ {
+ char *value = support_format_herrno (h_errno);
+ char *result = xasprintf ("error: %s\n", value);
+ free (value);
+ return result;
+ }
+
+ struct xmemstream mem;
+ xopen_memstream (&mem);
+
+ if (e->n_name != NULL)
+ fprintf (mem.out, "name: %s\n", e->n_name);
+ for (char **ap = e->n_aliases; *ap != NULL; ++ap)
+ fprintf (mem.out, "alias: %s\n", *ap);
+ if (e->n_addrtype != AF_INET)
+ fprintf (mem.out, "addrtype: %d\n", e->n_addrtype);
+ /* On alpha, e->n_net is an unsigned long. */
+ unsigned int n_net = e->n_net;
+ fprintf (mem.out, "net: 0x%08x\n", n_net);
+
+ xfclose_memstream (&mem);
+ return mem.buffer;
+}
diff --git a/support/support_isolate_in_subprocess.c b/support/support_isolate_in_subprocess.c
new file mode 100644
index 0000000000..cf48614383
--- /dev/null
+++ b/support/support_isolate_in_subprocess.c
@@ -0,0 +1,38 @@
+/* Run a function in a subprocess.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+
+void
+support_isolate_in_subprocess (void (*callback) (void *), void *closure)
+{
+ pid_t pid = xfork ();
+ if (pid == 0)
+ {
+ /* Child process. */
+ callback (closure);
+ _exit (0);
+ }
+
+ /* Parent process. */
+ int status;
+ xwaitpid (pid, &status, 0);
+ if (status != 0)
+ FAIL_EXIT1 ("child process exited with status %d", status);
+}
diff --git a/support/support_record_failure.c b/support/support_record_failure.c
new file mode 100644
index 0000000000..684055c746
--- /dev/null
+++ b/support/support_record_failure.c
@@ -0,0 +1,106 @@
+/* Global test failure counter.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+/* This structure keeps track of test failures. The counter is
+ incremented on each failure. The failed member is set to true if a
+ failure is detected, so that even if the counter wraps around to
+ zero, the failure of a test can be detected.
+
+ The init constructor function below puts *state on a shared
+ annonymous mapping, so that failure reports from subprocesses
+ propagate to the parent process. */
+struct test_failures
+{
+ unsigned int counter;
+ unsigned int failed;
+};
+static struct test_failures *state;
+
+static __attribute__ ((constructor)) void
+init (void)
+{
+ void *ptr = mmap (NULL, sizeof (*state), PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+ if (ptr == MAP_FAILED)
+ {
+ printf ("error: could not map %zu bytes: %m\n", sizeof (*state));
+ exit (1);
+ }
+ /* Zero-initialization of the struct is sufficient. */
+ state = ptr;
+}
+
+void
+support_record_failure (void)
+{
+ if (state == NULL)
+ {
+ write_message
+ ("error: support_record_failure called without initialization\n");
+ _exit (1);
+ }
+ /* Relaxed MO is sufficient because we are only interested in the
+ values themselves, in isolation. */
+ __atomic_store_n (&state->failed, 1, __ATOMIC_RELEASE);
+ __atomic_add_fetch (&state->counter, 1, __ATOMIC_RELEASE);
+}
+
+int
+support_report_failure (int status)
+{
+ if (state == NULL)
+ {
+ write_message
+ ("error: support_report_failure called without initialization\n");
+ return 1;
+ }
+
+ /* Relaxed MO is sufficient because acquire test result reporting
+ assumes that exiting from the main thread happens before the
+ error reporting via support_record_failure, which requires some
+ form of external synchronization. */
+ bool failed = __atomic_load_n (&state->failed, __ATOMIC_RELAXED);
+ if (failed)
+ printf ("error: %u test failures\n",
+ __atomic_load_n (&state->counter, __ATOMIC_RELAXED));
+
+ if ((status == 0 || status == EXIT_UNSUPPORTED) && failed)
+ /* If we have a recorded failure, it overrides a non-failure
+ report from the test function. */
+ status = 1;
+ return status;
+}
+
+void
+support_record_failure_reset (void)
+{
+ /* Only used for testing the test framework, with external
+ synchronization, but use release MO for consistency. */
+ __atomic_store_n (&state->failed, 0, __ATOMIC_RELAXED);
+ __atomic_add_fetch (&state->counter, 0, __ATOMIC_RELAXED);
+}
diff --git a/support/support_run_diff.c b/support/support_run_diff.c
new file mode 100644
index 0000000000..f5155de727
--- /dev/null
+++ b/support/support_run_diff.c
@@ -0,0 +1,76 @@
+/* Invoke the system diff tool to compare two strings.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/run_diff.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <sys/wait.h>
+
+static char *
+write_to_temp_file (const char *prefix, const char *str)
+{
+ char *template = xasprintf ("run_diff-%s", prefix);
+ char *name = NULL;
+ int fd = create_temp_file (template, &name);
+ TEST_VERIFY_EXIT (fd >= 0);
+ free (template);
+ xwrite (fd, str, strlen (str));
+ xclose (fd);
+ return name;
+}
+
+void
+support_run_diff (const char *left_label, const char *left,
+ const char *right_label, const char *right)
+{
+ /* Ensure that the diff command output is ordered properly with
+ standard output. */
+ TEST_VERIFY_EXIT (fflush (stdout) == 0);
+
+ char *left_path = write_to_temp_file ("left-diff", left);
+ char *right_path = write_to_temp_file ("right-diff", right);
+
+ pid_t pid = xfork ();
+ if (pid == 0)
+ {
+ execlp ("diff", "diff", "-u",
+ "--label", left_label, "--label", right_label,
+ "--", left_path, right_path,
+ NULL);
+ _exit (17);
+ }
+ else
+ {
+ int status;
+ xwaitpid (pid, &status, 0);
+ if (!WIFEXITED (status) || WEXITSTATUS (status) != 1)
+ printf ("warning: could not run diff, exit status: %d\n"
+ "*** %s ***\n%s\n"
+ "*** %s ***\n%s\n",
+ status, left_label, left, right_label, right);
+ }
+
+ free (right_path);
+ free (left_path);
+}
diff --git a/support/support_shared_allocate.c b/support/support_shared_allocate.c
new file mode 100644
index 0000000000..61d088e8cf
--- /dev/null
+++ b/support/support_shared_allocate.c
@@ -0,0 +1,57 @@
+/* Allocate a memory region shared across processes.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <support/support.h>
+#include <support/xunistd.h>
+#include <sys/mman.h>
+
+/* Header for the allocation. It contains the size of the allocation
+ for subsequent unmapping. */
+struct header
+{
+ size_t total_size;
+ char data[] __attribute__ ((aligned (__alignof__ (max_align_t))));
+};
+
+void *
+support_shared_allocate (size_t size)
+{
+ size_t total_size = size + offsetof (struct header, data);
+ if (total_size < size)
+ {
+ errno = ENOMEM;
+ oom_error (__func__, size);
+ return NULL;
+ }
+ else
+ {
+ struct header *result = xmmap (NULL, total_size, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_SHARED, -1);
+ result->total_size = total_size;
+ return &result->data;
+ }
+}
+
+void
+support_shared_free (void *data)
+{
+ struct header *header = data - offsetof (struct header, data);
+ xmunmap (header, header->total_size);
+}
diff --git a/support/support_test_main.c b/support/support_test_main.c
new file mode 100644
index 0000000000..914d64f603
--- /dev/null
+++ b/support/support_test_main.c
@@ -0,0 +1,423 @@
+/* Main worker function for the test driver.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/test-driver.h>
+#include <support/check.h>
+#include <support/temp_file-internal.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <getopt.h>
+#include <malloc.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+static const struct option default_options[] =
+{
+ TEST_DEFAULT_OPTIONS
+ { NULL, 0, NULL, 0 }
+};
+
+/* Show people how to run the program. */
+static void
+usage (const struct option *options)
+{
+ size_t i;
+
+ printf ("Usage: %s [options]\n"
+ "\n"
+ "Environment Variables:\n"
+ " TIMEOUTFACTOR An integer used to scale the timeout\n"
+ " TMPDIR Where to place temporary files\n"
+ " TEST_COREDUMPS Do not disable coredumps if set\n"
+ "\n",
+ program_invocation_short_name);
+ printf ("Options:\n");
+ for (i = 0; options[i].name; ++i)
+ {
+ int indent;
+
+ indent = printf (" --%s", options[i].name);
+ if (options[i].has_arg == required_argument)
+ indent += printf (" <arg>");
+ printf ("%*s", 25 - indent, "");
+ switch (options[i].val)
+ {
+ case 'v':
+ printf ("Increase the output verbosity");
+ break;
+ case OPT_DIRECT:
+ printf ("Run the test directly (instead of forking & monitoring)");
+ break;
+ case OPT_TESTDIR:
+ printf ("Override the TMPDIR env var");
+ break;
+ }
+ printf ("\n");
+ }
+}
+
+/* The PID of the test process. */
+static pid_t test_pid;
+
+/* The cleanup handler passed to test_main. */
+static void (*cleanup_function) (void);
+
+/* Timeout handler. We kill the child and exit with an error. */
+static void
+__attribute__ ((noreturn))
+signal_handler (int sig)
+{
+ int killed;
+ int status;
+
+ assert (test_pid > 1);
+ /* Kill the whole process group. */
+ kill (-test_pid, SIGKILL);
+ /* In case setpgid failed in the child, kill it individually too. */
+ kill (test_pid, SIGKILL);
+
+ /* Wait for it to terminate. */
+ int i;
+ for (i = 0; i < 5; ++i)
+ {
+ killed = waitpid (test_pid, &status, WNOHANG|WUNTRACED);
+ if (killed != 0)
+ break;
+
+ /* Delay, give the system time to process the kill. If the
+ nanosleep() call return prematurely, all the better. We
+ won't restart it since this probably means the child process
+ finally died. */
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100000000;
+ nanosleep (&ts, NULL);
+ }
+ if (killed != 0 && killed != test_pid)
+ {
+ printf ("Failed to kill test process: %m\n");
+ exit (1);
+ }
+
+ if (cleanup_function != NULL)
+ cleanup_function ();
+
+ if (sig == SIGINT)
+ {
+ signal (sig, SIG_DFL);
+ raise (sig);
+ }
+
+ if (killed == 0 || (WIFSIGNALED (status) && WTERMSIG (status) == SIGKILL))
+ puts ("Timed out: killed the child process");
+ else if (WIFSTOPPED (status))
+ printf ("Timed out: the child process was %s\n",
+ strsignal (WSTOPSIG (status)));
+ else if (WIFSIGNALED (status))
+ printf ("Timed out: the child process got signal %s\n",
+ strsignal (WTERMSIG (status)));
+ else
+ printf ("Timed out: killed the child process but it exited %d\n",
+ WEXITSTATUS (status));
+
+ /* Exit with an error. */
+ exit (1);
+}
+
+/* Run test_function or test_function_argv. */
+static int
+run_test_function (int argc, char **argv, const struct test_config *config)
+{
+ if (config->test_function != NULL)
+ return config->test_function ();
+ else if (config->test_function_argv != NULL)
+ return config->test_function_argv (argc, argv);
+ else
+ {
+ printf ("error: no test function defined\n");
+ exit (1);
+ }
+}
+
+static bool test_main_called;
+
+const char *test_dir = NULL;
+unsigned int test_verbose = 0;
+
+/* If test failure reporting has been linked in, it may contribute
+ additional test failures. */
+static int
+adjust_exit_status (int status)
+{
+ if (support_report_failure != NULL)
+ return support_report_failure (status);
+ return status;
+}
+
+int
+support_test_main (int argc, char **argv, const struct test_config *config)
+{
+ if (test_main_called)
+ {
+ printf ("error: test_main called for a second time\n");
+ exit (1);
+ }
+ test_main_called = true;
+ const struct option *options;
+ if (config->options != NULL)
+ options = config->options;
+ else
+ options = default_options;
+
+ cleanup_function = config->cleanup_function;
+
+ int direct = 0; /* Directly call the test function? */
+ int status;
+ int opt;
+ unsigned int timeoutfactor = 1;
+ pid_t termpid;
+
+ if (!config->no_mallopt)
+ {
+ /* Make uses of freed and uninitialized memory known. Do not
+ pull in a definition for mallopt if it has not been defined
+ already. */
+ extern __typeof__ (mallopt) mallopt __attribute__ ((weak));
+ if (mallopt != NULL)
+ mallopt (M_PERTURB, 42);
+ }
+
+ while ((opt = getopt_long (argc, argv, "+", options, NULL)) != -1)
+ switch (opt)
+ {
+ case '?':
+ usage (options);
+ exit (1);
+ case 'v':
+ ++test_verbose;
+ break;
+ case OPT_DIRECT:
+ direct = 1;
+ break;
+ case OPT_TESTDIR:
+ test_dir = optarg;
+ break;
+ default:
+ if (config->cmdline_function != NULL)
+ config->cmdline_function (opt);
+ }
+
+ /* If set, read the test TIMEOUTFACTOR value from the environment.
+ This value is used to scale the default test timeout values. */
+ char *envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
+ if (envstr_timeoutfactor != NULL)
+ {
+ char *envstr_conv = envstr_timeoutfactor;
+ unsigned long int env_fact;
+
+ env_fact = strtoul (envstr_timeoutfactor, &envstr_conv, 0);
+ if (*envstr_conv == '\0' && envstr_conv != envstr_timeoutfactor)
+ timeoutfactor = MAX (env_fact, 1);
+ }
+
+ /* Set TMPDIR to specified test directory. */
+ if (test_dir != NULL)
+ {
+ setenv ("TMPDIR", test_dir, 1);
+
+ if (chdir (test_dir) < 0)
+ {
+ printf ("chdir: %m\n");
+ exit (1);
+ }
+ }
+ else
+ {
+ test_dir = getenv ("TMPDIR");
+ if (test_dir == NULL || test_dir[0] == '\0')
+ test_dir = "/tmp";
+ }
+ if (support_set_test_dir != NULL)
+ support_set_test_dir (test_dir);
+
+ int timeout = config->timeout;
+ if (timeout == 0)
+ timeout = DEFAULT_TIMEOUT;
+
+ /* Make sure we see all message, even those on stdout. */
+ setvbuf (stdout, NULL, _IONBF, 0);
+
+ /* Make sure temporary files are deleted. */
+ if (support_delete_temp_files != NULL)
+ atexit (support_delete_temp_files);
+
+ /* Correct for the possible parameters. */
+ argv[optind - 1] = argv[0];
+ argv += optind - 1;
+ argc -= optind - 1;
+
+ /* Call the initializing function, if one is available. */
+ if (config->prepare_function != NULL)
+ config->prepare_function (argc, argv);
+
+ const char *envstr_direct = getenv ("TEST_DIRECT");
+ if (envstr_direct != NULL)
+ {
+ FILE *f = fopen (envstr_direct, "w");
+ if (f == NULL)
+ {
+ printf ("cannot open TEST_DIRECT output file '%s': %m\n",
+ envstr_direct);
+ exit (1);
+ }
+
+ fprintf (f, "timeout=%u\ntimeoutfactor=%u\n",
+ config->timeout, timeoutfactor);
+ if (config->expected_status != 0)
+ fprintf (f, "exit=%u\n", config->expected_status);
+ if (config->expected_signal != 0)
+ fprintf (f, "signal=%s\n", strsignal (config->expected_signal));
+
+ if (support_print_temp_files != NULL)
+ support_print_temp_files (f);
+
+ fclose (f);
+ direct = 1;
+ }
+
+ bool disable_coredumps;
+ {
+ const char *coredumps = getenv ("TEST_COREDUMPS");
+ disable_coredumps = coredumps == NULL || coredumps[0] == '\0';
+ }
+
+ /* If we are not expected to fork run the function immediately. */
+ if (direct)
+ return adjust_exit_status (run_test_function (argc, argv, config));
+
+ /* Set up the test environment:
+ - prevent core dumps
+ - set up the timer
+ - fork and execute the function. */
+
+ test_pid = fork ();
+ if (test_pid == 0)
+ {
+ /* This is the child. */
+ if (disable_coredumps)
+ {
+ /* Try to avoid dumping core. This is necessary because we
+ run the test from the source tree, and the coredumps
+ would end up there (and not in the build tree). */
+ struct rlimit core_limit;
+ core_limit.rlim_cur = 0;
+ core_limit.rlim_max = 0;
+ setrlimit (RLIMIT_CORE, &core_limit);
+ }
+
+ /* We put the test process in its own pgrp so that if it bogusly
+ generates any job control signals, they won't hit the whole build. */
+ if (setpgid (0, 0) != 0)
+ printf ("Failed to set the process group ID: %m\n");
+
+ /* Execute the test function and exit with the return value. */
+ exit (run_test_function (argc, argv, config));
+ }
+ else if (test_pid < 0)
+ {
+ printf ("Cannot fork test program: %m\n");
+ exit (1);
+ }
+
+ /* Set timeout. */
+ signal (SIGALRM, signal_handler);
+ alarm (timeout * timeoutfactor);
+
+ /* Make sure we clean up if the wrapper gets interrupted. */
+ signal (SIGINT, signal_handler);
+
+ /* Wait for the regular termination. */
+ termpid = TEMP_FAILURE_RETRY (waitpid (test_pid, &status, 0));
+ if (termpid == -1)
+ {
+ printf ("Waiting for test program failed: %m\n");
+ exit (1);
+ }
+ if (termpid != test_pid)
+ {
+ printf ("Oops, wrong test program terminated: expected %ld, got %ld\n",
+ (long int) test_pid, (long int) termpid);
+ exit (1);
+ }
+
+ /* Process terminated normaly without timeout etc. */
+ if (WIFEXITED (status))
+ {
+ if (config->expected_status == 0)
+ {
+ if (config->expected_signal == 0)
+ /* Exit with the return value of the test. */
+ return adjust_exit_status (WEXITSTATUS (status));
+ else
+ {
+ printf ("Expected signal '%s' from child, got none\n",
+ strsignal (config->expected_signal));
+ exit (1);
+ }
+ }
+ else
+ {
+ /* Non-zero exit status is expected */
+ if (WEXITSTATUS (status) != config->expected_status)
+ {
+ printf ("Expected status %d, got %d\n",
+ config->expected_status, WEXITSTATUS (status));
+ exit (1);
+ }
+ }
+ return adjust_exit_status (0);
+ }
+ /* Process was killed by timer or other signal. */
+ else
+ {
+ if (config->expected_signal == 0)
+ {
+ printf ("Didn't expect signal from child: got `%s'\n",
+ strsignal (WTERMSIG (status)));
+ exit (1);
+ }
+ else if (WTERMSIG (status) != config->expected_signal)
+ {
+ printf ("Incorrect signal from child: got `%s', need `%s'\n",
+ strsignal (WTERMSIG (status)),
+ strsignal (config->expected_signal));
+ exit (1);
+ }
+
+ return adjust_exit_status (0);
+ }
+}
diff --git a/support/support_test_verify_impl.c b/support/support_test_verify_impl.c
new file mode 100644
index 0000000000..5bae38f8b1
--- /dev/null
+++ b/support/support_test_verify_impl.c
@@ -0,0 +1,33 @@
+/* Implementation of the TEST_VERIFY and TEST_VERIFY_EXIT macros.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+support_test_verify_impl (int status, const char *file, int line,
+ const char *expr)
+{
+ support_record_failure ();
+ printf ("error: %s:%d: not true: %s\n", file, line, expr);
+ if (status >= 0)
+ exit (status);
+
+}
diff --git a/support/support_write_file_string.c b/support/support_write_file_string.c
new file mode 100644
index 0000000000..48e89597f3
--- /dev/null
+++ b/support/support_write_file_string.c
@@ -0,0 +1,39 @@
+/* Write a string to a file.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <fcntl.h>
+#include <string.h>
+#include <support/check.h>
+#include <xunistd.h>
+
+void
+support_write_file_string (const char *path, const char *contents)
+{
+ int fd = xopen (path, O_CREAT | O_TRUNC | O_WRONLY, 0666);
+ const char *end = contents + strlen (contents);
+ for (const char *p = contents; p < end; )
+ {
+ ssize_t ret = write (fd, p, end - p);
+ if (ret < 0)
+ FAIL_EXIT1 ("cannot write to \"%s\": %m", path);
+ if (ret == 0)
+ FAIL_EXIT1 ("zero-length write to \"%s\"", path);
+ p += ret;
+ }
+ xclose (fd);
+}
diff --git a/support/temp_file-internal.h b/support/temp_file-internal.h
new file mode 100644
index 0000000000..fb6cceb065
--- /dev/null
+++ b/support/temp_file-internal.h
@@ -0,0 +1,31 @@
+/* Internal weak declarations for temporary file handling.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_TEMP_FILE_INTERNAL_H
+#define SUPPORT_TEMP_FILE_INTERNAL_H
+
+/* These functions are called by the test driver if they are
+ defined. Tests should not call them directly. */
+
+#include <stdio.h>
+
+void support_set_test_dir (const char *name) __attribute__ ((weak));
+void support_delete_temp_files (void) __attribute__ ((weak));
+void support_print_temp_files (FILE *) __attribute__ ((weak));
+
+#endif /* SUPPORT_TEMP_FILE_INTERNAL_H */
diff --git a/support/temp_file.c b/support/temp_file.c
new file mode 100644
index 0000000000..fdb2477ab9
--- /dev/null
+++ b/support/temp_file.c
@@ -0,0 +1,132 @@
+/* Temporary file handling for tests.
+ Copyright (C) 1998-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This is required to get an mkstemp which can create large files on
+ some 32-bit platforms. */
+#define _FILE_OFFSET_BITS 64
+
+#include <support/temp_file.h>
+#include <support/temp_file-internal.h>
+#include <support/support.h>
+
+#include <paths.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* List of temporary files. */
+static struct temp_name_list
+{
+ struct temp_name_list *next;
+ char *name;
+ pid_t owner;
+} *temp_name_list;
+
+/* Location of the temporary files. Set by the test skeleton via
+ support_set_test_dir. The string is not be freed. */
+static const char *test_dir = _PATH_TMP;
+
+void
+add_temp_file (const char *name)
+{
+ struct temp_name_list *newp
+ = (struct temp_name_list *) xcalloc (sizeof (*newp), 1);
+ char *newname = strdup (name);
+ if (newname != NULL)
+ {
+ newp->name = newname;
+ newp->next = temp_name_list;
+ newp->owner = getpid ();
+ temp_name_list = newp;
+ }
+ else
+ free (newp);
+}
+
+int
+create_temp_file (const char *base, char **filename)
+{
+ char *fname;
+ int fd;
+
+ fname = (char *) xmalloc (strlen (test_dir) + 1 + strlen (base)
+ + sizeof ("XXXXXX"));
+ strcpy (stpcpy (stpcpy (stpcpy (fname, test_dir), "/"), base), "XXXXXX");
+
+ fd = mkstemp (fname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file '%s': %m\n", fname);
+ free (fname);
+ return -1;
+ }
+
+ add_temp_file (fname);
+ if (filename != NULL)
+ *filename = fname;
+ else
+ free (fname);
+
+ return fd;
+}
+
+/* Helper functions called by the test skeleton follow. */
+
+void
+support_set_test_dir (const char *path)
+{
+ test_dir = path;
+}
+
+void
+support_delete_temp_files (void)
+{
+ pid_t pid = getpid ();
+ while (temp_name_list != NULL)
+ {
+ /* Only perform the removal if the path was registed in the same
+ process, as identified by the PID. (This assumes that the
+ parent process which registered the temporary file sticks
+ around, to prevent PID reuse.) */
+ if (temp_name_list->owner == pid)
+ {
+ if (remove (temp_name_list->name) != 0)
+ printf ("warning: could not remove temporary file: %s: %m\n",
+ temp_name_list->name);
+ }
+ free (temp_name_list->name);
+
+ struct temp_name_list *next = temp_name_list->next;
+ free (temp_name_list);
+ temp_name_list = next;
+ }
+}
+
+void
+support_print_temp_files (FILE *f)
+{
+ if (temp_name_list != NULL)
+ {
+ struct temp_name_list *n;
+ fprintf (f, "temp_files=(\n");
+ for (n = temp_name_list; n != NULL; n = n->next)
+ fprintf (f, " '%s'\n", n->name);
+ fprintf (f, ")\n");
+ }
+}
diff --git a/support/temp_file.h b/support/temp_file.h
new file mode 100644
index 0000000000..6fed8df1ea
--- /dev/null
+++ b/support/temp_file.h
@@ -0,0 +1,37 @@
+/* Declarations for temporary file handling.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_TEMP_FILE_H
+#define SUPPORT_TEMP_FILE_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Schedule a temporary file for deletion on exit. */
+void add_temp_file (const char *name);
+
+/* Create a temporary file. Return the opened file descriptor on
+ success, or -1 on failure. Write the file name to *FILENAME if
+ FILENAME is not NULL. In this case, the caller is expected to free
+ *FILENAME. */
+int create_temp_file (const char *base, char **filename);
+
+__END_DECLS
+
+#endif /* SUPPORT_TEMP_FILE_H */
diff --git a/support/test-driver.c b/support/test-driver.c
new file mode 100644
index 0000000000..482066dbeb
--- /dev/null
+++ b/support/test-driver.c
@@ -0,0 +1,156 @@
+/* Main function for test programs.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file should be included from test cases. It will define a
+ main function which provides the test wrapper.
+
+ It assumes that the test case defines a function
+
+ int do_test (void);
+
+ and arranges for that function being called under the test wrapper.
+ The do_test function should return 0 to indicate a passing test, 1
+ to indicate a failing test, or 77 to indicate an unsupported test.
+ Other result values could be used to indicate a failing test, but
+ the result of the expression is passed to exit and exit only
+ returns the lower 8 bits of its input. A non-zero return with some
+ values could cause a test to incorrectly be considered passing when
+ it really failed. For this reason, the function should always
+ return 0 (EXIT_SUCCESS), 1 (EXIT_FAILURE), or 77
+ (EXIT_UNSUPPORTED).
+
+ The test function may print out diagnostic or warning messages as well
+ as messages about failures. These messages should be printed to stdout
+ and not stderr so that the output is properly ordered with respect to
+ the rest of the glibc testsuite run output.
+
+ Several preprocessors macros can be defined before including this
+ file.
+
+ The name of the do_test function can be changed with the
+ TEST_FUNCTION macro. It must expand to the desired function name.
+
+ If the test case needs access to command line parameters, it must
+ define the TEST_FUNCTION_ARGV macro with the name of the test
+ function. It must have the following type:
+
+ int TEST_FUNCTION_ARGV (int argc, char **argv);
+
+ This overrides the do_test default function and is incompatible
+ with the TEST_FUNCTION macro.
+
+ If PREPARE is defined, it must expand to the name of a function of
+ the type
+
+ void PREPARE (int argc, char **);
+
+ This function will be called early, after parsing the command line,
+ but before running the test, in the parent process which acts as
+ the test supervisor.
+
+ If CLEANUP_HANDLER is defined, it must expand to the name of a
+ function of the type
+
+ void CLEANUP_HANDLER (void);
+
+ This function will be called from the timeout (SIGALRM) signal
+ handler.
+
+ If EXPECTED_SIGNAL is defined, it must expanded to a constant which
+ denotes the expected signal number.
+
+ If EXPECTED_STATUS is defined, it must expand to the expected exit
+ status.
+
+ If TIMEOUT is defined, it must be positive constant. It overrides
+ the default test timeout and is measured in seconds.
+
+ If TEST_NO_MALLOPT is defined, the test wrapper will not call
+ mallopt.
+
+ Custom command line handling can be implemented by defining the
+ CMDLINE_OPTION macro (after including the <getopt.h> header; this
+ requires _GNU_SOURCE to be defined). This macro must expand to a
+ to a comma-separated list of braced initializers for struct option
+ from <getopt.h>, with a trailing comma. CMDLINE_PROCESS can be
+ defined as the name of a function which is called to process these
+ options. The function is passed the option character/number and
+ has this type:
+
+ void CMDLINE_PROCESS (int);
+*/
+
+#include <support/test-driver.h>
+
+#include <string.h>
+
+int
+main (int argc, char **argv)
+{
+ struct test_config test_config;
+ memset (&test_config, 0, sizeof (test_config));
+
+#ifdef PREPARE
+ test_config.prepare_function = (PREPARE);
+#endif
+
+#if defined (TEST_FUNCTION) && defined (TEST_FUNCTON_ARGV)
+# error TEST_FUNCTION and TEST_FUNCTION_ARGV cannot be defined at the same time
+#endif
+#if defined (TEST_FUNCTION)
+ test_config.test_function = TEST_FUNCTION;
+#elif defined (TEST_FUNCTION_ARGV)
+ test_config.test_function_argv = TEST_FUNCTION_ARGV;
+#else
+ test_config.test_function = do_test;
+#endif
+
+#ifdef CLEANUP_HANDLER
+ test_config.cleanup_function = CLEANUP_HANDLER;
+#endif
+
+#ifdef EXPECTED_SIGNAL
+ test_config.expected_signal = (EXPECTED_SIGNAL);
+#endif
+
+#ifdef EXPECTED_STATUS
+ test_config.expected_status = (EXPECTED_STATUS);
+#endif
+
+#ifdef TEST_NO_MALLOPT
+ test_config.no_mallopt = 1;
+#endif
+
+#ifdef TIMEOUT
+ test_config.timeout = TIMEOUT;
+#endif
+
+#ifdef CMDLINE_OPTIONS
+ struct option options[] =
+ {
+ CMDLINE_OPTIONS
+ TEST_DEFAULT_OPTIONS
+ };
+ test_config.options = &options;
+#endif
+#ifdef CMDLINE_PROCESS
+ test_config.cmdline_function = CMDLINE_PROCESS;
+#endif
+
+ return support_test_main (argc, argv, &test_config);
+}
diff --git a/support/test-driver.h b/support/test-driver.h
new file mode 100644
index 0000000000..af1971a9ca
--- /dev/null
+++ b/support/test-driver.h
@@ -0,0 +1,74 @@
+/* Interfaces for the test driver.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_TEST_DRIVER_H
+#define SUPPORT_TEST_DRIVER_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+struct test_config
+{
+ void (*prepare_function) (int argc, char **argv);
+ int (*test_function) (void);
+ int (*test_function_argv) (int argc, char **argv);
+ void (*cleanup_function) (void);
+ void (*cmdline_function) (int);
+ const void *options; /* Custom options if not NULL. */
+ int timeout; /* Test timeout in seconds. */
+ int expected_status; /* Expected exit status. */
+ int expected_signal; /* If non-zero, expect termination by signal. */
+ char no_mallopt; /* Boolean flag to disable mallopt. */
+};
+
+enum
+ {
+ /* Test exit status which indicates that the feature is
+ unsupported. */
+ EXIT_UNSUPPORTED = 77,
+
+ /* Default timeout is twenty seconds. Tests should normally
+ complete faster than this, but if they don't, that's abnormal
+ (a bug) anyways. */
+ DEFAULT_TIMEOUT = 20,
+
+ /* Used for command line argument parsing. */
+ OPT_DIRECT = 1000,
+ OPT_TESTDIR,
+ };
+
+/* Options provided by the test driver. */
+#define TEST_DEFAULT_OPTIONS \
+ { "verbose", no_argument, NULL, 'v' }, \
+ { "direct", no_argument, NULL, OPT_DIRECT }, \
+ { "test-dir", required_argument, NULL, OPT_TESTDIR }, \
+
+/* The directory the test should use for temporary files. */
+extern const char *test_dir;
+
+/* The number of --verbose arguments specified during program
+ invocation. This variable can be used to control the verbosity of
+ tests. */
+extern unsigned int test_verbose;
+
+int support_test_main (int argc, char **argv, const struct test_config *);
+
+__END_DECLS
+
+#endif /* SUPPORT_TEST_DRIVER_H */
diff --git a/support/tst-support-namespace.c b/support/tst-support-namespace.c
new file mode 100644
index 0000000000..a50b074f5e
--- /dev/null
+++ b/support/tst-support-namespace.c
@@ -0,0 +1,34 @@
+/* Test entering namespaces.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <support/namespace.h>
+
+static int
+do_test (void)
+{
+ if (support_become_root ())
+ printf ("info: acquired root-like privileges\n");
+ if (support_enter_network_namespace ())
+ printf ("info: entered network namespace\n");
+ if (support_in_uts_namespace ())
+ printf ("info: also entered UTS namespace\n");
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c
new file mode 100644
index 0000000000..5672fba0f7
--- /dev/null
+++ b/support/tst-support_capture_subprocess.c
@@ -0,0 +1,188 @@
+/* Test capturing output from a subprocess.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+/* Write one byte at *P to FD and advance *P. Do nothing if *P is
+ '\0'. */
+static void
+transfer (const unsigned char **p, int fd)
+{
+ if (**p != '\0')
+ {
+ TEST_VERIFY (write (fd, *p, 1) == 1);
+ ++*p;
+ }
+}
+
+/* Determine the order in which stdout and stderr are written. */
+enum write_mode { out_first, err_first, interleave,
+ write_mode_last = interleave };
+
+/* Describe what to write in the subprocess. */
+struct test
+{
+ char *out;
+ char *err;
+ enum write_mode write_mode;
+ int signal;
+ int status;
+};
+
+/* For use with support_capture_subprocess. */
+static void
+callback (void *closure)
+{
+ const struct test *test = closure;
+ bool mode_ok = false;
+ switch (test->write_mode)
+ {
+ case out_first:
+ TEST_VERIFY (fputs (test->out, stdout) >= 0);
+ TEST_VERIFY (fflush (stdout) == 0);
+ TEST_VERIFY (fputs (test->err, stderr) >= 0);
+ TEST_VERIFY (fflush (stderr) == 0);
+ mode_ok = true;
+ break;
+ case err_first:
+ TEST_VERIFY (fputs (test->err, stderr) >= 0);
+ TEST_VERIFY (fflush (stderr) == 0);
+ TEST_VERIFY (fputs (test->out, stdout) >= 0);
+ TEST_VERIFY (fflush (stdout) == 0);
+ mode_ok = true;
+ break;
+ case interleave:
+ {
+ const unsigned char *pout = (const unsigned char *) test->out;
+ const unsigned char *perr = (const unsigned char *) test->err;
+ do
+ {
+ transfer (&pout, STDOUT_FILENO);
+ transfer (&perr, STDERR_FILENO);
+ }
+ while (*pout != '\0' || *perr != '\0');
+ }
+ mode_ok = true;
+ break;
+ }
+ TEST_VERIFY (mode_ok);
+
+ if (test->signal != 0)
+ raise (test->signal);
+ exit (test->status);
+}
+
+/* Create a heap-allocated random string of letters. */
+static char *
+random_string (size_t length)
+{
+ char *result = xmalloc (length + 1);
+ for (size_t i = 0; i < length; ++i)
+ result[i] = 'a' + (rand () % 26);
+ result[length] = '\0';
+ return result;
+}
+
+/* Check that the specific stream from the captured subprocess matches
+ expectations. */
+static void
+check_stream (const char *what, const struct xmemstream *stream,
+ const char *expected)
+{
+ if (strcmp (stream->buffer, expected) != 0)
+ {
+ support_record_failure ();
+ printf ("error: captured %s data incorrect\n"
+ " expected: %s\n"
+ " actual: %s\n",
+ what, expected, stream->buffer);
+ }
+ if (stream->length != strlen (expected))
+ {
+ support_record_failure ();
+ printf ("error: captured %s data length incorrect\n"
+ " expected: %zu\n"
+ " actual: %zu\n",
+ what, strlen (expected), stream->length);
+ }
+}
+
+static int
+do_test (void)
+{
+ const int lengths[] = {0, 1, 17, 512, 20000, -1};
+
+ /* Test multiple combinations of support_capture_subprocess.
+
+ length_idx_stdout: Index into the lengths array above,
+ controls how many bytes are written by the subprocess to
+ standard output.
+ length_idx_stderr: Same for standard error.
+ write_mode: How standard output and standard error writes are
+ ordered.
+ signal: Exit with no signal if zero, with SIGTERM if one.
+ status: Process exit status: 0 if zero, 3 if one. */
+ for (int length_idx_stdout = 0; lengths[length_idx_stdout] >= 0;
+ ++length_idx_stdout)
+ for (int length_idx_stderr = 0; lengths[length_idx_stderr] >= 0;
+ ++length_idx_stderr)
+ for (int write_mode = 0; write_mode < write_mode_last; ++write_mode)
+ for (int signal = 0; signal < 2; ++signal)
+ for (int status = 0; status < 2; ++status)
+ {
+ struct test test =
+ {
+ .out = random_string (lengths[length_idx_stdout]),
+ .err = random_string (lengths[length_idx_stderr]),
+ .write_mode = write_mode,
+ .signal = signal * SIGTERM, /* 0 or SIGTERM. */
+ .status = status * 3, /* 0 or 3. */
+ };
+ TEST_VERIFY (strlen (test.out) == lengths[length_idx_stdout]);
+ TEST_VERIFY (strlen (test.err) == lengths[length_idx_stderr]);
+
+ struct support_capture_subprocess result
+ = support_capture_subprocess (callback, &test);
+ check_stream ("stdout", &result.out, test.out);
+ check_stream ("stderr", &result.err, test.err);
+ if (test.signal != 0)
+ {
+ TEST_VERIFY (WIFSIGNALED (result.status));
+ TEST_VERIFY (WTERMSIG (result.status) == test.signal);
+ }
+ else
+ {
+ TEST_VERIFY (WIFEXITED (result.status));
+ TEST_VERIFY (WEXITSTATUS (result.status) == test.status);
+ }
+ support_capture_subprocess_free (&result);
+ free (test.out);
+ free (test.err);
+ }
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/tst-support_format_dns_packet.c b/support/tst-support_format_dns_packet.c
new file mode 100644
index 0000000000..9c8589c09c
--- /dev/null
+++ b/support/tst-support_format_dns_packet.c
@@ -0,0 +1,101 @@
+/* Tests for the support_format_dns_packet function.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/format_nss.h>
+#include <support/run_diff.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void
+check_packet (const void *buffer, size_t length,
+ const char *name, const char *expected)
+{
+ char *actual = support_format_dns_packet (buffer, length);
+ if (strcmp (actual, expected) != 0)
+ {
+ support_record_failure ();
+ printf ("error: formatted packet does not match: %s\n", name);
+ support_run_diff ("expected", expected,
+ "actual", actual);
+ }
+ free (actual);
+}
+
+static void
+test_aaaa_length (void)
+{
+ static const char packet[] =
+ /* Header: Response with two records. */
+ "\x12\x34\x80\x00\x00\x01\x00\x02\x00\x00\x00\x00"
+ /* Question section. www.example/IN/AAAA. */
+ "\x03www\x07""example\x00\x00\x1c\x00\x01"
+ /* Answer section. www.example AAAA [corrupted]. */
+ "\xc0\x0c"
+ "\x00\x1c\x00\x01\x00\x00\x00\x00\x00\x10"
+ "\x20\x01\x0d\xb8\x05\x06\x07\x08"
+ "\x11\x12\x13\x14\x15\x16\x17\x18"
+ /* www.example AAAA [corrupted]. */
+ "\xc0\x0c"
+ "\x00\x1c\x00\x01\x00\x00\x00\x00\x00\x11"
+ "\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x11\x12\x13\x14\x15\x16\x17\x18" "\xff";
+ check_packet (packet, sizeof (packet) - 1, __func__,
+ "name: www.example\n"
+ "address: 2001:db8:506:708:1112:1314:1516:1718\n"
+ "error: AAAA record of size 17: www.example\n");
+}
+
+static void
+test_multiple_cnames (void)
+{
+ static const char packet[] =
+ /* Header: Response with three records. */
+ "\x12\x34\x80\x00\x00\x01\x00\x03\x00\x00\x00\x00"
+ /* Question section. www.example/IN/A. */
+ "\x03www\x07""example\x00\x00\x01\x00\x01"
+ /* Answer section. www.example CNAME www1.example. */
+ "\xc0\x0c"
+ "\x00\x05\x00\x01\x00\x00\x00\x00\x00\x07"
+ "\x04www1\xc0\x10"
+ /* www1 CNAME www2. */
+ "\x04www1\xc0\x10"
+ "\x00\x05\x00\x01\x00\x00\x00\x00\x00\x07"
+ "\x04www2\xc0\x10"
+ /* www2 A 192.0.2.1. */
+ "\x04www2\xc0\x10"
+ "\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04"
+ "\xc0\x00\x02\x01";
+ check_packet (packet, sizeof (packet) - 1, __func__,
+ "name: www.example\n"
+ "name: www1.example\n"
+ "name: www2.example\n"
+ "address: 192.0.2.1\n");
+}
+
+static int
+do_test (void)
+{
+ test_aaaa_length ();
+ test_multiple_cnames ();
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/tst-support_record_failure-2.sh b/support/tst-support_record_failure-2.sh
new file mode 100644
index 0000000000..2c9372cc29
--- /dev/null
+++ b/support/tst-support_record_failure-2.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+# Test failure recording (with and without --direct).
+# Copyright (C) 2016-2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>. */
+
+set -e
+
+common_objpfx=$1; shift
+test_program_prefix_before_env=$1; shift
+run_program_env=$1; shift
+test_program_prefix_after_env=$1; shift
+
+run_test () {
+ expected_status="$1"
+ expected_output="$2"
+ shift 2
+ args="${common_objpfx}support/tst-support_record_failure $*"
+ echo "running: $args"
+ set +e
+ output="$(${test_program_prefix_before_env} \
+ ${run_program} ${test_program_prefix_after_env} $args)"
+ status=$?
+ set -e
+ echo " exit status: $status"
+ if test "$output" != "$expected_output" ; then
+ echo "error: unexpected output: $output"
+ exit 1
+ fi
+ if test "$status" -ne "$expected_status" ; then
+ echo "error: exit status $expected_status expected"
+ exit 1
+ fi
+}
+
+different_status () {
+ direct="$1"
+ run_test 1 "error: 1 test failures" $direct --status=0
+ run_test 1 "error: 1 test failures" $direct --status=1
+ run_test 2 "error: 1 test failures" $direct --status=2
+ run_test 1 "error: 1 test failures" $direct --status=77
+ run_test 2 "error: tst-support_record_failure.c:109: not true: false
+error: 1 test failures" $direct --test-verify
+ run_test 2 "error: tst-support_record_failure.c:109: not true: false
+info: execution passed failed TEST_VERIFY
+error: 1 test failures" $direct --test-verify --verbose
+}
+
+different_status
+different_status --direct
+
+run_test 1 "error: tst-support_record_failure.c:116: not true: false
+error: 1 test failures" --test-verify-exit
+# --direct does not print the summary error message if exit is called.
+run_test 1 "error: tst-support_record_failure.c:116: not true: false" \
+ --direct --test-verify-exit
diff --git a/support/tst-support_record_failure.c b/support/tst-support_record_failure.c
new file mode 100644
index 0000000000..e739e739c3
--- /dev/null
+++ b/support/tst-support_record_failure.c
@@ -0,0 +1,153 @@
+/* Test support_record_failure state sharing.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/support.h>
+#include <support/test-driver.h>
+#include <support/xunistd.h>
+
+#include <getopt.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+static int exit_status_with_failure = -1;
+static bool test_verify;
+static bool test_verify_exit;
+enum
+ {
+ OPT_STATUS = 10001,
+ OPT_TEST_VERIFY,
+ OPT_TEST_VERIFY_EXIT,
+ };
+#define CMDLINE_OPTIONS \
+ { "status", required_argument, NULL, OPT_STATUS }, \
+ { "test-verify", no_argument, NULL, OPT_TEST_VERIFY }, \
+ { "test-verify-exit", no_argument, NULL, OPT_TEST_VERIFY_EXIT },
+static void
+cmdline_process (int c)
+{
+ switch (c)
+ {
+ case OPT_STATUS:
+ exit_status_with_failure = atoi (optarg);
+ break;
+ case OPT_TEST_VERIFY:
+ test_verify = true;
+ break;
+ case OPT_TEST_VERIFY_EXIT:
+ test_verify_exit = true;
+ break;
+ }
+}
+#define CMDLINE_PROCESS cmdline_process
+
+static void
+check_failure_reporting (int phase, int zero, int unsupported)
+{
+ int status = support_report_failure (0);
+ if (status != zero)
+ {
+ printf ("real-error (phase %d): support_report_failure (0) == %d\n",
+ phase, status);
+ exit (1);
+ }
+ status = support_report_failure (1);
+ if (status != 1)
+ {
+ printf ("real-error (phase %d): support_report_failure (1) == %d\n",
+ phase, status);
+ exit (1);
+ }
+ status = support_report_failure (2);
+ if (status != 2)
+ {
+ printf ("real-error (phase %d): support_report_failure (2) == %d\n",
+ phase, status);
+ exit (1);
+ }
+ status = support_report_failure (EXIT_UNSUPPORTED);
+ if (status != unsupported)
+ {
+ printf ("real-error (phase %d): "
+ "support_report_failure (EXIT_UNSUPPORTED) == %d\n",
+ phase, status);
+ exit (1);
+ }
+}
+
+static int
+do_test (void)
+{
+ if (exit_status_with_failure >= 0)
+ {
+ /* External invocation with requested error status. Used by
+ tst-support_report_failure-2.sh. */
+ support_record_failure ();
+ return exit_status_with_failure;
+ }
+ TEST_VERIFY (true);
+ TEST_VERIFY_EXIT (true);
+ if (test_verify)
+ {
+ TEST_VERIFY (false);
+ if (test_verbose)
+ printf ("info: execution passed failed TEST_VERIFY\n");
+ return 2; /* Expected exit status. */
+ }
+ if (test_verify_exit)
+ {
+ TEST_VERIFY_EXIT (false);
+ return 3; /* Not reached. Expected exit status is 1. */
+ }
+
+ printf ("info: This test tests the test framework.\n"
+ "info: It reports some expected errors on stdout.\n");
+
+ /* Check that the status is passed through unchanged. */
+ check_failure_reporting (1, 0, EXIT_UNSUPPORTED);
+
+ /* Check state propagation from a subprocess. */
+ pid_t pid = xfork ();
+ if (pid == 0)
+ {
+ support_record_failure ();
+ _exit (0);
+ }
+ int status;
+ xwaitpid (pid, &status, 0);
+ if (status != 0)
+ {
+ printf ("real-error: incorrect status from subprocess: %d\n", status);
+ return 1;
+ }
+ check_failure_reporting (2, 1, 1);
+
+ /* Also test directly in the parent process. */
+ support_record_failure_reset ();
+ check_failure_reporting (3, 0, EXIT_UNSUPPORTED);
+ support_record_failure ();
+ check_failure_reporting (4, 1, 1);
+
+ /* We need to mask the failure above. */
+ support_record_failure_reset ();
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/write_message.c b/support/write_message.c
new file mode 100644
index 0000000000..f03ed931d6
--- /dev/null
+++ b/support/write_message.c
@@ -0,0 +1,29 @@
+/* Write a message to standard output.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <string.h>
+#include <unistd.h>
+
+void
+write_message (const char *message)
+{
+ ssize_t unused __attribute__ ((unused));
+ unused = write (STDOUT_FILENO, message, strlen (message));
+}
diff --git a/support/xaccept.c b/support/xaccept.c
new file mode 100644
index 0000000000..7b25af3b05
--- /dev/null
+++ b/support/xaccept.c
@@ -0,0 +1,32 @@
+/* accept with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+int
+xaccept (int fd, struct sockaddr *sa, socklen_t *salen)
+{
+ int clientfd = accept (fd, sa, salen);
+ if (clientfd < 0)
+ FAIL_EXIT1 ("accept (%d): %m", fd);
+ return clientfd;
+}
diff --git a/support/xaccept4.c b/support/xaccept4.c
new file mode 100644
index 0000000000..67dd95e9fb
--- /dev/null
+++ b/support/xaccept4.c
@@ -0,0 +1,32 @@
+/* accept4 with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+int
+xaccept4 (int fd, struct sockaddr *sa, socklen_t *salen, int flags)
+{
+ int clientfd = accept4 (fd, sa, salen, flags);
+ if (clientfd < 0)
+ FAIL_EXIT1 ("accept4 (%d, 0x%x): %m", fd, flags);
+ return clientfd;
+}
diff --git a/support/xasprintf.c b/support/xasprintf.c
new file mode 100644
index 0000000000..5157680fa2
--- /dev/null
+++ b/support/xasprintf.c
@@ -0,0 +1,36 @@
+/* Error-checking wrapper for asprintf.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+char *
+xasprintf (const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ char *result;
+ if (vasprintf (&result, format, ap) < 0)
+ FAIL_EXIT1 ("asprintf: %m");
+ va_end (ap);
+ return result;
+}
diff --git a/support/xbind.c b/support/xbind.c
new file mode 100644
index 0000000000..cfc6dd8fa8
--- /dev/null
+++ b/support/xbind.c
@@ -0,0 +1,30 @@
+/* bind with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xbind (int fd, const struct sockaddr *sa, socklen_t sa_len)
+{
+ if (bind (fd, sa, sa_len) != 0)
+ FAIL_EXIT1 ("bind (%d), family %d: %m", fd, sa->sa_family);
+}
diff --git a/support/xcalloc.c b/support/xcalloc.c
new file mode 100644
index 0000000000..135f42dab2
--- /dev/null
+++ b/support/xcalloc.c
@@ -0,0 +1,34 @@
+/* Error-checking wrapper for calloc.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void *
+xcalloc (size_t n, size_t s)
+{
+ void *p;
+
+ p = calloc (n, s);
+ if (p == NULL)
+ oom_error ("calloc", n * s);
+ return p;
+}
diff --git a/support/xchroot.c b/support/xchroot.c
new file mode 100644
index 0000000000..abcc299e00
--- /dev/null
+++ b/support/xchroot.c
@@ -0,0 +1,28 @@
+/* chroot with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+void
+xchroot (const char *path)
+{
+ if (chroot (path) != 0)
+ FAIL_EXIT1 ("chroot (\"%s\"): %m", path);
+}
diff --git a/support/xclose.c b/support/xclose.c
new file mode 100644
index 0000000000..c931e08421
--- /dev/null
+++ b/support/xclose.c
@@ -0,0 +1,28 @@
+/* close with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+#include <support/check.h>
+#include <errno.h>
+
+void
+xclose (int fd)
+{
+ if (close (fd) < 0 && errno != EINTR)
+ FAIL_EXIT1 ("close of descriptor %d failed: %m", fd);
+}
diff --git a/support/xconnect.c b/support/xconnect.c
new file mode 100644
index 0000000000..0266dbc643
--- /dev/null
+++ b/support/xconnect.c
@@ -0,0 +1,30 @@
+/* connect with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xconnect (int fd, const struct sockaddr *sa, socklen_t sa_len)
+{
+ if (connect (fd, sa, sa_len) != 0)
+ FAIL_EXIT1 ("connect (%d), family %d: %m", fd, sa->sa_family);
+}
diff --git a/support/xdup2.c b/support/xdup2.c
new file mode 100644
index 0000000000..dc08c94518
--- /dev/null
+++ b/support/xdup2.c
@@ -0,0 +1,28 @@
+/* dup2 with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+
+#include <support/check.h>
+
+void
+xdup2 (int from, int to)
+{
+ if (dup2 (from, to) < 0)
+ FAIL_EXIT1 ("dup2 (%d, %d): %m", from, to);
+}
diff --git a/support/xfclose.c b/support/xfclose.c
new file mode 100644
index 0000000000..2737f05044
--- /dev/null
+++ b/support/xfclose.c
@@ -0,0 +1,33 @@
+/* fclose with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xstdio.h>
+
+#include <support/check.h>
+#include <stdlib.h>
+
+void
+xfclose (FILE *fp)
+{
+ if (ferror (fp))
+ FAIL_EXIT1 ("stdio stream closed with pending errors");
+ if (fflush (fp) != 0)
+ FAIL_EXIT1 ("fflush: %m");
+ if (fclose (fp) != 0)
+ FAIL_EXIT1 ("fclose: %m");
+}
diff --git a/support/xfopen.c b/support/xfopen.c
new file mode 100644
index 0000000000..14532a09f3
--- /dev/null
+++ b/support/xfopen.c
@@ -0,0 +1,31 @@
+/* fopen with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xstdio.h>
+
+#include <support/check.h>
+#include <stdlib.h>
+
+FILE *
+xfopen (const char *path, const char *mode)
+{
+ FILE *fp = fopen (path, mode);
+ if (fp == NULL)
+ FAIL_EXIT1 ("could not open %s (mode \"%s\"): %m", path, mode);
+ return fp;
+}
diff --git a/support/xfork.c b/support/xfork.c
new file mode 100644
index 0000000000..aa52ba62c5
--- /dev/null
+++ b/support/xfork.c
@@ -0,0 +1,32 @@
+/* fork with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+pid_t
+xfork (void)
+{
+ pid_t result = fork ();
+ if (result < 0)
+ FAIL_EXIT1 ("fork: %m");
+ return result;
+}
diff --git a/support/xgetsockname.c b/support/xgetsockname.c
new file mode 100644
index 0000000000..c3bd884f8d
--- /dev/null
+++ b/support/xgetsockname.c
@@ -0,0 +1,30 @@
+/* getsockname with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xgetsockname (int fd, struct sockaddr *sa, socklen_t *plen)
+{
+ if (getsockname (fd, sa, plen) != 0)
+ FAIL_EXIT1 ("setsockopt (%d): %m", fd);
+}
diff --git a/support/xlisten.c b/support/xlisten.c
new file mode 100644
index 0000000000..1953e5900a
--- /dev/null
+++ b/support/xlisten.c
@@ -0,0 +1,30 @@
+/* listen with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xlisten (int fd, int backlog)
+{
+ if (listen (fd, backlog) != 0)
+ FAIL_EXIT1 ("listen (%d, %d): %m", fd, backlog);
+}
diff --git a/support/xmalloc.c b/support/xmalloc.c
new file mode 100644
index 0000000000..450f699789
--- /dev/null
+++ b/support/xmalloc.c
@@ -0,0 +1,34 @@
+/* Error-checking wrapper for malloc.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void *
+xmalloc (size_t n)
+{
+ void *p;
+
+ p = malloc (n);
+ if (p == NULL)
+ oom_error ("malloc", n);
+ return p;
+}
diff --git a/support/xmemstream.c b/support/xmemstream.c
new file mode 100644
index 0000000000..bce6dc9170
--- /dev/null
+++ b/support/xmemstream.c
@@ -0,0 +1,42 @@
+/* Error-checking wrappers for memstream functions.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xmemstream.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <support/xstdio.h>
+
+void
+xopen_memstream (struct xmemstream *stream)
+{
+ int old_errno = errno;
+ *stream = (struct xmemstream) {};
+ stream->out = open_memstream (&stream->buffer, &stream->length);
+ if (stream->out == NULL)
+ FAIL_EXIT1 ("open_memstream: %m");
+ errno = old_errno;
+}
+
+void
+xfclose_memstream (struct xmemstream *stream)
+{
+ xfclose (stream->out);
+ stream->out = NULL;
+}
diff --git a/support/xmemstream.h b/support/xmemstream.h
new file mode 100644
index 0000000000..e5ba231e4d
--- /dev/null
+++ b/support/xmemstream.h
@@ -0,0 +1,49 @@
+/* Error-checking wrappers for memstream functions.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_XMEMSTREAM_H
+#define SUPPORT_XMEMSTREAM_H
+
+#include <stdio.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Wrappers for other libc functions. */
+struct xmemstream
+{
+ FILE *out;
+ char *buffer;
+ size_t length;
+};
+
+/* Create a new in-memory stream. Initializes *STREAM. After this
+ function returns, STREAM->out is a file descriptor open for
+ writing. errno is preserved, so that the %m format specifier can
+ be used for writing to STREAM->out. */
+void xopen_memstream (struct xmemstream *stream);
+
+/* Closes STREAM->OUT. After this function returns, STREAM->buffer
+ and STREAM->length denote a memory range which contains the bytes
+ written to the output stream. The caller should free
+ STREAM->buffer. */
+void xfclose_memstream (struct xmemstream *stream);
+
+__END_DECLS
+
+#endif /* SUPPORT_XMEMSTREAM_H */
diff --git a/support/xmkdir.c b/support/xmkdir.c
new file mode 100644
index 0000000000..ea17d49391
--- /dev/null
+++ b/support/xmkdir.c
@@ -0,0 +1,28 @@
+/* mkdir with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+void
+xmkdir (const char *path, mode_t mode)
+{
+ if (mkdir (path, mode) != 0)
+ FAIL_EXIT1 ("mkdir (\"%s\", 0%o): %m", path, mode);
+}
diff --git a/support/xmmap.c b/support/xmmap.c
new file mode 100644
index 0000000000..435b1eb733
--- /dev/null
+++ b/support/xmmap.c
@@ -0,0 +1,31 @@
+/* mmap with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/mman.h>
+
+void *
+xmmap (void *addr, size_t length, int prot, int flags, int fd)
+{
+ void *result = mmap (addr, length, prot, flags, fd, 0);
+ if (result == MAP_FAILED)
+ FAIL_EXIT1 ("mmap of %zu bytes, prot=0x%x, flags=0x%x: %m",
+ length, prot, flags);
+ return result;
+}
diff --git a/support/xmunmap.c b/support/xmunmap.c
new file mode 100644
index 0000000000..6ef5a4a468
--- /dev/null
+++ b/support/xmunmap.c
@@ -0,0 +1,28 @@
+/* munmap with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/mman.h>
+
+void
+xmunmap (void *addr, size_t length)
+{
+ if (munmap (addr, length) != 0)
+ FAIL_EXIT1 ("munmap of %zu bytes: %m", length);
+}
diff --git a/support/xopen.c b/support/xopen.c
new file mode 100644
index 0000000000..7f033a03a7
--- /dev/null
+++ b/support/xopen.c
@@ -0,0 +1,30 @@
+/* open64 with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <fcntl.h>
+
+int
+xopen (const char *path, int flags, mode_t mode)
+{
+ int ret = open64 (path, flags, mode);
+ if (ret < 0)
+ FAIL_EXIT1 ("open64 (\"%s\", 0x%x, 0%o): %m", path, flags, mode);
+ return ret;
+}
diff --git a/support/xpipe.c b/support/xpipe.c
new file mode 100644
index 0000000000..89a64a55c1
--- /dev/null
+++ b/support/xpipe.c
@@ -0,0 +1,28 @@
+/* pipe with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+
+#include <support/check.h>
+
+void
+xpipe (int fds[2])
+{
+ if (pipe (fds) < 0)
+ FAIL_EXIT1 ("pipe: %m");
+}
diff --git a/support/xpoll.c b/support/xpoll.c
new file mode 100644
index 0000000000..bec2521ffc
--- /dev/null
+++ b/support/xpoll.c
@@ -0,0 +1,32 @@
+/* poll with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+int
+xpoll (struct pollfd *fds, nfds_t nfds, int timeout)
+{
+ int ret = poll (fds, nfds, timeout);
+ if (ret < 0)
+ FAIL_EXIT1 ("poll: %m");
+ return ret;
+}
diff --git a/support/xpthread_attr_destroy.c b/support/xpthread_attr_destroy.c
new file mode 100644
index 0000000000..664c809e9f
--- /dev/null
+++ b/support/xpthread_attr_destroy.c
@@ -0,0 +1,26 @@
+/* pthread_attr_destroy with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_attr_destroy (pthread_attr_t *attr)
+{
+ xpthread_check_return ("pthread_attr_destroy",
+ pthread_attr_destroy (attr));
+}
diff --git a/support/xpthread_attr_init.c b/support/xpthread_attr_init.c
new file mode 100644
index 0000000000..2e30ade9ab
--- /dev/null
+++ b/support/xpthread_attr_init.c
@@ -0,0 +1,25 @@
+/* pthread_attr_init with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_attr_init (pthread_attr_t *attr)
+{
+ xpthread_check_return ("pthread_attr_init", pthread_attr_init (attr));
+}
diff --git a/support/xpthread_attr_setdetachstate.c b/support/xpthread_attr_setdetachstate.c
new file mode 100644
index 0000000000..b544dbaa42
--- /dev/null
+++ b/support/xpthread_attr_setdetachstate.c
@@ -0,0 +1,27 @@
+/* pthread_attr_setdetachstate with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
+{
+ xpthread_check_return ("pthread_attr_setdetachstate",
+ pthread_attr_setdetachstate (attr,
+ detachstate));
+}
diff --git a/support/xpthread_attr_setstacksize.c b/support/xpthread_attr_setstacksize.c
new file mode 100644
index 0000000000..02d06310a9
--- /dev/null
+++ b/support/xpthread_attr_setstacksize.c
@@ -0,0 +1,26 @@
+/* pthread_attr_setstacksize with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
+{
+ xpthread_check_return ("pthread_attr_setstacksize",
+ pthread_attr_setstacksize (attr, stacksize));
+}
diff --git a/support/xpthread_barrier_destroy.c b/support/xpthread_barrier_destroy.c
new file mode 100644
index 0000000000..efc0719a63
--- /dev/null
+++ b/support/xpthread_barrier_destroy.c
@@ -0,0 +1,26 @@
+/* pthread_barrier_destroy with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_barrier_destroy (pthread_barrier_t *barrier)
+{
+ xpthread_check_return ("pthread_barrier_destroy",
+ pthread_barrier_destroy (barrier));
+}
diff --git a/support/xpthread_barrier_init.c b/support/xpthread_barrier_init.c
new file mode 100644
index 0000000000..b32dad1315
--- /dev/null
+++ b/support/xpthread_barrier_init.c
@@ -0,0 +1,27 @@
+/* pthread_barrier_init with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_barrier_init (pthread_barrier_t *barrier,
+ pthread_barrierattr_t *attr, unsigned int count)
+{
+ xpthread_check_return ("pthread_barrier_init",
+ pthread_barrier_init (barrier, attr, count));
+}
diff --git a/support/xpthread_barrier_wait.c b/support/xpthread_barrier_wait.c
new file mode 100644
index 0000000000..7cee44d0a3
--- /dev/null
+++ b/support/xpthread_barrier_wait.c
@@ -0,0 +1,28 @@
+/* pthread_barrier_wait with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+int
+xpthread_barrier_wait (pthread_barrier_t *barrier)
+{
+ int ret = pthread_barrier_wait (barrier);
+ if (ret != 0 && ret != PTHREAD_BARRIER_SERIAL_THREAD)
+ xpthread_check_return ("pthread_barrier_wait", ret);
+ return ret == PTHREAD_BARRIER_SERIAL_THREAD;
+}
diff --git a/support/xpthread_cancel.c b/support/xpthread_cancel.c
new file mode 100644
index 0000000000..3af16f9b54
--- /dev/null
+++ b/support/xpthread_cancel.c
@@ -0,0 +1,25 @@
+/* pthread_cancel with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_cancel (pthread_t thr)
+{
+ xpthread_check_return ("pthread_cancel", pthread_cancel (thr));
+}
diff --git a/support/xpthread_check_return.c b/support/xpthread_check_return.c
new file mode 100644
index 0000000000..3094d82e9c
--- /dev/null
+++ b/support/xpthread_check_return.c
@@ -0,0 +1,34 @@
+/* Return value checking for pthread functions, exit variant.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xpthread_check_return (const char *function, int value)
+{
+ if (value != 0)
+ {
+ errno = value;
+ FAIL_EXIT1 ("%s: %m", function);
+ }
+}
diff --git a/support/xpthread_cond_wait.c b/support/xpthread_cond_wait.c
new file mode 100644
index 0000000000..b0e9b2a232
--- /dev/null
+++ b/support/xpthread_cond_wait.c
@@ -0,0 +1,26 @@
+/* pthread_cond_wait with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ xpthread_check_return
+ ("pthread_cond_wait", pthread_cond_wait (cond, mutex));
+}
diff --git a/support/xpthread_create.c b/support/xpthread_create.c
new file mode 100644
index 0000000000..98c63e54c3
--- /dev/null
+++ b/support/xpthread_create.c
@@ -0,0 +1,29 @@
+/* pthread_create with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+pthread_t
+xpthread_create (pthread_attr_t *attr,
+ void *(*thread_func) (void *), void *closure)
+{
+ pthread_t thr;
+ xpthread_check_return
+ ("pthread_create", pthread_create (&thr, attr, thread_func, closure));
+ return thr;
+}
diff --git a/support/xpthread_detach.c b/support/xpthread_detach.c
new file mode 100644
index 0000000000..2088af2f57
--- /dev/null
+++ b/support/xpthread_detach.c
@@ -0,0 +1,25 @@
+/* pthread_detach with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_detach (pthread_t thr)
+{
+ xpthread_check_return ("pthread_detach", pthread_detach (thr));
+}
diff --git a/support/xpthread_join.c b/support/xpthread_join.c
new file mode 100644
index 0000000000..f23bb9a5ae
--- /dev/null
+++ b/support/xpthread_join.c
@@ -0,0 +1,27 @@
+/* pthread_join with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void *
+xpthread_join (pthread_t thr)
+{
+ void *result;
+ xpthread_check_return ("pthread_join", pthread_join (thr, &result));
+ return result;
+}
diff --git a/support/xpthread_mutex_consistent.c b/support/xpthread_mutex_consistent.c
new file mode 100644
index 0000000000..52364be365
--- /dev/null
+++ b/support/xpthread_mutex_consistent.c
@@ -0,0 +1,26 @@
+/* pthread_mutex_consistent with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutex_consistent (pthread_mutex_t *mutex)
+{
+ xpthread_check_return ("pthread_mutex_consistent",
+ pthread_mutex_consistent (mutex));
+}
diff --git a/support/xpthread_mutex_destroy.c b/support/xpthread_mutex_destroy.c
new file mode 100644
index 0000000000..f11f8f0acd
--- /dev/null
+++ b/support/xpthread_mutex_destroy.c
@@ -0,0 +1,26 @@
+/* pthread_mutex_destroy with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutex_destroy (pthread_mutex_t *mutex)
+{
+ xpthread_check_return ("pthread_mutex_destroy",
+ pthread_mutex_destroy (mutex));
+}
diff --git a/support/xpthread_mutex_init.c b/support/xpthread_mutex_init.c
new file mode 100644
index 0000000000..2d16d1b9d9
--- /dev/null
+++ b/support/xpthread_mutex_init.c
@@ -0,0 +1,26 @@
+/* pthread_mutex_init with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
+{
+ xpthread_check_return ("pthread_mutex_init",
+ pthread_mutex_init (mutex, attr));
+}
diff --git a/support/xpthread_mutex_lock.c b/support/xpthread_mutex_lock.c
new file mode 100644
index 0000000000..af727b45f3
--- /dev/null
+++ b/support/xpthread_mutex_lock.c
@@ -0,0 +1,25 @@
+/* pthread_mutex_lock with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutex_lock (pthread_mutex_t *mutex)
+{
+ xpthread_check_return ("pthread_mutex_lock", pthread_mutex_lock (mutex));
+}
diff --git a/support/xpthread_mutex_unlock.c b/support/xpthread_mutex_unlock.c
new file mode 100644
index 0000000000..161b41edf6
--- /dev/null
+++ b/support/xpthread_mutex_unlock.c
@@ -0,0 +1,25 @@
+/* pthread_mutex_unlock with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutex_unlock (pthread_mutex_t *mutex)
+{
+ xpthread_check_return ("pthread_mutex_unlock", pthread_mutex_unlock (mutex));
+}
diff --git a/support/xpthread_mutexattr_destroy.c b/support/xpthread_mutexattr_destroy.c
new file mode 100644
index 0000000000..c699e32b41
--- /dev/null
+++ b/support/xpthread_mutexattr_destroy.c
@@ -0,0 +1,26 @@
+/* pthread_mutexattr_destroy with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutexattr_destroy (pthread_mutexattr_t *attr)
+{
+ xpthread_check_return ("pthread_mutexattr_destroy",
+ pthread_mutexattr_destroy (attr));
+}
diff --git a/support/xpthread_mutexattr_init.c b/support/xpthread_mutexattr_init.c
new file mode 100644
index 0000000000..fa93fab178
--- /dev/null
+++ b/support/xpthread_mutexattr_init.c
@@ -0,0 +1,25 @@
+/* pthread_mutexattr_init with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutexattr_init (pthread_mutexattr_t *attr)
+{
+ xpthread_check_return ("pthread_mutexattr_init", pthread_mutexattr_init (attr));
+}
diff --git a/support/xpthread_mutexattr_setprotocol.c b/support/xpthread_mutexattr_setprotocol.c
new file mode 100644
index 0000000000..353f75e3d7
--- /dev/null
+++ b/support/xpthread_mutexattr_setprotocol.c
@@ -0,0 +1,26 @@
+/* pthread_mutexattr_setprotocol with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutexattr_setprotocol (pthread_mutexattr_t *attr, int flag)
+{
+ xpthread_check_return ("pthread_mutexattr_setprotocol",
+ pthread_mutexattr_setprotocol (attr, flag));
+}
diff --git a/support/xpthread_mutexattr_setpshared.c b/support/xpthread_mutexattr_setpshared.c
new file mode 100644
index 0000000000..242da1aeca
--- /dev/null
+++ b/support/xpthread_mutexattr_setpshared.c
@@ -0,0 +1,26 @@
+/* pthread_mutexattr_setpshared with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int flag)
+{
+ xpthread_check_return ("pthread_mutexattr_setpshared",
+ pthread_mutexattr_setpshared (attr, flag));
+}
diff --git a/support/xpthread_mutexattr_setrobust.c b/support/xpthread_mutexattr_setrobust.c
new file mode 100644
index 0000000000..d7d6fa8630
--- /dev/null
+++ b/support/xpthread_mutexattr_setrobust.c
@@ -0,0 +1,26 @@
+/* pthread_mutexattr_setrobust with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutexattr_setrobust (pthread_mutexattr_t *attr, int flag)
+{
+ xpthread_check_return ("pthread_mutexattr_setrobust",
+ pthread_mutexattr_setrobust (attr, flag));
+}
diff --git a/support/xpthread_mutexattr_settype.c b/support/xpthread_mutexattr_settype.c
new file mode 100644
index 0000000000..cf22170b56
--- /dev/null
+++ b/support/xpthread_mutexattr_settype.c
@@ -0,0 +1,26 @@
+/* pthread_mutexattr_settype with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_mutexattr_settype (pthread_mutexattr_t *attr, int flag)
+{
+ xpthread_check_return ("pthread_mutexattr_settype",
+ pthread_mutexattr_settype (attr, flag));
+}
diff --git a/support/xpthread_once.c b/support/xpthread_once.c
new file mode 100644
index 0000000000..70d58dbab2
--- /dev/null
+++ b/support/xpthread_once.c
@@ -0,0 +1,25 @@
+/* pthread_once with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_once (pthread_once_t *guard, void (*func) (void))
+{
+ xpthread_check_return ("pthread_once", pthread_once (guard, func));
+}
diff --git a/support/xpthread_sigmask.c b/support/xpthread_sigmask.c
new file mode 100644
index 0000000000..0ba9ca02dc
--- /dev/null
+++ b/support/xpthread_sigmask.c
@@ -0,0 +1,34 @@
+/* pthread_sigmask with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsignal.h>
+#include <support/support.h>
+
+#include <unistd.h>
+
+void
+xpthread_sigmask (int how, const sigset_t *set, sigset_t *oldset)
+{
+ if (pthread_sigmask (how, set, oldset) != 0)
+ {
+ write_message ("error: pthread_setmask failed\n");
+ /* Do not use exit because pthread_sigmask can be called from a
+ signal handler. */
+ _exit (1);
+ }
+}
diff --git a/support/xpthread_spin_lock.c b/support/xpthread_spin_lock.c
new file mode 100644
index 0000000000..6975215b17
--- /dev/null
+++ b/support/xpthread_spin_lock.c
@@ -0,0 +1,25 @@
+/* pthread_spin_lock with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_spin_lock (pthread_spinlock_t *lock)
+{
+ xpthread_check_return ("pthread_spin_lock", pthread_spin_lock (lock));
+}
diff --git a/support/xpthread_spin_unlock.c b/support/xpthread_spin_unlock.c
new file mode 100644
index 0000000000..4f19a44c48
--- /dev/null
+++ b/support/xpthread_spin_unlock.c
@@ -0,0 +1,25 @@
+/* pthread_spin_unlock with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+
+void
+xpthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ xpthread_check_return ("pthread_spin_unlock", pthread_spin_unlock (lock));
+}
diff --git a/support/xrealloc.c b/support/xrealloc.c
new file mode 100644
index 0000000000..00c313880c
--- /dev/null
+++ b/support/xrealloc.c
@@ -0,0 +1,32 @@
+/* Error-checking wrapper for realloc.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void *
+xrealloc (void *p, size_t n)
+{
+ void *result = realloc (p, n);
+ if (result == NULL && (n > 0 || p == NULL))
+ oom_error ("realloc", n);
+ return result;
+}
diff --git a/support/xrecvfrom.c b/support/xrecvfrom.c
new file mode 100644
index 0000000000..17809c4dd2
--- /dev/null
+++ b/support/xrecvfrom.c
@@ -0,0 +1,33 @@
+/* recvfrom with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+size_t
+xrecvfrom (int fd, void *buf, size_t buflen, int flags,
+ struct sockaddr *sa, socklen_t *salen)
+{
+ ssize_t ret = recvfrom (fd, buf, buflen, flags, sa, salen);
+ if (ret < 0)
+ FAIL_EXIT1 ("error: recvfrom (%d), %zu bytes buffer: %m", fd, buflen);
+ return ret;
+}
diff --git a/support/xsendto.c b/support/xsendto.c
new file mode 100644
index 0000000000..20bddf6965
--- /dev/null
+++ b/support/xsendto.c
@@ -0,0 +1,35 @@
+/* sendto with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xsendto (int fd, const void *buf, size_t buflen, int flags,
+ const struct sockaddr *sa, socklen_t salen)
+{
+ ssize_t ret = sendto (fd, buf, buflen, flags, sa, salen);
+ if (ret < 0)
+ FAIL_EXIT1 ("sendto (%d), %zu bytes, family %d: %m",
+ fd, buflen, sa->sa_family);
+ if (ret != buflen)
+ FAIL_EXIT1 ("sendto (%d) sent %zd bytes instead of %zu", fd, ret, buflen);
+}
diff --git a/support/xsetsockopt.c b/support/xsetsockopt.c
new file mode 100644
index 0000000000..9931882e75
--- /dev/null
+++ b/support/xsetsockopt.c
@@ -0,0 +1,31 @@
+/* setsockopt with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+void
+xsetsockopt (int fd, int level, int name, const void *val, socklen_t vallen)
+{
+ if (setsockopt (fd, level, name, val, vallen) != 0)
+ FAIL_EXIT1 ("setsockopt (%d, %d, %d), %zu bytes: %m",
+ fd, level, name, (size_t) vallen);
+}
diff --git a/support/xsignal.h b/support/xsignal.h
new file mode 100644
index 0000000000..3dc0d9d5ce
--- /dev/null
+++ b/support/xsignal.h
@@ -0,0 +1,34 @@
+/* Support functionality for using signals.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_SIGNAL_H
+#define SUPPORT_SIGNAL_H
+
+#include <signal.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* The following functions call the corresponding libpthread functions
+ and terminate the process on error. */
+
+void xpthread_sigmask (int how, const sigset_t *set, sigset_t *oldset);
+
+__END_DECLS
+
+#endif /* SUPPORT_SIGNAL_H */
diff --git a/support/xsocket.c b/support/xsocket.c
new file mode 100644
index 0000000000..c1deaee924
--- /dev/null
+++ b/support/xsocket.c
@@ -0,0 +1,32 @@
+/* socket with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+int
+xsocket (int domain, int type, int protocol)
+{
+ int fd = socket (domain, type, protocol);
+ if (fd < 0)
+ FAIL_EXIT1 ("socket (%d, %d, %d): %m\n", domain, type, protocol);
+ return fd;
+}
diff --git a/support/xsocket.h b/support/xsocket.h
new file mode 100644
index 0000000000..d6724948d8
--- /dev/null
+++ b/support/xsocket.h
@@ -0,0 +1,39 @@
+/* Error-checking wrappers for socket functions.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_XSOCKET_H
+#define SUPPORT_XSOCKET_H
+
+#include <poll.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+int xsocket (int, int, int);
+void xsetsockopt (int, int, int, const void *, socklen_t);
+void xgetsockname (int, struct sockaddr *, socklen_t *);
+void xconnect (int, const struct sockaddr *, socklen_t);
+void xbind (int, const struct sockaddr *, socklen_t);
+void xlisten (int, int);
+int xaccept (int, struct sockaddr *, socklen_t *);
+int xaccept4 (int, struct sockaddr *, socklen_t *, int);
+void xsendto (int, const void *, size_t, int,
+ const struct sockaddr *, socklen_t);
+size_t xrecvfrom (int, void *, size_t, int, struct sockaddr *, socklen_t *);
+int xpoll (struct pollfd *, nfds_t, int);
+
+#endif /* SUPPORT_XSOCKET_H */
diff --git a/support/xstdio.h b/support/xstdio.h
new file mode 100644
index 0000000000..bcc2e863bf
--- /dev/null
+++ b/support/xstdio.h
@@ -0,0 +1,32 @@
+/* Error-checking wrappers for stdio functions.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_XSTDIO_H
+#define SUPPORT_XSTDIO_H
+
+#include <stdio.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+FILE *xfopen (const char *path, const char *mode);
+void xfclose (FILE *);
+
+__END_DECLS
+
+#endif /* SUPPORT_XSTDIO_H */
diff --git a/support/xstrdup.c b/support/xstrdup.c
new file mode 100644
index 0000000000..d6a8c04baf
--- /dev/null
+++ b/support/xstrdup.c
@@ -0,0 +1,30 @@
+/* strdup with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/support.h>
+
+#include <string.h>
+
+char *
+xstrdup (const char *s)
+{
+ char *p = strdup (s);
+ if (p == NULL)
+ oom_error ("strdup", strlen (s));
+ return p;
+}
diff --git a/support/xthread.h b/support/xthread.h
new file mode 100644
index 0000000000..6dd7e709be
--- /dev/null
+++ b/support/xthread.h
@@ -0,0 +1,77 @@
+/* Support functionality for using threads.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SUPPORT_THREAD_H
+#define SUPPORT_THREAD_H
+
+#include <pthread.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* Terminate the process (with exit status 0) after SECONDS have
+ elapsed, from a helper thread. The process is terminated with the
+ exit function, so atexit handlers are executed. */
+void delayed_exit (int seconds);
+
+/* Terminate the process (with exit status 1) if VALUE is not zero.
+ In that case, print a failure message to standard output mentioning
+ FUNCTION. The process is terminated with the exit function, so
+ atexit handlers are executed. */
+void xpthread_check_return (const char *function, int value);
+
+/* The following functions call the corresponding libpthread functions
+ and terminate the process on error. */
+
+void xpthread_barrier_init (pthread_barrier_t *barrier,
+ pthread_barrierattr_t *attr, unsigned int count);
+void xpthread_barrier_destroy (pthread_barrier_t *barrier);
+void xpthread_mutexattr_destroy (pthread_mutexattr_t *);
+void xpthread_mutexattr_init (pthread_mutexattr_t *);
+void xpthread_mutexattr_setprotocol (pthread_mutexattr_t *, int);
+void xpthread_mutexattr_setpshared (pthread_mutexattr_t *, int);
+void xpthread_mutexattr_setrobust (pthread_mutexattr_t *, int);
+void xpthread_mutexattr_settype (pthread_mutexattr_t *, int);
+void xpthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *);
+void xpthread_mutex_destroy (pthread_mutex_t *);
+void xpthread_mutex_lock (pthread_mutex_t *mutex);
+void xpthread_mutex_unlock (pthread_mutex_t *mutex);
+void xpthread_mutex_consistent (pthread_mutex_t *);
+void xpthread_spin_lock (pthread_spinlock_t *lock);
+void xpthread_spin_unlock (pthread_spinlock_t *lock);
+void xpthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex);
+pthread_t xpthread_create (pthread_attr_t *attr,
+ void *(*thread_func) (void *), void *closure);
+void xpthread_detach (pthread_t thr);
+void xpthread_cancel (pthread_t thr);
+void *xpthread_join (pthread_t thr);
+void xpthread_once (pthread_once_t *guard, void (*func) (void));
+void xpthread_attr_destroy (pthread_attr_t *attr);
+void xpthread_attr_init (pthread_attr_t *attr);
+void xpthread_attr_setdetachstate (pthread_attr_t *attr,
+ int detachstate);
+void xpthread_attr_setstacksize (pthread_attr_t *attr,
+ size_t stacksize);
+
+/* This function returns non-zero if pthread_barrier_wait returned
+ PTHREAD_BARRIER_SERIAL_THREAD. */
+int xpthread_barrier_wait (pthread_barrier_t *barrier);
+
+__END_DECLS
+
+#endif /* SUPPORT_THREAD_H */
diff --git a/support/xunistd.h b/support/xunistd.h
new file mode 100644
index 0000000000..151d743e1f
--- /dev/null
+++ b/support/xunistd.h
@@ -0,0 +1,56 @@
+/* POSIX-specific extra functions.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* These wrapper functions use POSIX types and therefore cannot be
+ declared in <support/support.h>. */
+
+#ifndef SUPPORT_XUNISTD_H
+#define SUPPORT_XUNISTD_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+__BEGIN_DECLS
+
+struct stat64;
+
+pid_t xfork (void);
+pid_t xwaitpid (pid_t, int *status, int flags);
+void xpipe (int[2]);
+void xdup2 (int, int);
+int xopen (const char *path, int flags, mode_t);
+void xstat (const char *path, struct stat64 *);
+void xmkdir (const char *path, mode_t);
+void xchroot (const char *path);
+
+/* Close the file descriptor. Ignore EINTR errors, but terminate the
+ process on other errors. */
+void xclose (int);
+
+/* Write the buffer. Retry on short writes. */
+void xwrite (int, const void *, size_t);
+
+/* Invoke mmap with a zero file offset. */
+void *xmmap (void *addr, size_t length, int prot, int flags, int fd);
+
+void xmunmap (void *addr, size_t length);
+
+__END_DECLS
+
+#endif /* SUPPORT_XUNISTD_H */
diff --git a/support/xwaitpid.c b/support/xwaitpid.c
new file mode 100644
index 0000000000..204795e4c0
--- /dev/null
+++ b/support/xwaitpid.c
@@ -0,0 +1,33 @@
+/* waitpid with error checking.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+#include <sys/wait.h>
+
+int
+xwaitpid (int pid, int *status, int flags)
+{
+ pid_t result = waitpid (pid, status, flags);
+ if (result < 0)
+ FAIL_EXIT1 ("waitpid: %m\n");
+ return result;
+}
diff --git a/support/xwrite.c b/support/xwrite.c
new file mode 100644
index 0000000000..134e8ee4c1
--- /dev/null
+++ b/support/xwrite.c
@@ -0,0 +1,39 @@
+/* write with error checking and retries.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xunistd.h>
+
+#include <support/check.h>
+
+void
+xwrite (int fd, const void *buffer, size_t length)
+{
+ const char *p = buffer;
+ const char *end = p + length;
+ while (p < end)
+ {
+ ssize_t ret = write (fd, p, end - p);
+ if (ret < 0)
+ FAIL_EXIT1 ("write of %zu bytes failed after %td: %m",
+ length, p - (const char *) buffer);
+ if (ret == 0)
+ FAIL_EXIT1 ("write return 0 after writing %td bytes of %zu",
+ p - (const char *) buffer, length);
+ p += ret;
+ }
+}
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 282805e396..e86d8b5b63 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -172,8 +172,8 @@ _dl_start_user: \n\
cmp x0, #0 \n\
bne 1b \n\
// Update _dl_argv \n\
- adrp x3, _dl_argv \n\
- str x2, [x3, #:lo12:_dl_argv] \n\
+ adrp x3, __GI__dl_argv \n\
+ str x2, [x3, #:lo12:__GI__dl_argv] \n\
.L_done_stack_adjust: \n\
// compute envp \n\
add x3, x2, x1, lsl #3 \n\
diff --git a/sysdeps/aarch64/nptl/tcb-offsets.sym b/sysdeps/aarch64/nptl/tcb-offsets.sym
index 0677aeabff..238647dd47 100644
--- a/sysdeps/aarch64/nptl/tcb-offsets.sym
+++ b/sysdeps/aarch64/nptl/tcb-offsets.sym
@@ -2,6 +2,5 @@
#include <tls.h>
PTHREAD_MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
-PTHREAD_PID_OFFSET offsetof (struct pthread, pid)
PTHREAD_TID_OFFSET offsetof (struct pthread, tid)
PTHREAD_SIZEOF sizeof (struct pthread)
diff --git a/sysdeps/alpha/fpu/s_ceil.c b/sysdeps/alpha/fpu/s_ceil.c
index c1ff864d4b..e9c350af1c 100644
--- a/sysdeps/alpha/fpu/s_ceil.c
+++ b/sysdeps/alpha/fpu/s_ceil.c
@@ -26,17 +26,16 @@
double
__ceil (double x)
{
+ if (isnan (x))
+ return x + x;
+
if (isless (fabs (x), 9007199254740992.0)) /* 1 << DBL_MANT_DIG */
{
double tmp1, new_x;
new_x = -x;
__asm (
-#ifdef _IEEE_FP_INEXACT
- "cvttq/svim %2,%1\n\t"
-#else
"cvttq/svm %2,%1\n\t"
-#endif
"cvtqt/m %1,%0\n\t"
: "=f"(new_x), "=&f"(tmp1)
: "f"(new_x));
diff --git a/sysdeps/alpha/fpu/s_ceilf.c b/sysdeps/alpha/fpu/s_ceilf.c
index 7e63a6fe94..77e01a99f7 100644
--- a/sysdeps/alpha/fpu/s_ceilf.c
+++ b/sysdeps/alpha/fpu/s_ceilf.c
@@ -25,6 +25,9 @@
float
__ceilf (float x)
{
+ if (isnanf (x))
+ return x + x;
+
if (isless (fabsf (x), 16777216.0f)) /* 1 << FLT_MANT_DIG */
{
/* Note that Alpha S_Floating is stored in registers in a
@@ -36,11 +39,7 @@ __ceilf (float x)
new_x = -x;
__asm ("cvtst/s %3,%2\n\t"
-#ifdef _IEEE_FP_INEXACT
- "cvttq/svim %2,%1\n\t"
-#else
"cvttq/svm %2,%1\n\t"
-#endif
"cvtqt/m %1,%0\n\t"
: "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
: "f"(new_x));
diff --git a/sysdeps/alpha/fpu/s_floor.c b/sysdeps/alpha/fpu/s_floor.c
index 1a6f8c4617..9930f6be42 100644
--- a/sysdeps/alpha/fpu/s_floor.c
+++ b/sysdeps/alpha/fpu/s_floor.c
@@ -27,16 +27,15 @@
double
__floor (double x)
{
+ if (isnan (x))
+ return x + x;
+
if (isless (fabs (x), 9007199254740992.0)) /* 1 << DBL_MANT_DIG */
{
double tmp1, new_x;
__asm (
-#ifdef _IEEE_FP_INEXACT
- "cvttq/svim %2,%1\n\t"
-#else
"cvttq/svm %2,%1\n\t"
-#endif
"cvtqt/m %1,%0\n\t"
: "=f"(new_x), "=&f"(tmp1)
: "f"(x));
diff --git a/sysdeps/alpha/fpu/s_floorf.c b/sysdeps/alpha/fpu/s_floorf.c
index 8cd80e2b42..015c04f40d 100644
--- a/sysdeps/alpha/fpu/s_floorf.c
+++ b/sysdeps/alpha/fpu/s_floorf.c
@@ -26,6 +26,9 @@
float
__floorf (float x)
{
+ if (isnanf (x))
+ return x + x;
+
if (isless (fabsf (x), 16777216.0f)) /* 1 << FLT_MANT_DIG */
{
/* Note that Alpha S_Floating is stored in registers in a
@@ -36,11 +39,7 @@ __floorf (float x)
float tmp1, tmp2, new_x;
__asm ("cvtst/s %3,%2\n\t"
-#ifdef _IEEE_FP_INEXACT
- "cvttq/svim %2,%1\n\t"
-#else
"cvttq/svm %2,%1\n\t"
-#endif
"cvtqt/m %1,%0\n\t"
: "=f"(new_x), "=&f"(tmp1), "=&f"(tmp2)
: "f"(x));
diff --git a/sysdeps/alpha/fpu/s_rint.c b/sysdeps/alpha/fpu/s_rint.c
index f33fe72c11..259348afc0 100644
--- a/sysdeps/alpha/fpu/s_rint.c
+++ b/sysdeps/alpha/fpu/s_rint.c
@@ -23,6 +23,9 @@
double
__rint (double x)
{
+ if (isnan (x))
+ return x + x;
+
if (isless (fabs (x), 9007199254740992.0)) /* 1 << DBL_MANT_DIG */
{
double tmp1, new_x;
diff --git a/sysdeps/alpha/fpu/s_rintf.c b/sysdeps/alpha/fpu/s_rintf.c
index 1400dfe8d7..645728ad5b 100644
--- a/sysdeps/alpha/fpu/s_rintf.c
+++ b/sysdeps/alpha/fpu/s_rintf.c
@@ -22,6 +22,9 @@
float
__rintf (float x)
{
+ if (isnanf (x))
+ return x + x;
+
if (isless (fabsf (x), 16777216.0f)) /* 1 << FLT_MANT_DIG */
{
/* Note that Alpha S_Floating is stored in registers in a
diff --git a/sysdeps/alpha/fpu/s_trunc.c b/sysdeps/alpha/fpu/s_trunc.c
index 16cb114a72..4b986a6926 100644
--- a/sysdeps/alpha/fpu/s_trunc.c
+++ b/sysdeps/alpha/fpu/s_trunc.c
@@ -28,12 +28,11 @@ __trunc (double x)
double two52 = copysign (0x1.0p52, x);
double r, tmp;
+ if (isgreaterequal (fabs (x), 0x1.0p52))
+ return x;
+
__asm (
-#ifdef _IEEE_FP_INEXACT
- "addt/suic %2, %3, %1\n\tsubt/suic %1, %3, %0"
-#else
"addt/suc %2, %3, %1\n\tsubt/suc %1, %3, %0"
-#endif
: "=&f"(r), "=&f"(tmp)
: "f"(x), "f"(two52));
diff --git a/sysdeps/alpha/fpu/s_truncf.c b/sysdeps/alpha/fpu/s_truncf.c
index 2290f28295..3e93356166 100644
--- a/sysdeps/alpha/fpu/s_truncf.c
+++ b/sysdeps/alpha/fpu/s_truncf.c
@@ -27,12 +27,11 @@ __truncf (float x)
float two23 = copysignf (0x1.0p23, x);
float r, tmp;
+ if (isgreaterequal (fabsf (x), 0x1.0p23))
+ return x;
+
__asm (
-#ifdef _IEEE_FP_INEXACT
- "adds/suic %2, %3, %1\n\tsubs/suic %1, %3, %0"
-#else
"adds/suc %2, %3, %1\n\tsubs/suc %1, %3, %0"
-#endif
: "=&f"(r), "=&f"(tmp)
: "f"(x), "f"(two23));
diff --git a/sysdeps/alpha/nptl/tcb-offsets.sym b/sysdeps/alpha/nptl/tcb-offsets.sym
index c21a791040..1005621b37 100644
--- a/sysdeps/alpha/nptl/tcb-offsets.sym
+++ b/sysdeps/alpha/nptl/tcb-offsets.sym
@@ -10,5 +10,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/sysdeps/arm/nacl/libc.abilist b/sysdeps/arm/nacl/libc.abilist
index 2f7751d167..dfa7198306 100644
--- a/sysdeps/arm/nacl/libc.abilist
+++ b/sysdeps/arm/nacl/libc.abilist
@@ -1840,4 +1840,5 @@ GLIBC_2.23 fts64_close F
GLIBC_2.23 fts64_open F
GLIBC_2.23 fts64_read F
GLIBC_2.23 fts64_set F
+GLIBC_2.24 GLIBC_2.24 A
GLIBC_2.24 quick_exit F
diff --git a/sysdeps/arm/nptl/tcb-offsets.sym b/sysdeps/arm/nptl/tcb-offsets.sym
index 92cc441d3d..bf9c0a1c17 100644
--- a/sysdeps/arm/nptl/tcb-offsets.sym
+++ b/sysdeps/arm/nptl/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/sysdeps/generic/unsecvars.h b/sysdeps/generic/unsecvars.h
index d5b8119c9c..ac57bd5db0 100644
--- a/sysdeps/generic/unsecvars.h
+++ b/sysdeps/generic/unsecvars.h
@@ -4,11 +4,13 @@
#define UNSECURE_ENVVARS \
"GCONV_PATH\0" \
"GETCONF_DIR\0" \
+ "GLIBC_TUNABLES\0" \
"HOSTALIASES\0" \
"LD_AUDIT\0" \
"LD_DEBUG\0" \
"LD_DEBUG_OUTPUT\0" \
"LD_DYNAMIC_WEAK\0" \
+ "LD_HWCAP_MASK\0" \
"LD_LIBRARY_PATH\0" \
"LD_ORIGIN_PATH\0" \
"LD_PRELOAD\0" \
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
index 9404211819..01bd5bf197 100644
--- a/sysdeps/hppa/dl-machine.h
+++ b/sysdeps/hppa/dl-machine.h
@@ -302,6 +302,10 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
#define ARCH_LA_PLTENTER hppa_gnu_pltenter
#define ARCH_LA_PLTEXIT hppa_gnu_pltexit
+/* Adjust DL_STACK_END to get value we want in __libc_stack_end. */
+#define DL_STACK_END(cookie) \
+ ((void *) (((long) (cookie)) + 0x160))
+
/* Initial entry point code for the dynamic linker.
The C function `_dl_start' is the real entry point;
its return value is the user program's entry point. */
@@ -401,11 +405,6 @@ asm ( \
/* Save the entry point in %r3. */ \
" copy %ret0,%r3\n" \
\
- /* Remember the lowest stack address. */ \
-" addil LT'__libc_stack_end,%r19\n" \
-" ldw RT'__libc_stack_end(%r1),%r20\n" \
-" stw %sp,0(%r20)\n" \
- \
/* See if we were called as a command with the executable file \
name as an extra leading argument. */ \
" addil LT'_dl_skip_args,%r19\n" \
diff --git a/sysdeps/hppa/nptl/tcb-offsets.sym b/sysdeps/hppa/nptl/tcb-offsets.sym
index c2f326ee3d..6e852f35b1 100644
--- a/sysdeps/hppa/nptl/tcb-offsets.sym
+++ b/sysdeps/hppa/nptl/tcb-offsets.sym
@@ -3,7 +3,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
@@ -14,6 +13,5 @@ MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
-- This way we get the offset of a member in the struct pthread that
-- preceeds the thread pointer (which points to the dtv).
#define thread_offsetof(mem) (unsigned int)(offsetof(struct pthread, mem) - sizeof(struct pthread))
-PID_THREAD_OFFSET thread_offsetof (pid)
TID_THREAD_OFFSET thread_offsetof (tid)
MULTIPLE_THREADS_THREAD_OFFSET thread_offsetof (header.multiple_threads)
diff --git a/sysdeps/i386/i686/multiarch/strcspn-c.c b/sysdeps/i386/i686/multiarch/strcspn-c.c
index 6d61e190a8..ec230fb383 100644
--- a/sysdeps/i386/i686/multiarch/strcspn-c.c
+++ b/sysdeps/i386/i686/multiarch/strcspn-c.c
@@ -1,2 +1,4 @@
-#define __strcspn_sse2 __strcspn_ia32
-#include <sysdeps/x86_64/multiarch/strcspn-c.c>
+#if IS_IN (libc)
+# define __strcspn_sse2 __strcspn_ia32
+# include <sysdeps/x86_64/multiarch/strcspn-c.c>
+#endif
diff --git a/sysdeps/i386/i686/multiarch/varshift.c b/sysdeps/i386/i686/multiarch/varshift.c
index 7760b966e2..6742a35d41 100644
--- a/sysdeps/i386/i686/multiarch/varshift.c
+++ b/sysdeps/i386/i686/multiarch/varshift.c
@@ -1 +1,3 @@
-#include <sysdeps/x86_64/multiarch/varshift.c>
+#if IS_IN (libc)
+# include <sysdeps/x86_64/multiarch/varshift.c>
+#endif
diff --git a/sysdeps/i386/nptl/tcb-offsets.sym b/sysdeps/i386/nptl/tcb-offsets.sym
index 7bdf161b29..695a810386 100644
--- a/sysdeps/i386/nptl/tcb-offsets.sym
+++ b/sysdeps/i386/nptl/tcb-offsets.sym
@@ -4,7 +4,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/sysdeps/ia64/nptl/Makefile b/sysdeps/ia64/nptl/Makefile
index 48f1327446..1e6be8eea8 100644
--- a/sysdeps/ia64/nptl/Makefile
+++ b/sysdeps/ia64/nptl/Makefile
@@ -21,4 +21,5 @@ endif
ifeq ($(subdir),nptl)
libpthread-routines += ptw-sysdep ptw-sigblock ptw-sigprocmask
+libpthread-shared-only-routines += ptw-sysdep ptw-sigblock ptw-sigprocmask
endif
diff --git a/sysdeps/ia64/nptl/tcb-offsets.sym b/sysdeps/ia64/nptl/tcb-offsets.sym
index e1707ab1c8..b01f712be2 100644
--- a/sysdeps/ia64/nptl/tcb-offsets.sym
+++ b/sysdeps/ia64/nptl/tcb-offsets.sym
@@ -1,7 +1,6 @@
#include <sysdep.h>
#include <tls.h>
-PID offsetof (struct pthread, pid) - TLS_PRE_TCB_SIZE
TID offsetof (struct pthread, tid) - TLS_PRE_TCB_SIZE
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) - TLS_PRE_TCB_SIZE
SYSINFO_OFFSET offsetof (tcbhead_t, __private)
diff --git a/sysdeps/ieee754/dbl-64/e_pow.c b/sysdeps/ieee754/dbl-64/e_pow.c
index 663fa392c2..bd758b5979 100644
--- a/sysdeps/ieee754/dbl-64/e_pow.c
+++ b/sysdeps/ieee754/dbl-64/e_pow.c
@@ -466,15 +466,15 @@ checkint (double x)
return (n & 1) ? -1 : 1; /* odd or even */
if (k > 20)
{
- if (n << (k - 20))
+ if (n << (k - 20) != 0)
return 0; /* if not integer */
- return (n << (k - 21)) ? -1 : 1;
+ return (n << (k - 21) != 0) ? -1 : 1;
}
if (n)
return 0; /*if not integer */
if (k == 20)
return (m & 1) ? -1 : 1;
- if (m << (k + 12))
+ if (m << (k + 12) != 0)
return 0;
- return (m << (k + 11)) ? -1 : 1;
+ return (m << (k + 11) != 0) ? -1 : 1;
}
diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h
index 24bc5c5ef7..65965cca9e 100644
--- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h
+++ b/sysdeps/m68k/m680x0/m68020/atomic-machine.h
@@ -73,7 +73,7 @@ typedef uintmax_t uatomic_max_t;
__typeof (mem) __memp = (mem); \
__asm __volatile ("cas2%.l %0:%R0,%1:%R1,(%2):(%3)" \
: "=d" (__ret) \
- : "d" (newval), "r" (__memp), \
+ : "d" ((__typeof (*(mem))) (newval)), "r" (__memp), \
"r" ((char *) __memp + 4), "0" (oldval) \
: "memory"); \
__ret; })
@@ -101,8 +101,9 @@ typedef uintmax_t uatomic_max_t;
__asm __volatile ("1: cas2%.l %0:%R0,%1:%R1,(%2):(%3);" \
" jbne 1b" \
: "=d" (__result) \
- : "d" (newvalue), "r" (__memp), \
- "r" ((char *) __memp + 4), "0" (__result) \
+ : "d" ((__typeof (*(mem))) (newvalue)), \
+ "r" (__memp), "r" ((char *) __memp + 4), \
+ "0" (__result) \
: "memory"); \
} \
__result; })
@@ -144,7 +145,7 @@ typedef uintmax_t uatomic_max_t;
" cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \
" jbne 1b" \
: "=d" (__result), "=&d" (__temp) \
- : "d" (value), "r" (__memp), \
+ : "d" ((__typeof (*(mem))) (value)), "r" (__memp), \
"r" ((char *) __memp + 4), "0" (__result) \
: "memory"); \
} \
@@ -175,8 +176,9 @@ typedef uintmax_t uatomic_max_t;
" cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \
" jbne 1b" \
: "=d" (__oldval), "=&d" (__temp) \
- : "d" (value), "r" (__memp), \
- "r" ((char *) __memp + 4), "0" (__oldval) \
+ : "d" ((__typeof (*(mem))) (value)), \
+ "r" (__memp), "r" ((char *) __memp + 4), \
+ "0" (__oldval) \
: "memory"); \
} \
})
diff --git a/sysdeps/m68k/nptl/tcb-offsets.sym b/sysdeps/m68k/nptl/tcb-offsets.sym
index b1bba65868..241fb8b47c 100644
--- a/sysdeps/m68k/nptl/tcb-offsets.sym
+++ b/sysdeps/m68k/nptl/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/sysdeps/microblaze/nptl/tcb-offsets.sym b/sysdeps/microblaze/nptl/tcb-offsets.sym
index 18afbee291..614f0dfed6 100644
--- a/sysdeps/microblaze/nptl/tcb-offsets.sym
+++ b/sysdeps/microblaze/nptl/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof (struct pthread, mem) - sizeof (struct pthread))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile
index 3d3552322b..7c1d77941e 100644
--- a/sysdeps/mips/Makefile
+++ b/sysdeps/mips/Makefile
@@ -9,6 +9,7 @@ endif
ifeq ($(subdir),rt)
librt-sysdep_routines += rt-sysdep
+librt-shared-only-routines += rt-sysdep
endif
ifeq ($(subdir),debug)
diff --git a/sysdeps/mips/mips32/crti.S b/sysdeps/mips/mips32/crti.S
index 5c0ad7328a..dfbbdc4f8f 100644
--- a/sysdeps/mips/mips32/crti.S
+++ b/sysdeps/mips/mips32/crti.S
@@ -74,6 +74,7 @@ _init:
.reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
+ .insn
#else
lw $25,%got(PREINIT_FUNCTION)($28)
.reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
diff --git a/sysdeps/mips/mips64/n32/crti.S b/sysdeps/mips/mips64/n32/crti.S
index 00b89f3894..afe6d8edaa 100644
--- a/sysdeps/mips/mips64/n32/crti.S
+++ b/sysdeps/mips/mips64/n32/crti.S
@@ -74,6 +74,7 @@ _init:
.reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
+ .insn
#else
lw $25,%got_disp(PREINIT_FUNCTION)($28)
.reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
diff --git a/sysdeps/mips/mips64/n64/crti.S b/sysdeps/mips/mips64/n64/crti.S
index f59b20c631..4049d29290 100644
--- a/sysdeps/mips/mips64/n64/crti.S
+++ b/sysdeps/mips/mips64/n64/crti.S
@@ -74,6 +74,7 @@ _init:
.reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
+ .insn
#else
ld $25,%got_disp(PREINIT_FUNCTION)($28)
.reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
diff --git a/sysdeps/mips/nptl/Makefile b/sysdeps/mips/nptl/Makefile
index 117744ffe2..dda154d842 100644
--- a/sysdeps/mips/nptl/Makefile
+++ b/sysdeps/mips/nptl/Makefile
@@ -21,4 +21,5 @@ endif
ifeq ($(subdir),nptl)
libpthread-sysdep_routines += nptl-sysdep
+libpthread-shared-only-routines += nptl-sysdep
endif
diff --git a/sysdeps/mips/nptl/tcb-offsets.sym b/sysdeps/mips/nptl/tcb-offsets.sym
index e0e71dc430..9ea25b94a8 100644
--- a/sysdeps/mips/nptl/tcb-offsets.sym
+++ b/sysdeps/mips/nptl/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/sysdeps/nacl/clock.c b/sysdeps/nacl/clock.c
index 664ad650c3..b6fbcfd2dd 100644
--- a/sysdeps/nacl/clock.c
+++ b/sysdeps/nacl/clock.c
@@ -24,6 +24,6 @@
clock_t
clock (void)
{
- nacl_abi_clock_t result;
+ nacl_irt_clock_t result;
return NACL_CALL (__nacl_irt_basic.clock (&result), result);
}
diff --git a/sysdeps/nacl/dup.c b/sysdeps/nacl/dup.c
index 34a7cd46d4..cbce3f5a5a 100644
--- a/sysdeps/nacl/dup.c
+++ b/sysdeps/nacl/dup.c
@@ -27,4 +27,5 @@ __dup (int fd)
int result;
return NACL_CALL (__nacl_irt_fdio.dup (fd, &result), result);
}
+libc_hidden_def (__dup)
weak_alias (__dup, dup)
diff --git a/sysdeps/nios2/nptl/tcb-offsets.sym b/sysdeps/nios2/nptl/tcb-offsets.sym
index d9ae952585..3cd8d984ac 100644
--- a/sysdeps/nios2/nptl/tcb-offsets.sym
+++ b/sysdeps/nios2/nptl/tcb-offsets.sym
@@ -9,6 +9,5 @@
# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
index 616d897a36..a5d1e86d71 100644
--- a/sysdeps/nptl/fork.c
+++ b/sysdeps/nptl/fork.c
@@ -131,16 +131,6 @@ __libc_fork (void)
__malloc_fork_lock_parent ();
}
-#ifndef NDEBUG
- pid_t ppid = THREAD_GETMEM (THREAD_SELF, tid);
-#endif
-
- /* We need to prevent the getpid() code to update the PID field so
- that, if a signal arrives in the child very early and the signal
- handler uses getpid(), the value returned is correct. */
- pid_t parentpid = THREAD_GETMEM (THREAD_SELF, pid);
- THREAD_SETMEM (THREAD_SELF, pid, -parentpid);
-
#ifdef ARCH_FORK
pid = ARCH_FORK ();
#else
@@ -153,15 +143,10 @@ __libc_fork (void)
{
struct pthread *self = THREAD_SELF;
- assert (THREAD_GETMEM (self, tid) != ppid);
-
/* See __pthread_once. */
if (__fork_generation_pointer != NULL)
*__fork_generation_pointer += __PTHREAD_ONCE_FORK_GEN_INCR;
- /* Adjust the PID field for the new process. */
- THREAD_SETMEM (self, pid, THREAD_GETMEM (self, tid));
-
#if HP_TIMING_AVAIL
/* The CPU clock of the thread and process have to be set to zero. */
hp_timing_t now;
@@ -231,11 +216,6 @@ __libc_fork (void)
}
else
{
- assert (THREAD_GETMEM (THREAD_SELF, tid) == ppid);
-
- /* Restore the PID value. */
- THREAD_SETMEM (THREAD_SELF, pid, parentpid);
-
/* Release acquired locks in the multi-threaded case. */
if (multiple_threads)
{
diff --git a/sysdeps/posix/wait3.c b/sysdeps/posix/wait3.c
index cf43d973a7..73722d2be6 100644
--- a/sysdeps/posix/wait3.c
+++ b/sysdeps/posix/wait3.c
@@ -33,7 +33,7 @@ __wait3 (int *stat_loc, int options, struct rusage *usage)
__set_errno (ENOSYS);
return (pid_t) -1;
}
- return __waitpid (WAIT_ANY, stat_loc.__iptr, options);
+ return __waitpid (WAIT_ANY, stat_loc, options);
}
weak_alias (__wait3, wait3)
diff --git a/sysdeps/powerpc/fpu/libm-test-ulps b/sysdeps/powerpc/fpu/libm-test-ulps
index 7f37c813d0..36b700c520 100644
--- a/sysdeps/powerpc/fpu/libm-test-ulps
+++ b/sysdeps/powerpc/fpu/libm-test-ulps
@@ -36,8 +36,8 @@ double: 2
float: 2
idouble: 2
ifloat: 2
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
Function: "acosh_downward":
double: 1
@@ -52,8 +52,8 @@ double: 2
float: 2
idouble: 2
ifloat: 2
-ildouble: 3
-ldouble: 3
+ildouble: 4
+ldouble: 4
Function: "acosh_upward":
double: 2
@@ -122,8 +122,8 @@ double: 3
float: 3
idouble: 3
ifloat: 3
-ildouble: 4
-ldouble: 4
+ildouble: 7
+ldouble: 7
Function: "atan":
double: 1
@@ -216,8 +216,8 @@ double: 3
float: 3
idouble: 3
ifloat: 3
-ildouble: 3
-ldouble: 3
+ildouble: 4
+ldouble: 4
Function: "cabs":
double: 1
@@ -272,8 +272,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Real part of "cacos_towardzero":
double: 2
@@ -288,8 +288,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Real part of "cacos_upward":
double: 2
@@ -328,8 +328,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Imaginary part of "cacosh_downward":
double: 2
@@ -344,8 +344,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Imaginary part of "cacosh_towardzero":
double: 2
@@ -432,8 +432,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Real part of "casin_towardzero":
double: 3
@@ -448,8 +448,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Real part of "casin_upward":
double: 2
@@ -488,8 +488,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Imaginary part of "casinh_downward":
double: 3
@@ -504,8 +504,8 @@ double: 5
float: 3
idouble: 5
ifloat: 3
-ildouble: 5
-ldouble: 5
+ildouble: 8
+ldouble: 8
Function: Imaginary part of "casinh_towardzero":
double: 3
@@ -696,8 +696,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
Function: Real part of "ccos_downward":
double: 1
@@ -1132,8 +1132,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
Function: Imaginary part of "csin":
ildouble: 1
@@ -1198,8 +1198,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
Function: Real part of "csinh_downward":
double: 2
@@ -1318,8 +1318,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 2
-ldouble: 2
+ildouble: 3
+ldouble: 3
Function: Imaginary part of "ctan":
double: 2
@@ -1390,8 +1390,8 @@ double: 2
float: 1
idouble: 2
ifloat: 1
-ildouble: 2
-ldouble: 2
+ildouble: 3
+ldouble: 3
Function: Real part of "ctanh_downward":
double: 4
@@ -1478,8 +1478,8 @@ double: 2
float: 2
idouble: 2
ifloat: 2
-ildouble: 2
-ldouble: 2
+ildouble: 3
+ldouble: 3
Function: "erfc_downward":
double: 3
@@ -1564,8 +1564,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
Function: "exp2_upward":
double: 1
@@ -1588,8 +1588,8 @@ ildouble: 2
ldouble: 2
Function: "exp_upward":
-float: 1
double: 1
+float: 1
idouble: 1
ifloat: 1
ildouble: 1
@@ -1624,8 +1624,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 4
-ldouble: 4
+ildouble: 6
+ldouble: 6
Function: "fma":
ildouble: 1
@@ -1688,8 +1688,8 @@ double: 4
float: 5
idouble: 4
ifloat: 5
-ildouble: 10
-ldouble: 10
+ildouble: 11
+ldouble: 11
Function: "hypot":
double: 1
@@ -1752,8 +1752,8 @@ double: 1
float: 2
idouble: 1
ifloat: 2
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
Function: "j1_downward":
double: 3
@@ -1840,8 +1840,8 @@ double: 4
float: 5
idouble: 4
ifloat: 5
-ildouble: 10
-ldouble: 10
+ildouble: 11
+ldouble: 11
Function: "log":
float: 1
@@ -1910,8 +1910,8 @@ double: 2
float: 2
idouble: 2
ifloat: 2
-ildouble: 2
-ldouble: 2
+ildouble: 3
+ldouble: 3
Function: "log2":
double: 1
@@ -2184,16 +2184,16 @@ double: 3
float: 3
idouble: 3
ifloat: 3
-ildouble: 3
-ldouble: 3
+ildouble: 4
+ldouble: 4
Function: "tanh_towardzero":
double: 2
float: 2
idouble: 2
ifloat: 2
-ildouble: 3
-ldouble: 3
+ildouble: 4
+ldouble: 4
Function: "tanh_upward":
double: 3
diff --git a/sysdeps/powerpc/ifunc-sel.h b/sysdeps/powerpc/ifunc-sel.h
index 526d8ed88b..ac589bd3c0 100644
--- a/sysdeps/powerpc/ifunc-sel.h
+++ b/sysdeps/powerpc/ifunc-sel.h
@@ -17,15 +17,17 @@ ifunc_sel (int (*f1) (void), int (*f2) (void), int (*f3) (void))
"addis %0,11,%2-1b@ha\n\t"
"addi %0,%0,%2-1b@l\n\t"
"cmpwi 12,1\n\t"
- "beqlr\n\t"
+ "beq 2f\n\t"
"addis %0,11,%3-1b@ha\n\t"
"addi %0,%0,%3-1b@l\n\t"
"cmpwi 12,-1\n\t"
- "beqlr\n\t"
+ "beq 2f\n\t"
"addis %0,11,%4-1b@ha\n\t"
- "addi %0,%0,%4-1b@l"
+ "addi %0,%0,%4-1b@l\n\t"
+ "2:"
: "=r" (ret)
- : "X" (&global), "X" (f1), "X" (f2), "X" (f3));
+ : "i" (&global), "i" (f1), "i" (f2), "i" (f3)
+ : "11", "12", "cr0");
return ret;
}
@@ -40,7 +42,8 @@ ifunc_one (int (*f1) (void))
"addis %0,%0,%1-1b@ha\n\t"
"addi %0,%0,%1-1b@l"
: "=r" (ret)
- : "X" (f1));
+ : "i" (f1)
+ : "12");
return ret;
}
#endif
diff --git a/sysdeps/powerpc/nptl/tcb-offsets.sym b/sysdeps/powerpc/nptl/tcb-offsets.sym
index f580e69555..7c9fd33562 100644
--- a/sysdeps/powerpc/nptl/tcb-offsets.sym
+++ b/sysdeps/powerpc/nptl/tcb-offsets.sym
@@ -13,7 +13,6 @@
#if TLS_MULTIPLE_THREADS_IN_TCB
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
#endif
-PID thread_offsetof (pid)
TID thread_offsetof (tid)
POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
TAR_SAVE (offsetof (tcbhead_t, tar_save) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/sysdeps/powerpc/powerpc32/power6/memset.S b/sysdeps/powerpc/powerpc32/power6/memset.S
index b2a222edd2..d5dbe83af2 100644
--- a/sysdeps/powerpc/powerpc32/power6/memset.S
+++ b/sysdeps/powerpc/powerpc32/power6/memset.S
@@ -394,7 +394,7 @@ L(cacheAlignedx):
/* A simple loop for the longer (>640 bytes) lengths. This form limits
the branch miss-predicted to exactly 1 at loop exit.*/
L(cacheAligned512):
- cmpli cr1,rLEN,128
+ cmplwi cr1,rLEN,128
blt cr1,L(cacheAligned1)
dcbz 0,rMEMP
addi rLEN,rLEN,-128
diff --git a/sysdeps/powerpc/powerpc32/power9/multiarch/Implies b/sysdeps/powerpc/powerpc32/power9/multiarch/Implies
index 4393b56872..1a46ef0035 100644
--- a/sysdeps/powerpc/powerpc32/power9/multiarch/Implies
+++ b/sysdeps/powerpc/powerpc32/power9/multiarch/Implies
@@ -1 +1 @@
-powerpc/powerpc32/power8/fpu/multiarch
+powerpc/powerpc32/power8/multiarch
diff --git a/sysdeps/powerpc/powerpc64/power6/memset.S b/sysdeps/powerpc/powerpc64/power6/memset.S
index c2d1c4e600..d445b1e1ef 100644
--- a/sysdeps/powerpc/powerpc64/power6/memset.S
+++ b/sysdeps/powerpc/powerpc64/power6/memset.S
@@ -251,7 +251,7 @@ L(cacheAlignedx):
/* A simple loop for the longer (>640 bytes) lengths. This form limits
the branch miss-predicted to exactly 1 at loop exit.*/
L(cacheAligned512):
- cmpli cr1,rLEN,128
+ cmpldi cr1,rLEN,128
blt cr1,L(cacheAligned1)
dcbz 0,rMEMP
addi rLEN,rLEN,-128
diff --git a/sysdeps/powerpc/powerpc64/power9/fpu/Implies b/sysdeps/powerpc/powerpc64/power9/fpu/Implies
index fad2505ab9..ae0dbaf857 100644
--- a/sysdeps/powerpc/powerpc64/power9/fpu/Implies
+++ b/sysdeps/powerpc/powerpc64/power9/fpu/Implies
@@ -1,2 +1 @@
powerpc/powerpc64/power8/fpu
-powerpc/powerpc64/power8
diff --git a/sysdeps/s390/nptl/Makefile b/sysdeps/s390/nptl/Makefile
index 5734b983b0..3a391c8217 100644
--- a/sysdeps/s390/nptl/Makefile
+++ b/sysdeps/s390/nptl/Makefile
@@ -21,4 +21,5 @@ endif
ifeq ($(subdir),nptl)
libpthread-routines += ptw-sysdep
+libpthread-shared-only-routines += ptw-sysdep
endif
diff --git a/sysdeps/s390/nptl/tcb-offsets.sym b/sysdeps/s390/nptl/tcb-offsets.sym
index 9cfae211e0..9c1c01f353 100644
--- a/sysdeps/s390/nptl/tcb-offsets.sym
+++ b/sysdeps/s390/nptl/tcb-offsets.sym
@@ -3,5 +3,4 @@
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
STACK_GUARD offsetof (tcbhead_t, stack_guard)
-PID offsetof (struct pthread, pid)
TID offsetof (struct pthread, tid)
diff --git a/sysdeps/sh/nptl/tcb-offsets.sym b/sysdeps/sh/nptl/tcb-offsets.sym
index ac63b5b93b..4963e1506f 100644
--- a/sysdeps/sh/nptl/tcb-offsets.sym
+++ b/sysdeps/sh/nptl/tcb-offsets.sym
@@ -4,7 +4,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
diff --git a/sysdeps/sparc/nptl/tcb-offsets.sym b/sysdeps/sparc/nptl/tcb-offsets.sym
index 923af8a5b7..f75d02065e 100644
--- a/sysdeps/sparc/nptl/tcb-offsets.sym
+++ b/sysdeps/sparc/nptl/tcb-offsets.sym
@@ -3,5 +3,4 @@
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
-PID offsetof (struct pthread, pid)
TID offsetof (struct pthread, tid)
diff --git a/sysdeps/sparc/sparc32/fpu/s_fdim.S b/sysdeps/sparc/sparc32/fpu/s_fdim.S
deleted file mode 100644
index e93970faae..0000000000
--- a/sysdeps/sparc/sparc32/fpu/s_fdim.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Compute positive difference, sparc 32-bit.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-ENTRY(__fdim)
- std %o0, [%sp + 72]
- std %o2, [%sp + 80]
- ldd [%sp + 72], %f0
- ldd [%sp + 80], %f2
- fcmpd %f0, %f2
- st %g0, [%sp + 72]
- fbug 1f
- st %g0, [%sp + 76]
- ldd [%sp + 72], %f0
- fnegs %f0, %f2
- fmovs %f1, %f3
-1: retl
- fsubd %f0, %f2, %f0
-END(__fdim)
-weak_alias (__fdim, fdim)
-
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __fdim, fdiml, GLIBC_2_1);
-#endif
diff --git a/sysdeps/sparc/sparc32/fpu/s_fdimf.S b/sysdeps/sparc/sparc32/fpu/s_fdimf.S
deleted file mode 100644
index c3fe8afa98..0000000000
--- a/sysdeps/sparc/sparc32/fpu/s_fdimf.S
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Compute positive difference, sparc 32-bit.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-ENTRY(__fdimf)
- st %o0, [%sp + 72]
- st %o1, [%sp + 76]
- ld [%sp + 72], %f0
- ld [%sp + 76], %f1
- fcmps %f0, %f1
- fbug 1f
- st %g0, [%sp + 72]
- ld [%sp + 72], %f0
- fnegs %f0, %f1
-1: retl
- fsubs %f0, %f1, %f0
-END(__fdimf)
-weak_alias (__fdimf, fdimf)
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
index ebbe28b07f..13d3c6db51 100644
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
@@ -4,8 +4,8 @@ libm-sysdep_routines += m_copysignf-vis3 m_copysign-vis3 s_fabs-vis3 \
s_fabsf-vis3 s_llrintf-vis3 s_llrint-vis3 \
s_rintf-vis3 s_rint-vis3 w_sqrt-vis3 w_sqrtf-vis3 \
s_fminf-vis3 s_fmin-vis3 s_fmaxf-vis3 s_fmax-vis3 \
- s_fmaf-vis3 s_fma-vis3 s_fdimf-vis3 s_fdim-vis3 \
- s_nearbyint-vis3 s_nearbyintf-vis3
+ s_fmaf-vis3 s_fma-vis3 s_nearbyint-vis3 \
+ s_nearbyintf-vis3
sysdep_routines += s_copysignf-vis3 s_copysign-vis3
endif
endif
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.S
deleted file mode 100644
index 4a479b1a59..0000000000
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Compute positive difference, sparc 32-bit+v9+vis3.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-ENTRY(__fdim_vis3)
- movwtos %o0, %f0
- movwtos %o1, %f1
- movwtos %o2, %f2
- movwtos %o3, %f3
- fcmpd %f0, %f2
- fbug 1f
- nop
- fzero %f0
- fnegd %f0, %f2
-1: retl
- fsubd %f0, %f2, %f0
-END(__fdim_vis3)
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.S
deleted file mode 100644
index 4b13408244..0000000000
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.S
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <sparc-ifunc.h>
-#include <math_ldbl_opt.h>
-
-SPARC_ASM_VIS3_IFUNC(fdim)
-
-weak_alias (__fdim, fdim)
-
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __fdim, fdiml, GLIBC_2_1);
-#endif
-
-# undef weak_alias
-# define weak_alias(a, b)
-# undef compat_symbol
-# define compat_symbol(a, b, c, d)
-
-#define __fdim __fdim_generic
-
-#include "../s_fdim.S"
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf-vis3.S
deleted file mode 100644
index 081fc15b62..0000000000
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf-vis3.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Compute positive difference, sparc 32-bit+v9+vis3.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-ENTRY(__fdimf_vis3)
- movwtos %o0, %f0
- movwtos %o1, %f1
- fcmps %f0, %f1
- fbug 1f
- nop
- fzeros %f0
- fnegs %f0, %f1
-1: retl
- fsubs %f0, %f1, %f0
-END(__fdimf_vis3)
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf.S
deleted file mode 100644
index 30381d6a59..0000000000
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf.S
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sparc-ifunc.h>
-
-SPARC_ASM_VIS3_IFUNC(fdimf)
-
-weak_alias (__fdimf, fdimf)
-
-# undef weak_alias
-# define weak_alias(a, b)
-
-#define __fdimf __fdimf_generic
-
-#include "../s_fdimf.S"
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
index d9ff0cc288..ff81b0da83 100644
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
@@ -36,15 +36,15 @@
#define SIGN_BIT %f12 /* -0.0 */
ENTRY (__nearbyint_vis3)
+ sllx %o0, 32, %o0
+ or %o0, %o1, %o0
+ movxtod %o0, %f0
fcmpd %fcc3, %f0, %f0 /* Check for sNaN */
st %fsr, [%sp + 88]
sethi %hi(TWO_FIFTYTWO), %o2
sethi %hi(0xf8003e0), %o5
ld [%sp + 88], %o4
- sllx %o0, 32, %o0
or %o5, %lo(0xf8003e0), %o5
- or %o0, %o1, %o0
- movxtod %o0, %f0
andn %o4, %o5, %o4
fzero ZERO
st %o4, [%sp + 80]
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
index 5cd1eb02db..833a0dfc24 100644
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
@@ -35,9 +35,9 @@
#define SIGN_BIT %f12 /* -0.0 */
ENTRY (__nearbyintf_vis3)
+ movwtos %o0, %f1
fcmps %fcc3, %f1, %f1 /* Check for sNaN */
st %fsr, [%sp + 88]
- movwtos %o0, %f1
sethi %hi(TWO_TWENTYTHREE), %o2
sethi %hi(0xf8003e0), %o5
ld [%sp + 88], %o4
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/s_fdim.S b/sysdeps/sparc/sparc32/sparcv9/fpu/s_fdim.S
deleted file mode 100644
index 37f7f44dfa..0000000000
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/s_fdim.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Compute positive difference, sparc 32-bit+v9.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-ENTRY(__fdim)
- std %o0, [%sp + 72]
- std %o2, [%sp + 80]
- ldd [%sp + 72], %f0
- ldd [%sp + 80], %f2
- fcmpd %f0, %f2
- fbug 1f
- nop
- fzero %f0
- fnegd %f0, %f2
-1: retl
- fsubd %f0, %f2, %f0
-END(__fdim)
-weak_alias (__fdim, fdim)
-
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
-compat_symbol (libm, __fdim, fdiml, GLIBC_2_1);
-#endif
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/s_fdimf.S b/sysdeps/sparc/sparc32/sparcv9/fpu/s_fdimf.S
deleted file mode 100644
index 9e0e3f21be..0000000000
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/s_fdimf.S
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Compute positive difference, sparc 32-bit+v9.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-ENTRY(__fdimf)
- st %o0, [%sp + 72]
- st %o1, [%sp + 76]
- ld [%sp + 72], %f0
- ld [%sp + 76], %f1
- fcmps %f0, %f1
- fbug 1f
- nop
- fzeros %f0
- fnegs %f0, %f1
-1: retl
- fsubs %f0, %f1, %f0
-END(__fdimf)
-weak_alias (__fdimf, fdimf)
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S b/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S
index 84a10971a4..198440a5bc 100644
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S
@@ -36,21 +36,21 @@
#define SIGN_BIT %f12 /* -0.0 */
ENTRY (__nearbyint)
+ sllx %o0, 32, %o0
+ or %o0, %o1, %o0
+ stx %o0, [%sp + 72]
+ ldd [%sp + 72], %f0
fcmpd %fcc3, %f0, %f0 /* Check for sNaN */
st %fsr, [%sp + 88]
sethi %hi(TWO_FIFTYTWO), %o2
sethi %hi(0xf8003e0), %o5
ld [%sp + 88], %o4
- sllx %o0, 32, %o0
or %o5, %lo(0xf8003e0), %o5
- or %o0, %o1, %o0
andn %o4, %o5, %o4
fzero ZERO
st %o4, [%sp + 80]
- stx %o0, [%sp + 72]
sllx %o2, 32, %o2
fnegd ZERO, SIGN_BIT
- ldd [%sp + 72], %f0
ld [%sp + 80], %fsr
stx %o2, [%sp + 72]
fabsd %f0, %f14
diff --git a/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S b/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S
index d5cf5ce815..9be41f6c22 100644
--- a/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S
+++ b/sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S
@@ -35,9 +35,10 @@
#define SIGN_BIT %f12 /* -0.0 */
ENTRY (__nearbyintf)
+ st %o0, [%sp + 68]
+ ld [%sp + 68], %f1
fcmps %fcc3, %f1, %f1 /* Check for sNaN */
st %fsr, [%sp + 88]
- st %o0, [%sp + 68]
sethi %hi(TWO_TWENTYTHREE), %o2
sethi %hi(0xf8003e0), %o5
ld [%sp + 88], %o4
@@ -46,7 +47,6 @@ ENTRY (__nearbyintf)
fnegs ZERO, SIGN_BIT
andn %o4, %o5, %o4
st %o4, [%sp + 80]
- ld [%sp + 68], %f1
ld [%sp + 80], %fsr
st %o2, [%sp + 68]
fabss %f1, %f14
diff --git a/sysdeps/sparc/sparc64/fpu/s_fdim.S b/sysdeps/sparc/sparc64/fpu/s_fdim.S
deleted file mode 100644
index 7fae72a251..0000000000
--- a/sysdeps/sparc/sparc64/fpu/s_fdim.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Compute positive difference, sparc 64-bit.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-ENTRY(__fdim)
- fcmpd %f0, %f2
- fbug 1f
- nop
- fzero %f0
- fnegd %f0, %f2
-1: retl
- fsubd %f0, %f2, %f0
-END(__fdim)
-weak_alias (__fdim, fdim)
diff --git a/sysdeps/sparc/sparc64/fpu/s_fdimf.S b/sysdeps/sparc/sparc64/fpu/s_fdimf.S
deleted file mode 100644
index 356c23c4e3..0000000000
--- a/sysdeps/sparc/sparc64/fpu/s_fdimf.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Compute positive difference, sparc 64-bit.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller <davem@davemloft.net>.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-ENTRY(__fdimf)
- fcmps %f1, %f3
- fbug 1f
- nop
- fzeros %f1
- fnegs %f1, %f3
-1: retl
- fsubs %f1, %f3, %f0
-END(__fdimf)
-weak_alias (__fdimf, fdimf)
diff --git a/sysdeps/tile/nptl/tcb-offsets.sym b/sysdeps/tile/nptl/tcb-offsets.sym
index 6740bc976f..0147ffafb7 100644
--- a/sysdeps/tile/nptl/tcb-offsets.sym
+++ b/sysdeps/tile/nptl/tcb-offsets.sym
@@ -9,7 +9,6 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
FEEDBACK_DATA_OFFSET (offsetof (tcbhead_t, feedback_data) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/sysdeps/unix/alpha/Makefile b/sysdeps/unix/alpha/Makefile
index 441aa02a83..0660847f15 100644
--- a/sysdeps/unix/alpha/Makefile
+++ b/sysdeps/unix/alpha/Makefile
@@ -1,3 +1,4 @@
ifeq ($(subdir),rt)
librt-sysdep_routines += rt-sysdep
+librt-shared-only-routines += rt-sysdep
endif
diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h
index 94a2ce0e37..38c2432002 100644
--- a/sysdeps/unix/sysdep.h
+++ b/sysdeps/unix/sysdep.h
@@ -24,42 +24,79 @@
#define SYSCALL__(name, args) PSEUDO (__##name, name, args)
#define SYSCALL(name, args) PSEUDO (name, name, args)
-#define __SYSCALL0(name) \
+#define __SYSCALL_CONCAT_X(a,b) a##b
+#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b)
+
+
+#define __INTERNAL_SYSCALL0(name, err) \
+ INTERNAL_SYSCALL (name, err, 0)
+#define __INTERNAL_SYSCALL1(name, err, a1) \
+ INTERNAL_SYSCALL (name, err, 1, a1)
+#define __INTERNAL_SYSCALL2(name, err, a1, a2) \
+ INTERNAL_SYSCALL (name, err, 2, a1, a2)
+#define __INTERNAL_SYSCALL3(name, err, a1, a2, a3) \
+ INTERNAL_SYSCALL (name, err, 3, a1, a2, a3)
+#define __INTERNAL_SYSCALL4(name, err, a1, a2, a3, a4) \
+ INTERNAL_SYSCALL (name, err, 4, a1, a2, a3, a4)
+#define __INTERNAL_SYSCALL5(name, err, a1, a2, a3, a4, a5) \
+ INTERNAL_SYSCALL (name, err, 5, a1, a2, a3, a4, a5)
+#define __INTERNAL_SYSCALL6(name, err, a1, a2, a3, a4, a5, a6) \
+ INTERNAL_SYSCALL (name, err, 6, a1, a2, a3, a4, a5, a6)
+#define __INTERNAL_SYSCALL7(name, err, a1, a2, a3, a4, a5, a6, a7) \
+ INTERNAL_SYSCALL (name, err, 7, a1, a2, a3, a4, a5, a6, a7)
+
+#define __INTERNAL_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,o,...) o
+#define __INTERNAL_SYSCALL_NARGS(...) \
+ __INTERNAL_SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
+#define __INTERNAL_SYSCALL_DISP(b,...) \
+ __SYSCALL_CONCAT (b,__INTERNAL_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
+
+/* Issue a syscall defined by syscall number plus any other argument required.
+ It is similar to INTERNAL_SYSCALL macro, but without the need to pass the
+ expected argument number as second parameter. */
+#define INTERNAL_SYSCALL_CALL(...) \
+ __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL, __VA_ARGS__)
+
+#define __INLINE_SYSCALL0(name) \
INLINE_SYSCALL (name, 0)
-#define __SYSCALL1(name, a1) \
+#define __INLINE_SYSCALL1(name, a1) \
INLINE_SYSCALL (name, 1, a1)
-#define __SYSCALL2(name, a1, a2) \
+#define __INLINE_SYSCALL2(name, a1, a2) \
INLINE_SYSCALL (name, 2, a1, a2)
-#define __SYSCALL3(name, a1, a2, a3) \
+#define __INLINE_SYSCALL3(name, a1, a2, a3) \
INLINE_SYSCALL (name, 3, a1, a2, a3)
-#define __SYSCALL4(name, a1, a2, a3, a4) \
+#define __INLINE_SYSCALL4(name, a1, a2, a3, a4) \
INLINE_SYSCALL (name, 4, a1, a2, a3, a4)
-#define __SYSCALL5(name, a1, a2, a3, a4, a5) \
+#define __INLINE_SYSCALL5(name, a1, a2, a3, a4, a5) \
INLINE_SYSCALL (name, 5, a1, a2, a3, a4, a5)
-#define __SYSCALL6(name, a1, a2, a3, a4, a5, a6) \
+#define __INLINE_SYSCALL6(name, a1, a2, a3, a4, a5, a6) \
INLINE_SYSCALL (name, 6, a1, a2, a3, a4, a5, a6)
-#define __SYSCALL7(name, a1, a2, a3, a4, a5, a6, a7) \
+#define __INLINE_SYSCALL7(name, a1, a2, a3, a4, a5, a6, a7) \
INLINE_SYSCALL (name, 7, a1, a2, a3, a4, a5, a6, a7)
-#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
-#define __SYSCALL_NARGS(...) \
- __SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
-#define __SYSCALL_CONCAT_X(a,b) a##b
-#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b)
-#define __SYSCALL_DISP(b,...) \
- __SYSCALL_CONCAT (b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
+#define __INLINE_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
+#define __INLINE_SYSCALL_NARGS(...) \
+ __INLINE_SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
+#define __INLINE_SYSCALL_DISP(b,...) \
+ __SYSCALL_CONCAT (b,__INLINE_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
-#define __SYSCALL_CALL(...) __SYSCALL_DISP (__SYSCALL, __VA_ARGS__)
+/* Issue a syscall defined by syscall number plus any other argument
+ required. Any error will be handled using arch defined macros and errno
+ will be set accordingly.
+ It is similar to INLINE_SYSCALL macro, but without the need to pass the
+ expected argument number as second parameter. */
+#define INLINE_SYSCALL_CALL(...) \
+ __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__)
#define SYSCALL_CANCEL(...) \
({ \
long int sc_ret; \
if (SINGLE_THREAD_P) \
- sc_ret = __SYSCALL_CALL (__VA_ARGS__); \
+ sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \
else \
{ \
int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \
- sc_ret = __SYSCALL_CALL (__VA_ARGS__); \
+ sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \
LIBC_CANCEL_RESET (sc_cancel_oldtype); \
} \
sc_ret; \
diff --git a/sysdeps/unix/sysv/linux/aarch64/clone.S b/sysdeps/unix/sysv/linux/aarch64/clone.S
index 76baa7a698..96482e53c0 100644
--- a/sysdeps/unix/sysv/linux/aarch64/clone.S
+++ b/sysdeps/unix/sysv/linux/aarch64/clone.S
@@ -72,16 +72,6 @@ thread_start:
cfi_undefined (x30)
mov x29, 0
- tbnz x11, #CLONE_VM_BIT, 1f
-
- mov x8, #SYS_ify(getpid)
- svc 0x0
- mrs x1, tpidr_el0
- sub x1, x1, #PTHREAD_SIZEOF
- str w0, [x1, #PTHREAD_PID_OFFSET]
- str w0, [x1, #PTHREAD_TID_OFFSET]
-1:
-
/* Pick the function arg and execute. */
mov x0, x12
blr x10
diff --git a/sysdeps/unix/sysv/linux/aarch64/vfork.S b/sysdeps/unix/sysv/linux/aarch64/vfork.S
index 577895eeb2..aeed0b29ce 100644
--- a/sysdeps/unix/sysv/linux/aarch64/vfork.S
+++ b/sysdeps/unix/sysv/linux/aarch64/vfork.S
@@ -27,27 +27,10 @@
ENTRY (__vfork)
- /* Save the TCB-cached PID away in w3, and then negate the TCB
- field. But if it's zero, set it to 0x80000000 instead. See
- raise.c for the logic that relies on this value. */
- mrs x2, tpidr_el0
- sub x2, x2, #PTHREAD_SIZEOF
- ldr w3, [x2, #PTHREAD_PID_OFFSET]
- mov w1, #0x80000000
- negs w0, w3
- csel w0, w1, w0, eq
- str w0, [x2, #PTHREAD_PID_OFFSET]
-
mov x0, #0x4111 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
mov x1, sp
DO_CALL (clone, 2)
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- cbz x0, 1f
- str w3, [x2, #PTHREAD_PID_OFFSET]
-1:
cmn x0, #4095
b.cs .Lsyscall_error
RET
diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index c089545e9b..3b523b70cf 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -40,4 +40,5 @@ endif # math
ifeq ($(subdir),nptl)
# pull in __syscall_error routine, __sigprocmask, __syscall_rt_sigaction
libpthread-routines += ptw-sysdep ptw-sigprocmask ptw-rt_sigaction
+libpthread-shared-only-routines += ptw-sysdep ptw-sigprocmask ptw-rt_sigaction
endif
diff --git a/sysdeps/unix/sysv/linux/alpha/clone.S b/sysdeps/unix/sysv/linux/alpha/clone.S
index 6a3154f9a7..2757bf20c3 100644
--- a/sysdeps/unix/sysv/linux/alpha/clone.S
+++ b/sysdeps/unix/sysv/linux/alpha/clone.S
@@ -91,13 +91,6 @@ thread_start:
cfi_def_cfa_register(fp)
cfi_undefined(ra)
- /* Check and see if we need to reset the PID. */
- ldq t0, 16(sp)
- lda t1, CLONE_VM
- and t0, t1, t2
- beq t2, 2f
-1:
-
/* Load up the arguments. */
ldq pv, 0(sp)
ldq a0, 8(sp)
@@ -120,15 +113,6 @@ thread_start:
halt
.align 4
-2:
- rduniq
- mov v0, s0
- lda v0, __NR_getxpid
- callsys
-3:
- stl v0, PID_OFFSET(s0)
- stl v0, TID_OFFSET(s0)
- br 1b
cfi_endproc
.end thread_start
diff --git a/sysdeps/unix/sysv/linux/alpha/vfork.S b/sysdeps/unix/sysv/linux/alpha/vfork.S
index 9fc199ac41..e5f7ed0661 100644
--- a/sysdeps/unix/sysv/linux/alpha/vfork.S
+++ b/sysdeps/unix/sysv/linux/alpha/vfork.S
@@ -25,24 +25,9 @@ ENTRY(__libc_vfork)
rduniq
mov v0, a1
- /* Save the TCB-cached PID away in A2, and then negate the TCB
- field. But if it's zero, set it to 0x80000000 instead. See
- raise.c for the logic that relies on this value. */
- ldl a2, PID_OFFSET(v0)
- ldah t0, -0x8000
- negl a2, t1
- cmovne a2, t1, t0
- stl t0, PID_OFFSET(v0);
-
lda v0, SYS_ify(vfork)
call_pal PAL_callsys
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- beq v0, 1f
- stl a2, PID_OFFSET(a1)
-1:
/* Normal error check and return. */
bne a3, SYSCALL_ERROR_LABEL
ret
diff --git a/sysdeps/unix/sysv/linux/arm/clone.S b/sysdeps/unix/sysv/linux/arm/clone.S
index 7ff681804b..4c6325d088 100644
--- a/sysdeps/unix/sysv/linux/arm/clone.S
+++ b/sysdeps/unix/sysv/linux/arm/clone.S
@@ -70,16 +70,6 @@ PSEUDO_END (__clone)
1:
.fnstart
.cantunwind
- tst ip, #CLONE_VM
- bne 2f
- GET_TLS (lr)
- mov r1, r0
- ldr r7, =SYS_ify(getpid)
- swi 0x0
- NEGOFF_ADJ_BASE (r1, TID_OFFSET)
- str r0, NEGOFF_OFF1 (r1, TID_OFFSET)
- str r0, NEGOFF_OFF2 (r1, PID_OFFSET, TID_OFFSET)
-2:
@ pick the function arg and call address off the stack and execute
ldr r0, [sp, #4]
ldr ip, [sp], #8
diff --git a/sysdeps/unix/sysv/linux/arm/setcontext.S b/sysdeps/unix/sysv/linux/arm/setcontext.S
index 603e508858..d1f168fece 100644
--- a/sysdeps/unix/sysv/linux/arm/setcontext.S
+++ b/sysdeps/unix/sysv/linux/arm/setcontext.S
@@ -86,12 +86,19 @@ weak_alias(__setcontext, setcontext)
/* Called when a makecontext() context returns. Start the
context in R4 or fall through to exit(). */
+ /* Unwind descriptors are looked up based on PC - 2, so we have to
+ make sure to mark the instruction preceding the __startcontext
+ label as .cantunwind. */
+ .fnstart
+ .cantunwind
+ nop
ENTRY(__startcontext)
movs r0, r4
bne PLTJMP(__setcontext)
@ New context was 0 - exit
b PLTJMP(HIDDEN_JUMPTARGET(exit))
+ .fnend
END(__startcontext)
#ifdef PIC
diff --git a/sysdeps/unix/sysv/linux/arm/vfork.S b/sysdeps/unix/sysv/linux/arm/vfork.S
index 500f5ca4be..794372ee12 100644
--- a/sysdeps/unix/sysv/linux/arm/vfork.S
+++ b/sysdeps/unix/sysv/linux/arm/vfork.S
@@ -28,16 +28,6 @@
and the process ID of the new process to the old process. */
ENTRY (__vfork)
- /* Save the PID value. */
- GET_TLS (r2)
- NEGOFF_ADJ_BASE2 (r2, r0, PID_OFFSET) /* Save the TLS addr in r2. */
- ldr r3, NEGOFF_OFF1 (r2, PID_OFFSET) /* Load the saved PID. */
- rsbs r0, r3, #0 /* Negate it, and test for zero. */
- /* Use 0x80000000 if it was 0. See raise.c for how this is used. */
- it eq
- moveq r0, #0x80000000
- str r0, NEGOFF_OFF1 (r2, PID_OFFSET) /* Store the temp PID. */
-
/* The DO_CALL macro saves r7 on the stack, to enable generation
of ARM unwind info. Since the stack is initially shared between
parent and child of vfork, that saved value could be corrupted.
@@ -57,11 +47,6 @@ ENTRY (__vfork)
mov r7, ip
cfi_restore (r7)
- /* Restore the old PID value in the parent. */
- cmp r0, #0 /* If we are the parent... */
- it ne
- strne r3, NEGOFF_OFF1 (r2, PID_OFFSET) /* restore the saved PID. */
-
cmn a1, #4096
it cc
RETINSTR(cc, lr)
diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c
index 6d32cece48..ec86f50814 100644
--- a/sysdeps/unix/sysv/linux/createthread.c
+++ b/sysdeps/unix/sysv/linux/createthread.c
@@ -128,10 +128,10 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
/* The operation failed. We have to kill the thread.
We let the normal cancellation mechanism do the work. */
+ pid_t pid = __getpid ();
INTERNAL_SYSCALL_DECL (err2);
- (void) INTERNAL_SYSCALL (tgkill, err2, 3,
- THREAD_GETMEM (THREAD_SELF, pid),
- pd->tid, SIGCANCEL);
+ (void) INTERNAL_SYSCALL_CALL (tgkill, err2, pid, pd->tid,
+ SIGCANCEL);
return INTERNAL_SYSCALL_ERRNO (res, err);
}
diff --git a/sysdeps/unix/sysv/linux/getpid.c b/sysdeps/unix/sysv/linux/getpid.c
deleted file mode 100644
index 1124549326..0000000000
--- a/sysdeps/unix/sysv/linux/getpid.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <unistd.h>
-#include <tls.h>
-#include <sysdep.h>
-
-
-#if IS_IN (libc)
-static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval);
-
-static inline __attribute__((always_inline)) pid_t
-really_getpid (pid_t oldval)
-{
- if (__glibc_likely (oldval == 0))
- {
- pid_t selftid = THREAD_GETMEM (THREAD_SELF, tid);
- if (__glibc_likely (selftid != 0))
- return selftid;
- }
-
- INTERNAL_SYSCALL_DECL (err);
- pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
-
- /* We do not set the PID field in the TID here since we might be
- called from a signal handler while the thread executes fork. */
- if (oldval == 0)
- THREAD_SETMEM (THREAD_SELF, tid, result);
- return result;
-}
-#endif
-
-pid_t
-__getpid (void)
-{
-#if !IS_IN (libc)
- INTERNAL_SYSCALL_DECL (err);
- pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
-#else
- pid_t result = THREAD_GETMEM (THREAD_SELF, pid);
- if (__glibc_unlikely (result <= 0))
- result = really_getpid (result);
-#endif
- return result;
-}
-
-libc_hidden_def (__getpid)
-weak_alias (__getpid, getpid)
-libc_hidden_def (getpid)
diff --git a/sysdeps/unix/sysv/linux/hppa/clone.S b/sysdeps/unix/sysv/linux/hppa/clone.S
index 3d037f1430..25fcd497f7 100644
--- a/sysdeps/unix/sysv/linux/hppa/clone.S
+++ b/sysdeps/unix/sysv/linux/hppa/clone.S
@@ -132,18 +132,6 @@ ENTRY(__clone)
ldwm -64(%sp), %r4
.LthreadStart:
-# define CLONE_VM_BIT 23 /* 0x00000100 */
- /* Load original clone flags.
- If CLONE_VM was passed, don't modify PID/TID.
- Otherwise store the result of getpid to PID/TID. */
- ldw -56(%sp), %r26
- bb,<,n %r26, CLONE_VM_BIT, 1f
- ble 0x100(%sr2, %r0)
- ldi __NR_getpid, %r20
- mfctl %cr27, %r26
- stw %ret0, PID_THREAD_OFFSET(%r26)
- stw %ret0, TID_THREAD_OFFSET(%r26)
-1:
/* Load up the arguments. */
ldw -60(%sp), %arg0
ldw -64(%sp), %r22
diff --git a/sysdeps/unix/sysv/linux/hppa/pt-vfork.S b/sysdeps/unix/sysv/linux/hppa/pt-vfork.S
index df532362d2..4684048502 100644
--- a/sysdeps/unix/sysv/linux/hppa/pt-vfork.S
+++ b/sysdeps/unix/sysv/linux/hppa/pt-vfork.S
@@ -25,26 +25,6 @@
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
-/* Load the thread register.
- Load the saved PID value.
- Negate the value.
- Store the temporary PID. */
-#define SAVE_PID \
- mfctl %cr27, %r26 ASM_LINE_SEP \
- ldw PID_THREAD_OFFSET(%r26),%r1 ASM_LINE_SEP \
- sub %r0,%r1,%r1 ASM_LINE_SEP \
- stw %r1,PID_THREAD_OFFSET(%r26) ASM_LINE_SEP
-/* If we are the parent...
- Get the thread pointer.
- Load the saved PID.
- Negate the value (got back original)
- Restore the PID. */
-#define RESTORE_PID \
- cmpb,=,n %r0,%ret0,.Lthread_start ASM_LINE_SEP \
- mfctl %cr27, %r26 ASM_LINE_SEP \
- ldw PID_THREAD_OFFSET(%r26),%r1 ASM_LINE_SEP \
- sub %r0,%r1,%r1 ASM_LINE_SEP \
- stw %r1,PID_THREAD_OFFSET(%r26) ASM_LINE_SEP \
.Lthread_start: ASM_LINE_SEP
/* r26, r25, r24, r23 are free since vfork has no arguments */
@@ -58,16 +38,10 @@ ENTRY(__vfork)
copy %r19, %r25 /* parent */
#endif
- /* Save the process PID */
- SAVE_PID
-
/* Syscall saves and restores all register states */
ble 0x100(%sr2,%r0)
ldi __NR_vfork,%r20
- /* Conditionally restore the PID */
- RESTORE_PID
-
/* Check for error */
ldi -4096,%r1
comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index 71ba61e9d7..6073a9fe04 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -31,6 +31,7 @@ endif
# libpthread uses six-argument inline syscalls.
ifeq ($(subdir),nptl)
libpthread-sysdep_routines += libc-do-syscall
+libpthread-shared-only-routines += libc-do-syscall
endif
ifeq ($(subdir),resource)
@@ -48,9 +49,11 @@ endif
ifeq ($(subdir),nptl)
# pull in __syscall_error routine
libpthread-routines += sysdep
+libpthread-shared-only-routines += sysdep
endif
ifeq ($(subdir),rt)
# pull in __syscall_error routine
librt-routines += sysdep
+librt-shared-only-routines += sysdep
endif
diff --git a/sysdeps/unix/sysv/linux/i386/clone.S b/sysdeps/unix/sysv/linux/i386/clone.S
index 25f2a9c340..feae504ce6 100644
--- a/sysdeps/unix/sysv/linux/i386/clone.S
+++ b/sysdeps/unix/sysv/linux/i386/clone.S
@@ -107,9 +107,6 @@ L(thread_start):
cfi_undefined (eip);
/* Note: %esi is zero. */
movl %esi,%ebp /* terminate the stack frame */
- testl $CLONE_VM, %edi
- je L(newpid)
-L(haspid):
call *%ebx
#ifdef PIC
call L(here)
@@ -121,18 +118,6 @@ L(here):
movl $SYS_ify(exit), %eax
ENTER_KERNEL
- .subsection 2
-L(newpid):
- movl $SYS_ify(getpid), %eax
- ENTER_KERNEL
-L(nomoregetpid):
- movl %eax, %gs:PID
- movl %eax, %gs:TID
- jmp L(haspid)
- .previous
- cfi_endproc;
-
- cfi_startproc
PSEUDO_END (__clone)
libc_hidden_def (__clone)
diff --git a/sysdeps/unix/sysv/linux/i386/vfork.S b/sysdeps/unix/sysv/linux/i386/vfork.S
index 7a1d3373bb..a865de2201 100644
--- a/sysdeps/unix/sysv/linux/i386/vfork.S
+++ b/sysdeps/unix/sysv/linux/i386/vfork.S
@@ -34,17 +34,6 @@ ENTRY (__vfork)
cfi_adjust_cfa_offset (-4)
cfi_register (%eip, %ecx)
- /* Save the TCB-cached PID away in %edx, and then negate the TCB
- field. But if it's zero, set it to 0x80000000 instead. See
- raise.c for the logic that relies on this value. */
- movl %gs:PID, %edx
- movl %edx, %eax
- negl %eax
- jne 1f
- movl $0x80000000, %eax
-1: movl %eax, %gs:PID
-
-
/* Stuff the syscall number in EAX and enter into the kernel. */
movl $SYS_ify (vfork), %eax
int $0x80
@@ -55,14 +44,6 @@ ENTRY (__vfork)
pushl %ecx
cfi_adjust_cfa_offset (4)
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- testl %eax, %eax
- je 1f
- movl %edx, %gs:PID
-1:
-
cmpl $-4095, %eax
/* Branch forward if it failed. */
jae SYSCALL_ERROR_LABEL
diff --git a/sysdeps/unix/sysv/linux/ia64/Makefile b/sysdeps/unix/sysv/linux/ia64/Makefile
index 1de62c528a..4d6766db5e 100644
--- a/sysdeps/unix/sysv/linux/ia64/Makefile
+++ b/sysdeps/unix/sysv/linux/ia64/Makefile
@@ -19,6 +19,7 @@ endif
ifeq ($(subdir),rt)
librt-routines += rt-sysdep
+librt-shared-only-routines += rt-sysdep
endif
ifeq ($(subdir),nptl)
diff --git a/sysdeps/unix/sysv/linux/ia64/clone2.S b/sysdeps/unix/sysv/linux/ia64/clone2.S
index b4cfdfc959..e637b6d4a5 100644
--- a/sysdeps/unix/sysv/linux/ia64/clone2.S
+++ b/sysdeps/unix/sysv/linux/ia64/clone2.S
@@ -67,19 +67,7 @@ ENTRY(__clone2)
(CHILD) mov loc0=gp
(PARENT) ret
;;
- tbit.nz p6,p0=in3,8 /* CLONE_VM */
-(p6) br.cond.dptk 1f
- ;;
- mov r15=SYS_ify (getpid)
-(p7) break __BREAK_SYSCALL
- ;;
- add r9=PID,r13
- add r10=TID,r13
- ;;
- st4 [r9]=r8
- st4 [r10]=r8
- ;;
-1: ld8 out1=[in0],8 /* Retrieve code pointer. */
+ ld8 out1=[in0],8 /* Retrieve code pointer. */
mov out0=in4 /* Pass proper argument to fn */
;;
ld8 gp=[in0] /* Load function gp. */
diff --git a/sysdeps/unix/sysv/linux/ia64/vfork.S b/sysdeps/unix/sysv/linux/ia64/vfork.S
index 9154d7c0fd..84bfdd5d8a 100644
--- a/sysdeps/unix/sysv/linux/ia64/vfork.S
+++ b/sysdeps/unix/sysv/linux/ia64/vfork.S
@@ -33,32 +33,12 @@ ENTRY (__libc_vfork)
.prologue // work around a GAS bug which triggers if
.body // first .prologue is not at the beginning of proc.
alloc r2=ar.pfs,0,0,2,0
- adds r14=PID,r13
- ;;
- ld4 r16=[r14]
- ;;
- sub r15=0,r16
- cmp.eq p6,p0=0,r16
- ;;
-(p6) movl r15=0x80000000
mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD
mov out1=0 /* Standard sp value. */
;;
- st4 [r14]=r15
DO_CALL (SYS_ify (clone))
cmp.eq p6,p0=0,r8
- adds r14=PID,r13
(p6) br.cond.dptk 1f
- ;;
- ld4 r15=[r14]
- ;;
- extr.u r16=r15,0,31
- ;;
- cmp.eq p0,p6=0,r16
- ;;
-(p6) sub r16=0,r15
- ;;
- st4 [r14]=r16
1:
cmp.eq p6,p0=-1,r10
(p6) br.cond.spnt.few __syscall_error
diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
index 3a828443dc..630a29209d 100644
--- a/sysdeps/unix/sysv/linux/m68k/clone.S
+++ b/sysdeps/unix/sysv/linux/m68k/clone.S
@@ -98,19 +98,6 @@ ENTRY (__clone)
cfi_startproc
cfi_undefined (pc) /* Mark end of stack */
subl %fp, %fp /* terminate the stack frame */
- /* Check and see if we need to reset the PID. */
- andl #CLONE_VM, %d1
- jne 1f
- movel #SYS_ify (getpid), %d0
- trap #0
- movel %a0, -(%sp)
- movel %d0, -(%sp)
- bsrl __m68k_read_tp@PLTPC
- movel (%sp)+, %d0
- movel %d0, PID_OFFSET(%a0)
- movel %d0, TID_OFFSET(%a0)
- movel (%sp)+, %a0
-1:
jsr (%a0)
movel %d0, %d1
movel #SYS_ify (exit), %d0
diff --git a/sysdeps/unix/sysv/linux/m68k/vfork.S b/sysdeps/unix/sysv/linux/m68k/vfork.S
index 1625a7b7a0..e27479361b 100644
--- a/sysdeps/unix/sysv/linux/m68k/vfork.S
+++ b/sysdeps/unix/sysv/linux/m68k/vfork.S
@@ -28,18 +28,6 @@
ENTRY (__vfork)
- /* Save the TCB-cached PID away in %d1, and then negate the TCB
- field. But if it's zero, set it to 0x80000000 instead. See
- raise.c for the logic that relies on this value. */
- jbsr __m68k_read_tp@PLTPC
- movel %a0, %a1
- movel PID_OFFSET(%a1), %d0
- movel %d0, %d1
- negl %d0
- jne 1f
- movel #0x80000000, %d0
-1: movel %d0, PID_OFFSET(%a1)
-
/* Pop the return PC value into A0. */
movel %sp@+, %a0
cfi_adjust_cfa_offset (-4)
@@ -49,14 +37,6 @@ ENTRY (__vfork)
movel #SYS_ify (vfork), %d0
trap #0
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- tstl %d0
- jeq 1f
- movel %d1, PID_OFFSET(%a1)
-1:
-
tstl %d0
jmi .Lerror /* Branch forward if it failed. */
diff --git a/sysdeps/unix/sysv/linux/microblaze/Makefile b/sysdeps/unix/sysv/linux/microblaze/Makefile
index 44a838fa11..d178bc6f34 100644
--- a/sysdeps/unix/sysv/linux/microblaze/Makefile
+++ b/sysdeps/unix/sysv/linux/microblaze/Makefile
@@ -5,4 +5,5 @@ endif
ifeq ($(subdir),nptl)
# pull in __syscall_error routine
libpthread-routines += sysdep
-endif
\ No newline at end of file
+libpthread-shared-only-routines += sysdep
+endif
diff --git a/sysdeps/unix/sysv/linux/mips/clone.S b/sysdeps/unix/sysv/linux/mips/clone.S
index 39634c5cf0..7ae65ef723 100644
--- a/sysdeps/unix/sysv/linux/mips/clone.S
+++ b/sysdeps/unix/sysv/linux/mips/clone.S
@@ -130,11 +130,6 @@ L(thread_start):
SAVE_GP (GPOFF)
/* The stackframe has been created on entry of clone(). */
- /* Check and see if we need to reset the PID. */
- and a1,a0,CLONE_VM
- beqz a1,L(restore_pid)
-L(donepid):
-
/* Restore the arg for user's function. */
PTR_L t9,0(sp) /* Function pointer. */
PTR_L a0,PTRSIZE(sp) /* Argument pointer. */
@@ -151,14 +146,6 @@ L(donepid):
jal _exit
#endif
-L(restore_pid):
- li v0,__NR_getpid
- syscall
- READ_THREAD_POINTER(v1)
- INT_S v0,PID_OFFSET(v1)
- INT_S v0,TID_OFFSET(v1)
- b L(donepid)
-
END(__thread_start)
libc_hidden_def (__clone)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index 890a74494a..26ab6d0b75 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -4,6 +4,8 @@ mmap - mmap b:aniiii __mmap mmap __mmap64 mmap64
sync_file_range - sync_file_range Ci:iiii sync_file_range
+readahead - readahead i:iii __readahead readahead
+
prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/mips/vfork.S b/sysdeps/unix/sysv/linux/mips/vfork.S
index 1867c8626e..0b9244b7f8 100644
--- a/sysdeps/unix/sysv/linux/mips/vfork.S
+++ b/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -60,14 +60,6 @@ NESTED(__libc_vfork,FRAMESZ,sp)
PTR_ADDU sp, FRAMESZ
cfi_adjust_cfa_offset (-FRAMESZ)
- /* Save the PID value. */
- READ_THREAD_POINTER(v1) /* Get the thread pointer. */
- lw a2, PID_OFFSET(v1) /* Load the saved PID. */
- subu a2, $0, a2 /* Negate it. */
- bnez a2, 1f /* If it was zero... */
- lui a2, 0x8000 /* use 0x80000000 instead. */
-1: sw a2, PID_OFFSET(v1) /* Store the temporary PID. */
-
li a0, 0x4112 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
move a1, sp
@@ -75,17 +67,6 @@ NESTED(__libc_vfork,FRAMESZ,sp)
li v0,__NR_clone
syscall
- /* Restore the old PID value in the parent. */
- beqz v0, 1f /* If we are the parent... */
- READ_THREAD_POINTER(v1) /* Get the thread pointer. */
- lw a2, PID_OFFSET(v1) /* Load the saved PID. */
- subu a2, $0, a2 /* Re-negate it. */
- lui a0, 0x8000 /* Load 0x80000000... */
- bne a2, a0, 2f /* ... compare against it... */
- li a2, 0 /* ... use 0 instead. */
-2: sw a2, PID_OFFSET(v1) /* Restore the PID. */
-1:
-
cfi_remember_state
bnez a3,L(error)
diff --git a/sysdeps/unix/sysv/linux/nios2/clone.S b/sysdeps/unix/sysv/linux/nios2/clone.S
index 30b6e4a6c8..c9fa00f94c 100644
--- a/sysdeps/unix/sysv/linux/nios2/clone.S
+++ b/sysdeps/unix/sysv/linux/nios2/clone.S
@@ -68,14 +68,6 @@ thread_start:
cfi_startproc
cfi_undefined (ra)
- /* We expect the argument registers to be preserved across system
- calls and across task cloning, so flags should be in r4 here. */
- andi r2, r4, CLONE_VM
- bne r2, zero, 2f
- DO_CALL (getpid, 0)
- stw r2, PID_OFFSET(r23)
- stw r2, TID_OFFSET(r23)
-2:
ldw r5, 4(sp) /* Function pointer. */
ldw r4, 0(sp) /* Argument pointer. */
addi sp, sp, 8
diff --git a/sysdeps/unix/sysv/linux/nios2/vfork.S b/sysdeps/unix/sysv/linux/nios2/vfork.S
index c1bb9c7134..8997269199 100644
--- a/sysdeps/unix/sysv/linux/nios2/vfork.S
+++ b/sysdeps/unix/sysv/linux/nios2/vfork.S
@@ -21,20 +21,10 @@
ENTRY(__vfork)
- ldw r6, PID_OFFSET(r23)
- sub r7, zero, r6
- bne r7, zero, 2f
- movhi r7, %hi(0x80000000)
-2:
- stw r7, PID_OFFSET(r23)
-
movi r4, 0x4111 /* (CLONE_VM | CLONE_VFORK | SIGCHLD) */
mov r5, zero
DO_CALL (clone, 2)
- beq r2, zero, 1f
- stw r6, PID_OFFSET(r23)
-1:
bne r7, zero, SYSCALL_ERROR_LABEL
ret
diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile
index c89ed9ec7d..2cfb46eca3 100644
--- a/sysdeps/unix/sysv/linux/powerpc/Makefile
+++ b/sysdeps/unix/sysv/linux/powerpc/Makefile
@@ -8,6 +8,7 @@ abi-64-v2-condition := __WORDSIZE == 64 && _CALL_ELF == 2
ifeq ($(subdir),rt)
librt-routines += rt-sysdep
+librt-shared-only-routines += rt-sysdep
endif
ifeq ($(subdir),stdlib)
@@ -34,4 +35,5 @@ ifeq ($(subdir),nptl)
libpthread-routines += sysdep
libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
elision-trylock
+libpthread-shared-only-routines += sysdep
endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
index dd1e4c3b17..7dd3d835b6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-lock.c
@@ -45,7 +45,9 @@
int
__lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
{
- if (*adapt_count > 0)
+ /* adapt_count is accessed concurrently but is just a hint. Thus,
+ use atomic accesses but relaxed MO is sufficient. */
+ if (atomic_load_relaxed (adapt_count) > 0)
{
goto use_lock;
}
@@ -67,7 +69,8 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
{
if (aconf.skip_lock_internal_abort > 0)
- *adapt_count = aconf.skip_lock_internal_abort;
+ atomic_store_relaxed (adapt_count,
+ aconf.skip_lock_internal_abort);
goto use_lock;
}
}
@@ -75,7 +78,8 @@ __lll_lock_elision (int *lock, short *adapt_count, EXTRAARG int pshared)
/* Fall back to locks for a bit if retries have been exhausted */
if (aconf.try_tbegin > 0 && aconf.skip_lock_out_of_tbegin_retries > 0)
- *adapt_count = aconf.skip_lock_out_of_tbegin_retries;
+ atomic_store_relaxed (adapt_count,
+ aconf.skip_lock_out_of_tbegin_retries);
use_lock:
return LLL_LOCK ((*lock), pshared);
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c b/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
index 0807a6a432..606185670d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
@@ -34,7 +34,7 @@ __lll_trylock_elision (int *futex, short *adapt_count)
__libc_tabort (_ABORT_NESTED_TRYLOCK);
/* Only try a transaction if it's worth it. */
- if (*adapt_count > 0)
+ if (atomic_load_relaxed (adapt_count) > 0)
{
goto use_lock;
}
@@ -49,7 +49,7 @@ __lll_trylock_elision (int *futex, short *adapt_count)
__libc_tend (0);
if (aconf.skip_lock_busy > 0)
- *adapt_count = aconf.skip_lock_busy;
+ atomic_store_relaxed (adapt_count, aconf.skip_lock_busy);
}
else
{
@@ -59,7 +59,8 @@ __lll_trylock_elision (int *futex, short *adapt_count)
result in another failure. Use normal locking now and
for the next couple of calls. */
if (aconf.skip_trylock_internal_abort > 0)
- *adapt_count = aconf.skip_trylock_internal_abort;
+ atomic_store_relaxed (adapt_count,
+ aconf.skip_trylock_internal_abort);
}
}
diff --git a/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c b/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
index 43c5a67df2..51d7018e4c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
+++ b/sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
@@ -28,13 +28,16 @@ __lll_unlock_elision (int *lock, short *adapt_count, int pshared)
__libc_tend (0);
else
{
- lll_unlock ((*lock), pshared);
+ /* Update adapt_count in the critical section to prevent a
+ write-after-destroy error as mentioned in BZ 20822. The
+ following update of adapt_count has to be contained within
+ the critical region of the fall-back lock in order to not violate
+ the mutex destruction requirements. */
+ short __tmp = atomic_load_relaxed (adapt_count);
+ if (__tmp > 0)
+ atomic_store_relaxed (adapt_count, __tmp - 1);
- /* Update the adapt count AFTER completing the critical section.
- Doing this here prevents unneeded stalling when entering
- a critical section. Saving about 8% runtime on P8. */
- if (*adapt_count > 0)
- (*adapt_count)--;
+ lll_unlock ((*lock), pshared);
}
return 0;
}
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
index bebadbfbb9..49fe01ecde 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
@@ -76,15 +76,6 @@ ENTRY (__clone)
crandc cr1*4+eq,cr1*4+eq,cr0*4+so
bne- cr1,L(parent) /* The '-' is to minimise the race. */
- /* If CLONE_VM is set do not update the pid/tid field. */
- andi. r0,r28,CLONE_VM
- bne+ cr0,L(oldpid)
-
- DO_CALL(SYS_ify(getpid))
- stw r3,TID(r2)
- stw r3,PID(r2)
-L(oldpid):
-
/* Call procedure. */
mtctr r30
mr r3,r31
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
index edbc7de1e6..0a724953a4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
@@ -27,34 +27,8 @@
ENTRY (__vfork)
- /* Load the TCB-cached PID value and negates it. If It it is zero
- sets it to 0x800000. And then sets its value again on TCB field.
- See raise.c for the logic that relies on this value. */
-
- lwz r0,PID(r2)
- cmpwi cr0,r0,0
- neg r0,r0
- bne- cr0,1f
- lis r0,0x8000
-1: stw r0,PID(r2)
-
DO_CALL (SYS_ify (vfork))
- cmpwi cr1,r3,0
- beqlr- 1
-
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- lwz r0,PID(r2)
- /* Cannot use clrlwi. here, because cr0 needs to be preserved
- until PSEUDO_RET. */
- clrlwi r4,r0,1
- cmpwi cr1,r4,0
- beq- cr1,1f
- neg r4,r0
-1: stw r4,PID(r2)
-
PSEUDO_RET
PSEUDO_END (__vfork)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
index 7c59b9b4e9..d8604f6731 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
@@ -78,15 +78,6 @@ ENTRY (__clone)
crandc cr1*4+eq,cr1*4+eq,cr0*4+so
bne- cr1,L(parent) /* The '-' is to minimise the race. */
- /* If CLONE_VM is set do not update the pid/tid field. */
- rldicl. r0,r29,56,63 /* flags & CLONE_VM. */
- bne+ cr0,L(oldpid)
-
- DO_CALL(SYS_ify(getpid))
- stw r3,TID(r13)
- stw r3,PID(r13)
-L(oldpid):
-
std r2,FRAME_TOC_SAVE(r1)
/* Call procedure. */
PPC64_LOAD_FUNCPTR r30
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
index 3083ab7b3c..6b4cf432c1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
@@ -28,31 +28,8 @@
ENTRY (__vfork)
CALL_MCOUNT 0
- /* Load the TCB-cached PID value and negates it. If It it is zero
- sets it to 0x800000. And then sets its value again on TCB field.
- See raise.c for the logic that relies on this value. */
- lwz r0,PID(r13)
- cmpwi cr0,r0,0
- neg r0,r0
- bne- cr0,1f
- lis r0,0x8000
-1: stw r0,PID(r13)
-
DO_CALL (SYS_ify (vfork))
- cmpwi cr1,r3,0
- beqlr- 1
-
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- lwz r0,PID(r13)
- clrlwi r4,r0,1
- cmpwi cr1,r4,0
- beq- cr1,1f
- neg r4,r0
-1: stw r4,PID(r13)
-
PSEUDO_RET
PSEUDO_END (__vfork)
diff --git a/sysdeps/unix/sysv/linux/pread.c b/sysdeps/unix/sysv/linux/pread.c
index 1bcff64781..46d974d952 100644
--- a/sysdeps/unix/sysv/linux/pread.c
+++ b/sysdeps/unix/sysv/linux/pread.c
@@ -28,8 +28,7 @@
ssize_t
__libc_pread (int fd, void *buf, size_t count, off_t offset)
{
- return SYSCALL_CANCEL (pread, fd, buf, count,
- __ALIGNMENT_ARG SYSCALL_LL (offset));
+ return SYSCALL_CANCEL (pread, fd, buf, count, SYSCALL_LL_PRW (offset));
}
strong_alias (__libc_pread, __pread)
diff --git a/sysdeps/unix/sysv/linux/pread64.c b/sysdeps/unix/sysv/linux/pread64.c
index 58c6aeb541..f51beae77a 100644
--- a/sysdeps/unix/sysv/linux/pread64.c
+++ b/sysdeps/unix/sysv/linux/pread64.c
@@ -26,8 +26,7 @@
ssize_t
__libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
{
- return SYSCALL_CANCEL (pread64, fd, buf, count,
- __ALIGNMENT_ARG SYSCALL_LL64 (offset));
+ return SYSCALL_CANCEL (pread64, fd, buf, count, SYSCALL_LL64_PRW (offset));
}
weak_alias (__libc_pread64, __pread64)
diff --git a/sysdeps/unix/sysv/linux/pthread-pids.h b/sysdeps/unix/sysv/linux/pthread-pids.h
index d42bba03cf..618a5b1b9f 100644
--- a/sysdeps/unix/sysv/linux/pthread-pids.h
+++ b/sysdeps/unix/sysv/linux/pthread-pids.h
@@ -26,5 +26,5 @@ static inline void
__pthread_initialize_pids (struct pthread *pd)
{
INTERNAL_SYSCALL_DECL (err);
- pd->pid = pd->tid = INTERNAL_SYSCALL (set_tid_address, err, 1, &pd->tid);
+ pd->tid = INTERNAL_SYSCALL_CALL (set_tid_address, err, &pd->tid);
}
diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill.c
index bcb3009675..cc109973cc 100644
--- a/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -21,6 +21,7 @@
#include <pthreadP.h>
#include <tls.h>
#include <sysdep.h>
+#include <unistd.h>
int
@@ -49,15 +50,9 @@ __pthread_kill (pthread_t threadid, int signo)
/* We have a special syscall to do the work. */
INTERNAL_SYSCALL_DECL (err);
- /* One comment: The PID field in the TCB can temporarily be changed
- (in fork). But this must not affect this code here. Since this
- function would have to be called while the thread is executing
- fork, it would have to happen in a signal handler. But this is
- no allowed, pthread_kill is not guaranteed to be async-safe. */
- int val;
- val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- tid, signo);
+ pid_t pid = __getpid ();
+ int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, tid, signo);
return (INTERNAL_SYSCALL_ERROR_P (val, err)
? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
}
diff --git a/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
index 7694d5467c..e393e0bd73 100644
--- a/sysdeps/unix/sysv/linux/pthread_sigqueue.c
+++ b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
@@ -49,27 +49,22 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value)
if (signo == SIGCANCEL || signo == SIGTIMER || signo == SIGSETXID)
return EINVAL;
+ pid_t pid = getpid ();
+
/* Set up the siginfo_t structure. */
siginfo_t info;
memset (&info, '\0', sizeof (siginfo_t));
info.si_signo = signo;
info.si_code = SI_QUEUE;
- info.si_pid = THREAD_GETMEM (THREAD_SELF, pid);
+ info.si_pid = pid;
info.si_uid = getuid ();
info.si_value = value;
/* We have a special syscall to do the work. */
INTERNAL_SYSCALL_DECL (err);
- /* One comment: The PID field in the TCB can temporarily be changed
- (in fork). But this must not affect this code here. Since this
- function would have to be called while the thread is executing
- fork, it would have to happen in a signal handler. But this is
- no allowed, pthread_sigqueue is not guaranteed to be async-safe. */
- int val = INTERNAL_SYSCALL (rt_tgsigqueueinfo, err, 4,
- THREAD_GETMEM (THREAD_SELF, pid),
- tid, signo, &info);
-
+ int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, err, pid, tid, signo,
+ &info);
return (INTERNAL_SYSCALL_ERROR_P (val, err)
? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
#else
diff --git a/sysdeps/unix/sysv/linux/pwrite.c b/sysdeps/unix/sysv/linux/pwrite.c
index 9c502beac1..1371df8a60 100644
--- a/sysdeps/unix/sysv/linux/pwrite.c
+++ b/sysdeps/unix/sysv/linux/pwrite.c
@@ -28,8 +28,7 @@
ssize_t
__libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
{
- return SYSCALL_CANCEL (pwrite, fd, buf, count,
- __ALIGNMENT_ARG SYSCALL_LL (offset));
+ return SYSCALL_CANCEL (pwrite, fd, buf, count, SYSCALL_LL_PRW (offset));
}
strong_alias (__libc_pwrite, __pwrite)
diff --git a/sysdeps/unix/sysv/linux/pwrite64.c b/sysdeps/unix/sysv/linux/pwrite64.c
index b49e6bc286..22f1f05a44 100644
--- a/sysdeps/unix/sysv/linux/pwrite64.c
+++ b/sysdeps/unix/sysv/linux/pwrite64.c
@@ -26,8 +26,7 @@
ssize_t
__libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
{
- return SYSCALL_CANCEL (pwrite64, fd, buf, count,
- __ALIGNMENT_ARG SYSCALL_LL64 (offset));
+ return SYSCALL_CANCEL (pwrite64, fd, buf, count, SYSCALL_LL64_PRW (offset));
}
weak_alias (__libc_pwrite64, __pwrite64)
libc_hidden_weak (__pwrite64)
diff --git a/sysdeps/unix/sysv/linux/raise.c b/sysdeps/unix/sysv/linux/raise.c
index 470033e83d..49bb7cb0d4 100644
--- a/sysdeps/unix/sysv/linux/raise.c
+++ b/sysdeps/unix/sysv/linux/raise.c
@@ -26,13 +26,6 @@
int
raise (int sig)
{
- /* raise is an async-safe function so it could be called while the
- fork/vfork function temporarily invalidated the PID field. To avoid
- relying on cached value we block all user-defined signal handler
- (which might call fork/vfork) and issue the getpid and gettid
- syscalls directly. */
-
-
/* rt_sigprocmask may fail if:
1. sigsetsize != sizeof (sigset_t) (EINVAL)
diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile
index 497ffd566c..f8ed013e9e 100644
--- a/sysdeps/unix/sysv/linux/s390/Makefile
+++ b/sysdeps/unix/sysv/linux/s390/Makefile
@@ -6,6 +6,7 @@ abi-64-condition := __WORDSIZE == 64
ifeq ($(subdir),rt)
librt-routines += rt-sysdep
+librt-shared-only-routines += rt-sysdep
endif
ifeq ($(subdir),stdlib)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/clone.S b/sysdeps/unix/sysv/linux/s390/s390-32/clone.S
index 2f8fa0b840..b1de1480d1 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/clone.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/clone.S
@@ -54,13 +54,6 @@ error:
PSEUDO_END (__clone)
thread_start:
- tml %r3,256 /* CLONE_VM == 0x00000100 */
- jne 1f
- svc SYS_ify(getpid)
- ear %r3,%a0
- st %r2,PID(%r3)
- st %r2,TID(%r3)
-1:
/* fn is in gpr 1, arg in gpr 0 */
lr %r2,%r0 /* set first parameter to void *arg */
ahi %r15,-96 /* make room on the stack for the save area */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S b/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S
index b7588ebd7c..cc60e139ba 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S
@@ -28,21 +28,9 @@
and the process ID of the new process to the old process. */
ENTRY (__libc_vfork)
- ear %r4,%a0
- lhi %r1,1
- icm %r3,15,PID(%r4)
- sll %r1,31
- je 1f
- lcr %r1,%r3
-1: st %r1,PID(%r4)
-
/* Do vfork system call. */
svc SYS_ify (vfork)
- ltr %r2,%r2
- je 1f
- st %r3,PID(%r4)
-1:
/* Check for error. */
lhi %r4,-4095
clr %r2,%r4
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/clone.S b/sysdeps/unix/sysv/linux/s390/s390-64/clone.S
index fb816922ca..29606acf03 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/clone.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/clone.S
@@ -55,15 +55,6 @@ error:
PSEUDO_END (__clone)
thread_start:
- tmll %r3,256 /* CLONE_VM == 0x00000100 */
- jne 1f
- svc SYS_ify(getpid)
- ear %r3,%a0
- sllg %r3,%r3,32
- ear %r3,%a1
- st %r2,PID(%r3)
- st %r2,TID(%r3)
-1:
/* fn is in gpr 1, arg in gpr 0 */
lgr %r2,%r0 /* set first parameter to void *arg */
aghi %r15,-160 /* make room on the stack for the save area */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S b/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S
index 0bd2161381..b9a813f2cc 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S
@@ -28,22 +28,9 @@
and the process ID of the new process to the old process. */
ENTRY (__libc_vfork)
- ear %r4,%a0
- sllg %r4,%r4,32
- ear %r4,%a1
- icm %r3,15,PID(%r4)
- llilh %r1,32768
- je 1f
- lcr %r1,%r3
-1: st %r1,PID(%r4)
-
/* Do vfork system call. */
svc SYS_ify (vfork)
- ltgr %r2,%r2
- je 1f
- st %r3,PID(%r4)
-1:
/* Check for error. */
lghi %r4,-4095
clgr %r2,%r4
diff --git a/sysdeps/unix/sysv/linux/sh/clone.S b/sysdeps/unix/sysv/linux/sh/clone.S
index 4cd7df117c..ce7cddcb19 100644
--- a/sysdeps/unix/sysv/linux/sh/clone.S
+++ b/sysdeps/unix/sysv/linux/sh/clone.S
@@ -66,23 +66,7 @@ ENTRY(__clone)
2:
/* terminate the stack frame */
mov #0, r14
- mov r4, r0
- shlr8 r0
- tst #1, r0 // CLONE_VM = (1 << 8)
- bf/s 4f
- mov r4, r0
- /* new pid */
- mov #+SYS_ify(getpid), r3
- trapa #0x15
-3:
- stc gbr, r1
- mov.w .Lpidoff, r2
- add r1, r2
- mov.l r0, @r2
- mov.w .Ltidoff, r2
- add r1, r2
- mov.l r0, @r2
-4:
+
/* thread starts */
mov.l @r15, r1
jsr @r1
@@ -113,10 +97,6 @@ ENTRY(__clone)
.long _GLOBAL_OFFSET_TABLE_
.L3:
.long PLTJMP(C_SYMBOL_NAME(_exit))
-.Lpidoff:
- .word PID - TLS_PRE_TCB_SIZE
-.Ltidoff:
- .word TID - TLS_PRE_TCB_SIZE
PSEUDO_END (__clone)
libc_hidden_def (__clone)
diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h
index ad05fc39e1..c5240fafbd 100644
--- a/sysdeps/unix/sysv/linux/sh/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h
@@ -44,3 +44,8 @@
/* SH does not have a 64-bit inode field. */
#undef __ASSUME_ST_INO_64_BIT
+
+/* SH4 ABI does not really require argument alignment for 64-bits, but
+ the kernel interface for p{read,write}64 adds a dummy long argument
+ before the offset. */
+#define __ASSUME_PRW_DUMMY_ARG 1
diff --git a/sysdeps/unix/sysv/linux/sh/pread.c b/sysdeps/unix/sysv/linux/sh/pread.c
deleted file mode 100644
index d3f99f35db..0000000000
--- a/sysdeps/unix/sysv/linux/sh/pread.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* SH4 ABI does not really require argument alignment for 64-bits, but
- the kernel interface for pread adds a dummy long argument before the
- offset. */
-#define __ALIGNMENT_ARG
-#include <sysdeps/unix/sysv/linux/pread.c>
diff --git a/sysdeps/unix/sysv/linux/sh/pread64.c b/sysdeps/unix/sysv/linux/sh/pread64.c
deleted file mode 100644
index b2e8a25788..0000000000
--- a/sysdeps/unix/sysv/linux/sh/pread64.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* SH4 ABI does not really require argument alignment for 64-bits, but
- the kernel interface for pread adds a dummy long argument before the
- offset. */
-#define __ALIGNMENT_ARG
-#include <sysdeps/unix/sysv/linux/pread64.c>
diff --git a/sysdeps/unix/sysv/linux/sh/pwrite.c b/sysdeps/unix/sysv/linux/sh/pwrite.c
deleted file mode 100644
index 391ed5e17b..0000000000
--- a/sysdeps/unix/sysv/linux/sh/pwrite.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* SH4 ABI does not really require argument alignment for 64-bits, but
- the kernel interface for pwrite adds a dummy long argument before the
- offset. */
-#define __ALIGNMENT_ARG
-#include <sysdeps/unix/sysv/linux/pwrite.c>
diff --git a/sysdeps/unix/sysv/linux/sh/pwrite64.c b/sysdeps/unix/sysv/linux/sh/pwrite64.c
deleted file mode 100644
index 683a5d9886..0000000000
--- a/sysdeps/unix/sysv/linux/sh/pwrite64.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ralf Baechle <ralf@gnu.org>, 1998.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* SH4 ABI does not really require argument alignment for 64-bits, but
- the kernel interface for pread adds a dummy long argument before the
- offset. */
-#define __ALIGNMENT_ARG
-#include <sysdeps/unix/sysv/linux/pwrite64.c>
diff --git a/sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym b/sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym
index 17397c5511..25f914a93b 100644
--- a/sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym
+++ b/sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym
@@ -13,22 +13,22 @@ SIG_SETMASK
oLINK ucontext (uc_link)
oSS_SP ucontext (uc_stack.ss_sp)
oSS_SIZE ucontext (uc_stack.ss_size)
-oR0 mcontext (gregs[R0])
-oR1 mcontext (gregs[R1])
-oR2 mcontext (gregs[R2])
-oR3 mcontext (gregs[R3])
-oR4 mcontext (gregs[R4])
-oR5 mcontext (gregs[R5])
-oR6 mcontext (gregs[R6])
-oR7 mcontext (gregs[R7])
-oR8 mcontext (gregs[R8])
-oR9 mcontext (gregs[R9])
-oR10 mcontext (gregs[R10])
-oR11 mcontext (gregs[R11])
-oR12 mcontext (gregs[R12])
-oR13 mcontext (gregs[R13])
-oR14 mcontext (gregs[R14])
-oR15 mcontext (gregs[R15])
+oR0 mcontext (gregs[REG_R0])
+oR1 mcontext (gregs[REG_R1])
+oR2 mcontext (gregs[REG_R2])
+oR3 mcontext (gregs[REG_R3])
+oR4 mcontext (gregs[REG_R4])
+oR5 mcontext (gregs[REG_R5])
+oR6 mcontext (gregs[REG_R6])
+oR7 mcontext (gregs[REG_R7])
+oR8 mcontext (gregs[REG_R8])
+oR9 mcontext (gregs[REG_R9])
+oR10 mcontext (gregs[REG_R10])
+oR11 mcontext (gregs[REG_R11])
+oR12 mcontext (gregs[REG_R12])
+oR13 mcontext (gregs[REG_R13])
+oR14 mcontext (gregs[REG_R14])
+oR15 mcontext (gregs[REG_R15])
oPC mcontext (pc)
oPR mcontext (pr)
oSR mcontext (sr)
diff --git a/sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym b/sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym
index 65633fbcf4..130f60cd96 100644
--- a/sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym
+++ b/sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym
@@ -13,22 +13,22 @@ SIG_SETMASK
oLINK ucontext (uc_link)
oSS_SP ucontext (uc_stack.ss_sp)
oSS_SIZE ucontext (uc_stack.ss_size)
-oR0 mcontext (gregs[R0])
-oR1 mcontext (gregs[R1])
-oR2 mcontext (gregs[R2])
-oR3 mcontext (gregs[R3])
-oR4 mcontext (gregs[R4])
-oR5 mcontext (gregs[R5])
-oR6 mcontext (gregs[R6])
-oR7 mcontext (gregs[R7])
-oR8 mcontext (gregs[R8])
-oR9 mcontext (gregs[R9])
-oR10 mcontext (gregs[R10])
-oR11 mcontext (gregs[R11])
-oR12 mcontext (gregs[R12])
-oR13 mcontext (gregs[R13])
-oR14 mcontext (gregs[R14])
-oR15 mcontext (gregs[R15])
+oR0 mcontext (gregs[REG_R0])
+oR1 mcontext (gregs[REG_R1])
+oR2 mcontext (gregs[REG_R2])
+oR3 mcontext (gregs[REG_R3])
+oR4 mcontext (gregs[REG_R4])
+oR5 mcontext (gregs[REG_R5])
+oR6 mcontext (gregs[REG_R6])
+oR7 mcontext (gregs[REG_R7])
+oR8 mcontext (gregs[REG_R8])
+oR9 mcontext (gregs[REG_R9])
+oR10 mcontext (gregs[REG_R10])
+oR11 mcontext (gregs[REG_R11])
+oR12 mcontext (gregs[REG_R12])
+oR13 mcontext (gregs[REG_R13])
+oR14 mcontext (gregs[REG_R14])
+oR15 mcontext (gregs[REG_R15])
oPC mcontext (pc)
oPR mcontext (pr)
oSR mcontext (sr)
diff --git a/sysdeps/unix/sysv/linux/sh/sys/ucontext.h b/sysdeps/unix/sysv/linux/sh/sys/ucontext.h
index ab9a7e66bf..037fbb73e8 100644
--- a/sysdeps/unix/sysv/linux/sh/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/sh/sys/ucontext.h
@@ -31,49 +31,47 @@
typedef int greg_t;
/* Number of general registers. */
-#define NGPREG 16
+#define NGREG 16
/* Container for all general registers. */
-typedef greg_t gregset_t[NGPREG];
+typedef greg_t gregset_t[NGREG];
-#ifdef __USE_GNU
/* Number of each register is the `gregset_t' array. */
enum
{
- R0 = 0,
-#define R0 R0
- R1 = 1,
-#define R1 R1
- R2 = 2,
-#define R2 R2
- R3 = 3,
-#define R3 R3
- R4 = 4,
-#define R4 R4
- R5 = 5,
-#define R5 R5
- R6 = 6,
-#define R6 R6
- R7 = 7,
-#define R7 R7
- R8 = 8,
-#define R8 R8
- R9 = 9,
-#define R9 R9
- R10 = 10,
-#define R10 R10
- R11 = 11,
-#define R11 R11
- R12 = 12,
-#define R12 R12
- R13 = 13,
-#define R13 R13
- R14 = 14,
-#define R14 R14
- R15 = 15,
-#define R15 R15
+ REG_R0 = 0,
+#define REG_R0 REG_R0
+ REG_R1 = 1,
+#define REG_R1 REG_R1
+ REG_R2 = 2,
+#define REG_R2 REG_R2
+ REG_R3 = 3,
+#define REG_R3 REG_R3
+ REG_R4 = 4,
+#define REG_R4 REG_R4
+ REG_R5 = 5,
+#define REG_R5 REG_R5
+ REG_R6 = 6,
+#define REG_R6 REG_R6
+ REG_R7 = 7,
+#define REG_R7 REG_R7
+ REG_R8 = 8,
+#define REG_R8 REG_R8
+ REG_R9 = 9,
+#define REG_R9 REG_R9
+ REG_R10 = 10,
+#define REG_R10 REG_R10
+ REG_R11 = 11,
+#define REG_R11 REG_R11
+ REG_R12 = 12,
+#define REG_R12 REG_R12
+ REG_R13 = 13,
+#define REG_R13 REG_R13
+ REG_R14 = 14,
+#define REG_R14 REG_R14
+ REG_R15 = 15,
+#define REG_R15 REG_R15
};
-#endif
#if (defined(__SH4__) || defined(__SH4A__))
typedef int freg_t;
diff --git a/sysdeps/unix/sysv/linux/sh/vfork.S b/sysdeps/unix/sysv/linux/sh/vfork.S
index 6895bc5491..df559cb439 100644
--- a/sysdeps/unix/sysv/linux/sh/vfork.S
+++ b/sysdeps/unix/sysv/linux/sh/vfork.S
@@ -26,30 +26,11 @@
and the process ID of the new process to the old process. */
ENTRY (__libc_vfork)
- /* Save the PID value. */
- stc gbr, r2
- mov.w .L2, r0
- mov.l @(r0,r2), r4
- neg r4, r1
- tst r1, r1
- bf 1f
- mov #1, r1
- rotr r1
-1:
- mov.l r1, @(r0,r2)
mov.w .L1, r3
trapa #0x10
mov r0, r1
- /* Restore the old PID value in the parent. */
- tst r0, r0
- bt.s 2f
- stc gbr, r2
- mov.w .L2, r0
- mov.l r4, @(r0,r2)
- mov r1, r0
-2:
mov #-12, r2
shad r2, r1
not r1, r1 // r1=0 means r0 = -1 to -4095
@@ -61,8 +42,6 @@ ENTRY (__libc_vfork)
nop
.L1:
.word __NR_vfork
-.L2:
- .word PID - TLS_PRE_TCB_SIZE
.align 2
PSEUDO_END (__libc_vfork)
diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile
index e67aecf8f0..a67d199eb5 100644
--- a/sysdeps/unix/sysv/linux/sparc/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -6,6 +6,7 @@ abi-64-condition := __WORDSIZE == 64
ifeq ($(subdir),rt)
librt-routines += rt-sysdep
+librt-shared-only-routines += rt-sysdep
endif
ifeq ($(subdir),sysvipc)
@@ -15,4 +16,5 @@ endif
ifeq ($(subdir),nptl)
# pull in __syscall_error routine
libpthread-routines += sysdep
+libpthread-shared-only-routines += sysdep
endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S b/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S
index d6c92f6133..0456a0d16e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S
@@ -79,13 +79,6 @@ END(__clone)
.type __thread_start,@function
__thread_start:
- andcc %g4, CLONE_VM, %g0
- bne 1f
- set __NR_getpid,%g1
- ta 0x10
- st %o0,[%g7 + PID]
- st %o0,[%g7 + TID]
-1:
mov %g0, %fp /* terminate backtrace */
call %g2
mov %g3,%o0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
index 0d0a3b5298..6d985034f0 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
@@ -22,24 +22,14 @@
.text
.globl __syscall_error
ENTRY(__libc_vfork)
- ld [%g7 + PID], %o5
- cmp %o5, 0
- bne 1f
- sub %g0, %o5, %o4
- sethi %hi(0x80000000), %o4
-1: st %o4, [%g7 + PID]
-
LOADSYSCALL(vfork)
ta 0x10
bcc 2f
mov %o7, %g1
- st %o5, [%g7 + PID]
call __syscall_error
mov %g1, %o7
2: sub %o1, 1, %o1
andcc %o0, %o1, %o0
- bne,a 1f
- st %o5, [%g7 + PID]
1: retl
nop
END(__libc_vfork)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S b/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S
index b0f62660a7..6ffead88e2 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S
@@ -76,13 +76,6 @@ END(__clone)
.type __thread_start,@function
__thread_start:
- andcc %g4, CLONE_VM, %g0
- bne,pt %icc, 1f
- set __NR_getpid,%g1
- ta 0x6d
- st %o0,[%g7 + PID]
- st %o0,[%g7 + TID]
-1:
mov %g0, %fp /* terminate backtrace */
call %g2
mov %g3,%o0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
index 0818eba02e..298dd197a9 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
@@ -22,24 +22,14 @@
.text
.globl __syscall_error
ENTRY(__libc_vfork)
- ld [%g7 + PID], %o5
- sethi %hi(0x80000000), %o3
- cmp %o5, 0
- sub %g0, %o5, %o4
- move %icc, %o3, %o4
- st %o4, [%g7 + PID]
-
LOADSYSCALL(vfork)
ta 0x6d
bcc,pt %xcc, 2f
mov %o7, %g1
- st %o5, [%g7 + PID]
call __syscall_error
mov %g1, %o7
2: sub %o1, 1, %o1
andcc %o0, %o1, %o0
- bne,a,pt %icc, 1f
- st %o5, [%g7 + PID]
1: retl
nop
END(__libc_vfork)
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index bb3eecfde1..b5f20a710b 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -58,22 +58,19 @@
normal program exit with the exit code 127. */
#define SPAWN_ERROR 127
-/* We need to block both SIGCANCEL and SIGSETXID. */
-#define SIGALL_SET \
- ((__sigset_t) { .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } })
-
#ifdef __ia64__
-# define CLONE(__fn, __stack, __stacksize, __flags, __args) \
- __clone2 (__fn, __stack, __stacksize, __flags, __args, 0, 0, 0)
+# define CLONE(__fn, __stackbase, __stacksize, __flags, __args) \
+ __clone2 (__fn, __stackbase, __stacksize, __flags, __args, 0, 0, 0)
#else
# define CLONE(__fn, __stack, __stacksize, __flags, __args) \
__clone (__fn, __stack, __flags, __args)
#endif
-#if _STACK_GROWS_DOWN
-# define STACK(__stack, __stack_size) (__stack + __stack_size)
-#elif _STACK_GROWS_UP
+/* Since ia64 wants the stackbase w/clone2, re-use the grows-up macro. */
+#if _STACK_GROWS_UP || defined (__ia64__)
# define STACK(__stack, __stack_size) (__stack)
+#elif _STACK_GROWS_DOWN
+# define STACK(__stack, __stack_size) (__stack + __stack_size)
#endif
@@ -329,6 +326,11 @@ __spawnix (pid_t * pid, const char *file,
/* Add a slack area for child's stack. */
size_t argv_size = (argc * sizeof (void *)) + 512;
+ /* We need at least a few pages in case the compiler's stack checking is
+ enabled. In some configs, it is known to use at least 24KiB. We use
+ 32KiB to be "safe" from anything the compiler might do. Besides, the
+ extra pages won't actually be allocated unless they get used. */
+ argv_size += (32 * 1024);
size_t stack_size = ALIGN_UP (argv_size, GLRO(dl_pagesize));
void *stack = __mmap (NULL, stack_size, prot,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
@@ -340,7 +342,9 @@ __spawnix (pid_t * pid, const char *file,
}
/* Disable asynchronous cancellation. */
- int cs = LIBC_CANCEL_ASYNC ();
+ int state;
+ __libc_ptf_call (__pthread_setcancelstate,
+ (PTHREAD_CANCEL_DISABLE, &state), 0);
args.file = file;
args.exec = exec;
@@ -351,7 +355,7 @@ __spawnix (pid_t * pid, const char *file,
args.envp = envp;
args.xflags = xflags;
- __sigprocmask (SIG_BLOCK, &SIGALL_SET, &args.oldmask);
+ __libc_signal_block_all (&args.oldmask);
/* The clone flags used will create a new child that will run in the same
memory space (CLONE_VM) and the execution of calling thread will be
@@ -384,9 +388,9 @@ __spawnix (pid_t * pid, const char *file,
if ((ec == 0) && (pid != NULL))
*pid = new_pid;
- __sigprocmask (SIG_SETMASK, &args.oldmask, 0);
+ __libc_signal_restore_set (&args.oldmask);
- LIBC_CANCEL_RESET (cs);
+ __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0);
return ec;
}
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 7ae2541f8f..248641b830 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -18,6 +18,7 @@ execve - execve i:spp __execve execve
fdatasync - fdatasync Ci:i fdatasync
flock - flock i:ii __flock flock
get_kernel_syms EXTRA get_kernel_syms i:p __compat_get_kernel_syms get_kernel_syms@GLIBC_2.0:GLIBC_2.23
+getpid - getpid Ei: __getpid getpid
getegid - getegid Ei: __getegid getegid
geteuid - geteuid Ei: __geteuid geteuid
getpgid - getpgid i:i __getpgid getpgid
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index a469f57121..e3ecd5638e 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -48,6 +48,16 @@
__LONG_LONG_PAIR ((long) ((val) >> 32), (long) ((val) & 0xffffffff))
#endif
+/* Provide a common macro to pass 64-bit value on pread and pwrite
+ syscalls. */
+#ifdef __ASSUME_PRW_DUMMY_ARG
+# define SYSCALL_LL_PRW(val) 0, SYSCALL_LL (val)
+# define SYSCALL_LL64_PRW(val) 0, SYSCALL_LL64 (val)
+#else
+# define SYSCALL_LL_PRW(val) __ALIGNMENT_ARG SYSCALL_LL (val)
+# define SYSCALL_LL64_PRW(val) __ALIGNMENT_ARG SYSCALL_LL64 (val)
+#endif
+
/* Provide a macro to pass the off{64}_t argument on p{readv,writev}{64}. */
#define LO_HI_LONG(val) \
(long) (val), \
diff --git a/sysdeps/unix/sysv/linux/tile/Makefile b/sysdeps/unix/sysv/linux/tile/Makefile
index 1c1cfff280..43acea3633 100644
--- a/sysdeps/unix/sysv/linux/tile/Makefile
+++ b/sysdeps/unix/sysv/linux/tile/Makefile
@@ -25,4 +25,5 @@ endif
ifeq ($(subdir),nptl)
# pull in __syscall_error routine
libpthread-routines += sysdep
+libpthread-shared-only-routines += sysdep
endif
diff --git a/sysdeps/unix/sysv/linux/tile/clone.S b/sysdeps/unix/sysv/linux/tile/clone.S
index d1d36462e7..3f9e3d56c4 100644
--- a/sysdeps/unix/sysv/linux/tile/clone.S
+++ b/sysdeps/unix/sysv/linux/tile/clone.S
@@ -163,22 +163,6 @@ ENTRY (__clone)
.Lthread_start:
cfi_def_cfa_offset (FRAME_SIZE)
cfi_undefined (lr)
- /* Check and see if we need to reset the PID, which we do if
- CLONE_VM isn't set, i.e. it's a fork-like clone with a new
- address space. In that case we update the cached values
- from the true system pid (retrieved via __NR_getpid syscall). */
- moveli r0, CLONE_VM
- and r0, r30, r0
- BNEZ r0, .Lno_reset_pid /* CLONE_VM is set */
- moveli TREG_SYSCALL_NR_NAME, __NR_getpid
- swint1
- ADDLI_PTR r2, tp, PID_OFFSET
- {
- ST4 r2, r0
- ADDLI_PTR r2, tp, TID_OFFSET
- }
- ST4 r2, r0
-.Lno_reset_pid:
{
/* Invoke user function with specified argument. */
move r0, r31
diff --git a/sysdeps/unix/sysv/linux/tile/vfork.S b/sysdeps/unix/sysv/linux/tile/vfork.S
index d8c5ce3e24..2272777187 100644
--- a/sysdeps/unix/sysv/linux/tile/vfork.S
+++ b/sysdeps/unix/sysv/linux/tile/vfork.S
@@ -29,18 +29,6 @@
.text
ENTRY (__vfork)
- {
- addli r11, tp, PID_OFFSET /* Point at PID. */
- movei r13, 1
- }
- {
- LD4U r12, r11 /* Load the saved PID. */
- shli r13, r13, 31 /* Build 0x80000000. */
- }
- sub r12, zero, r12 /* Negate it. */
- CMOVEQZ r12, r12, r13 /* Replace zero pids. */
- ST4 r11, r12 /* Store the temporary PID. */
-
{
moveli r0, CLONE_VFORK | CLONE_VM | SIGCHLD
move r1, zero
@@ -52,22 +40,6 @@ ENTRY (__vfork)
moveli TREG_SYSCALL_NR_NAME, __NR_clone
swint1
- BEQZ r0, 1f /* If we are the parent... */
- {
- addli r11, tp, PID_OFFSET /* Point at PID. */
- movei r13, 1
- }
- {
- LD4U r12, r11 /* Load the saved PID. */
- shli r13, r13, 31 /* Build 0x80000000. */
- }
- {
- CMPEQ r13, r12, r12 /* Test for that value. */
- sub r12, zero, r12 /* Re-negate it. */
- }
- CMOVNEZ r12, r13, zero /* Replace zero pids. */
- ST4 r11, r12 /* Restore the PID. */
-1:
BNEZ r1, 0f
jrp lr
PSEUDO_END (__vfork)
diff --git a/sysdeps/unix/sysv/linux/tst-clone2.c b/sysdeps/unix/sysv/linux/tst-clone2.c
index 68a7e6d6e2..1472311947 100644
--- a/sysdeps/unix/sysv/linux/tst-clone2.c
+++ b/sysdeps/unix/sysv/linux/tst-clone2.c
@@ -28,8 +28,11 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/syscall.h>
-#include <tls.h> /* for THREAD_* macros. */
+#include <stackinfo.h> /* For _STACK_GROWS_{UP,DOWN}. */
+
+#include <support/check.h>
static int sig;
static int pipefd[2];
@@ -39,39 +42,35 @@ f (void *a)
{
close (pipefd[0]);
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
- pid_t tid = THREAD_GETMEM (THREAD_SELF, tid);
+ pid_t ppid = getppid ();
+ pid_t pid = getpid ();
+ pid_t tid = syscall (__NR_gettid);
- while (write (pipefd[1], &pid, sizeof pid) < 0)
- continue;
- while (write (pipefd[1], &tid, sizeof tid) < 0)
- continue;
+ if (write (pipefd[1], &ppid, sizeof ppid) != sizeof (ppid))
+ FAIL_EXIT1 ("write ppid failed\n");
+ if (write (pipefd[1], &pid, sizeof pid) != sizeof (pid))
+ FAIL_EXIT1 ("write pid failed\n");
+ if (write (pipefd[1], &tid, sizeof tid) != sizeof (tid))
+ FAIL_EXIT1 ("write tid failed\n");
return 0;
}
static int
-clone_test (int clone_flags)
+do_test (void)
{
sig = SIGRTMIN;
sigset_t ss;
sigemptyset (&ss);
sigaddset (&ss, sig);
if (sigprocmask (SIG_BLOCK, &ss, NULL) != 0)
- {
- printf ("sigprocmask failed: %m\n");
- return 1;
- }
+ FAIL_EXIT1 ("sigprocmask failed: %m");
if (pipe2 (pipefd, O_CLOEXEC))
- {
- printf ("sigprocmask failed: %m\n");
- return 1;
- }
-
- pid_t ppid = getpid ();
+ FAIL_EXIT1 ("pipe failed: %m");
+ int clone_flags = 0;
#ifdef __ia64__
extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
size_t __child_stack_size, int __flags,
@@ -88,61 +87,47 @@ clone_test (int clone_flags)
#error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
#endif
#endif
+
close (pipefd[1]);
if (p == -1)
+ FAIL_EXIT1("clone failed: %m");
+
+ pid_t ppid, pid, tid;
+ if (read (pipefd[0], &ppid, sizeof pid) != sizeof pid)
{
- printf ("clone failed: %m\n");
- return 1;
+ kill (p, SIGKILL);
+ FAIL_EXIT1 ("read ppid failed: %m");
}
-
- pid_t pid, tid;
if (read (pipefd[0], &pid, sizeof pid) != sizeof pid)
{
- printf ("read pid failed: %m\n");
kill (p, SIGKILL);
- return 1;
+ FAIL_EXIT1 ("read pid failed: %m");
}
if (read (pipefd[0], &tid, sizeof tid) != sizeof tid)
{
- printf ("read pid failed: %m\n");
kill (p, SIGKILL);
- return 1;
+ FAIL_EXIT1 ("read tid failed: %m");
}
close (pipefd[0]);
int ret = 0;
- /* For CLONE_VM glibc clone implementation does not change the pthread
- pid/tid field. */
- if ((clone_flags & CLONE_VM) == CLONE_VM)
- {
- if ((ppid != pid) || (ppid != tid))
- {
- printf ("parent pid (%i) != received pid/tid (%i/%i)\n",
- (int)ppid, (int)pid, (int)tid);
- ret = 1;
- }
- }
- /* For any other flag clone updates the new pthread pid and tid with
- the clone return value. */
- else
- {
- if ((p != pid) || (p != tid))
- {
- printf ("child pid (%i) != received pid/tid (%i/%i)\n",
- (int)p, (int)pid, (int)tid);
- ret = 1;
- }
- }
+ pid_t own_pid = getpid ();
+ pid_t own_tid = syscall (__NR_gettid);
+
+ /* Some sanity checks for clone syscall: returned ppid should be current
+ pid and both returned tid/pid should be different from current one. */
+ if ((ppid != own_pid) || (pid == own_pid) || (tid == own_tid))
+ FAIL_RET ("ppid=%i pid=%i tid=%i | own_pid=%i own_tid=%i",
+ (int)ppid, (int)pid, (int)tid, (int)own_pid, (int)own_tid);
int e;
if (waitpid (p, &e, __WCLONE) != p)
{
- puts ("waitpid failed");
kill (p, SIGKILL);
- return 1;
+ FAIL_EXIT1 ("waitpid failed");
}
if (!WIFEXITED (e))
{
@@ -150,29 +135,12 @@ clone_test (int clone_flags)
printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
else
puts ("did not terminate correctly");
- return 1;
+ exit (EXIT_FAILURE);
}
if (WEXITSTATUS (e) != 0)
- {
- printf ("exit code %d\n", WEXITSTATUS (e));
- return 1;
- }
+ FAIL_EXIT1 ("exit code %d", WEXITSTATUS (e));
return ret;
}
-int
-do_test (void)
-{
- /* First, check that the clone implementation, without any flag, updates
- the struct pthread to contain the new PID and TID. */
- int ret = clone_test (0);
- /* Second, check that with CLONE_VM the struct pthread PID and TID fields
- remain unmodified after the clone. Any modifications would cause problem
- for the parent as described in bug 19957. */
- ret += clone_test (CLONE_VM);
- return ret;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
index 66f4b11490..5629aed395 100644
--- a/sysdeps/unix/sysv/linux/x86_64/clone.S
+++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
@@ -91,14 +91,6 @@ L(thread_start):
the outermost frame obviously. */
xorl %ebp, %ebp
- andq $CLONE_VM, %rdi
- jne 1f
- movl $SYS_ify(getpid), %eax
- syscall
- movl %eax, %fs:PID
- movl %eax, %fs:TID
-1:
-
/* Set up arguments for the function call. */
popq %rax /* Function to call. */
popq %rdi /* Argument. */
diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
index 8332ade9fb..cdd2dea32a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
+++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
@@ -34,16 +34,6 @@ ENTRY (__vfork)
cfi_adjust_cfa_offset(-8)
cfi_register(%rip, %rdi)
- /* Save the TCB-cached PID away in %esi, and then negate the TCB
- field. But if it's zero, set it to 0x80000000 instead. See
- raise.c for the logic that relies on this value. */
- movl %fs:PID, %esi
- movl $0x80000000, %ecx
- movl %esi, %edx
- negl %edx
- cmove %ecx, %edx
- movl %edx, %fs:PID
-
/* Stuff the syscall number in RAX and enter into the kernel. */
movl $SYS_ify (vfork), %eax
syscall
@@ -52,14 +42,6 @@ ENTRY (__vfork)
pushq %rdi
cfi_adjust_cfa_offset(8)
- /* Restore the original value of the TCB cache of the PID, if we're
- the parent. But in the child (syscall return value equals zero),
- leave things as they are. */
- testq %rax, %rax
- je 1f
- movl %esi, %fs:PID
-1:
-
cmpl $-4095, %eax
jae SYSCALL_ERROR_LABEL /* Branch forward if it failed. */
diff --git a/sysdeps/x86/cpu-features-offsets.sym b/sysdeps/x86/cpu-features-offsets.sym
index f6739fae81..33dd094e37 100644
--- a/sysdeps/x86/cpu-features-offsets.sym
+++ b/sysdeps/x86/cpu-features-offsets.sym
@@ -15,6 +15,7 @@ CPUID_ECX_OFFSET offsetof (struct cpuid_registers, ecx)
CPUID_EDX_OFFSET offsetof (struct cpuid_registers, edx)
FAMILY_OFFSET offsetof (struct cpu_features, family)
MODEL_OFFSET offsetof (struct cpu_features, model)
+XSAVE_STATE_SIZE_OFFSET offsetof (struct cpu_features, xsave_state_size)
FEATURE_OFFSET offsetof (struct cpu_features, feature)
FEATURE_SIZE sizeof (unsigned int)
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 9ce4b495a5..9eca98817d 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -18,6 +18,7 @@
#include <cpuid.h>
#include <cpu-features.h>
+#include <libc-internal.h>
static void
get_common_indeces (struct cpu_features *cpu_features,
@@ -88,6 +89,71 @@ get_common_indeces (struct cpu_features *cpu_features,
cpu_features->feature[index_arch_FMA_Usable]
|= bit_arch_FMA_Usable;
}
+
+ /* For _dl_runtime_resolve, set xsave_state_size to xsave area
+ size + integer register save size and align it to 64 bytes. */
+ if (cpu_features->max_cpuid >= 0xd)
+ {
+ unsigned int eax, ebx, ecx, edx;
+
+ __cpuid_count (0xd, 0, eax, ebx, ecx, edx);
+ if (ebx != 0)
+ {
+ cpu_features->xsave_state_size
+ = ALIGN_UP (ebx + STATE_SAVE_OFFSET, 64);
+
+ __cpuid_count (0xd, 1, eax, ebx, ecx, edx);
+
+ /* Check if XSAVEC is available. */
+ if ((eax & (1 << 1)) != 0)
+ {
+ unsigned int xstate_comp_offsets[32];
+ unsigned int xstate_comp_sizes[32];
+ unsigned int i;
+
+ xstate_comp_offsets[0] = 0;
+ xstate_comp_offsets[1] = 160;
+ xstate_comp_offsets[2] = 576;
+ xstate_comp_sizes[0] = 160;
+ xstate_comp_sizes[1] = 256;
+
+ for (i = 2; i < 32; i++)
+ {
+ if ((STATE_SAVE_MASK & (1 << i)) != 0)
+ {
+ __cpuid_count (0xd, i, eax, ebx, ecx, edx);
+ xstate_comp_sizes[i] = eax;
+ }
+ else
+ {
+ ecx = 0;
+ xstate_comp_sizes[i] = 0;
+ }
+
+ if (i > 2)
+ {
+ xstate_comp_offsets[i]
+ = (xstate_comp_offsets[i - 1]
+ + xstate_comp_sizes[i -1]);
+ if ((ecx & (1 << 1)) != 0)
+ xstate_comp_offsets[i]
+ = ALIGN_UP (xstate_comp_offsets[i], 64);
+ }
+ }
+
+ /* Use XSAVEC. */
+ unsigned int size
+ = xstate_comp_offsets[31] + xstate_comp_sizes[31];
+ if (size)
+ {
+ cpu_features->xsave_state_size
+ = ALIGN_UP (size + STATE_SAVE_OFFSET, 64);
+ cpu_features->feature[index_arch_XSAVEC_Usable]
+ |= bit_arch_XSAVEC_Usable;
+ }
+ }
+ }
+ }
}
}
@@ -133,8 +199,6 @@ init_cpu_features (struct cpu_features *cpu_features)
case 0x57:
/* Knights Landing. Enable Silvermont optimizations. */
- cpu_features->feature[index_arch_Prefer_No_VZEROUPPER]
- |= bit_arch_Prefer_No_VZEROUPPER;
case 0x5c:
case 0x5f:
@@ -205,6 +269,16 @@ init_cpu_features (struct cpu_features *cpu_features)
if (CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable))
cpu_features->feature[index_arch_AVX_Fast_Unaligned_Load]
|= bit_arch_AVX_Fast_Unaligned_Load;
+
+ /* Since AVX512ER is unique to Xeon Phi, set Prefer_No_VZEROUPPER
+ if AVX512ER is available. Don't use AVX512 to avoid lower CPU
+ frequency if AVX512ER isn't available. */
+ if (CPU_FEATURES_CPU_P (cpu_features, AVX512ER))
+ cpu_features->feature[index_arch_Prefer_No_VZEROUPPER]
+ |= bit_arch_Prefer_No_VZEROUPPER;
+ else
+ cpu_features->feature[index_arch_Prefer_No_AVX512]
+ |= bit_arch_Prefer_No_AVX512;
}
/* This spells out "AuthenticAMD". */
else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index 97ffe765f4..507a141414 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -37,6 +37,8 @@
#define bit_arch_Prefer_No_VZEROUPPER (1 << 17)
#define bit_arch_Fast_Unaligned_Copy (1 << 18)
#define bit_arch_Prefer_ERMS (1 << 19)
+#define bit_arch_Prefer_No_AVX512 (1 << 20)
+#define bit_arch_XSAVEC_Usable (1 << 21)
/* CPUID Feature flags. */
@@ -60,6 +62,11 @@
#define bit_cpu_AVX2 (1 << 5)
#define bit_cpu_AVX512F (1 << 16)
#define bit_cpu_AVX512DQ (1 << 17)
+#define bit_cpu_AVX512PF (1 << 26)
+#define bit_cpu_AVX512ER (1 << 27)
+#define bit_cpu_AVX512CD (1 << 28)
+#define bit_cpu_AVX512BW (1 << 30)
+#define bit_cpu_AVX512VL (1u << 31)
/* XCR0 Feature flags. */
#define bit_XMM_state (1 << 1)
@@ -74,6 +81,15 @@
/* The current maximum size of the feature integer bit array. */
#define FEATURE_INDEX_MAX 1
+/* Offset for fxsave/xsave area used by _dl_runtime_resolve. Also need
+ space to preserve RCX, RDX, RSI, RDI, R8, R9 and RAX. It must be
+ aligned to 16 bytes for fxsave and 64 bytes for xsave. */
+#define STATE_SAVE_OFFSET (8 * 7 + 8)
+
+/* Save SSE, AVX, AVX512, mask and bound registers. */
+#define STATE_SAVE_MASK \
+ ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | (1 << 7))
+
#ifdef __ASSEMBLER__
# include <cpu-features-offsets.h>
@@ -107,6 +123,9 @@
# define index_arch_Prefer_No_VZEROUPPER FEATURE_INDEX_1*FEATURE_SIZE
# define index_arch_Fast_Unaligned_Copy FEATURE_INDEX_1*FEATURE_SIZE
# define index_arch_Prefer_ERMS FEATURE_INDEX_1*FEATURE_SIZE
+# define index_arch_Use_dl_runtime_resolve_opt FEATURE_INDEX_1*FEATURE_SIZE
+# define index_arch_Use_dl_runtime_resolve_slow FEATURE_INDEX_1*FEATURE_SIZE
+# define index_arch_Prefer_No_AVX512 FEATURE_INDEX_1*FEATURE_SIZE
# if defined (_LIBC) && !IS_IN (nonlib)
@@ -195,6 +214,12 @@ struct cpu_features
} cpuid[COMMON_CPUID_INDEX_MAX];
unsigned int family;
unsigned int model;
+ /* The type must be unsigned long int so that we use
+
+ sub xsave_state_size_offset(%rip) %RSP_LP
+
+ in _dl_runtime_resolve. */
+ unsigned long int xsave_state_size;
unsigned int feature[FEATURE_INDEX_MAX];
};
@@ -232,6 +257,11 @@ extern const struct cpu_features *__get_cpu_features (void)
# define index_cpu_AVX2 COMMON_CPUID_INDEX_7
# define index_cpu_AVX512F COMMON_CPUID_INDEX_7
# define index_cpu_AVX512DQ COMMON_CPUID_INDEX_7
+# define index_cpu_AVX512PF COMMON_CPUID_INDEX_7
+# define index_cpu_AVX512ER COMMON_CPUID_INDEX_7
+# define index_cpu_AVX512CD COMMON_CPUID_INDEX_7
+# define index_cpu_AVX512BW COMMON_CPUID_INDEX_7
+# define index_cpu_AVX512VL COMMON_CPUID_INDEX_7
# define index_cpu_ERMS COMMON_CPUID_INDEX_7
# define index_cpu_RTM COMMON_CPUID_INDEX_7
# define index_cpu_FMA COMMON_CPUID_INDEX_1
@@ -250,6 +280,11 @@ extern const struct cpu_features *__get_cpu_features (void)
# define reg_AVX2 ebx
# define reg_AVX512F ebx
# define reg_AVX512DQ ebx
+# define reg_AVX512PF ebx
+# define reg_AVX512ER ebx
+# define reg_AVX512CD ebx
+# define reg_AVX512BW ebx
+# define reg_AVX512VL ebx
# define reg_ERMS ebx
# define reg_RTM ebx
# define reg_FMA ecx
@@ -277,6 +312,8 @@ extern const struct cpu_features *__get_cpu_features (void)
# define index_arch_Prefer_No_VZEROUPPER FEATURE_INDEX_1
# define index_arch_Fast_Unaligned_Copy FEATURE_INDEX_1
# define index_arch_Prefer_ERMS FEATURE_INDEX_1
+# define index_arch_Prefer_No_AVX512 FEATURE_INDEX_1
+# define index_arch_XSAVEC_Usable FEATURE_INDEX_1
#endif /* !__ASSEMBLER__ */
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 6d99284cd0..cc990a9685 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -27,7 +27,7 @@ ifeq ($(subdir),elf)
CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
-mno-mmx)
-sysdep-dl-routines += tlsdesc dl-tlsdesc
+sysdep-dl-routines += tlsdesc dl-tlsdesc tls_get_addr
tests += ifuncmain8
modules-names += ifuncmod8
@@ -49,9 +49,12 @@ extra-test-objs += tst-quadmod1pie.o tst-quadmod2pie.o
$(objpfx)tst-quad1pie: $(objpfx)tst-quadmod1pie.o
$(objpfx)tst-quad2pie: $(objpfx)tst-quadmod2pie.o
-tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 tst-audit10
-test-extras += tst-audit4-aux tst-audit10-aux
-extra-test-objs += tst-audit4-aux.o tst-audit10-aux.o
+tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \
+ tst-audit10 tst-sse tst-avx tst-avx512
+test-extras += tst-audit4-aux tst-audit10-aux \
+ tst-avx-aux tst-avx512-aux
+extra-test-objs += tst-audit4-aux.o tst-audit10-aux.o \
+ tst-avx-aux.o tst-avx512-aux.o
tests += tst-split-dynreloc
LDFLAGS-tst-split-dynreloc = -Wl,-T,$(..)sysdeps/x86_64/tst-split-dynreloc.lds
@@ -62,7 +65,8 @@ modules-names += tst-auditmod3a tst-auditmod3b \
tst-auditmod5a tst-auditmod5b \
tst-auditmod6a tst-auditmod6b tst-auditmod6c \
tst-auditmod7a tst-auditmod7b \
- tst-auditmod10a tst-auditmod10b
+ tst-auditmod10a tst-auditmod10b \
+ tst-ssemod tst-avxmod tst-avx512mod
$(objpfx)tst-audit3: $(objpfx)tst-auditmod3a.so
$(objpfx)tst-audit3.out: $(objpfx)tst-auditmod3b.so
@@ -89,6 +93,10 @@ $(objpfx)tst-audit10: $(objpfx)tst-audit10-aux.o $(objpfx)tst-auditmod10a.so
$(objpfx)tst-audit10.out: $(objpfx)tst-auditmod10b.so
tst-audit10-ENV = LD_AUDIT=$(objpfx)tst-auditmod10b.so
+$(objpfx)tst-sse: $(objpfx)tst-ssemod.so
+$(objpfx)tst-avx: $(objpfx)tst-avx-aux.o $(objpfx)tst-avxmod.so
+$(objpfx)tst-avx512: $(objpfx)tst-avx512-aux.o $(objpfx)tst-avx512mod.so
+
AVX-CFLAGS=-mavx -mno-vzeroupper
CFLAGS-tst-audit4-aux.c += $(AVX-CFLAGS)
CFLAGS-tst-auditmod4a.c += $(AVX-CFLAGS)
@@ -96,14 +104,18 @@ CFLAGS-tst-auditmod4b.c += $(AVX-CFLAGS)
CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS)
CFLAGS-tst-auditmod6c.c += $(AVX-CFLAGS)
CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS)
+CFLAGS-tst-avx-aux.c += $(AVX-CFLAGS)
+CFLAGS-tst-avxmod.c += $(AVX-CFLAGS)
ifeq (yes,$(config-cflags-avx512))
AVX512-CFLAGS = -mavx512f
CFLAGS-tst-audit10-aux.c += $(AVX512-CFLAGS)
CFLAGS-tst-auditmod10a.c += $(AVX512-CFLAGS)
CFLAGS-tst-auditmod10b.c += $(AVX512-CFLAGS)
+CFLAGS-tst-avx512-aux.c += $(AVX512-CFLAGS)
+CFLAGS-tst-avx512mod.c += $(AVX512-CFLAGS)
endif
endif
ifeq ($(subdir),csu)
-gen-as-const-headers += tlsdesc.sym
+gen-as-const-headers += tlsdesc.sym rtld-offsets.sym
endif
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index ed0c1a8efd..8355432dfc 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -66,9 +66,9 @@ static inline int __attribute__ ((unused, always_inline))
elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
{
Elf64_Addr *got;
- extern void _dl_runtime_resolve_sse (ElfW(Word)) attribute_hidden;
- extern void _dl_runtime_resolve_avx (ElfW(Word)) attribute_hidden;
- extern void _dl_runtime_resolve_avx512 (ElfW(Word)) attribute_hidden;
+ extern void _dl_runtime_resolve_fxsave (ElfW(Word)) attribute_hidden;
+ extern void _dl_runtime_resolve_xsave (ElfW(Word)) attribute_hidden;
+ extern void _dl_runtime_resolve_xsavec (ElfW(Word)) attribute_hidden;
extern void _dl_runtime_profile_sse (ElfW(Word)) attribute_hidden;
extern void _dl_runtime_profile_avx (ElfW(Word)) attribute_hidden;
extern void _dl_runtime_profile_avx512 (ElfW(Word)) attribute_hidden;
@@ -117,12 +117,14 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
/* This function will get called to fix up the GOT entry
indicated by the offset on the stack, and then jump to
the resolved address. */
- if (HAS_ARCH_FEATURE (AVX512F_Usable))
- *(ElfW(Addr) *) (got + 2) = (ElfW(Addr)) &_dl_runtime_resolve_avx512;
- else if (HAS_ARCH_FEATURE (AVX_Usable))
- *(ElfW(Addr) *) (got + 2) = (ElfW(Addr)) &_dl_runtime_resolve_avx;
+ if (GLRO(dl_x86_cpu_features).xsave_state_size != 0)
+ *(ElfW(Addr) *) (got + 2)
+ = (HAS_ARCH_FEATURE (XSAVEC_Usable)
+ ? (ElfW(Addr)) &_dl_runtime_resolve_xsavec
+ : (ElfW(Addr)) &_dl_runtime_resolve_xsave);
else
- *(ElfW(Addr) *) (got + 2) = (ElfW(Addr)) &_dl_runtime_resolve_sse;
+ *(ElfW(Addr) *) (got + 2)
+ = (ElfW(Addr)) &_dl_runtime_resolve_fxsave;
}
}
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/dl-tls.c
new file mode 100644
index 0000000000..3584805c8e
--- /dev/null
+++ b/sysdeps/x86_64/dl-tls.c
@@ -0,0 +1,53 @@
+/* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef SHARED
+/* Work around GCC PR58066, due to which __tls_get_addr may be called
+ with an unaligned stack. The compat implementation is in
+ tls_get_addr-compat.S. */
+
+# include <dl-tls.h>
+
+/* Define __tls_get_addr within elf/dl-tls.c under a different
+ name. */
+extern __typeof__ (__tls_get_addr) ___tls_get_addr;
+
+# define __tls_get_addr ___tls_get_addr
+# include <elf/dl-tls.c>
+# undef __tls_get_addr
+
+hidden_ver (___tls_get_addr, __tls_get_addr)
+
+/* Only handle slow paths for __tls_get_addr. */
+attribute_hidden
+void *
+__tls_get_addr_slow (GET_ADDR_ARGS)
+{
+ dtv_t *dtv = THREAD_DTV ();
+
+ if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
+ return update_get_addr (GET_ADDR_PARAM);
+
+ return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL);
+}
+#else
+
+/* No compatibility symbol needed. */
+# include <elf/dl-tls.c>
+
+#endif
diff --git a/sysdeps/x86_64/dl-tls.h b/sysdeps/x86_64/dl-tls.h
index cf6c107f54..fa5bf6cd93 100644
--- a/sysdeps/x86_64/dl-tls.h
+++ b/sysdeps/x86_64/dl-tls.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _X86_64_DL_TLS_H
+#define _X86_64_DL_TLS_H
+
#include <stdint.h>
/* Type used for the representation of TLS information in the GOT. */
@@ -27,3 +30,5 @@ typedef struct dl_tls_index
extern void *__tls_get_addr (tls_index *ti);
+
+#endif /* _X86_64_DL_TLS_H */
diff --git a/sysdeps/x86_64/dl-trampoline.S b/sysdeps/x86_64/dl-trampoline.S
index 12f1a5cf84..b4cda0f535 100644
--- a/sysdeps/x86_64/dl-trampoline.S
+++ b/sysdeps/x86_64/dl-trampoline.S
@@ -18,6 +18,7 @@
#include <config.h>
#include <sysdep.h>
+#include <cpu-features.h>
#include <link-defines.h>
#ifndef DL_STACK_ALIGNMENT
@@ -33,41 +34,24 @@
# define DL_STACK_ALIGNMENT 8
#endif
-#ifndef DL_RUNTIME_UNALIGNED_VEC_SIZE
-/* The maximum size in bytes of unaligned vector load and store in the
- dynamic linker. Since SSE optimized memory/string functions with
- aligned SSE register load and store are used in the dynamic linker,
- we must set this to 8 so that _dl_runtime_resolve_sse will align the
- stack before calling _dl_fixup. */
-# define DL_RUNTIME_UNALIGNED_VEC_SIZE 8
-#endif
-
-/* True if _dl_runtime_resolve should align stack to VEC_SIZE bytes. */
+/* True if _dl_runtime_resolve should align stack for STATE_SAVE or align
+ stack to 16 bytes before calling _dl_fixup. */
#define DL_RUNTIME_RESOLVE_REALIGN_STACK \
- (VEC_SIZE > DL_STACK_ALIGNMENT \
- && VEC_SIZE > DL_RUNTIME_UNALIGNED_VEC_SIZE)
-
-/* Align vector register save area to 16 bytes. */
-#define REGISTER_SAVE_VEC_OFF 0
+ (STATE_SAVE_ALIGNMENT > DL_STACK_ALIGNMENT \
+ || 16 > DL_STACK_ALIGNMENT)
/* Area on stack to save and restore registers used for parameter
passing when calling _dl_fixup. */
#ifdef __ILP32__
-# define REGISTER_SAVE_RAX (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 8)
# define PRESERVE_BND_REGS_PREFIX
#else
-/* Align bound register save area to 16 bytes. */
-# define REGISTER_SAVE_BND0 (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 8)
-# define REGISTER_SAVE_BND1 (REGISTER_SAVE_BND0 + 16)
-# define REGISTER_SAVE_BND2 (REGISTER_SAVE_BND1 + 16)
-# define REGISTER_SAVE_BND3 (REGISTER_SAVE_BND2 + 16)
-# define REGISTER_SAVE_RAX (REGISTER_SAVE_BND3 + 16)
# ifdef HAVE_MPX_SUPPORT
# define PRESERVE_BND_REGS_PREFIX bnd
# else
# define PRESERVE_BND_REGS_PREFIX .byte 0xf2
# endif
#endif
+#define REGISTER_SAVE_RAX 0
#define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8)
#define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8)
#define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8)
@@ -79,50 +63,56 @@
#define VEC_SIZE 64
#define VMOVA vmovdqa64
-#if DL_RUNTIME_RESOLVE_REALIGN_STACK || VEC_SIZE <= DL_STACK_ALIGNMENT
-# define VMOV vmovdqa64
-#else
-# define VMOV vmovdqu64
-#endif
#define VEC(i) zmm##i
-#define _dl_runtime_resolve _dl_runtime_resolve_avx512
#define _dl_runtime_profile _dl_runtime_profile_avx512
#include "dl-trampoline.h"
-#undef _dl_runtime_resolve
#undef _dl_runtime_profile
#undef VEC
-#undef VMOV
#undef VMOVA
#undef VEC_SIZE
#define VEC_SIZE 32
#define VMOVA vmovdqa
-#if DL_RUNTIME_RESOLVE_REALIGN_STACK || VEC_SIZE <= DL_STACK_ALIGNMENT
-# define VMOV vmovdqa
-#else
-# define VMOV vmovdqu
-#endif
#define VEC(i) ymm##i
-#define _dl_runtime_resolve _dl_runtime_resolve_avx
#define _dl_runtime_profile _dl_runtime_profile_avx
#include "dl-trampoline.h"
-#undef _dl_runtime_resolve
#undef _dl_runtime_profile
#undef VEC
-#undef VMOV
#undef VMOVA
#undef VEC_SIZE
/* movaps/movups is 1-byte shorter. */
#define VEC_SIZE 16
#define VMOVA movaps
-#if DL_RUNTIME_RESOLVE_REALIGN_STACK || VEC_SIZE <= DL_STACK_ALIGNMENT
-# define VMOV movaps
-#else
-# define VMOV movups
-#endif
#define VEC(i) xmm##i
-#define _dl_runtime_resolve _dl_runtime_resolve_sse
#define _dl_runtime_profile _dl_runtime_profile_sse
#undef RESTORE_AVX
#include "dl-trampoline.h"
+#undef _dl_runtime_profile
+#undef VEC
+#undef VMOVA
+#undef VEC_SIZE
+
+#define USE_FXSAVE
+#define STATE_SAVE_ALIGNMENT 16
+#define _dl_runtime_resolve _dl_runtime_resolve_fxsave
+#include "dl-trampoline.h"
+#undef _dl_runtime_resolve
+#undef USE_FXSAVE
+#undef STATE_SAVE_ALIGNMENT
+
+#define USE_XSAVE
+#define STATE_SAVE_ALIGNMENT 64
+#define _dl_runtime_resolve _dl_runtime_resolve_xsave
+#include "dl-trampoline.h"
+#undef _dl_runtime_resolve
+#undef USE_XSAVE
+#undef STATE_SAVE_ALIGNMENT
+
+#define USE_XSAVEC
+#define STATE_SAVE_ALIGNMENT 64
+#define _dl_runtime_resolve _dl_runtime_resolve_xsavec
+#include "dl-trampoline.h"
+#undef _dl_runtime_resolve
+#undef USE_XSAVEC
+#undef STATE_SAVE_ALIGNMENT
diff --git a/sysdeps/x86_64/dl-trampoline.h b/sysdeps/x86_64/dl-trampoline.h
index b90836ab13..b9c2f1796f 100644
--- a/sysdeps/x86_64/dl-trampoline.h
+++ b/sysdeps/x86_64/dl-trampoline.h
@@ -16,40 +16,47 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#undef REGISTER_SAVE_AREA_RAW
-#ifdef __ILP32__
-/* X32 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX as well as VEC0 to
- VEC7. */
-# define REGISTER_SAVE_AREA_RAW (8 * 7 + VEC_SIZE * 8)
-#else
-/* X86-64 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX as well as
- BND0, BND1, BND2, BND3 and VEC0 to VEC7. */
-# define REGISTER_SAVE_AREA_RAW (8 * 7 + 16 * 4 + VEC_SIZE * 8)
-#endif
+ .text
+#ifdef _dl_runtime_resolve
-#undef REGISTER_SAVE_AREA
-#undef LOCAL_STORAGE_AREA
-#undef BASE
-#if DL_RUNTIME_RESOLVE_REALIGN_STACK
-# define REGISTER_SAVE_AREA (REGISTER_SAVE_AREA_RAW + 8)
-/* Local stack area before jumping to function address: RBX. */
-# define LOCAL_STORAGE_AREA 8
-# define BASE rbx
-# if (REGISTER_SAVE_AREA % VEC_SIZE) != 0
-# error REGISTER_SAVE_AREA must be multples of VEC_SIZE
+# undef REGISTER_SAVE_AREA
+# undef LOCAL_STORAGE_AREA
+# undef BASE
+
+# if (STATE_SAVE_ALIGNMENT % 16) != 0
+# error STATE_SAVE_ALIGNMENT must be multples of 16
# endif
-#else
-# define REGISTER_SAVE_AREA REGISTER_SAVE_AREA_RAW
+
+# if (STATE_SAVE_OFFSET % STATE_SAVE_ALIGNMENT) != 0
+# error STATE_SAVE_OFFSET must be multples of STATE_SAVE_ALIGNMENT
+# endif
+
+# if DL_RUNTIME_RESOLVE_REALIGN_STACK
+/* Local stack area before jumping to function address: RBX. */
+# define LOCAL_STORAGE_AREA 8
+# define BASE rbx
+# ifdef USE_FXSAVE
+/* Use fxsave to save XMM registers. */
+# define REGISTER_SAVE_AREA (512 + STATE_SAVE_OFFSET)
+# if (REGISTER_SAVE_AREA % 16) != 0
+# error REGISTER_SAVE_AREA must be multples of 16
+# endif
+# endif
+# else
+# ifndef USE_FXSAVE
+# error USE_FXSAVE must be defined
+# endif
+/* Use fxsave to save XMM registers. */
+# define REGISTER_SAVE_AREA (512 + STATE_SAVE_OFFSET + 8)
/* Local stack area before jumping to function address: All saved
registers. */
-# define LOCAL_STORAGE_AREA REGISTER_SAVE_AREA
-# define BASE rsp
-# if (REGISTER_SAVE_AREA % 16) != 8
-# error REGISTER_SAVE_AREA must be odd multples of 8
+# define LOCAL_STORAGE_AREA REGISTER_SAVE_AREA
+# define BASE rsp
+# if (REGISTER_SAVE_AREA % 16) != 8
+# error REGISTER_SAVE_AREA must be odd multples of 8
+# endif
# endif
-#endif
- .text
.globl _dl_runtime_resolve
.hidden _dl_runtime_resolve
.type _dl_runtime_resolve, @function
@@ -57,19 +64,30 @@
cfi_startproc
_dl_runtime_resolve:
cfi_adjust_cfa_offset(16) # Incorporate PLT
-#if DL_RUNTIME_RESOLVE_REALIGN_STACK
-# if LOCAL_STORAGE_AREA != 8
-# error LOCAL_STORAGE_AREA must be 8
-# endif
+# if DL_RUNTIME_RESOLVE_REALIGN_STACK
+# if LOCAL_STORAGE_AREA != 8
+# error LOCAL_STORAGE_AREA must be 8
+# endif
pushq %rbx # push subtracts stack by 8.
cfi_adjust_cfa_offset(8)
cfi_rel_offset(%rbx, 0)
mov %RSP_LP, %RBX_LP
cfi_def_cfa_register(%rbx)
- and $-VEC_SIZE, %RSP_LP
-#endif
+ and $-STATE_SAVE_ALIGNMENT, %RSP_LP
+# endif
+# ifdef REGISTER_SAVE_AREA
sub $REGISTER_SAVE_AREA, %RSP_LP
+# if !DL_RUNTIME_RESOLVE_REALIGN_STACK
cfi_adjust_cfa_offset(REGISTER_SAVE_AREA)
+# endif
+# else
+ # Allocate stack space of the required size to save the state.
+# if IS_IN (rtld)
+ sub _rtld_local_ro+RTLD_GLOBAL_RO_DL_X86_CPU_FEATURES_OFFSET+XSAVE_STATE_SIZE_OFFSET(%rip), %RSP_LP
+# else
+ sub _dl_x86_cpu_features+XSAVE_STATE_SIZE_OFFSET(%rip), %RSP_LP
+# endif
+# endif
# Preserve registers otherwise clobbered.
movq %rax, REGISTER_SAVE_RAX(%rsp)
movq %rcx, REGISTER_SAVE_RCX(%rsp)
@@ -78,59 +96,42 @@ _dl_runtime_resolve:
movq %rdi, REGISTER_SAVE_RDI(%rsp)
movq %r8, REGISTER_SAVE_R8(%rsp)
movq %r9, REGISTER_SAVE_R9(%rsp)
- VMOV %VEC(0), (REGISTER_SAVE_VEC_OFF)(%rsp)
- VMOV %VEC(1), (REGISTER_SAVE_VEC_OFF + VEC_SIZE)(%rsp)
- VMOV %VEC(2), (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 2)(%rsp)
- VMOV %VEC(3), (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 3)(%rsp)
- VMOV %VEC(4), (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 4)(%rsp)
- VMOV %VEC(5), (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 5)(%rsp)
- VMOV %VEC(6), (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 6)(%rsp)
- VMOV %VEC(7), (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 7)(%rsp)
-#ifndef __ILP32__
- # We also have to preserve bound registers. These are nops if
- # Intel MPX isn't available or disabled.
-# ifdef HAVE_MPX_SUPPORT
- bndmov %bnd0, REGISTER_SAVE_BND0(%rsp)
- bndmov %bnd1, REGISTER_SAVE_BND1(%rsp)
- bndmov %bnd2, REGISTER_SAVE_BND2(%rsp)
- bndmov %bnd3, REGISTER_SAVE_BND3(%rsp)
+# ifdef USE_FXSAVE
+ fxsave STATE_SAVE_OFFSET(%rsp)
# else
-# if REGISTER_SAVE_BND0 == 0
- .byte 0x66,0x0f,0x1b,0x04,0x24
+ movl $STATE_SAVE_MASK, %eax
+ xorl %edx, %edx
+ # Clear the XSAVE Header.
+# ifdef USE_XSAVE
+ movq %rdx, (STATE_SAVE_OFFSET + 512)(%rsp)
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8)(%rsp)
+# endif
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8 * 2)(%rsp)
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8 * 3)(%rsp)
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8 * 4)(%rsp)
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8 * 5)(%rsp)
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8 * 6)(%rsp)
+ movq %rdx, (STATE_SAVE_OFFSET + 512 + 8 * 7)(%rsp)
+# ifdef USE_XSAVE
+ xsave STATE_SAVE_OFFSET(%rsp)
# else
- .byte 0x66,0x0f,0x1b,0x44,0x24,REGISTER_SAVE_BND0
+ xsavec STATE_SAVE_OFFSET(%rsp)
# endif
- .byte 0x66,0x0f,0x1b,0x4c,0x24,REGISTER_SAVE_BND1
- .byte 0x66,0x0f,0x1b,0x54,0x24,REGISTER_SAVE_BND2
- .byte 0x66,0x0f,0x1b,0x5c,0x24,REGISTER_SAVE_BND3
# endif
-#endif
# Copy args pushed by PLT in register.
# %rdi: link_map, %rsi: reloc_index
mov (LOCAL_STORAGE_AREA + 8)(%BASE), %RSI_LP
mov LOCAL_STORAGE_AREA(%BASE), %RDI_LP
call _dl_fixup # Call resolver.
mov %RAX_LP, %R11_LP # Save return value
-#ifndef __ILP32__
- # Restore bound registers. These are nops if Intel MPX isn't
- # avaiable or disabled.
-# ifdef HAVE_MPX_SUPPORT
- bndmov REGISTER_SAVE_BND3(%rsp), %bnd3
- bndmov REGISTER_SAVE_BND2(%rsp), %bnd2
- bndmov REGISTER_SAVE_BND1(%rsp), %bnd1
- bndmov REGISTER_SAVE_BND0(%rsp), %bnd0
+ # Get register content back.
+# ifdef USE_FXSAVE
+ fxrstor STATE_SAVE_OFFSET(%rsp)
# else
- .byte 0x66,0x0f,0x1a,0x5c,0x24,REGISTER_SAVE_BND3
- .byte 0x66,0x0f,0x1a,0x54,0x24,REGISTER_SAVE_BND2
- .byte 0x66,0x0f,0x1a,0x4c,0x24,REGISTER_SAVE_BND1
-# if REGISTER_SAVE_BND0 == 0
- .byte 0x66,0x0f,0x1a,0x04,0x24
-# else
- .byte 0x66,0x0f,0x1a,0x44,0x24,REGISTER_SAVE_BND0
-# endif
+ movl $STATE_SAVE_MASK, %eax
+ xorl %edx, %edx
+ xrstor STATE_SAVE_OFFSET(%rsp)
# endif
-#endif
- # Get register content back.
movq REGISTER_SAVE_R9(%rsp), %r9
movq REGISTER_SAVE_R8(%rsp), %r8
movq REGISTER_SAVE_RDI(%rsp), %rdi
@@ -138,20 +139,12 @@ _dl_runtime_resolve:
movq REGISTER_SAVE_RDX(%rsp), %rdx
movq REGISTER_SAVE_RCX(%rsp), %rcx
movq REGISTER_SAVE_RAX(%rsp), %rax
- VMOV (REGISTER_SAVE_VEC_OFF)(%rsp), %VEC(0)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE)(%rsp), %VEC(1)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 2)(%rsp), %VEC(2)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 3)(%rsp), %VEC(3)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 4)(%rsp), %VEC(4)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 5)(%rsp), %VEC(5)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 6)(%rsp), %VEC(6)
- VMOV (REGISTER_SAVE_VEC_OFF + VEC_SIZE * 7)(%rsp), %VEC(7)
-#if DL_RUNTIME_RESOLVE_REALIGN_STACK
+# if DL_RUNTIME_RESOLVE_REALIGN_STACK
mov %RBX_LP, %RSP_LP
cfi_def_cfa_register(%rsp)
movq (%rsp), %rbx
cfi_restore(%rbx)
-#endif
+# endif
# Adjust stack(PLT did 2 pushes)
add $(LOCAL_STORAGE_AREA + 16), %RSP_LP
cfi_adjust_cfa_offset(-(LOCAL_STORAGE_AREA + 16))
@@ -160,9 +153,10 @@ _dl_runtime_resolve:
jmp *%r11 # Jump to function address.
cfi_endproc
.size _dl_runtime_resolve, .-_dl_runtime_resolve
+#endif
-#ifndef PROF
+#if !defined PROF && defined _dl_runtime_profile
# if (LR_VECTOR_OFFSET % VEC_SIZE) != 0
# error LR_VECTOR_OFFSET must be multples of VEC_SIZE
# endif
diff --git a/sysdeps/x86_64/memcpy_chk.S b/sysdeps/x86_64/memcpy_chk.S
index 2296b55119..a95b3ad3cf 100644
--- a/sysdeps/x86_64/memcpy_chk.S
+++ b/sysdeps/x86_64/memcpy_chk.S
@@ -19,7 +19,7 @@
#include <sysdep.h>
#include "asm-syntax.h"
-#ifndef PIC
+#ifndef SHARED
/* For libc.so this is defined in memcpy.S.
For libc.a, this is a separate source to avoid
memcpy bringing in __chk_fail and all routines
diff --git a/sysdeps/x86_64/multiarch/memcpy.S b/sysdeps/x86_64/multiarch/memcpy.S
index b8677596f9..ea4ec70d1a 100644
--- a/sysdeps/x86_64/multiarch/memcpy.S
+++ b/sysdeps/x86_64/multiarch/memcpy.S
@@ -32,6 +32,8 @@ ENTRY(__new_memcpy)
lea __memcpy_erms(%rip), %RAX_LP
HAS_ARCH_FEATURE (Prefer_ERMS)
jnz 2f
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 1f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 1f
lea __memcpy_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/memcpy_chk.S b/sysdeps/x86_64/multiarch/memcpy_chk.S
index 9d92c8a7e3..26b49de6f6 100644
--- a/sysdeps/x86_64/multiarch/memcpy_chk.S
+++ b/sysdeps/x86_64/multiarch/memcpy_chk.S
@@ -30,6 +30,8 @@
ENTRY(__memcpy_chk)
.type __memcpy_chk, @gnu_indirect_function
LOAD_RTLD_GLOBAL_RO_RDX
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 1f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 1f
lea __memcpy_chk_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/memmove.S b/sysdeps/x86_64/multiarch/memmove.S
index ff5e041420..ef92afde5a 100644
--- a/sysdeps/x86_64/multiarch/memmove.S
+++ b/sysdeps/x86_64/multiarch/memmove.S
@@ -30,6 +30,8 @@ ENTRY(__libc_memmove)
lea __memmove_erms(%rip), %RAX_LP
HAS_ARCH_FEATURE (Prefer_ERMS)
jnz 2f
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 1f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 1f
lea __memmove_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/memmove_chk.S b/sysdeps/x86_64/multiarch/memmove_chk.S
index 7f861206df..a9129c460a 100644
--- a/sysdeps/x86_64/multiarch/memmove_chk.S
+++ b/sysdeps/x86_64/multiarch/memmove_chk.S
@@ -29,6 +29,8 @@
ENTRY(__memmove_chk)
.type __memmove_chk, @gnu_indirect_function
LOAD_RTLD_GLOBAL_RO_RDX
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 1f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 1f
lea __memmove_chk_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/mempcpy.S b/sysdeps/x86_64/multiarch/mempcpy.S
index 51970687cf..87c8299fea 100644
--- a/sysdeps/x86_64/multiarch/mempcpy.S
+++ b/sysdeps/x86_64/multiarch/mempcpy.S
@@ -32,6 +32,8 @@ ENTRY(__mempcpy)
lea __mempcpy_erms(%rip), %RAX_LP
HAS_ARCH_FEATURE (Prefer_ERMS)
jnz 2f
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 1f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 1f
lea __mempcpy_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/mempcpy_chk.S b/sysdeps/x86_64/multiarch/mempcpy_chk.S
index 9e49f6f26e..642c67973b 100644
--- a/sysdeps/x86_64/multiarch/mempcpy_chk.S
+++ b/sysdeps/x86_64/multiarch/mempcpy_chk.S
@@ -30,6 +30,8 @@
ENTRY(__mempcpy_chk)
.type __mempcpy_chk, @gnu_indirect_function
LOAD_RTLD_GLOBAL_RO_RDX
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 1f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 1f
lea __mempcpy_chk_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
index 28e71fd576..acf448c9a6 100644
--- a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
@@ -110,6 +110,8 @@ ENTRY (__memset_erms)
ENTRY (MEMSET_SYMBOL (__memset, erms))
# endif
L(stosb):
+ /* Issue vzeroupper before rep stosb. */
+ VZEROUPPER
movq %rdx, %rcx
movzbl %sil, %eax
movq %rdi, %rdx
diff --git a/sysdeps/x86_64/multiarch/memset.S b/sysdeps/x86_64/multiarch/memset.S
index 96e99341aa..eae39e2ecd 100644
--- a/sysdeps/x86_64/multiarch/memset.S
+++ b/sysdeps/x86_64/multiarch/memset.S
@@ -41,6 +41,8 @@ ENTRY(memset)
jnz L(AVX512F)
lea __memset_avx2_unaligned(%rip), %RAX_LP
L(AVX512F):
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 2f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 2f
lea __memset_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/multiarch/memset_chk.S b/sysdeps/x86_64/multiarch/memset_chk.S
index 2efe6ed909..38d7bef6df 100644
--- a/sysdeps/x86_64/multiarch/memset_chk.S
+++ b/sysdeps/x86_64/multiarch/memset_chk.S
@@ -38,6 +38,8 @@ ENTRY(__memset_chk)
jnz L(AVX512F)
lea __memset_chk_avx2_unaligned(%rip), %RAX_LP
L(AVX512F):
+ HAS_ARCH_FEATURE (Prefer_No_AVX512)
+ jnz 2f
HAS_ARCH_FEATURE (AVX512F_Usable)
jz 2f
lea __memset_chk_avx512_no_vzeroupper(%rip), %RAX_LP
diff --git a/sysdeps/x86_64/nptl/tcb-offsets.sym b/sysdeps/x86_64/nptl/tcb-offsets.sym
index aeb752673a..8a25c482cb 100644
--- a/sysdeps/x86_64/nptl/tcb-offsets.sym
+++ b/sysdeps/x86_64/nptl/tcb-offsets.sym
@@ -4,7 +4,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
CLEANUP offsetof (struct pthread, cleanup)
diff --git a/sysdeps/x86_64/rtld-offsets.sym b/sysdeps/x86_64/rtld-offsets.sym
new file mode 100644
index 0000000000..fd41b51521
--- /dev/null
+++ b/sysdeps/x86_64/rtld-offsets.sym
@@ -0,0 +1,6 @@
+#define SHARED
+#include <ldsodefs.h>
+
+--
+
+GL_TLS_GENERATION_OFFSET offsetof (struct rtld_global, _dl_tls_generation)
diff --git a/sysdeps/x86_64/sysdep.h b/sysdeps/x86_64/sysdep.h
index 75ac747be8..4b67fa80c1 100644
--- a/sysdeps/x86_64/sysdep.h
+++ b/sysdeps/x86_64/sysdep.h
@@ -89,13 +89,14 @@ lose: \
END (name)
#undef JUMPTARGET
-#ifdef PIC
+#ifdef SHARED
# ifdef BIND_NOW
# define JUMPTARGET(name) *name##@GOTPCREL(%rip)
# else
# define JUMPTARGET(name) name##@PLT
# endif
#else
+/* For static archives, branch to target directly. */
# define JUMPTARGET(name) name
#endif
diff --git a/sysdeps/x86_64/tls_get_addr.S b/sysdeps/x86_64/tls_get_addr.S
new file mode 100644
index 0000000000..9d38fb3be5
--- /dev/null
+++ b/sysdeps/x86_64/tls_get_addr.S
@@ -0,0 +1,61 @@
+/* Stack-aligning implementation of __tls_get_addr. x86-64 version.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef SHARED
+
+# include <sysdep.h>
+# include "tlsdesc.h"
+# include "rtld-offsets.h"
+
+/* See __tls_get_addr and __tls_get_addr_slow in dl-tls.c. This function
+ call __tls_get_addr_slow on both slow paths. It realigns the stack
+ before the call to work around GCC PR58066. */
+
+ENTRY (__tls_get_addr)
+ mov %fs:DTV_OFFSET, %RDX_LP
+ mov GL_TLS_GENERATION_OFFSET+_rtld_local(%rip), %RAX_LP
+ /* GL(dl_tls_generation) == dtv[0].counter */
+ cmp %RAX_LP, (%rdx)
+ jne 1f
+ mov TI_MODULE_OFFSET(%rdi), %RAX_LP
+ /* dtv[ti->ti_module] */
+# ifdef __LP64__
+ salq $4, %rax
+ movq (%rdx,%rax), %rax
+# else
+ movl (%rdx,%rax, 8), %eax
+# endif
+ cmp $-1, %RAX_LP
+ je 1f
+ add TI_OFFSET_OFFSET(%rdi), %RAX_LP
+ ret
+1:
+ /* On the slow path, align the stack. */
+ pushq %rbp
+ cfi_def_cfa_offset (16)
+ cfi_offset (%rbp, -16)
+ mov %RSP_LP, %RBP_LP
+ cfi_def_cfa_register (%rbp)
+ and $-16, %RSP_LP
+ call __tls_get_addr_slow
+ mov %RBP_LP, %RSP_LP
+ popq %rbp
+ cfi_def_cfa (%rsp, 8)
+ ret
+END (__tls_get_addr)
+#endif /* SHARED */
diff --git a/sysdeps/x86_64/tlsdesc.sym b/sysdeps/x86_64/tlsdesc.sym
index 33854975d0..fc897ab4b5 100644
--- a/sysdeps/x86_64/tlsdesc.sym
+++ b/sysdeps/x86_64/tlsdesc.sym
@@ -15,3 +15,6 @@ TLSDESC_ARG offsetof(struct tlsdesc, arg)
TLSDESC_GEN_COUNT offsetof(struct tlsdesc_dynamic_arg, gen_count)
TLSDESC_MODID offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_module)
TLSDESC_MODOFF offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_offset)
+
+TI_MODULE_OFFSET offsetof(tls_index, ti_module)
+TI_OFFSET_OFFSET offsetof(tls_index, ti_offset)
diff --git a/sysdeps/x86_64/tst-avx-aux.c b/sysdeps/x86_64/tst-avx-aux.c
new file mode 100644
index 0000000000..e3807de7bb
--- /dev/null
+++ b/sysdeps/x86_64/tst-avx-aux.c
@@ -0,0 +1,47 @@
+/* Test case for preserved AVX registers in dynamic linker, -mavx part.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <immintrin.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+tst_avx_aux (void)
+{
+#ifdef __AVX__
+ extern __m256i avx_test (__m256i, __m256i, __m256i, __m256i,
+ __m256i, __m256i, __m256i, __m256i);
+
+ __m256i ymm0 = _mm256_set1_epi32 (0);
+ __m256i ymm1 = _mm256_set1_epi32 (1);
+ __m256i ymm2 = _mm256_set1_epi32 (2);
+ __m256i ymm3 = _mm256_set1_epi32 (3);
+ __m256i ymm4 = _mm256_set1_epi32 (4);
+ __m256i ymm5 = _mm256_set1_epi32 (5);
+ __m256i ymm6 = _mm256_set1_epi32 (6);
+ __m256i ymm7 = _mm256_set1_epi32 (7);
+ __m256i ret = avx_test (ymm0, ymm1, ymm2, ymm3,
+ ymm4, ymm5, ymm6, ymm7);
+ ymm0 = _mm256_set1_epi32 (0x12349876);
+ if (memcmp (&ymm0, &ret, sizeof (ret)))
+ abort ();
+ return 0;
+#else /* __AVX__ */
+ return 77;
+#endif /* __AVX__ */
+}
diff --git a/sysdeps/x86_64/tst-avx.c b/sysdeps/x86_64/tst-avx.c
new file mode 100644
index 0000000000..ec2e3a79ff
--- /dev/null
+++ b/sysdeps/x86_64/tst-avx.c
@@ -0,0 +1,49 @@
+/* Test case for preserved AVX registers in dynamic linker.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <cpuid.h>
+
+int tst_avx_aux (void);
+
+static int
+avx_enabled (void)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
+ || (ecx & (bit_AVX | bit_OSXSAVE)) != (bit_AVX | bit_OSXSAVE))
+ return 0;
+
+ /* Check the OS has AVX and SSE saving enabled. */
+ asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
+
+ return (eax & 6) == 6;
+}
+
+static int
+do_test (void)
+{
+ /* Run AVX test only if AVX is supported. */
+ if (avx_enabled ())
+ return tst_avx_aux ();
+ else
+ return 77;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../../test-skeleton.c"
diff --git a/sysdeps/x86_64/tst-avx512-aux.c b/sysdeps/x86_64/tst-avx512-aux.c
new file mode 100644
index 0000000000..6cebc523f2
--- /dev/null
+++ b/sysdeps/x86_64/tst-avx512-aux.c
@@ -0,0 +1,48 @@
+/* Test case for preserved AVX512 registers in dynamic linker,
+ -mavx512 part.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <immintrin.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+tst_avx512_aux (void)
+{
+#ifdef __AVX512F__
+ extern __m512i avx512_test (__m512i, __m512i, __m512i, __m512i,
+ __m512i, __m512i, __m512i, __m512i);
+
+ __m512i zmm0 = _mm512_set1_epi32 (0);
+ __m512i zmm1 = _mm512_set1_epi32 (1);
+ __m512i zmm2 = _mm512_set1_epi32 (2);
+ __m512i zmm3 = _mm512_set1_epi32 (3);
+ __m512i zmm4 = _mm512_set1_epi32 (4);
+ __m512i zmm5 = _mm512_set1_epi32 (5);
+ __m512i zmm6 = _mm512_set1_epi32 (6);
+ __m512i zmm7 = _mm512_set1_epi32 (7);
+ __m512i ret = avx512_test (zmm0, zmm1, zmm2, zmm3,
+ zmm4, zmm5, zmm6, zmm7);
+ zmm0 = _mm512_set1_epi32 (0x12349876);
+ if (memcmp (&zmm0, &ret, sizeof (ret)))
+ abort ();
+ return 0;
+#else /* __AVX512F__ */
+ return 77;
+#endif /* __AVX512F__ */
+}
diff --git a/sysdeps/x86_64/tst-avx512.c b/sysdeps/x86_64/tst-avx512.c
new file mode 100644
index 0000000000..a8e42ef553
--- /dev/null
+++ b/sysdeps/x86_64/tst-avx512.c
@@ -0,0 +1,57 @@
+/* Test case for preserved AVX512 registers in dynamic linker.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <cpuid.h>
+
+int tst_avx512_aux (void);
+
+static int
+avx512_enabled (void)
+{
+#ifdef bit_AVX512F
+ unsigned int eax, ebx, ecx, edx;
+
+ if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
+ || (ecx & (bit_AVX | bit_OSXSAVE)) != (bit_AVX | bit_OSXSAVE))
+ return 0;
+
+ __cpuid_count (7, 0, eax, ebx, ecx, edx);
+ if (!(ebx & bit_AVX512F))
+ return 0;
+
+ asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
+
+ /* Verify that ZMM, YMM and XMM states are enabled. */
+ return (eax & 0xe6) == 0xe6;
+#else
+ return 0;
+#endif
+}
+
+static int
+do_test (void)
+{
+ /* Run AVX512 test only if AVX512 is supported. */
+ if (avx512_enabled ())
+ return tst_avx512_aux ();
+ else
+ return 77;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../../test-skeleton.c"
diff --git a/sysdeps/x86_64/tst-avx512mod.c b/sysdeps/x86_64/tst-avx512mod.c
new file mode 100644
index 0000000000..4cfb3a2c3d
--- /dev/null
+++ b/sysdeps/x86_64/tst-avx512mod.c
@@ -0,0 +1,48 @@
+/* Test case for x86-64 preserved AVX512 registers in dynamic linker. */
+
+#ifdef __AVX512F__
+#include <stdlib.h>
+#include <string.h>
+#include <immintrin.h>
+
+__m512i
+avx512_test (__m512i x0, __m512i x1, __m512i x2, __m512i x3,
+ __m512i x4, __m512i x5, __m512i x6, __m512i x7)
+{
+ __m512i zmm;
+
+ zmm = _mm512_set1_epi32 (0);
+ if (memcmp (&zmm, &x0, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (1);
+ if (memcmp (&zmm, &x1, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (2);
+ if (memcmp (&zmm, &x2, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (3);
+ if (memcmp (&zmm, &x3, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (4);
+ if (memcmp (&zmm, &x4, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (5);
+ if (memcmp (&zmm, &x5, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (6);
+ if (memcmp (&zmm, &x6, sizeof (zmm)))
+ abort ();
+
+ zmm = _mm512_set1_epi32 (7);
+ if (memcmp (&zmm, &x7, sizeof (zmm)))
+ abort ();
+
+ return _mm512_set1_epi32 (0x12349876);
+}
+#endif
diff --git a/sysdeps/x86_64/tst-avxmod.c b/sysdeps/x86_64/tst-avxmod.c
new file mode 100644
index 0000000000..6e5b154997
--- /dev/null
+++ b/sysdeps/x86_64/tst-avxmod.c
@@ -0,0 +1,48 @@
+/* Test case for x86-64 preserved AVX registers in dynamic linker. */
+
+#ifdef __AVX__
+#include <stdlib.h>
+#include <string.h>
+#include <immintrin.h>
+
+__m256i
+avx_test (__m256i x0, __m256i x1, __m256i x2, __m256i x3,
+ __m256i x4, __m256i x5, __m256i x6, __m256i x7)
+{
+ __m256i ymm;
+
+ ymm = _mm256_set1_epi32 (0);
+ if (memcmp (&ymm, &x0, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (1);
+ if (memcmp (&ymm, &x1, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (2);
+ if (memcmp (&ymm, &x2, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (3);
+ if (memcmp (&ymm, &x3, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (4);
+ if (memcmp (&ymm, &x4, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (5);
+ if (memcmp (&ymm, &x5, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (6);
+ if (memcmp (&ymm, &x6, sizeof (ymm)))
+ abort ();
+
+ ymm = _mm256_set1_epi32 (7);
+ if (memcmp (&ymm, &x7, sizeof (ymm)))
+ abort ();
+
+ return _mm256_set1_epi32 (0x12349876);
+}
+#endif
diff --git a/sysdeps/x86_64/tst-sse.c b/sysdeps/x86_64/tst-sse.c
new file mode 100644
index 0000000000..dd1537cf27
--- /dev/null
+++ b/sysdeps/x86_64/tst-sse.c
@@ -0,0 +1,46 @@
+/* Test case for preserved SSE registers in dynamic linker.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <immintrin.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern __m128i sse_test (__m128i, __m128i, __m128i, __m128i,
+ __m128i, __m128i, __m128i, __m128i);
+
+static int
+do_test (void)
+{
+ __m128i xmm0 = _mm_set1_epi32 (0);
+ __m128i xmm1 = _mm_set1_epi32 (1);
+ __m128i xmm2 = _mm_set1_epi32 (2);
+ __m128i xmm3 = _mm_set1_epi32 (3);
+ __m128i xmm4 = _mm_set1_epi32 (4);
+ __m128i xmm5 = _mm_set1_epi32 (5);
+ __m128i xmm6 = _mm_set1_epi32 (6);
+ __m128i xmm7 = _mm_set1_epi32 (7);
+ __m128i ret = sse_test (xmm0, xmm1, xmm2, xmm3,
+ xmm4, xmm5, xmm6, xmm7);
+ xmm0 = _mm_set1_epi32 (0x12349876);
+ if (memcmp (&xmm0, &ret, sizeof (ret)))
+ abort ();
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../../test-skeleton.c"
diff --git a/sysdeps/x86_64/tst-ssemod.c b/sysdeps/x86_64/tst-ssemod.c
new file mode 100644
index 0000000000..907a64c69e
--- /dev/null
+++ b/sysdeps/x86_64/tst-ssemod.c
@@ -0,0 +1,46 @@
+/* Test case for x86-64 preserved SSE registers in dynamic linker. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <immintrin.h>
+
+__m128i
+sse_test (__m128i x0, __m128i x1, __m128i x2, __m128i x3,
+ __m128i x4, __m128i x5, __m128i x6, __m128i x7)
+{
+ __m128i xmm;
+
+ xmm = _mm_set1_epi32 (0);
+ if (memcmp (&xmm, &x0, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (1);
+ if (memcmp (&xmm, &x1, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (2);
+ if (memcmp (&xmm, &x2, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (3);
+ if (memcmp (&xmm, &x3, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (4);
+ if (memcmp (&xmm, &x4, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (5);
+ if (memcmp (&xmm, &x5, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (6);
+ if (memcmp (&xmm, &x6, sizeof (xmm)))
+ abort ();
+
+ xmm = _mm_set1_epi32 (7);
+ if (memcmp (&xmm, &x7, sizeof (xmm)))
+ abort ();
+
+ return _mm_set1_epi32 (0x12349876);
+}
|