public
Last active

  • Download Gist
threads.i
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
# 1 "vm/threads.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "vm/threads.c"
# 17 "vm/threads.c"
# 1 "vm/vm.h" 1
# 19 "vm/vm.h"
# 1 "/usr/include/setjmp.h" 1 3 4
# 26 "/usr/include/setjmp.h" 3 4
# 1 "/usr/include/machine/setjmp.h" 1 3 4
# 37 "/usr/include/machine/setjmp.h" 3 4
# 1 "/usr/include/i386/setjmp.h" 1 3 4
# 37 "/usr/include/i386/setjmp.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 38 "/usr/include/i386/setjmp.h" 2 3 4
# 60 "/usr/include/i386/setjmp.h" 3 4
typedef int jmp_buf[(18)];
typedef int sigjmp_buf[(18) + 1];
 
 
 
 
int setjmp(jmp_buf);
void longjmp(jmp_buf, int);
 
 
int _setjmp(jmp_buf);
void _longjmp(jmp_buf, int);
int sigsetjmp(sigjmp_buf, int);
void siglongjmp(sigjmp_buf, int);
 
 
 
void longjmperror(void);
 
 
# 38 "/usr/include/machine/setjmp.h" 2 3 4
# 27 "/usr/include/setjmp.h" 2 3 4
# 20 "vm/vm.h" 2
# 1 "vm/neko_vm.h" 1
# 19 "vm/neko_vm.h"
# 1 "vm/neko.h" 1
# 79 "vm/neko.h"
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 1 3 4
# 152 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 214 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 326 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 3 4
typedef int wchar_t;
# 80 "vm/neko.h" 2
 
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h" 1 3 4
# 20 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h" 3 4
typedef signed char int8_t;
 
 
 
 
typedef short int16_t;
 
 
 
 
typedef int int32_t;
 
 
 
 
typedef long long int64_t;
 
 
 
 
typedef unsigned char uint8_t;
 
 
 
 
typedef unsigned short uint16_t;
 
 
 
 
typedef unsigned int uint32_t;
 
 
 
 
typedef unsigned long long uint64_t;
 
 
 
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
 
 
 
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
 
 
 
 
 
 
typedef long intptr_t;
 
 
 
 
typedef unsigned long uintptr_t;
 
 
 
 
 
 
 
typedef long long int intmax_t;
# 106 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h" 3 4
typedef long long unsigned int uintmax_t;
# 82 "vm/neko.h" 2
 
 
 
 
typedef intptr_t int_val;
 
typedef enum {
VAL_INT = 0xFF,
VAL_NULL = 0,
VAL_FLOAT = 1,
VAL_BOOL = 2,
VAL_STRING = 3,
VAL_OBJECT = 4,
VAL_ARRAY = 5,
VAL_FUNCTION = 6,
VAL_ABSTRACT = 7,
VAL_PRIMITIVE = 6 | 8,
VAL_JITFUN = 6 | 16,
VAL_32_BITS = 0xFFFFFFFF
} val_type;
 
struct _value {
val_type t;
};
 
struct _buffer;
typedef int field;
typedef struct { int __zero; } *vkind;
typedef struct _value *value;
 
typedef struct {
field id;
value v;
} objcell;
 
typedef struct _objtable
{
int count;
objcell *cells;
} objtable;
 
typedef struct _buffer *buffer;
typedef double tfloat;
 
typedef void (*finalizer)(value v);
 
#pragma pack(4)
typedef struct {
val_type t;
tfloat f;
} vfloat;
#pragma pack()
 
typedef struct _vobject {
val_type t;
objtable table;
struct _vobject *proto;
} vobject;
 
typedef struct {
val_type t;
int nargs;
void *addr;
value env;
void *module;
} vfunction;
 
typedef struct {
val_type t;
char c;
} vstring;
 
typedef struct {
val_type t;
value ptr;
} varray;
 
typedef struct {
val_type t;
vkind kind;
void *data;
} vabstract;
 
typedef struct hcell {
int hkey;
value key;
value val;
struct hcell *next;
} hcell;
 
typedef struct {
hcell **cells;
int ncells;
int nitems;
} vhash;
 
struct _mt_local;
struct _mt_lock;
typedef struct _mt_local mt_local;
typedef struct _mt_lock mt_lock;
# 252 "vm/neko.h"
typedef int bool;
# 272 "vm/neko.h"
# 1 "/usr/include/errno.h" 1 3 4
# 23 "/usr/include/errno.h" 3 4
# 1 "/usr/include/sys/errno.h" 1 3 4
# 73 "/usr/include/sys/errno.h" 3 4
 
extern int * __error(void);
 
 
# 24 "/usr/include/errno.h" 2 3 4
# 273 "vm/neko.h" 2
# 356 "vm/neko.h"
 
 
extern vkind neko_k_int32;
extern vkind neko_k_hash;
 
extern value val_null;
extern value val_true;
extern value val_false;
 
value neko_alloc_float( tfloat t );
 
value neko_alloc_string( const char *str );
value neko_alloc_empty_string( unsigned int size );
value neko_copy_string( const char *str, int_val size );
 
value neko_val_this();
field neko_val_id( const char *str );
value neko_val_field( value o, field f );
value neko_alloc_object( value o );
void neko_alloc_field( value obj, field f, value v );
void neko_val_iter_fields( value obj, void f( value v, field f, void * ), void *p );
value neko_val_field_name( field f );
 
value neko_alloc_array( unsigned int n );
value neko_alloc_abstract( vkind k, void *data );
 
value neko_val_call0( value f );
value neko_val_call1( value f, value arg );
value neko_val_call2( value f, value arg1, value arg2 );
value neko_val_call3( value f, value arg1, value arg2, value arg3 );
value neko_val_callN( value f, value *args, int nargs );
value neko_val_ocall0( value o, field f );
value neko_val_ocall1( value o, field f, value arg );
value neko_val_ocall2( value o, field f, value arg1, value arg2 );
value neko_val_ocallN( value o, field f, value *args, int nargs );
value neko_val_callEx( value vthis, value f, value *args, int nargs, value *exc );
 
value *neko_alloc_root( unsigned int nvals );
void neko_free_root( value *r );
char *neko_alloc( unsigned int nbytes );
char *neko_alloc_private( unsigned int nbytes );
value neko_alloc_function( void *c_prim, unsigned int nargs, const char *name );
 
buffer neko_alloc_buffer( const char *init );
void neko_buffer_append( buffer b, const char *s );
void neko_buffer_append_sub( buffer b, const char *s, int_val len );
void neko_buffer_append_char( buffer b, char c );
value neko_buffer_to_string( buffer b );
void neko_val_buffer( buffer b, value v );
 
int neko_val_compare( value a, value b );
void neko_val_print( value s );
void neko_val_gc( value v, finalizer f );
void neko_val_throw( value v );
void neko_val_rethrow( value v );
int neko_val_hash( value v );
 
void neko_kind_share( vkind *k, const char *name );
void _neko_failure( value msg, const char *file, int line );
 
 
mt_local *neko_alloc_local();
void *neko_local_get( mt_local *l );
void neko_local_set( mt_local *l, void *v );
void neko_free_local( mt_local *l );
 
mt_lock *neko_alloc_lock();
void neko_lock_acquire( mt_lock *l );
int neko_lock_try( mt_lock *l );
void neko_lock_release( mt_lock *l );
void neko_free_lock( mt_lock *l );
 
 
# 20 "vm/neko_vm.h" 2
 
typedef void (*neko_printer)( const char *data, int size, void *param );
typedef void (*thread_main_func)( void *param );
 
typedef struct _neko_vm neko_vm;
 
typedef void (*neko_stat_func)( neko_vm *vm, const char *kind, int start );
 
 
 
void neko_global_init();
void neko_global_free();
void neko_gc_major();
void neko_gc_loop();
void neko_gc_stats( int *heap, int *free );
int neko_thread_create( thread_main_func init, thread_main_func main, void *param, void **handle );
void neko_thread_blocking( thread_main_func f, void *p );
bool neko_thread_register( bool t );
 
neko_vm *neko_vm_alloc( void *unused );
neko_vm *neko_vm_current();
value neko_exc_stack( neko_vm *vm );
value neko_call_stack( neko_vm *vm );
void *neko_vm_custom( neko_vm *vm, vkind k );
void neko_vm_set_custom( neko_vm *vm, vkind k, void *v );
value neko_vm_execute( neko_vm *vm, void *module );
void neko_vm_select( neko_vm *vm );
int neko_vm_jit( neko_vm *vm, int enable_jit );
int neko_vm_trusted( neko_vm *vm, int trusted );
value neko_default_loader( char **argv, int argc );
void neko_vm_redirect( neko_vm *vm, neko_printer print, void *param );
void neko_vm_set_stats( neko_vm *vm, neko_stat_func fstats, neko_stat_func pstats );
void neko_vm_dump_stack( neko_vm *vm );
 
int neko_is_big_endian();
 
 
# 21 "vm/vm.h" 2
# 29 "vm/vm.h"
typedef struct _custom_list {
vkind tag;
void *custom;
struct _custom_list *next;
} custom_list;
 
struct _neko_vm {
int_val *sp;
int_val *csp;
value env;
value vthis;
int_val *spmin;
int_val *spmax;
int_val trap;
void *jit_val;
jmp_buf start;
void *c_stack_max;
int run_jit;
value exc_stack;
neko_printer print;
void *print_param;
custom_list *clist;
value resolver;
char tmp[100];
int trusted_code;
neko_stat_func fstats;
neko_stat_func pstats;
};
 
extern int_val *callback_return;
extern mt_local *neko_vm_context;
 
 
 
extern value neko_alloc_apply( int nargs, value env );
extern value neko_interp( neko_vm *vm, void *m, int_val acc, int_val *pc );
extern int_val *neko_get_ttable();
# 18 "vm/threads.c" 2
# 1 "/usr/include/string.h" 1 3 4
# 60 "/usr/include/string.h" 3 4
# 1 "/usr/include/_types.h" 1 3 4
# 27 "/usr/include/_types.h" 3 4
# 1 "/usr/include/sys/_types.h" 1 3 4
# 33 "/usr/include/sys/_types.h" 3 4
# 1 "/usr/include/machine/_types.h" 1 3 4
# 34 "/usr/include/machine/_types.h" 3 4
# 1 "/usr/include/i386/_types.h" 1 3 4
# 37 "/usr/include/i386/_types.h" 3 4
typedef signed char __int8_t;
 
 
 
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
 
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
# 70 "/usr/include/i386/_types.h" 3 4
typedef int __darwin_ct_rune_t;
 
 
 
 
 
typedef union {
char __mbstate8[128];
long long _mbstateL;
} __mbstate_t;
 
typedef __mbstate_t __darwin_mbstate_t;
 
 
typedef int __darwin_ptrdiff_t;
 
 
 
 
 
typedef long unsigned int __darwin_size_t;
 
 
 
 
 
typedef __builtin_va_list __darwin_va_list;
 
 
 
 
 
typedef int __darwin_wchar_t;
 
 
 
 
typedef __darwin_wchar_t __darwin_rune_t;
 
 
typedef int __darwin_wint_t;
 
 
 
 
typedef unsigned long __darwin_clock_t;
typedef __uint32_t __darwin_socklen_t;
typedef long __darwin_ssize_t;
typedef long __darwin_time_t;
# 35 "/usr/include/machine/_types.h" 2 3 4
# 34 "/usr/include/sys/_types.h" 2 3 4
# 58 "/usr/include/sys/_types.h" 3 4
struct __darwin_pthread_handler_rec
{
void (*__routine)(void *);
void *__arg;
struct __darwin_pthread_handler_rec *__next;
};
struct _opaque_pthread_attr_t { long __sig; char __opaque[36]; };
struct _opaque_pthread_cond_t { long __sig; char __opaque[24]; };
struct _opaque_pthread_condattr_t { long __sig; char __opaque[4]; };
struct _opaque_pthread_mutex_t { long __sig; char __opaque[40]; };
struct _opaque_pthread_mutexattr_t { long __sig; char __opaque[8]; };
struct _opaque_pthread_once_t { long __sig; char __opaque[4]; };
struct _opaque_pthread_rwlock_t { long __sig; char __opaque[124]; };
struct _opaque_pthread_rwlockattr_t { long __sig; char __opaque[12]; };
struct _opaque_pthread_t { long __sig; struct __darwin_pthread_handler_rec *__cleanup_stack; char __opaque[596]; };
# 94 "/usr/include/sys/_types.h" 3 4
typedef __int64_t __darwin_blkcnt_t;
typedef __int32_t __darwin_blksize_t;
typedef __int32_t __darwin_dev_t;
typedef unsigned int __darwin_fsblkcnt_t;
typedef unsigned int __darwin_fsfilcnt_t;
typedef __uint32_t __darwin_gid_t;
typedef __uint32_t __darwin_id_t;
typedef __uint64_t __darwin_ino64_t;
 
 
 
typedef __uint32_t __darwin_ino_t;
 
typedef __darwin_natural_t __darwin_mach_port_name_t;
typedef __darwin_mach_port_name_t __darwin_mach_port_t;
typedef __uint16_t __darwin_mode_t;
typedef __int64_t __darwin_off_t;
typedef __int32_t __darwin_pid_t;
typedef struct _opaque_pthread_attr_t
__darwin_pthread_attr_t;
typedef struct _opaque_pthread_cond_t
__darwin_pthread_cond_t;
typedef struct _opaque_pthread_condattr_t
__darwin_pthread_condattr_t;
typedef unsigned long __darwin_pthread_key_t;
typedef struct _opaque_pthread_mutex_t
__darwin_pthread_mutex_t;
typedef struct _opaque_pthread_mutexattr_t
__darwin_pthread_mutexattr_t;
typedef struct _opaque_pthread_once_t
__darwin_pthread_once_t;
typedef struct _opaque_pthread_rwlock_t
__darwin_pthread_rwlock_t;
typedef struct _opaque_pthread_rwlockattr_t
__darwin_pthread_rwlockattr_t;
typedef struct _opaque_pthread_t
*__darwin_pthread_t;
typedef __uint32_t __darwin_sigset_t;
typedef __int32_t __darwin_suseconds_t;
typedef __uint32_t __darwin_uid_t;
typedef __uint32_t __darwin_useconds_t;
typedef unsigned char __darwin_uuid_t[16];
# 28 "/usr/include/_types.h" 2 3 4
 
typedef int __darwin_nl_item;
typedef int __darwin_wctrans_t;
 
 
 
typedef unsigned long __darwin_wctype_t;
# 61 "/usr/include/string.h" 2 3 4
# 70 "/usr/include/string.h" 3 4
typedef __darwin_ssize_t ssize_t;
# 80 "/usr/include/string.h" 3 4
 
void *memchr(const void *, int, size_t);
int memcmp(const void *, const void *, size_t);
void *memcpy(void *, const void *, size_t);
void *memmove(void *, const void *, size_t);
void *memset(void *, int, size_t);
 
char *stpcpy(char *, const char *);
char *strcasestr(const char *, const char *);
 
char *strcat(char *, const char *);
char *strchr(const char *, int);
int strcmp(const char *, const char *);
int strcoll(const char *, const char *);
char *strcpy(char *, const char *);
size_t strcspn(const char *, const char *);
char *strerror(int) __asm("_" "strerror" "$UNIX2003");
int strerror_r(int, char *, size_t);
size_t strlen(const char *);
char *strncat(char *, const char *, size_t);
int strncmp(const char *, const char *, size_t);
char *strncpy(char *, const char *, size_t);
 
char *strnstr(const char *, const char *, size_t);
 
char *strpbrk(const char *, const char *);
char *strrchr(const char *, int);
size_t strspn(const char *, const char *);
char *strstr(const char *, const char *);
char *strtok(char *, const char *);
size_t strxfrm(char *, const char *, size_t);
 
 
 
void *memccpy(void *, const void *, int, size_t);
char *strtok_r(char *, const char *, char **);
char *strdup(const char *);
 
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);
void bzero(void *, size_t);
int ffs(int);
int ffsl(long);
int fls(int);
int flsl(long);
char *index(const char *, int);
void memset_pattern4(void *, const void *, size_t);
void memset_pattern8(void *, const void *, size_t);
void memset_pattern16(void *, const void *, size_t);
char *rindex(const char *, int);
int strcasecmp(const char *, const char *);
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
void strmode(int, char *);
int strncasecmp(const char *, const char *, size_t);
char *strsep(char **, const char *);
char *strsignal(int sig);
void swab(const void * , void * , ssize_t);
 
 
 
# 19 "vm/threads.c" 2
# 38 "vm/threads.c"
# 1 "/opt/local/include/gc/gc.h" 1
# 34 "/opt/local/include/gc/gc.h"
# 1 "/opt/local/include/gc/gc_version.h" 1
# 35 "/opt/local/include/gc/gc.h" 2
 
 
 
 
 
 
# 1 "/opt/local/include/gc/gc_config_macros.h" 1
# 135 "/opt/local/include/gc/gc_config_macros.h"
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h" 1 3 4
# 136 "/opt/local/include/gc/gc_config_macros.h" 2
# 42 "/opt/local/include/gc/gc.h" 2
# 56 "/opt/local/include/gc/gc.h"
typedef unsigned long GC_word;
typedef long GC_signed_word;
# 68 "/opt/local/include/gc/gc.h"
extern GC_word GC_gc_no;
 
 
extern int GC_parallel;
# 84 "/opt/local/include/gc/gc.h"
extern void * (*GC_oom_fn) (size_t bytes_requested);
# 93 "/opt/local/include/gc/gc.h"
extern int GC_find_leak;
 
 
 
 
 
extern int GC_all_interior_pointers;
# 111 "/opt/local/include/gc/gc.h"
extern int GC_finalize_on_demand;
 
 
 
 
 
 
extern int GC_java_finalization;
# 127 "/opt/local/include/gc/gc.h"
extern void (* GC_finalizer_notifier)(void);
# 136 "/opt/local/include/gc/gc.h"
extern int GC_dont_gc;
# 145 "/opt/local/include/gc/gc.h"
extern int GC_dont_expand;
 
 
 
extern int GC_use_entire_heap;
# 160 "/opt/local/include/gc/gc.h"
extern int GC_full_freq;
# 170 "/opt/local/include/gc/gc.h"
extern GC_word GC_non_gc_bytes;
 
 
 
 
 
extern int GC_no_dls;
 
 
 
 
 
 
 
extern GC_word GC_free_space_divisor;
# 198 "/opt/local/include/gc/gc.h"
extern GC_word GC_max_retries;
 
 
 
 
 
extern char *GC_stackbottom;
# 216 "/opt/local/include/gc/gc.h"
extern int GC_dont_precollect;
 
 
 
 
 
 
 
extern unsigned long GC_time_limit;
# 243 "/opt/local/include/gc/gc.h"
extern void GC_init(void);
# 261 "/opt/local/include/gc/gc.h"
extern void * GC_malloc(size_t size_in_bytes);
extern void * GC_malloc_atomic(size_t size_in_bytes);
extern char * GC_strdup (const char *str);
extern void * GC_malloc_uncollectable(size_t size_in_bytes);
extern void * GC_malloc_stubborn(size_t size_in_bytes);
 
 
 
extern void * GC_malloc_atomic_uncollectable(size_t size_in_bytes);
 
 
 
 
 
 
 
extern void GC_free(void * object_addr);
# 294 "/opt/local/include/gc/gc.h"
extern void GC_change_stubborn(void *);
extern void GC_end_stubborn_change(void *);
# 308 "/opt/local/include/gc/gc.h"
extern void * GC_base(void * displaced_pointer);
 
 
 
 
extern size_t GC_size(void * object_addr);
# 323 "/opt/local/include/gc/gc.h"
extern void * GC_realloc(void * old_object, size_t new_size_in_bytes);
 
 
 
extern int GC_expand_hp(size_t number_of_bytes);
 
 
 
 
extern void GC_set_max_heap_size(GC_word n);
 
 
 
 
 
 
extern void GC_exclude_static_roots(void * low_address,
void * high_address_plus_1);
 
 
extern void GC_clear_roots(void);
 
 
extern void GC_add_roots(void * low_address, void * high_address_plus_1);
 
 
extern void GC_remove_roots(void * low_address, void * high_address_plus_1);
# 363 "/opt/local/include/gc/gc.h"
extern void GC_register_displacement(size_t n);
 
 
 
extern void GC_debug_register_displacement(size_t n);
 
 
extern void GC_gcollect(void);
# 381 "/opt/local/include/gc/gc.h"
typedef int (* GC_stop_func)(void);
extern int GC_try_to_collect(GC_stop_func stop_func);
 
 
 
 
extern size_t GC_get_heap_size(void);
 
 
extern size_t GC_get_free_bytes(void);
 
 
extern size_t GC_get_bytes_since_gc(void);
 
 
 
extern size_t GC_get_total_bytes(void);
 
 
 
extern void GC_disable(void);
 
 
 
 
extern void GC_enable(void);
# 423 "/opt/local/include/gc/gc.h"
extern void GC_enable_incremental(void);
# 433 "/opt/local/include/gc/gc.h"
extern int GC_incremental_protection_needs(void);
# 442 "/opt/local/include/gc/gc.h"
extern int GC_collect_a_little(void);
# 458 "/opt/local/include/gc/gc.h"
extern void * GC_malloc_ignore_off_page(size_t lb);
extern void * GC_malloc_atomic_ignore_off_page(size_t lb);
# 524 "/opt/local/include/gc/gc.h"
extern void * GC_debug_malloc(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_atomic(size_t size_in_bytes, const char * s, int i);
extern char * GC_debug_strdup(const char *str, const char * s, int i);
extern void * GC_debug_malloc_uncollectable
(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_stubborn
(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_ignore_off_page
(size_t size_in_bytes, const char * s, int i);
extern void * GC_debug_malloc_atomic_ignore_off_page
(size_t size_in_bytes, const char * s, int i);
extern void GC_debug_free (void * object_addr);
extern void * GC_debug_realloc
(void * old_object, size_t new_size_in_bytes, const char * s, int i);
extern void GC_debug_change_stubborn(void *);
extern void GC_debug_end_stubborn_change(void *);
# 553 "/opt/local/include/gc/gc.h"
extern void * GC_debug_malloc_replacement (size_t size_in_bytes);
extern void * GC_debug_realloc_replacement
(void * object_addr, size_t size_in_bytes);
# 625 "/opt/local/include/gc/gc.h"
typedef void (*GC_finalization_proc) (void * obj, void * client_data);
 
extern void GC_register_finalizer(void * obj, GC_finalization_proc fn,
void * cd, GC_finalization_proc *ofn,
void * *ocd);
extern void GC_debug_register_finalizer
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
# 675 "/opt/local/include/gc/gc.h"
extern void GC_register_finalizer_ignore_self
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_debug_register_finalizer_ignore_self
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
 
 
 
 
 
extern void GC_register_finalizer_no_order
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_debug_register_finalizer_no_order
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
# 709 "/opt/local/include/gc/gc.h"
extern void GC_register_finalizer_unreachable
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
extern void GC_debug_register_finalizer_unreachable
(void * obj, GC_finalization_proc fn, void * cd,
GC_finalization_proc *ofn, void * *ocd);
# 723 "/opt/local/include/gc/gc.h"
extern int GC_register_disappearing_link(void * * link );
# 744 "/opt/local/include/gc/gc.h"
extern int GC_general_register_disappearing_link (void * * link, void * obj);
# 771 "/opt/local/include/gc/gc.h"
extern int GC_unregister_disappearing_link (void * * link);
 
 
 
 
 
extern int GC_should_invoke_finalizers(void);
 
extern int GC_invoke_finalizers(void);
# 806 "/opt/local/include/gc/gc.h"
typedef void (*GC_warn_proc) (char *msg, GC_word arg);
extern GC_warn_proc GC_set_warn_proc(GC_warn_proc p);
 
 
extern GC_word GC_set_free_space_divisor(GC_word value);
# 831 "/opt/local/include/gc/gc.h"
typedef void * (*GC_fn_type) (void * client_data);
extern void * GC_call_with_alloc_lock (GC_fn_type fn, void * client_data);
# 846 "/opt/local/include/gc/gc.h"
struct GC_stack_base {
void * mem_base;
 
 
 
};
 
typedef void * (*GC_stack_base_func)(struct GC_stack_base *sb, void *arg);
 
 
 
 
 
void * GC_call_with_stack_base(GC_stack_base_func fn, void *arg);
# 872 "/opt/local/include/gc/gc.h"
int GC_register_my_thread(struct GC_stack_base *);
# 881 "/opt/local/include/gc/gc.h"
int GC_unregister_my_thread(void);
 
 
 
 
 
 
 
int GC_get_stack_base(struct GC_stack_base *);
# 900 "/opt/local/include/gc/gc.h"
extern void * GC_same_obj (void * p, void * q);
 
 
 
 
 
extern void * GC_pre_incr (void * *p, size_t how_much);
extern void * GC_post_incr (void * *p, size_t how_much);
# 917 "/opt/local/include/gc/gc.h"
extern void * GC_is_visible (void * p);
 
 
 
 
 
 
extern void * GC_is_valid_displacement (void * p);
 
 
 
 
void GC_dump(void);
# 972 "/opt/local/include/gc/gc.h"
extern void (*GC_same_obj_print_proc) (void * p, void * q);
 
extern void (*GC_is_valid_displacement_print_proc) (void * p);
 
extern void (*GC_is_visible_print_proc) (void * p);
 
 
 
 
 
 
 
# 1 "/opt/local/include/gc/gc_pthread_redirects.h" 1
# 18 "/opt/local/include/gc/gc_pthread_redirects.h"
# 1 "/usr/include/pthread.h" 1 3 4
# 57 "/usr/include/pthread.h" 3 4
# 1 "/usr/include/pthread_impl.h" 1 3 4
# 58 "/usr/include/pthread.h" 2 3 4
 
# 1 "/usr/include/sched.h" 1 3 4
# 30 "/usr/include/sched.h" 3 4
 
 
 
 
 
struct sched_param { int sched_priority; char __opaque[4]; };
 
 
extern int sched_yield(void);
extern int sched_get_priority_min(int);
extern int sched_get_priority_max(int);
 
# 60 "/usr/include/pthread.h" 2 3 4
# 1 "/usr/include/time.h" 1 3 4
# 69 "/usr/include/time.h" 3 4
# 1 "/usr/include/_structs.h" 1 3 4
# 24 "/usr/include/_structs.h" 3 4
# 1 "/usr/include/sys/_structs.h" 1 3 4
# 88 "/usr/include/sys/_structs.h" 3 4
struct timespec
{
__darwin_time_t tv_sec;
long tv_nsec;
};
# 25 "/usr/include/_structs.h" 2 3 4
# 70 "/usr/include/time.h" 2 3 4
 
 
 
 
 
 
 
typedef __darwin_clock_t clock_t;
# 87 "/usr/include/time.h" 3 4
typedef __darwin_time_t time_t;
 
 
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long tm_gmtoff;
char *tm_zone;
};
# 113 "/usr/include/time.h" 3 4
extern char *tzname[];
 
 
extern int getdate_err;
 
extern long timezone __asm("_" "timezone" "$UNIX2003");
 
extern int daylight;
 
 
char *asctime(const struct tm *);
clock_t clock(void) __asm("_" "clock" "$UNIX2003");
char *ctime(const time_t *);
double difftime(time_t, time_t);
struct tm *getdate(const char *);
struct tm *gmtime(const time_t *);
struct tm *localtime(const time_t *);
time_t mktime(struct tm *) __asm("_" "mktime" "$UNIX2003");
size_t strftime(char * , size_t, const char * , const struct tm * ) __asm("_" "strftime" "$UNIX2003");
char *strptime(const char * , const char * , struct tm * ) __asm("_" "strptime" "$UNIX2003");
time_t time(time_t *);
 
 
void tzset(void);
 
 
 
char *asctime_r(const struct tm * , char * );
char *ctime_r(const time_t *, char *);
struct tm *gmtime_r(const time_t * , struct tm * );
struct tm *localtime_r(const time_t * , struct tm * );
 
 
time_t posix2time(time_t);
 
 
 
void tzsetwall(void);
time_t time2posix(time_t);
time_t timelocal(struct tm * const);
time_t timegm(struct tm * const);
 
 
 
int nanosleep(const struct timespec *, struct timespec *) __asm("_" "nanosleep" "$UNIX2003");
 
 
# 61 "/usr/include/pthread.h" 2 3 4
 
 
 
typedef __darwin_pthread_attr_t pthread_attr_t;
 
 
 
 
typedef __darwin_pthread_cond_t pthread_cond_t;
 
 
 
 
typedef __darwin_pthread_condattr_t pthread_condattr_t;
 
 
 
 
typedef __darwin_pthread_key_t pthread_key_t;
 
 
 
 
typedef __darwin_pthread_mutex_t pthread_mutex_t;
 
 
 
 
typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t;
 
 
 
 
typedef __darwin_pthread_once_t pthread_once_t;
 
 
 
 
typedef __darwin_pthread_rwlock_t pthread_rwlock_t;
 
 
 
 
typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t;
 
 
 
 
typedef __darwin_pthread_t pthread_t;
 
 
 
 
 
 
typedef __darwin_mach_port_t mach_port_t;
 
 
 
 
typedef __darwin_sigset_t sigset_t;
# 148 "/usr/include/pthread.h" 3 4
 
# 244 "/usr/include/pthread.h" 3 4
int pthread_atfork(void (*)(void), void (*)(void),
void (*)(void));
int pthread_attr_destroy(pthread_attr_t *);
int pthread_attr_getdetachstate(const pthread_attr_t *,
int *);
int pthread_attr_getguardsize(const pthread_attr_t * ,
size_t * );
int pthread_attr_getinheritsched(const pthread_attr_t * ,
int * );
int pthread_attr_getschedparam(const pthread_attr_t * ,
struct sched_param * );
int pthread_attr_getschedpolicy(const pthread_attr_t * ,
int * );
int pthread_attr_getscope(const pthread_attr_t * , int * );
int pthread_attr_getstack(const pthread_attr_t * ,
void ** , size_t * );
int pthread_attr_getstackaddr(const pthread_attr_t * ,
void ** );
int pthread_attr_getstacksize(const pthread_attr_t * ,
size_t * );
int pthread_attr_init(pthread_attr_t *);
int pthread_attr_setdetachstate(pthread_attr_t *,
int );
int pthread_attr_setguardsize(pthread_attr_t *, size_t );
int pthread_attr_setinheritsched(pthread_attr_t *,
int );
int pthread_attr_setschedparam(pthread_attr_t * ,
const struct sched_param * );
int pthread_attr_setschedpolicy(pthread_attr_t *,
int );
int pthread_attr_setscope(pthread_attr_t *, int);
int pthread_attr_setstack(pthread_attr_t *,
void *, size_t );
int pthread_attr_setstackaddr(pthread_attr_t *,
void *);
int pthread_attr_setstacksize(pthread_attr_t *, size_t );
int pthread_cancel(pthread_t ) __asm("_" "pthread_cancel" "$UNIX2003");
 
int pthread_cond_broadcast(pthread_cond_t *);
int pthread_cond_destroy(pthread_cond_t *);
int pthread_cond_init(pthread_cond_t * ,
const pthread_condattr_t * ) __asm("_" "pthread_cond_init" "$UNIX2003");
int pthread_cond_signal(pthread_cond_t *);
int pthread_cond_timedwait(pthread_cond_t * ,
pthread_mutex_t * ,
const struct timespec * ) __asm("_" "pthread_cond_timedwait" "$UNIX2003");
int pthread_cond_wait(pthread_cond_t * ,
pthread_mutex_t * ) __asm("_" "pthread_cond_wait" "$UNIX2003");
int pthread_condattr_destroy(pthread_condattr_t *);
int pthread_condattr_init(pthread_condattr_t *);
int pthread_condattr_getpshared(const pthread_condattr_t * ,
int * );
int pthread_condattr_setpshared(pthread_condattr_t *,
int );
int pthread_create(pthread_t * ,
const pthread_attr_t * ,
void *(*)(void *),
void * );
int pthread_detach(pthread_t );
int pthread_equal(pthread_t ,
pthread_t );
void pthread_exit(void *) __attribute__((__noreturn__));
int pthread_getconcurrency(void);
int pthread_getschedparam(pthread_t , int * , struct sched_param * );
void *pthread_getspecific(pthread_key_t );
int pthread_join(pthread_t , void **) __asm("_" "pthread_join" "$UNIX2003");
int pthread_key_create(pthread_key_t *, void (*)(void *));
int pthread_key_delete(pthread_key_t );
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_getprioceiling(const pthread_mutex_t * , int * );
int pthread_mutex_init(pthread_mutex_t * , const pthread_mutexattr_t * );
int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_setprioceiling(pthread_mutex_t * , int, int * );
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
int pthread_mutexattr_destroy(pthread_mutexattr_t *) __asm("_" "pthread_mutexattr_destroy" "$UNIX2003");
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_getpshared(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_gettype(const pthread_mutexattr_t * , int * );
int pthread_mutexattr_init(pthread_mutexattr_t *);
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int );
int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
int pthread_once(pthread_once_t *, void (*)(void));
int pthread_rwlock_destroy(pthread_rwlock_t * ) __asm("_" "pthread_rwlock_destroy" "$UNIX2003");
int pthread_rwlock_init(pthread_rwlock_t * , const pthread_rwlockattr_t * ) __asm("_" "pthread_rwlock_init" "$UNIX2003");
int pthread_rwlock_rdlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_rdlock" "$UNIX2003");
int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_tryrdlock" "$UNIX2003");
int pthread_rwlock_trywrlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_trywrlock" "$UNIX2003");
int pthread_rwlock_wrlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_wrlock" "$UNIX2003");
int pthread_rwlock_unlock(pthread_rwlock_t *) __asm("_" "pthread_rwlock_unlock" "$UNIX2003");
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * ,
int * );
int pthread_rwlockattr_init(pthread_rwlockattr_t *);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *,
int );
pthread_t pthread_self(void);
 
int pthread_setcancelstate(int , int *) __asm("_" "pthread_setcancelstate" "$UNIX2003");
int pthread_setcanceltype(int , int *) __asm("_" "pthread_setcanceltype" "$UNIX2003");
int pthread_setconcurrency(int);
int pthread_setschedparam(pthread_t ,
int ,
const struct sched_param *);
int pthread_setspecific(pthread_key_t ,
const void *);
void pthread_testcancel(void) __asm("_" "pthread_testcancel" "$UNIX2003");
 
 
 
int pthread_is_threaded_np(void);
 
 
int pthread_main_np(void);
 
 
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void * pthread_get_stackaddr_np(pthread_t);
 
 
int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t);
 
 
int pthread_cond_timedwait_relative_np(pthread_cond_t *,
pthread_mutex_t *,
const struct timespec *);
 
 
int pthread_create_suspended_np(pthread_t *,
const pthread_attr_t *,
void *(*)(void *),
void *);
int pthread_kill(pthread_t, int);
 
pthread_t pthread_from_mach_thread_np(mach_port_t);
 
int pthread_sigmask(int, const sigset_t *, sigset_t *) __asm("_" "pthread_sigmask" "$UNIX2003");
void pthread_yield_np(void);
 
 
# 19 "/opt/local/include/gc/gc_pthread_redirects.h" 2
# 1 "/usr/include/signal.h" 1 3 4
# 63 "/usr/include/signal.h" 3 4
# 1 "/usr/include/sys/signal.h" 1 3 4
# 73 "/usr/include/sys/signal.h" 3 4
# 1 "/usr/include/sys/appleapiopts.h" 1 3 4
# 74 "/usr/include/sys/signal.h" 2 3 4
 
 
 
 
 
 
 
# 1 "/usr/include/machine/signal.h" 1 3 4
# 34 "/usr/include/machine/signal.h" 3 4
# 1 "/usr/include/i386/signal.h" 1 3 4
# 39 "/usr/include/i386/signal.h" 3 4
typedef int sig_atomic_t;
# 55 "/usr/include/i386/signal.h" 3 4
# 1 "/usr/include/i386/_structs.h" 1 3 4
# 56 "/usr/include/i386/signal.h" 2 3 4
# 35 "/usr/include/machine/signal.h" 2 3 4
# 82 "/usr/include/sys/signal.h" 2 3 4
# 154 "/usr/include/sys/signal.h" 3 4
# 1 "/usr/include/sys/_structs.h" 1 3 4
# 57 "/usr/include/sys/_structs.h" 3 4
# 1 "/usr/include/machine/_structs.h" 1 3 4
# 31 "/usr/include/machine/_structs.h" 3 4
# 1 "/usr/include/i386/_structs.h" 1 3 4
# 38 "/usr/include/i386/_structs.h" 3 4
# 1 "/usr/include/mach/i386/_structs.h" 1 3 4
# 43 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_i386_thread_state
{
unsigned int __eax;
unsigned int __ebx;
unsigned int __ecx;
unsigned int __edx;
unsigned int __edi;
unsigned int __esi;
unsigned int __ebp;
unsigned int __esp;
unsigned int __ss;
unsigned int __eflags;
unsigned int __eip;
unsigned int __cs;
unsigned int __ds;
unsigned int __es;
unsigned int __fs;
unsigned int __gs;
};
# 89 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_fp_control
{
unsigned short __invalid :1,
__denorm :1,
__zdiv :1,
__ovrfl :1,
__undfl :1,
__precis :1,
:2,
__pc :2,
 
 
 
 
 
__rc :2,
 
 
 
 
 
 
:1,
:3;
};
typedef struct __darwin_fp_control __darwin_fp_control_t;
# 147 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_fp_status
{
unsigned short __invalid :1,
__denorm :1,
__zdiv :1,
__ovrfl :1,
__undfl :1,
__precis :1,
__stkflt :1,
__errsumm :1,
__c0 :1,
__c1 :1,
__c2 :1,
__tos :3,
__c3 :1,
__busy :1;
};
typedef struct __darwin_fp_status __darwin_fp_status_t;
# 191 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_mmst_reg
{
char __mmst_reg[10];
char __mmst_rsrv[6];
};
# 210 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_xmm_reg
{
char __xmm_reg[16];
};
# 232 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_i386_float_state
{
int __fpu_reserved[2];
struct __darwin_fp_control __fpu_fcw;
struct __darwin_fp_status __fpu_fsw;
__uint8_t __fpu_ftw;
__uint8_t __fpu_rsrv1;
__uint16_t __fpu_fop;
__uint32_t __fpu_ip;
__uint16_t __fpu_cs;
__uint16_t __fpu_rsrv2;
__uint32_t __fpu_dp;
__uint16_t __fpu_ds;
__uint16_t __fpu_rsrv3;
__uint32_t __fpu_mxcsr;
__uint32_t __fpu_mxcsrmask;
struct __darwin_mmst_reg __fpu_stmm0;
struct __darwin_mmst_reg __fpu_stmm1;
struct __darwin_mmst_reg __fpu_stmm2;
struct __darwin_mmst_reg __fpu_stmm3;
struct __darwin_mmst_reg __fpu_stmm4;
struct __darwin_mmst_reg __fpu_stmm5;
struct __darwin_mmst_reg __fpu_stmm6;
struct __darwin_mmst_reg __fpu_stmm7;
struct __darwin_xmm_reg __fpu_xmm0;
struct __darwin_xmm_reg __fpu_xmm1;
struct __darwin_xmm_reg __fpu_xmm2;
struct __darwin_xmm_reg __fpu_xmm3;
struct __darwin_xmm_reg __fpu_xmm4;
struct __darwin_xmm_reg __fpu_xmm5;
struct __darwin_xmm_reg __fpu_xmm6;
struct __darwin_xmm_reg __fpu_xmm7;
char __fpu_rsrv4[14*16];
int __fpu_reserved1;
};
# 308 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_i386_exception_state
{
unsigned int __trapno;
unsigned int __err;
unsigned int __faultvaddr;
};
# 326 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_debug_state32
{
unsigned int __dr0;
unsigned int __dr1;
unsigned int __dr2;
unsigned int __dr3;
unsigned int __dr4;
unsigned int __dr5;
unsigned int __dr6;
unsigned int __dr7;
};
# 358 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_thread_state64
{
__uint64_t __rax;
__uint64_t __rbx;
__uint64_t __rcx;
__uint64_t __rdx;
__uint64_t __rdi;
__uint64_t __rsi;
__uint64_t __rbp;
__uint64_t __rsp;
__uint64_t __r8;
__uint64_t __r9;
__uint64_t __r10;
__uint64_t __r11;
__uint64_t __r12;
__uint64_t __r13;
__uint64_t __r14;
__uint64_t __r15;
__uint64_t __rip;
__uint64_t __rflags;
__uint64_t __cs;
__uint64_t __fs;
__uint64_t __gs;
};
# 413 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_float_state64
{
int __fpu_reserved[2];
struct __darwin_fp_control __fpu_fcw;
struct __darwin_fp_status __fpu_fsw;
__uint8_t __fpu_ftw;
__uint8_t __fpu_rsrv1;
__uint16_t __fpu_fop;
 
 
__uint32_t __fpu_ip;
__uint16_t __fpu_cs;
 
__uint16_t __fpu_rsrv2;
 
 
__uint32_t __fpu_dp;
__uint16_t __fpu_ds;
 
__uint16_t __fpu_rsrv3;
__uint32_t __fpu_mxcsr;
__uint32_t __fpu_mxcsrmask;
struct __darwin_mmst_reg __fpu_stmm0;
struct __darwin_mmst_reg __fpu_stmm1;
struct __darwin_mmst_reg __fpu_stmm2;
struct __darwin_mmst_reg __fpu_stmm3;
struct __darwin_mmst_reg __fpu_stmm4;
struct __darwin_mmst_reg __fpu_stmm5;
struct __darwin_mmst_reg __fpu_stmm6;
struct __darwin_mmst_reg __fpu_stmm7;
struct __darwin_xmm_reg __fpu_xmm0;
struct __darwin_xmm_reg __fpu_xmm1;
struct __darwin_xmm_reg __fpu_xmm2;
struct __darwin_xmm_reg __fpu_xmm3;
struct __darwin_xmm_reg __fpu_xmm4;
struct __darwin_xmm_reg __fpu_xmm5;
struct __darwin_xmm_reg __fpu_xmm6;
struct __darwin_xmm_reg __fpu_xmm7;
struct __darwin_xmm_reg __fpu_xmm8;
struct __darwin_xmm_reg __fpu_xmm9;
struct __darwin_xmm_reg __fpu_xmm10;
struct __darwin_xmm_reg __fpu_xmm11;
struct __darwin_xmm_reg __fpu_xmm12;
struct __darwin_xmm_reg __fpu_xmm13;
struct __darwin_xmm_reg __fpu_xmm14;
struct __darwin_xmm_reg __fpu_xmm15;
char __fpu_rsrv4[6*16];
int __fpu_reserved1;
};
# 517 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_exception_state64
{
unsigned int __trapno;
unsigned int __err;
__uint64_t __faultvaddr;
};
# 535 "/usr/include/mach/i386/_structs.h" 3 4
struct __darwin_x86_debug_state64
{
__uint64_t __dr0;
__uint64_t __dr1;
__uint64_t __dr2;
__uint64_t __dr3;
__uint64_t __dr4;
__uint64_t __dr5;
__uint64_t __dr6;
__uint64_t __dr7;
};
# 39 "/usr/include/i386/_structs.h" 2 3 4
# 48 "/usr/include/i386/_structs.h" 3 4
struct __darwin_mcontext32
{
struct __darwin_i386_exception_state __es;
struct __darwin_i386_thread_state __ss;
struct __darwin_i386_float_state __fs;
};
# 68 "/usr/include/i386/_structs.h" 3 4
struct __darwin_mcontext64
{
struct __darwin_x86_exception_state64 __es;
struct __darwin_x86_thread_state64 __ss;
struct __darwin_x86_float_state64 __fs;
};
# 94 "/usr/include/i386/_structs.h" 3 4
typedef struct __darwin_mcontext32 *mcontext_t;
# 32 "/usr/include/machine/_structs.h" 2 3 4
# 58 "/usr/include/sys/_structs.h" 2 3 4
# 75 "/usr/include/sys/_structs.h" 3 4
struct __darwin_sigaltstack
{
void *ss_sp;
__darwin_size_t ss_size;
int ss_flags;
};
# 128 "/usr/include/sys/_structs.h" 3 4
struct __darwin_ucontext
{
int uc_onstack;
__darwin_sigset_t uc_sigmask;
struct __darwin_sigaltstack uc_stack;
struct __darwin_ucontext *uc_link;
__darwin_size_t uc_mcsize;
struct __darwin_mcontext32 *uc_mcontext;
 
 
 
};
# 218 "/usr/include/sys/_structs.h" 3 4
typedef struct __darwin_sigaltstack stack_t;
# 227 "/usr/include/sys/_structs.h" 3 4
typedef struct __darwin_ucontext ucontext_t;
# 155 "/usr/include/sys/signal.h" 2 3 4
 
 
 
typedef __darwin_pid_t pid_t;
# 178 "/usr/include/sys/signal.h" 3 4
typedef __darwin_uid_t uid_t;
 
 
union sigval {
 
int sival_int;
void *sival_ptr;
};
 
 
 
 
 
struct sigevent {
int sigev_notify;
int sigev_signo;
union sigval sigev_value;
void (*sigev_notify_function)(union sigval);
pthread_attr_t *sigev_notify_attributes;
};
 
 
typedef struct __siginfo {
int si_signo;
int si_errno;
int si_code;
pid_t si_pid;
uid_t si_uid;
int si_status;
void *si_addr;
union sigval si_value;
long si_band;
unsigned long __pad[7];
} siginfo_t;
# 292 "/usr/include/sys/signal.h" 3 4
union __sigaction_u {
void (*__sa_handler)(int);
void (*__sa_sigaction)(int, struct __siginfo *,
void *);
};
 
 
struct __sigaction {
union __sigaction_u __sigaction_u;
void (*sa_tramp)(void *, int, int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
};
 
 
 
 
struct sigaction {
union __sigaction_u __sigaction_u;
sigset_t sa_mask;
int sa_flags;
};
# 354 "/usr/include/sys/signal.h" 3 4
typedef void (*sig_t)(int);
# 371 "/usr/include/sys/signal.h" 3 4
struct sigvec {
void (*sv_handler)(int);
int sv_mask;
int sv_flags;
};
# 390 "/usr/include/sys/signal.h" 3 4
struct sigstack {
char *ss_sp;
int ss_onstack;
};
# 412 "/usr/include/sys/signal.h" 3 4
 
void (*signal(int, void (*)(int)))(int);
 
# 64 "/usr/include/signal.h" 2 3 4
 
 
 
 
 
 
 
extern const char *const sys_signame[32];
extern const char *const sys_siglist[32];
 
 
 
int raise(int);
 
 
 
 
void (*bsd_signal(int, void (*)(int)))(int);
int kill(pid_t, int) __asm("_" "kill" "$UNIX2003");
int killpg(pid_t, int) __asm("_" "killpg" "$UNIX2003");
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, const sigset_t *, sigset_t *) __asm("_" "pthread_sigmask" "$UNIX2003");
int sigaction(int, const struct sigaction * ,
struct sigaction * );
int sigaddset(sigset_t *, int);
int sigaltstack(const stack_t * , stack_t * ) __asm("_" "sigaltstack" "$UNIX2003");
int sigdelset(sigset_t *, int);
int sigemptyset(sigset_t *);
int sigfillset(sigset_t *);
int sighold(int);
int sigignore(int);
int siginterrupt(int, int);
int sigismember(const sigset_t *, int);
int sigpause(int) __asm("_" "sigpause" "$UNIX2003");
int sigpending(sigset_t *);
int sigprocmask(int, const sigset_t * , sigset_t * );
int sigrelse(int);
void (*sigset(int, void (*)(int)))(int);
int sigsuspend(const sigset_t *) __asm("_" "sigsuspend" "$UNIX2003");
int sigwait(const sigset_t * , int * ) __asm("_" "sigwait" "$UNIX2003");
 
void psignal(unsigned int, const char *);
int sigblock(int);
int sigsetmask(int);
int sigvec(int, struct sigvec *, struct sigvec *);
 
 
 
 
 
 
static __inline int
__sigbits(int __signo)
{
return __signo > 32 ? 0 : (1 << (__signo - 1));
}
# 20 "/opt/local/include/gc/gc_pthread_redirects.h" 2
 
int GC_pthread_create(pthread_t *new_thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
 
 
 
int GC_pthread_join(pthread_t thread, void **retval);
int GC_pthread_detach(pthread_t thread);
# 985 "/opt/local/include/gc/gc.h" 2
# 995 "/opt/local/include/gc/gc.h"
void * GC_malloc_many(size_t lb);
# 1006 "/opt/local/include/gc/gc.h"
extern void
GC_register_has_static_roots_callback
(int (*callback)(const char *, void *, size_t));
# 39 "vm/threads.c" 2
# 53 "vm/threads.c"
# 1 "/usr/include/stdlib.h" 1 3 4
# 61 "/usr/include/stdlib.h" 3 4
# 1 "/usr/include/available.h" 1 3 4
# 62 "/usr/include/stdlib.h" 2 3 4
 
 
 
# 1 "/usr/include/sys/wait.h" 1 3 4
# 79 "/usr/include/sys/wait.h" 3 4
typedef enum {
P_ALL,
P_PID,
P_PGID
} idtype_t;
# 95 "/usr/include/sys/wait.h" 3 4
typedef __darwin_id_t id_t;
# 117 "/usr/include/sys/wait.h" 3 4
# 1 "/usr/include/sys/resource.h" 1 3 4
# 76 "/usr/include/sys/resource.h" 3 4
# 1 "/usr/include/sys/_structs.h" 1 3 4
# 100 "/usr/include/sys/_structs.h" 3 4
struct timeval
{
__darwin_time_t tv_sec;
__darwin_suseconds_t tv_usec;
};
# 77 "/usr/include/sys/resource.h" 2 3 4
# 88 "/usr/include/sys/resource.h" 3 4
typedef __uint64_t rlim_t;
# 142 "/usr/include/sys/resource.h" 3 4
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
# 153 "/usr/include/sys/resource.h" 3 4
long ru_maxrss;
 
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
 
 
};
# 213 "/usr/include/sys/resource.h" 3 4
struct rlimit {
rlim_t rlim_cur;
rlim_t rlim_max;
};
# 235 "/usr/include/sys/resource.h" 3 4
 
int getpriority(int, id_t);
 
int getiopolicy_np(int, int);
 
int getrlimit(int, struct rlimit *) __asm("_" "getrlimit" "$UNIX2003");
int getrusage(int, struct rusage *);
int setpriority(int, id_t, int);
 
int setiopolicy_np(int, int, int);
 
int setrlimit(int, const struct rlimit *) __asm("_" "setrlimit" "$UNIX2003");
 
# 118 "/usr/include/sys/wait.h" 2 3 4
# 193 "/usr/include/sys/wait.h" 3 4
# 1 "/usr/include/machine/endian.h" 1 3 4
# 37 "/usr/include/machine/endian.h" 3 4
# 1 "/usr/include/i386/endian.h" 1 3 4
# 99 "/usr/include/i386/endian.h" 3 4
# 1 "/usr/include/sys/_endian.h" 1 3 4
# 124 "/usr/include/sys/_endian.h" 3 4
# 1 "/usr/include/libkern/_OSByteOrder.h" 1 3 4
# 66 "/usr/include/libkern/_OSByteOrder.h" 3 4
# 1 "/usr/include/libkern/i386/_OSByteOrder.h" 1 3 4
# 44 "/usr/include/libkern/i386/_OSByteOrder.h" 3 4
static __inline__
__uint16_t
_OSSwapInt16(
__uint16_t _data
)
{
return ((_data << 8) | (_data >> 8));
}
 
static __inline__
__uint32_t
_OSSwapInt32(
__uint32_t _data
)
{
__asm__ ("bswap %0" : "+r" (_data));
return _data;
}
 
 
static __inline__
__uint64_t
_OSSwapInt64(
__uint64_t _data
)
{
__asm__ ("bswap %%eax\n\t"
"bswap %%edx\n\t"
"xchgl %%eax, %%edx"
: "+A" (_data));
return _data;
}
# 67 "/usr/include/libkern/_OSByteOrder.h" 2 3 4
# 125 "/usr/include/sys/_endian.h" 2 3 4
# 100 "/usr/include/i386/endian.h" 2 3 4
# 38 "/usr/include/machine/endian.h" 2 3 4
# 194 "/usr/include/sys/wait.h" 2 3 4
 
 
 
 
 
 
 
union wait {
int w_status;
 
 
 
struct {
 
unsigned int w_Termsig:7,
w_Coredump:1,
w_Retcode:8,
w_Filler:16;
 
 
 
 
 
 
 
} w_T;
 
 
 
 
 
struct {
 
unsigned int w_Stopval:8,
w_Stopsig:8,
w_Filler:16;
 
 
 
 
 
 
} w_S;
};
# 254 "/usr/include/sys/wait.h" 3 4
 
pid_t wait(int *) __asm("_" "wait" "$UNIX2003");
pid_t waitpid(pid_t, int *, int) __asm("_" "waitpid" "$UNIX2003");
 
int waitid(idtype_t, id_t, siginfo_t *, int) __asm("_" "waitid" "$UNIX2003");
 
 
pid_t wait3(int *, int, struct rusage *);
pid_t wait4(pid_t, int *, int, struct rusage *);
 
 
# 66 "/usr/include/stdlib.h" 2 3 4
 
# 1 "/usr/include/alloca.h" 1 3 4
# 35 "/usr/include/alloca.h" 3 4
 
void *alloca(size_t);
 
# 68 "/usr/include/stdlib.h" 2 3 4
# 81 "/usr/include/stdlib.h" 3 4
typedef __darwin_ct_rune_t ct_rune_t;
 
 
 
 
typedef __darwin_rune_t rune_t;
# 97 "/usr/include/stdlib.h" 3 4
typedef struct {
int quot;
int rem;
} div_t;
 
typedef struct {
long quot;
long rem;
} ldiv_t;
 
 
typedef struct {
long long quot;
long long rem;
} lldiv_t;
# 134 "/usr/include/stdlib.h" 3 4
extern int __mb_cur_max;
# 144 "/usr/include/stdlib.h" 3 4
 
void abort(void) __attribute__((__noreturn__));
int abs(int) __attribute__((__const__));
int atexit(void (*)(void));
double atof(const char *);
int atoi(const char *);
long atol(const char *);
 
long long
atoll(const char *);
 
void *bsearch(const void *, const void *, size_t,
size_t, int (*)(const void *, const void *));
void *calloc(size_t, size_t);
div_t div(int, int) __attribute__((__const__));
void exit(int) __attribute__((__noreturn__));
void free(void *);
char *getenv(const char *);
long labs(long) __attribute__((__const__));
ldiv_t ldiv(long, long) __attribute__((__const__));
 
long long
llabs(long long);
lldiv_t lldiv(long long, long long);
 
void *malloc(size_t);
int mblen(const char *, size_t);
size_t mbstowcs(wchar_t * , const char * , size_t);
int mbtowc(wchar_t * , const char * , size_t);
void qsort(void *, size_t, size_t,
int (*)(const void *, const void *));
int rand(void);
void *realloc(void *, size_t);
void srand(unsigned);
double strtod(const char *, char **) __asm("_" "strtod" "$UNIX2003");
float strtof(const char *, char **) __asm("_" "strtof" "$UNIX2003");
long strtol(const char *, char **, int);
long double
strtold(const char *, char **) ;
 
long long
strtoll(const char *, char **, int);
 
unsigned long
strtoul(const char *, char **, int);
 
unsigned long long
strtoull(const char *, char **, int);
 
int system(const char *) __asm("_" "system" "$UNIX2003");
size_t wcstombs(char * , const wchar_t * , size_t);
int wctomb(char *, wchar_t);
 
 
void _Exit(int) __attribute__((__noreturn__));
long a64l(const char *);
double drand48(void);
char *ecvt(double, int, int *, int *);
double erand48(unsigned short[3]);
char *fcvt(double, int, int *, int *);
char *gcvt(double, int, char *);
int getsubopt(char **, char * const *, char **);
int grantpt(int);
 
char *initstate(unsigned, char *, size_t);
 
 
 
long jrand48(unsigned short[3]);
char *l64a(long);
void lcong48(unsigned short[7]);
long lrand48(void);
char *mktemp(char *);
int mkstemp(char *);
long mrand48(void);
long nrand48(unsigned short[3]);
int posix_openpt(int);
char *ptsname(int);
int putenv(char *) __asm("_" "putenv" "$UNIX2003");
long random(void);
int rand_r(unsigned *);
 
char *realpath(const char * , char * ) __asm("_" "realpath" "$DARWIN_EXTSN");
 
 
 
unsigned short
*seed48(unsigned short[3]);
int setenv(const char *, const char *, int) __asm("_" "setenv" "$UNIX2003");
 
void setkey(const char *) __asm("_" "setkey" "$UNIX2003");
 
 
 
char *setstate(const char *);
void srand48(long);
 
void srandom(unsigned);
 
 
 
int unlockpt(int);
 
int unsetenv(const char *) __asm("_" "unsetenv" "$UNIX2003");
 
 
 
 
 
 
# 1 "/usr/include/machine/types.h" 1 3 4
# 37 "/usr/include/machine/types.h" 3 4
# 1 "/usr/include/i386/types.h" 1 3 4
# 80 "/usr/include/i386/types.h" 3 4
typedef unsigned char u_int8_t;
 
 
 
 
typedef unsigned short u_int16_t;
 
 
 
 
typedef unsigned int u_int32_t;
 
 
 
 
typedef unsigned long long u_int64_t;
 
 
 
 
typedef int32_t register_t;
# 114 "/usr/include/i386/types.h" 3 4
typedef u_int64_t user_addr_t;
typedef u_int64_t user_size_t;
typedef int64_t user_ssize_t;
typedef int64_t user_long_t;
typedef u_int64_t user_ulong_t;
typedef int64_t user_time_t;
 
 
 
 
 
typedef u_int64_t syscall_arg_t;
# 38 "/usr/include/machine/types.h" 2 3 4
# 255 "/usr/include/stdlib.h" 2 3 4
 
 
typedef __darwin_dev_t dev_t;
 
 
 
 
typedef __darwin_mode_t mode_t;
 
 
 
u_int32_t
arc4random(void);
void arc4random_addrandom(unsigned char *dat, int datlen);
void arc4random_stir(void);
 
 
char *cgetcap(char *, const char *, int);
int cgetclose(void);
int cgetent(char **, char **, const char *);
int cgetfirst(char **, char **);
int cgetmatch(const char *, const char *);
int cgetnext(char **, char **);
int cgetnum(char *, const char *, long *);
int cgetset(const char *);
int cgetstr(char *, const char *, char **);
int cgetustr(char *, const char *, char **);
 
int daemon(int, int) __asm("_" "daemon" "$1050") __attribute__((deprecated));
char *devname(dev_t, mode_t);
char *devname_r(dev_t, mode_t, char *buf, int len);
char *getbsize(int *, long *);
int getloadavg(double [], int);
const char
*getprogname(void);
 
int heapsort(void *, size_t, size_t,
int (*)(const void *, const void *));
int mergesort(void *, size_t, size_t,
int (*)(const void *, const void *));
void qsort_r(void *, size_t, size_t, void *,
int (*)(void *, const void *, const void *));
int radixsort(const unsigned char **, int, const unsigned char *,
unsigned);
void setprogname(const char *);
int sradixsort(const unsigned char **, int, const unsigned char *,
unsigned);
void sranddev(void);
void srandomdev(void);
void *reallocf(void *, size_t);
 
long long
strtoq(const char *, char **, int);
unsigned long long
strtouq(const char *, char **, int);
 
extern char *suboptarg;
void *valloc(size_t);
 
 
 
 
 
 
 
# 54 "vm/threads.c" 2
 
 
struct _mt_local {
pthread_key_t key;
};
struct _mt_lock {
pthread_mutex_t lock;
};
 
 
 
typedef char __stack_base[64];
 
 
 
 
 
typedef struct {
thread_main_func init;
thread_main_func main;
void *param;
 
 
 
 
pthread_mutex_t lock;
 
 
} tparams;
# 92 "vm/threads.c"
typedef int (*rec)( int, void * );
 
static int clean_c_stack( int n, void *f ) {
char buf[256];
memset(buf,n,sizeof(buf));
if( n == 0 ) return *buf;
return ((rec)f)(n-1,f) ? 1 : 0;
}
 
static void * ThreadMain( void *_p ) {
tparams *lp = (tparams*)_p;
tparams p = *lp;
p.init(p.param);
 
 
 
 
 
pthread_mutex_unlock(&lp->lock);
 
clean_c_stack(40,clean_c_stack);
p.main(p.param);
return 0;
}
 
 
 
int neko_thread_create( thread_main_func init, thread_main_func main, void *param, void **handle ) {
tparams p;
p.init = init;
p.main = main;
p.param = param;
# 141 "vm/threads.c"
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,2);
pthread_mutex_init(&p.lock,((void *)0));
pthread_mutex_lock(&p.lock);
 
 
if( GC_pthread_create((pthread_t*)handle,&attr,&ThreadMain,&p) != 0 ) {
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&p.lock);
return 0;
}
pthread_mutex_lock(&p.lock);
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&p.lock);
return 1;
 
}
 
 
# 1 "/usr/include/dlfcn.h" 1 3 4
# 40 "/usr/include/dlfcn.h" 3 4
# 1 "/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdbool.h" 1 3 4
# 41 "/usr/include/dlfcn.h" 2 3 4
# 1 "/usr/include/AvailabilityMacros.h" 1 3 4
# 42 "/usr/include/dlfcn.h" 2 3 4
 
 
 
typedef struct dl_info {
const char *dli_fname;
void *dli_fbase;
const char *dli_sname;
void *dli_saddr;
} Dl_info;
 
extern int dladdr(const void *, Dl_info *);
 
 
extern int dlclose(void * __handle);
extern char * dlerror(void);
extern void * dlopen(const char * __path, int __mode);
extern void * dlsym(void * __handle, const char * __symbol);
 
 
extern _Bool dlopen_preflight(const char* __path) ;
# 162 "vm/threads.c" 2
typedef void (*callb_func)( thread_main_func, void * );
typedef int (*std_func)();
typedef int (*gc_stack_ptr)( __stack_base * );
 
static int do_nothing( __stack_base *sb ) {
return -1;
}
 
 
 
void neko_thread_blocking( thread_main_func f, void *p ) {
 
 
 
 
 
 
 
static callb_func do_blocking = ((void *)0);
static std_func start = ((void *)0), end = ((void *)0);
if( do_blocking )
do_blocking(f,p);
else if( start ) {
start();
f(p);
end();
} else {
void *self = dlopen(((void *)0),0);
do_blocking = (callb_func)dlsym(self,"GC_do_blocking");
if( !do_blocking ) {
start = (std_func)dlsym(self,"GC_start_blocking");
end = (std_func)dlsym(self,"GC_end_blocking");
if( !start || !end )
neko_val_throw(neko_alloc_string("Could not init GC blocking API"));
}
neko_thread_blocking(f,p);
}
 
}
 
_Bool neko_thread_register( _Bool t ) {
# 217 "vm/threads.c"
static gc_stack_ptr get_sb = ((void *)0), my_thread = ((void *)0);
static std_func unreg_my_thread = ((void *)0);
if( !t && unreg_my_thread != ((void *)0) ) {
return unreg_my_thread() == 0;
} else if( my_thread != ((void *)0) ) {
__stack_base sb;
int r;
if( get_sb(&sb) != 0 )
return 0;
r = my_thread(&sb);
return( r == 0 || r == 1 );
} else {
void *self = dlopen(((void *)0),0);
my_thread = (gc_stack_ptr)dlsym(self,"GC_register_my_thread");
get_sb = (gc_stack_ptr)dlsym(self,"GC_get_stack_base");
unreg_my_thread = (std_func)dlsym(self,"GC_unregister_my_thread");
if( my_thread == ((void *)0) ) my_thread = do_nothing;
if( get_sb == ((void *)0) ) get_sb = do_nothing;
if( unreg_my_thread == ((void *)0) ) unreg_my_thread = (std_func)do_nothing;
return neko_thread_register(t);
}
 
}
 
 
mt_local *neko_alloc_local() {
# 252 "vm/threads.c"
mt_local *l = malloc(sizeof(mt_local));
pthread_key_create(&l->key,((void *)0));
return l;
 
}
 
void neko_free_local( mt_local *l ) {
 
 
 
 
 
pthread_key_delete(l->key);
free(l);
 
}
 
void neko_local_set( mt_local *l, void *v ) {
 
 
 
 
 
pthread_setspecific(l->key,v);
 
}
 
void *neko_local_get( mt_local *l ) {
if( l == ((void *)0) )
return ((void *)0);
 
 
 
 
 
return pthread_getspecific(l->key);
 
}
 
mt_lock *neko_alloc_lock() {
 
 
 
 
 
 
 
mt_lock *l = (mt_lock*)malloc(sizeof(mt_lock));
pthread_mutexattr_t a;
pthread_mutexattr_init(&a);
pthread_mutexattr_settype(&a,2);
pthread_mutex_init(&l->lock,&a);
pthread_mutexattr_destroy(&a);
return l;
 
}
 
void neko_lock_acquire( mt_lock *l ) {
 
 
 
 
pthread_mutex_lock(&l->lock);
 
}
 
int neko_lock_try( mt_lock *l ) {
 
 
 
 
 
return pthread_mutex_trylock(&l->lock) == 0;
 
}
 
void neko_lock_release( mt_lock *l ) {
 
 
 
 
pthread_mutex_unlock(&l->lock);
 
}
 
void neko_free_lock( mt_lock *l ) {
 
 
 
 
 
pthread_mutex_destroy(&l->lock);
free(l);
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.