summaryrefslogtreecommitdiff
path: root/java/openjdk7/files/patch-set
blob: 7e47b52c086c045872d228d9b8f2ab0761d38f9b (plain) (blame)
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
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
--- ./.hgtags	2011-05-26 17:05:27.000000000 -0700
+++ ./.hgtags	2011-05-27 00:00:33.000000000 -0700
@@ -118,3 +118,4 @@
 c6569c5585851dfd39b8de8e021c3c312f51af12 jdk7-b141
 cfbbdb77eac0397b03eb99ee2e07ea00e0a7b81e jdk7-b142
 14b8e7eee1058fd4ed5a2700a2ce14b3616278f1 jdk7-b143
+7203965666a4fe63bf82f5e4204f41ce6285e716 jdk7-b144
--- ./.jcheck/conf	2011-05-26 17:05:28.000000000 -0700
+++ ./.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./corba/.hgtags	2011-05-26 17:08:44.000000000 -0700
+++ ./corba/.hgtags	2011-05-27 00:00:37.000000000 -0700
@@ -118,3 +118,4 @@
 a58635cdd921bafef353f4864184a0481353197b jdk7-b141
 a2f340a048c88d10cbedc0504f5cf03d39925a40 jdk7-b142
 51ed32f6f4de56f16e910ac54ba6c6f6606f4f17 jdk7-b143
+7033a5756ad552d88114594d8e2d2e4dc2c05963 jdk7-b144
--- ./corba/.jcheck/conf	2011-05-26 17:08:44.000000000 -0700
+++ ./corba/.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./corba/make/common/Defs-bsd.gmk	2011-05-29 11:28:25.000000000 -0700
+++ ./corba/make/common/Defs-bsd.gmk	2011-04-22 22:20:45.000000000 -0700
@@ -25,9 +25,18 @@
 
 #
 # Makefile to specify compiler flags for programs and libraries
-# targeted to Bsd.  Should not contain any rules.
+# targeted to BSD.  Should not contain any rules.
 #
 
+# Warning: the following variables are overriden by Defs.gmk. Set
+# values will be silently ignored:
+#   CFLAGS        (set $(OTHER_CFLAGS) instead)
+#   CPPFLAGS      (set $(OTHER_CPPFLAGS) instead)
+#   CXXFLAGS      (set $(OTHER_CXXFLAGS) instead)
+#   LDFLAGS       (set $(OTHER_LDFAGS) instead)
+#   LDLIBS        (set $(EXTRA_LIBS) instead)
+#   LDLIBS_COMMON (set $(EXTRA_LIBS) instead)
+
 # Get shared JDK settings
 include $(BUILDDIR)/common/shared/Defs.gmk
 
--- ./corba/make/common/Defs.gmk	2011-05-26 17:09:01.000000000 -0700
+++ ./corba/make/common/Defs.gmk	2011-04-22 22:20:45.000000000 -0700
@@ -53,6 +53,28 @@
 
 _OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH)
 
+ifneq ($(PLATFORM), windows)
+  ifdef ALT_X11_PATH
+    X11_PATH = $(ALT_X11_PATH)
+  else
+    X11_PATH = /usr/X11R6
+  endif 
+
+  ifdef ALT_PACKAGE_PATH
+    PACKAGE_PATH = $(ALT_PACKAGE_PATH)
+  else
+    ifeq ($(PLATFORM), linux)
+      PACKAGE_PATH = /usr
+    else
+      ifeq ($(OS_VENDOR), Apple)
+        PACKAGE_PATH = /opt/local
+      else
+        PACKAGE_PATH = /usr/local
+      endif
+    endif
+  endif
+endif
+
 #
 # Get platform definitions
 #
--- ./corba/make/common/shared/Defs-bsd.gmk	2011-05-29 11:28:25.000000000 -0700
+++ ./corba/make/common/shared/Defs-bsd.gmk	2011-04-22 22:20:45.000000000 -0700
@@ -54,7 +54,7 @@
 endef
 
 # Location on system where jdk installs might be
-USRJDKINSTANCES_PATH =/opt/java
+USRJDKINSTANCES_PATH =$(PACKAGE_PATH)
 
 # UNIXCOMMAND_PATH: path to where the most common Unix commands are.
 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
@@ -99,7 +99,7 @@
 ifneq "$(origin ALT_DEVTOOLS_PATH)" "undefined"
   DEVTOOLS_PATH :=$(call PrefixPath,$(ALT_DEVTOOLS_PATH))
 else
-  DEVTOOLS_PATH =/usr/bin/
+  DEVTOOLS_PATH =$(PACKAGE_PATH)/bin/
 endif
 
 # _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
--- ./corba/make/common/shared/Defs-utils.gmk	2011-05-26 17:09:02.000000000 -0700
+++ ./corba/make/common/shared/Defs-utils.gmk	2011-04-22 22:20:45.000000000 -0700
@@ -53,6 +53,13 @@
   UTILS_DEVTOOL_PATH=$(USRBIN_PATH)
 endif
 
+ifeq ($(PLATFORM),bsd)
+  UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
+  UTILS_USR_BIN_PATH=$(USRBIN_PATH)
+  UTILS_CCS_BIN_PATH=$(USRBIN_PATH)
+  UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
+endif
+
 ifeq ($(PLATFORM),solaris)
   UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
   UTILS_USR_BIN_PATH=$(UNIXCOMMAND_PATH)
@@ -198,3 +205,34 @@
   ECHO           = /usr/bin/echo
 endif
 
+# BSD specific
+ifeq ($(PLATFORM),bsd)
+  BASENAME     = $(UTILS_USR_BIN_PATH)basename
+  EGREP        = $(UTILS_USR_BIN_PATH)egrep
+  EXPR         = $(UTILS_COMMAND_PATH)expr
+  FMT          = $(UTILS_USR_BIN_PATH)fmt
+  GREP         = $(UTILS_USR_BIN_PATH)grep
+  GUNZIP       = $(UTILS_USR_BIN_PATH)gunzip
+  ID           = $(UTILS_USR_BIN_PATH)id
+  MSGFMT       = $(UTILS_DEVTOOL_PATH)msgfmt
+  SED          = $(UTILS_USR_BIN_PATH)sed
+  SORT         = $(UTILS_USR_BIN_PATH)sort
+  TEST         = $(UTILS_COMMAND_PATH)test
+  TOUCH        = $(UTILS_USR_BIN_PATH)touch
+  TRUE         = $(UTILS_USR_BIN_PATH)true
+  UNAME        = $(UTILS_USR_BIN_PATH)uname
+  # BSD OS_VENDOR specific
+  ifeq ($(OS_VENDOR), Apple)
+    NAWK       = $(UTILS_USR_BIN_PATH)awk
+    UNZIPSFX   = $(UTILS_USR_BIN_PATH)unzipsfx
+    ZIPEXE     = $(UTILS_USR_BIN_PATH)zip
+  else
+    UNZIP      = $(UTILS_DEVTOOL_PATH)unzip
+  endif
+  ifeq ($(OS_VENDOR), OpenBSD)
+    NAWK       = $(UTILS_USR_BIN_PATH)awk
+  else
+    CPIO       = $(UTILS_USR_BIN_PATH)cpio
+    TAR        = $(UTILS_USR_BIN_PATH)tar
+  endif
+endif
--- ./corba/make/common/shared/Platform.gmk	2011-05-26 17:09:03.000000000 -0700
+++ ./corba/make/common/shared/Platform.gmk	2011-04-22 22:20:45.000000000 -0700
@@ -231,6 +231,101 @@
   MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2)
 endif
 
+ifeq ($(SYSTEM_UNAME), FreeBSD)
+  PLATFORM = bsd
+  OS_NAME = freebsd
+  OS_VENDOR = FreeBSD
+  REQUIRED_OS_VERSION = 6.0
+endif
+
+ifeq ($(SYSTEM_UNAME), Darwin)
+  PLATFORM = bsd
+  OS_NAME = darwin
+  OS_VENDOR = Apple
+  REQUIRED_OS_VERSION = 8.0
+endif
+
+ifeq ($(SYSTEM_UNAME), NetBSD)
+  PLATFORM = bsd
+  OS_NAME = netbsd
+  OS_VENDOR = NetBSD
+  REQUIRED_OS_VERSION = 3.0
+endif
+
+ifeq ($(SYSTEM_UNAME), OpenBSD)
+  PLATFORM = bsd
+  OS_NAME = openbsd
+  OS_VENDOR = OpenBSD
+  REQUIRED_OS_VERSION = 4.2
+endif
+
+# Platform settings specific to BSD
+ifeq ($(PLATFORM), bsd)
+  OS_VERSION := $(shell uname -r)
+  # Arch and OS name/version
+  mach := $(shell uname -m)
+  archExpr = case "$(mach)" in \
+                i[3-9]86) \
+                    echo i586 \
+                    ;; \
+                sparc64) \
+                    echo sparcv9 \
+                    ;; \
+                sparc*) \
+                    echo sparc \
+                    ;; \
+                x86_64) \
+                    echo amd64 \
+                    ;; \
+                "Power Macintosh") \
+                    echo ppc \
+                    ;; \
+                *) \
+                    echo $(mach) \
+                    ;; \
+      esac
+  ARCH        := $(shell $(archExpr) )
+  ARCH_FAMILY := $(ARCH)
+
+  # Darwin builds may be 32-bit or 64-bit data model.
+  ifeq ($(SYSTEM_UNAME), Darwin)
+    ifeq ($(ARCH), i586)
+      ifeq ($(ARCH_DATA_MODEL), 64)
+        ARCH=amd64
+      endif
+    endif
+  endif
+
+  # i586, sparc, and ppc are 32 bit, amd64 and sparc64 are 64
+  ifneq (,$(findstring $(ARCH), i586 sparc ppc))
+    ARCH_DATA_MODEL=32
+  else
+    ARCH_DATA_MODEL=64
+  endif
+
+  # Need to maintain the jre/lib/i386 location for 32-bit Intel
+  ifeq ($(ARCH), i586)
+    LIBARCH = i386
+  else
+    LIBARCH = $(ARCH)
+  endif
+
+  # Value of Java os.arch property
+  ARCHPROP  = $(LIBARCH)
+
+  # Suffix for file bundles used in previous release
+  BUNDLE_FILE_SUFFIX=.tar.gz
+  # Minimum disk space needed as determined by running 'du -sk' on 
+  #    a fully built workspace.
+  REQUIRED_FREE_SPACE=1500000
+  # How much RAM does this machine have:
+  ifeq ($(OS_VENDOR), OpenBSD)
+    MB_OF_MEMORY=$(shell sysctl -n hw.physmem | awk '{print int($$NF / 1048576); }' )
+  else
+    MB_OF_MEMORY=$(shell (sysctl -n hw.physmem64 2> /dev/null || sysctl -n hw.physmem) | awk '{print int($$NF / 1048576); }' )
+  endif
+endif
+
 # Windows with and without CYGWIN will be slightly different
 ifeq ($(SYSTEM_UNAME), Windows_NT)
   PLATFORM = windows
@@ -381,6 +476,18 @@
   export MAX_VM_MEMORY
 endif
 
+# for OpenBSD/i386 limit to 736 max
+ifeq ($(OS_VENDOR), OpenBSD)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    MAX_VM_MEMORY := $(shell \
+      if [ $(MAX_VM_MEMORY) -gt 736 ] ; then \
+        echo "736"; \
+      else \
+        echo "$(MAX_VM_MEMORY)" ; \
+      fi)
+  endif
+endif
+
 REQUIRED_ZIP_VER = 2.2
 REQUIRED_UNZIP_VER = 5.12
 REQUIRED_MAKE_VER = 3.81
--- ./hotspot/.hgtags	2011-05-26 17:23:54.000000000 -0700
+++ ./hotspot/.hgtags	2011-05-27 00:00:43.000000000 -0700
@@ -174,3 +174,4 @@
 9ad1548c6b63d596c411afc35147ffd5254426d9 hs21-b12
 c149193c768b8b7233da4c3a3fdc0756b975848e hs21-b13
 c149193c768b8b7233da4c3a3fdc0756b975848e jdk7-b143
+fe189d4a44e9e8f0c7d78fcbd1c63701745752ca jdk7-b144
--- ./hotspot/.jcheck/conf	2011-05-26 17:23:54.000000000 -0700
+++ ./hotspot/.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./hotspot/agent/make/Makefile	2011-05-26 17:23:57.000000000 -0700
+++ ./hotspot/agent/make/Makefile	2011-05-12 20:54:44.000000000 -0700
@@ -52,6 +52,9 @@
 sun.jvm.hotspot.compiler \
 sun.jvm.hotspot.debugger \
 sun.jvm.hotspot.debugger.amd64 \
+sun.jvm.hotspot.debugger.bsd \
+sun.jvm.hotspot.debugger.bsd.amd64 \
+sun.jvm.hotspot.debugger.bsd.x86 \
 sun.jvm.hotspot.debugger.cdbg \
 sun.jvm.hotspot.debugger.cdbg.basic \
 sun.jvm.hotspot.debugger.cdbg.basic.amd64 \
@@ -94,6 +97,9 @@
 sun.jvm.hotspot.oops \
 sun.jvm.hotspot.runtime \
 sun.jvm.hotspot.runtime.amd64 \
+sun.jvm.hotspot.runtime.bsd \
+sun.jvm.hotspot.runtime.bsd_amd64 \
+sun.jvm.hotspot.runtime.bsd_x86 \
 sun.jvm.hotspot.runtime.ia64 \
 sun.jvm.hotspot.runtime.linux \
 sun.jvm.hotspot.runtime.linux_amd64 \
@@ -143,6 +149,8 @@
 sun/jvm/hotspot/compiler/*.java \
 sun/jvm/hotspot/debugger/*.java \
 sun/jvm/hotspot/debugger/amd64/*.java \
+sun/jvm/hotspot/debugger/bsd/*.java \
+sun/jvm/hotspot/debugger/bsd/x86/*.java \
 sun/jvm/hotspot/debugger/cdbg/*.java \
 sun/jvm/hotspot/debugger/cdbg/basic/*.java \
 sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \
--- ./hotspot/agent/src/os/bsd/BsdDebuggerLocal.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/BsdDebuggerLocal.c	2011-04-22 22:28:31.000000000 -0700
@@ -22,6 +22,7 @@
  *
  */
 
+#include <stdlib.h>
 #include <jni.h>
 #include "libproc.h"
 
@@ -73,7 +74,7 @@
   (JNIEnv *env, jclass cls) {
   jclass listClass;
 
-  if (init_libproc(getenv("LIBSAPROC_DEBUG")) != true) {
+  if (init_libproc(getenv("LIBSAPROC_DEBUG") != NULL) != true) {
      THROW_NEW_DEBUGGER_EXCEPTION("can't initialize libproc");
   }
 
@@ -275,7 +276,7 @@
   bufPtr = (*env)->GetByteArrayElements(env, array, &isCopy);
   CHECK_EXCEPTION_(0);
 
-  err = ps_pdread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
+  err = ps_pread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
   (*env)->ReleaseByteArrayElements(env, array, bufPtr, 0);
   return (err == PS_OK)? array : 0;
 }
@@ -283,11 +284,10 @@
 JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
   (JNIEnv *env, jobject this_obj, jint lwp_id) {
 
-  struct user_regs_struct gregs;
+  struct reg gregs;
   jboolean isCopy;
   jlongArray array;
   jlong *regs;
-  int i;
 
   struct ps_prochandle* ph = get_proc_handle(env, this_obj);
   if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
@@ -317,26 +317,27 @@
 #ifdef i386
 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
 
-  regs[REG_INDEX(GS)]  = (uintptr_t) gregs.xgs;
-  regs[REG_INDEX(FS)]  = (uintptr_t) gregs.xfs;
-  regs[REG_INDEX(ES)]  = (uintptr_t) gregs.xes;
-  regs[REG_INDEX(DS)]  = (uintptr_t) gregs.xds;
-  regs[REG_INDEX(EDI)] = (uintptr_t) gregs.edi;
-  regs[REG_INDEX(ESI)] = (uintptr_t) gregs.esi;
-  regs[REG_INDEX(FP)] = (uintptr_t) gregs.ebp;
-  regs[REG_INDEX(SP)] = (uintptr_t) gregs.esp;
-  regs[REG_INDEX(EBX)] = (uintptr_t) gregs.ebx;
-  regs[REG_INDEX(EDX)] = (uintptr_t) gregs.edx;
-  regs[REG_INDEX(ECX)] = (uintptr_t) gregs.ecx;
-  regs[REG_INDEX(EAX)] = (uintptr_t) gregs.eax;
-  regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
-  regs[REG_INDEX(CS)]  = (uintptr_t) gregs.xcs;
-  regs[REG_INDEX(SS)]  = (uintptr_t) gregs.xss;
+  regs[REG_INDEX(GS)]  = (uintptr_t) gregs.r_gs;
+  regs[REG_INDEX(FS)]  = (uintptr_t) gregs.r_fs;
+  regs[REG_INDEX(ES)]  = (uintptr_t) gregs.r_es;
+  regs[REG_INDEX(DS)]  = (uintptr_t) gregs.r_ds;
+  regs[REG_INDEX(EDI)] = (uintptr_t) gregs.r_edi;
+  regs[REG_INDEX(ESI)] = (uintptr_t) gregs.r_esi;
+  regs[REG_INDEX(FP)] = (uintptr_t) gregs.r_ebp;
+  regs[REG_INDEX(SP)] = (uintptr_t) gregs.r_isp;
+  regs[REG_INDEX(EBX)] = (uintptr_t) gregs.r_ebx;
+  regs[REG_INDEX(EDX)] = (uintptr_t) gregs.r_edx;
+  regs[REG_INDEX(ECX)] = (uintptr_t) gregs.r_ecx;
+  regs[REG_INDEX(EAX)] = (uintptr_t) gregs.r_eax;
+  regs[REG_INDEX(PC)] = (uintptr_t) gregs.r_eip;
+  regs[REG_INDEX(CS)]  = (uintptr_t) gregs.r_cs;
+  regs[REG_INDEX(SS)]  = (uintptr_t) gregs.r_ss;
 
 #endif /* i386 */
 
 #if ia64
   regs = (*env)->GetLongArrayElements(env, array, &isCopy);
+  int i;
   for (i = 0; i < NPRGREG; i++ ) {
     regs[i] = 0xDEADDEAD;
   }
@@ -345,31 +346,31 @@
 #ifdef amd64
 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
 
-  regs[REG_INDEX(R15)] = gregs.r15;
-  regs[REG_INDEX(R14)] = gregs.r14;
-  regs[REG_INDEX(R13)] = gregs.r13;
-  regs[REG_INDEX(R12)] = gregs.r12;
-  regs[REG_INDEX(RBP)] = gregs.rbp;
-  regs[REG_INDEX(RBX)] = gregs.rbx;
-  regs[REG_INDEX(R11)] = gregs.r11;
-  regs[REG_INDEX(R10)] = gregs.r10;
-  regs[REG_INDEX(R9)] = gregs.r9;
-  regs[REG_INDEX(R8)] = gregs.r8;
-  regs[REG_INDEX(RAX)] = gregs.rax;
-  regs[REG_INDEX(RCX)] = gregs.rcx;
-  regs[REG_INDEX(RDX)] = gregs.rdx;
-  regs[REG_INDEX(RSI)] = gregs.rsi;
-  regs[REG_INDEX(RDI)] = gregs.rdi;
-  regs[REG_INDEX(RIP)] = gregs.rip;
-  regs[REG_INDEX(CS)] = gregs.cs;
-  regs[REG_INDEX(RSP)] = gregs.rsp;
-  regs[REG_INDEX(SS)] = gregs.ss;
-  regs[REG_INDEX(FSBASE)] = gregs.fs_base;
-  regs[REG_INDEX(GSBASE)] = gregs.gs_base;
-  regs[REG_INDEX(DS)] = gregs.ds;
-  regs[REG_INDEX(ES)] = gregs.es;
-  regs[REG_INDEX(FS)] = gregs.fs;
-  regs[REG_INDEX(GS)] = gregs.gs;
+  regs[REG_INDEX(R15)] = gregs.r_r15;
+  regs[REG_INDEX(R14)] = gregs.r_r14;
+  regs[REG_INDEX(R13)] = gregs.r_r13;
+  regs[REG_INDEX(R12)] = gregs.r_r12;
+  regs[REG_INDEX(RBP)] = gregs.r_rbp;
+  regs[REG_INDEX(RBX)] = gregs.r_rbx;
+  regs[REG_INDEX(R11)] = gregs.r_r11;
+  regs[REG_INDEX(R10)] = gregs.r_r10;
+  regs[REG_INDEX(R9)] = gregs.r_r9;
+  regs[REG_INDEX(R8)] = gregs.r_r8;
+  regs[REG_INDEX(RAX)] = gregs.r_rax;
+  regs[REG_INDEX(RCX)] = gregs.r_rcx;
+  regs[REG_INDEX(RDX)] = gregs.r_rdx;
+  regs[REG_INDEX(RSI)] = gregs.r_rsi;
+  regs[REG_INDEX(RDI)] = gregs.r_rdi;
+  regs[REG_INDEX(RIP)] = gregs.r_rip;
+  regs[REG_INDEX(CS)] = gregs.r_cs;
+  regs[REG_INDEX(RSP)] = gregs.r_rsp;
+  regs[REG_INDEX(SS)] = gregs.r_ss;
+//  regs[REG_INDEX(FSBASE)] = gregs.fs_base;
+//  regs[REG_INDEX(GSBASE)] = gregs.gs_base;
+//  regs[REG_INDEX(DS)] = gregs.ds;
+//  regs[REG_INDEX(ES)] = gregs.es;
+//  regs[REG_INDEX(FS)] = gregs.fs;
+//  regs[REG_INDEX(GS)] = gregs.gs;
 
 #endif /* amd64 */
 
--- ./hotspot/agent/src/os/bsd/Makefile	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/Makefile	2011-04-22 22:28:31.000000000 -0700
@@ -22,7 +22,7 @@
 #  
 #
 
-ARCH := $(shell if ([ `uname -m` = "ia64" ])  ; then echo ia64 ; elif ([ `uname -m` = "x86_64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
+ARCH := $(shell if ([ `uname -m` = "ia64" ])  ; then echo ia64 ; elif ([ `uname -m` = "amd64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
 GCC      = gcc
 
 JAVAH    = ${JAVA_HOME}/bin/javah
@@ -32,25 +32,25 @@
 	libproc_impl.c  \
 	ps_proc.c       \
 	ps_core.c       \
-	BsdDebuggerLocal.c 
+	hsearch_r.c     \
+	BsdDebuggerLocal.c
 
-INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/bsd 
+INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/$(shell uname -s | tr "[:upper:]" "[:lower:]")
 
 OBJS     = $(SOURCES:.c=.o)
 
-LIBS     = -lthread_db
+LIBS     = -lutil -lthread_db
 
-CFLAGS   = -c -fPIC -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES)
+CFLAGS   = -c -fPIC -g -Wall -D_ALLBSD_SOURCE -D_GNU_SOURCE -D$(ARCH) $(INCLUDES)
 
 LIBSA = $(ARCH)/libsaproc.so
 
 all: $(LIBSA)
 
 BsdDebuggerLocal.o: BsdDebuggerLocal.c
-	$(JAVAH) -jni -classpath ../../../build/classes  \
+	$(JAVAH) -jni -classpath ../../../../../build/bsd-i586/hotspot/outputdir/bsd_i486_compiler2/generated/saclasses  \
 		sun.jvm.hotspot.debugger.x86.X86ThreadContext \
-		sun.jvm.hotspot.debugger.sparc.SPARCThreadContext \
-		sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext 
+		sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
 	$(GCC) $(CFLAGS) $<
 
 .c.obj:
@@ -60,26 +60,19 @@
   LFLAGS_LIBSA = -Xlinker --version-script=mapfile
 endif
 
-# If this is a --hash-style=gnu system, use --hash-style=both
-#   The gnu .hash section won't work on some Bsd systems like SuSE 10.
-_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
-ifneq ($(_HAS_HASH_STYLE_GNU),)
-  LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
-endif
-LFLAGS_LIBSA += $(LDFLAGS_HASH_STYLE)
-
 $(LIBSA): $(OBJS) mapfile
 	if [ ! -d $(ARCH) ] ; then mkdir $(ARCH) ; fi
 	$(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(OBJS) $(LIBS)
 
-test.o: test.c
+test.o: $(LIBSA) test.c
 	$(GCC) -c -o test.o -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) test.c
 
 test: test.o
 	$(GCC) -o test test.o -L$(ARCH) -lsaproc $(LIBS)
 
 clean:
-	rm -rf $(LIBSA)
-	rm -rf $(OBJS)
-	rmdir $(ARCH)
+	rm -f $(LIBSA)
+	rm -f $(OBJS)
+	rm -f test.o
+	-rmdir $(ARCH)
 
--- ./hotspot/agent/src/os/bsd/StubDebuggerLocal.c	1969-12-31 16:00:00.000000000 -0800
+++ ./hotspot/agent/src/os/bsd/StubDebuggerLocal.c	2011-04-22 22:28:31.000000000 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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 General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+#include <stdlib.h>
+#include <jni.h>
+
+#define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
+#define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
+#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
+#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
+
+static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
+  (*env)->ThrowNew(env, (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    init0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0
+  (JNIEnv *env, jclass cls) {
+}
+
+JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getAddressSize
+  (JNIEnv *env, jclass cls)
+{
+#ifdef _LP64
+ return 8;
+#else
+ return 4;
+#endif
+
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I
+  (JNIEnv *env, jobject this_obj, jint jpid) {
+
+  THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
+  (JNIEnv *env, jobject this_obj, jstring execName, jstring coreName) {
+  THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file");
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    detach0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0
+  (JNIEnv *env, jobject this_obj) {
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByName0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0
+  (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
+  return 0;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByAddress0
+ * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
+ */
+JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByAddress0
+  (JNIEnv *env, jobject this_obj, jlong addr) {
+  return 0;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    readBytesFromProcess0
+ * Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult;
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0
+  (JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) {
+  return 0;
+}
+
+JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
+  (JNIEnv *env, jobject this_obj, jint lwp_id) {
+  return 0;
+}
--- ./hotspot/agent/src/os/bsd/elfmacros.h	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/elfmacros.h	2011-04-22 22:28:31.000000000 -0700
@@ -25,16 +25,19 @@
 #ifndef _ELFMACROS_H_
 #define _ELFMACROS_H_
 
+#define ELF_NHDR        Elf_Note
+
 #if defined(_LP64)
 #define ELF_EHDR        Elf64_Ehdr
 #define ELF_SHDR        Elf64_Shdr
 #define ELF_PHDR        Elf64_Phdr
 #define ELF_SYM         Elf64_Sym
-#define ELF_NHDR        Elf64_Nhdr
 #define ELF_DYN         Elf64_Dyn
 #define ELF_ADDR        Elf64_Addr
 
+#ifndef ELF_ST_TYPE
 #define ELF_ST_TYPE     ELF64_ST_TYPE
+#endif
 
 #else
 
@@ -42,11 +45,12 @@
 #define ELF_SHDR        Elf32_Shdr
 #define ELF_PHDR        Elf32_Phdr
 #define ELF_SYM         Elf32_Sym
-#define ELF_NHDR        Elf32_Nhdr
 #define ELF_DYN         Elf32_Dyn
 #define ELF_ADDR        Elf32_Addr
 
+#ifndef ELF_ST_TYPE
 #define ELF_ST_TYPE     ELF32_ST_TYPE
+#endif
 
 #endif
 
--- ./hotspot/agent/src/os/bsd/hsearch_r.c	1969-12-31 16:00:00.000000000 -0800
+++ ./hotspot/agent/src/os/bsd/hsearch_r.c	2011-04-22 22:28:31.000000000 -0700
@@ -0,0 +1,217 @@
+/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993.
+
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <search.h>
+
+#include "hsearch_r.h"
+
+#define __set_errno(ERRNO) errno = ERRNO
+
+/* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
+   [Knuth]            The Art of Computer Programming, part 3 (6.4)  */
+
+
+/* The reentrant version has no static variables to maintain the state.
+   Instead the interface of all functions is extended to take an argument
+   which describes the current status.  */
+typedef struct _ENTRY
+{
+  unsigned int used;
+  ENTRY entry;
+}
+_ENTRY;
+
+
+/* For the used double hash method the table size has to be a prime. To
+   correct the user given table size we need a prime test.  This trivial
+   algorithm is adequate because
+   a)  the code is (most probably) called a few times per program run and
+   b)  the number is small because the table must fit in the core  */
+static int
+isprime (unsigned int number)
+{
+  /* no even number will be passed */
+  unsigned int div = 3;
+
+  while (div * div < number && number % div != 0)
+    div += 2;
+
+  return number % div != 0;
+}
+
+
+/* Before using the hash table we must allocate memory for it.
+   Test for an existing table are done. We allocate one element
+   more as the found prime number says. This is done for more effective
+   indexing as explained in the comment for the hsearch function.
+   The contents of the table is zeroed, especially the field used
+   becomes zero.  */
+int
+hcreate_r (size_t nel, struct hsearch_data *htab)
+{
+  /* Test for correct arguments.  */
+  if (htab == NULL)
+    {
+      __set_errno (EINVAL);
+      return 0;
+    }
+
+  /* There is still another table active. Return with error. */
+  if (htab->table != NULL)
+    return 0;
+
+  /* Change nel to the first prime number not smaller as nel. */
+  nel |= 1;      /* make odd */
+  while (!isprime (nel))
+    nel += 2;
+
+  htab->size = nel;
+  htab->filled = 0;
+
+  /* allocate memory and zero out */
+  htab->table = (_ENTRY *) calloc (htab->size + 1, sizeof (_ENTRY));
+  if (htab->table == NULL)
+    return 0;
+
+  /* everything went alright */
+  return 1;
+}
+
+
+/* After using the hash table it has to be destroyed. The used memory can
+   be freed and the local static variable can be marked as not used.  */
+void
+hdestroy_r (struct hsearch_data *htab)
+{
+  /* Test for correct arguments.  */
+  if (htab == NULL)
+    {
+      __set_errno (EINVAL);
+      return;
+    }
+
+  /* Free used memory.  */
+  free (htab->table);
+
+  /* the sign for an existing table is an value != NULL in htable */
+  htab->table = NULL;
+}
+
+
+/* This is the search function. It uses double hashing with open addressing.
+   The argument item.key has to be a pointer to an zero terminated, most
+   probably strings of chars. The function for generating a number of the
+   strings is simple but fast. It can be replaced by a more complex function
+   like ajw (see [Aho,Sethi,Ullman]) if the needs are shown.
+
+   We use an trick to speed up the lookup. The table is created by hcreate
+   with one more element available. This enables us to use the index zero
+   special. This index will never be used because we store the first hash
+   index in the field used where zero means not used. Every other value
+   means used. The used field can be used as a first fast comparison for
+   equality of the stored and the parameter value. This helps to prevent
+   unnecessary expensive calls of strcmp.  */
+int
+hsearch_r (ENTRY item, ACTION action, ENTRY **retval, struct hsearch_data *htab)
+{
+  unsigned int hval;
+  unsigned int count;
+  unsigned int len = strlen (item.key);
+  unsigned int idx;
+
+  /* Compute an value for the given string. Perhaps use a better method. */
+  hval = len;
+  count = len;
+  while (count-- > 0)
+    {
+      hval <<= 4;
+      hval += item.key[count];
+    }
+
+  /* First hash function: simply take the modul but prevent zero. */
+  idx = hval % htab->size + 1;
+
+  if (htab->table[idx].used)
+    {
+      /* Further action might be required according to the action value. */
+      if (htab->table[idx].used == hval
+	  && strcmp (item.key, htab->table[idx].entry.key) == 0)
+	{
+	  *retval = &htab->table[idx].entry;
+	  return 1;
+	}
+
+      /* Second hash function, as suggested in [Knuth] */
+      unsigned int hval2 = 1 + hval % (htab->size - 2);
+      unsigned int first_idx = idx;
+
+      do
+	{
+	  /* Because SIZE is prime this guarantees to step through all
+             available indeces.  */
+          if (idx <= hval2)
+	    idx = htab->size + idx - hval2;
+	  else
+	    idx -= hval2;
+
+	  /* If we visited all entries leave the loop unsuccessfully.  */
+	  if (idx == first_idx)
+	    break;
+
+            /* If entry is found use it. */
+          if (htab->table[idx].used == hval
+	      && strcmp (item.key, htab->table[idx].entry.key) == 0)
+	    {
+	      *retval = &htab->table[idx].entry;
+	      return 1;
+	    }
+	}
+      while (htab->table[idx].used);
+    }
+
+  /* An empty bucket has been found. */
+  if (action == ENTER)
+    {
+      /* If table is full and another entry should be entered return
+	 with error.  */
+      if (htab->filled == htab->size)
+	{
+	  __set_errno (ENOMEM);
+	  *retval = NULL;
+	  return 0;
+	}
+
+      htab->table[idx].used  = hval;
+      htab->table[idx].entry = item;
+
+      ++htab->filled;
+
+      *retval = &htab->table[idx].entry;
+      return 1;
+    }
+
+  __set_errno (ESRCH);
+  *retval = NULL;
+  return 0;
+}
--- ./hotspot/agent/src/os/bsd/hsearch_r.h	1969-12-31 16:00:00.000000000 -0800
+++ ./hotspot/agent/src/os/bsd/hsearch_r.h	2011-04-22 22:28:31.000000000 -0700
@@ -0,0 +1,42 @@
+/* Declarations for System V style searching functions.
+   Copyright (C) 1995-1999, 2000 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _HSEARCH_R_H_
+#define _HSEARCH_R_H_
+
+#include <search.h>
+
+struct _ENTRY;
+
+/* Data type for reentrant functions.  */
+struct hsearch_data
+  {
+    struct _ENTRY *table;
+    unsigned int size;
+    unsigned int filled;
+  };
+
+/* Reentrant versions which can handle multiple hashing tables at the
+   same time.  */
+extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
+                      struct hsearch_data *__htab);
+extern int hcreate_r (size_t __nel, struct hsearch_data *__htab);
+extern void hdestroy_r (struct hsearch_data *__htab);
+
+#endif /* _HSEARCH_R_H_ */
--- ./hotspot/agent/src/os/bsd/libproc.h	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/libproc.h	2011-04-22 22:28:31.000000000 -0700
@@ -27,7 +27,8 @@
 
 #include <unistd.h>
 #include <stdint.h>
-#include "proc_service.h"
+#include <machine/reg.h>
+#include <proc_service.h>
 
 #if defined(sparc) || defined(sparcv9)
 /*
@@ -50,14 +51,11 @@
 adds Pgrab__ and some missing stuff. We hide the difference b/w live process and core
 file by this interface.
 
-1. pthread_id unique in both NPTL & BsdThreads. We store this in
-OSThread::_pthread_id in JVM code.
+1. pthread_id is unique. We store this in OSThread::_pthread_id in JVM code.
 
-2. All threads see the same pid when they call getpid() under NPTL.
-Threads receive different pid under BsdThreads. We used to save the result of
-::getpid() call in OSThread::_thread_id. This way uniqueness of OSThread::_thread_id
-was lost under NPTL. Now, we store the result of ::gettid() call in
-OSThread::_thread_id. Because gettid returns actual pid of thread (lwp id), this is
+2. All threads see the same pid when they call getpid().
+We used to save the result of ::getpid() call in OSThread::_thread_id.
+Because gettid returns actual pid of thread (lwp id), this is
 unique again. We therefore use OSThread::_thread_id as unique identifier.
 
 3. There is a unique LWP id under both thread libraries. libthread_db  maps pthread_id
@@ -74,20 +72,7 @@
 
 *************************************************************************************/
 
-#ifdef ia64
-struct user_regs_struct {
-/* copied from user.h which doesn't define this in a struct */
-
-#define IA64_REG_COUNT (EF_SIZE/8+32)   /* integer and fp regs */
-unsigned long   regs[IA64_REG_COUNT];     /* integer and fp regs */
-};
-#endif
-
-#if defined(sparc)  || defined(sparcv9)
-#define user_regs_struct  pt_regs
-#endif
-
-// This C bool type must be int for compatibility with Bsd calls and
+// This C bool type must be int for compatibility with BSD calls and
 // it would be a mistake to equivalence it to C++ bool on many platforms
 
 typedef int bool;
@@ -118,7 +103,7 @@
 lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);
 
 // get regs for a given lwp
-bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct user_regs_struct* regs);
+bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct reg* regs);
 
 // get number of shared objects
 int get_num_libs(struct ps_prochandle* ph);
--- ./hotspot/agent/src/os/bsd/libproc_impl.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/libproc_impl.c	2011-04-22 22:28:31.000000000 -0700
@@ -174,10 +174,13 @@
       return NULL;
    }
 
-   newlib->symtab = build_symtab(newlib->fd, libname);
+   newlib->symtab = build_symtab(newlib->fd);
    if (newlib->symtab == NULL) {
       print_debug("symbol table build failed for %s\n", newlib->name);
    }
+   else {
+      print_debug("built symbol table for %s\n", newlib->name);
+   }
 
    // even if symbol table building fails, we add the lib_info.
    // This is because we may need to read from the ELF file for core file
@@ -272,7 +275,7 @@
 
   print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
 
-  if (ptr->callback(ptr->ph, ti.ti_tid, ti.ti_lid) != true)
+  if (ptr->callback(ptr->ph, (pthread_t)ti.ti_tid, ti.ti_lid) != true)
     return TD_ERR;
 
   return TD_OK;
@@ -324,7 +327,7 @@
 }
 
 // get regs for a given lwp
-bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, struct user_regs_struct* regs) {
+bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs) {
   return ph->ops->get_lwp_regs(ph, lwp_id, regs);
 }
 
@@ -375,11 +378,6 @@
 //--------------------------------------------------------------------------
 // proc service functions
 
-// get process id
-pid_t ps_getpid(struct ps_prochandle *ph) {
-   return ph->pid;
-}
-
 // ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
 // of the load object object_name in the target process identified by ph.
 // It returns the symbol's value as an address in the target process in
@@ -392,17 +390,33 @@
 }
 
 // read "size" bytes info "buf" from address "addr"
-ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t  addr,
-                   void *buf, size_t size) {
+ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t  addr,
+                  void *buf, size_t size) {
   return ph->ops->p_pread(ph, (uintptr_t) addr, buf, size)? PS_OK: PS_ERR;
 }
 
 // write "size" bytes of data to debuggee at address "addr"
-ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr,
-                    const void *buf, size_t size) {
+ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
+                   const void *buf, size_t size) {
   return ph->ops->p_pwrite(ph, (uintptr_t)addr, buf, size)? PS_OK: PS_ERR;
 }
 
+// fill in ptrace_lwpinfo for lid
+ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+  return ph->ops->get_lwp_info(ph, lwp_id, linfo)? PS_OK: PS_ERR;
+}
+
+// needed for when libthread_db is compiled with TD_DEBUG defined
+void
+ps_plog (const char *format, ...)
+{
+  va_list alist;
+
+  va_start(alist, format);
+  vfprintf(stderr, format, alist);
+  va_end(alist);
+}
+
 // ------------------------------------------------------------------------
 // Functions below this point are not yet implemented. They are here only
 // to make the linker happy.
@@ -427,8 +441,12 @@
   return PS_OK;
 }
 
-// new libthread_db of NPTL seem to require this symbol
-ps_err_e ps_get_thread_area() {
-  print_debug("ps_get_thread_area not implemented\n");
+ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lid) {
+  print_debug("ps_lstop not implemented\n");
+  return PS_OK;
+}
+
+ps_err_e ps_pcontinue(struct ps_prochandle *ph) {
+  print_debug("ps_pcontinue not implemented\n");
   return PS_OK;
 }
--- ./hotspot/agent/src/os/bsd/libproc_impl.h	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/libproc_impl.h	2011-04-22 22:28:31.000000000 -0700
@@ -47,7 +47,7 @@
 typedef struct thread_info {
    lwpid_t                  lwp_id;
    pthread_t                pthread_id; // not used cores, always -1
-   struct user_regs_struct  regs;       // not for process, core uses for caching regset
+   struct reg               regs;       // not for process, core uses for caching regset
    struct thread_info*      next;
 } thread_info;
 
@@ -71,7 +71,9 @@
    bool (*p_pwrite)(struct ps_prochandle *ph,
             uintptr_t addr, const char *buf , size_t size);
    // get integer regset of a thread
-   bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct user_regs_struct* regs);
+   bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs);
+   // get info on thread
+   bool (*get_lwp_info)(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
 } ps_prochandle_ops;
 
 // the ps_prochandle
@@ -79,7 +81,7 @@
 struct core_data {
    int                core_fd;   // file descriptor of core file
    int                exec_fd;   // file descriptor of exec file
-   int                interp_fd; // file descriptor of interpreter (ld-bsd.so.2)
+   int                interp_fd; // file descriptor of interpreter (ld-elf.so.1)
    // part of the class sharing workaround
    int                classes_jsa_fd; // file descriptor of class share archive
    uintptr_t          dynamic_addr;  // address of dynamic section of a.out
--- ./hotspot/agent/src/os/bsd/mapfile	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/mapfile	2011-04-22 22:28:31.000000000 -0700
@@ -43,13 +43,17 @@
 		# proc_service.h functions - to be used by libthread_db
 		ps_getpid;
 		ps_pglobal_lookup;
-		ps_pdread;
-		ps_pdwrite;
+		ps_pread;
+		ps_pwrite;
 		ps_lsetfpregs;
 		ps_lsetregs;
 		ps_lgetfpregs;
 		ps_lgetregs;
-		ps_get_thread_area;
+		ps_lcontinue;
+		ps_lgetxmmregs;
+		ps_lsetxmmregs;
+		ps_lstop;
+		ps_linfo;
 
                 # used by attach test program
                 init_libproc;
--- ./hotspot/agent/src/os/bsd/proc_service.h	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/proc_service.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef _PROC_SERVICE_H_
-#define _PROC_SERVICE_H_
-
-#include <stdio.h>
-#include <thread_db.h>
-
-// Bsd does not have the proc service library, though it does provide the
-// thread_db library which can be used to manipulate threads without having
-// to know the details of BsdThreads or NPTL
-
-// copied from Solaris "proc_service.h"
-typedef enum {
-        PS_OK,          /* generic "call succeeded" */
-        PS_ERR,         /* generic error */
-        PS_BADPID,      /* bad process handle */
-        PS_BADLID,      /* bad lwp identifier */
-        PS_BADADDR,     /* bad address */
-        PS_NOSYM,       /* p_lookup() could not find given symbol */
-        PS_NOFREGS      /* FPU register set not available for given lwp */
-} ps_err_e;
-
-// ps_getpid() is only defined on Bsd to return a thread's process ID
-pid_t ps_getpid(struct ps_prochandle *ph);
-
-// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
-// of the load object object_name in the target process identified by ph.
-// It returns the symbol's value as an address in the target process in
-// *sym_addr.
-
-ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
-                    const char *sym_name, psaddr_t *sym_addr);
-
-// read "size" bytes of data from debuggee at address "addr"
-ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t  addr,
-                   void *buf, size_t size);
-
-// write "size" bytes of data to debuggee at address "addr"
-ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr,
-                    const void *buf, size_t size);
-
-ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lid, const prfpregset_t *fpregs);
-
-ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lid, const prgregset_t gregset);
-
-ps_err_e  ps_lgetfpregs(struct  ps_prochandle  *ph,  lwpid_t lid, prfpregset_t *fpregs);
-
-ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset);
-
-// new libthread_db of NPTL seem to require this symbol
-ps_err_e ps_get_thread_area();
-
-#endif /* _PROC_SERVICE_H_ */
--- ./hotspot/agent/src/os/bsd/ps_core.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/ps_core.c	2011-04-22 22:28:31.000000000 -0700
@@ -142,6 +142,7 @@
 
    map->next = ph->core->class_share_maps;
    ph->core->class_share_maps = map;
+   return map;
 }
 
 // Return the map_info for the given virtual address.  We keep a sorted
@@ -228,8 +229,8 @@
 
     // 4991491 NOTICE These are C++ bool's in filemap.hpp and must match up with
     // the C type matching the C++ bool type on any given platform. For
-    // Hotspot on Bsd we assume the corresponding C type is char but
-    // licensees on Bsd versions may need to adjust the type of these fields.
+    // Hotspot on BSD we assume the corresponding C type is char but
+    // licensees on BSD versions may need to adjust the type of these fields.
     char   _read_only;       // read only space?
     char   _allow_exec;      // executable code in space?
 
@@ -240,7 +241,7 @@
 
 static bool read_jboolean(struct ps_prochandle* ph, uintptr_t addr, jboolean* pvalue) {
    jboolean i;
-   if (ps_pdread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
+   if (ps_pread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
       *pvalue = i;
       return true;
    } else {
@@ -250,7 +251,7 @@
 
 static bool read_pointer(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* pvalue) {
    uintptr_t uip;
-   if (ps_pdread(ph, (psaddr_t) addr, &uip, sizeof(uip)) == PS_OK) {
+   if (ps_pread(ph, (psaddr_t) addr, &uip, sizeof(uip)) == PS_OK) {
       *pvalue = uip;
       return true;
    } else {
@@ -264,7 +265,7 @@
    char  c = ' ';
 
    while (c != '\0') {
-     if (ps_pdread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK)
+     if (ps_pread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK)
          return false;
       if (i < size - 1)
          buf[i] = c;
@@ -296,7 +297,6 @@
          uintptr_t base = 0, useSharedSpacesAddr = 0;
          uintptr_t sharedArchivePathAddrAddr = 0, sharedArchivePathAddr = 0;
          jboolean useSharedSpaces = 0;
-         map_info* mi = 0;
 
          memset(classes_jsa, 0, sizeof(classes_jsa));
          jvm_name = lib->name;
@@ -306,9 +306,9 @@
             return false;
          }
 
-         // Hotspot vm types are not exported to build this library. So
-         // using equivalent type jboolean to read the value of
-         // UseSharedSpaces which is same as hotspot type "bool".
+	 // Hotspot vm types are not exported to build this library. So
+	 // using equivalent type jboolean to read the value of
+	 // UseSharedSpaces which is same as hotspot type "bool".
          if (read_jboolean(ph, useSharedSpacesAddr, &useSharedSpaces) != true) {
             print_debug("can't read the value of 'UseSharedSpaces' flag\n");
             return false;
@@ -507,12 +507,12 @@
 }
 
 static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id,
-                          struct user_regs_struct* regs) {
+                          struct reg* regs) {
    // for core we have cached the lwp regs from NOTE section
    thread_info* thr = ph->threads;
    while (thr) {
      if (thr->lwp_id == lwp_id) {
-       memcpy(regs, &thr->regs, sizeof(struct user_regs_struct));
+       memcpy(regs, &thr->regs, sizeof(struct reg));
        return true;
      }
      thr = thr->next;
@@ -520,11 +520,17 @@
    return false;
 }
 
+static bool core_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+   print_debug("core_get_lwp_info not implemented\n");
+   return false;
+}
+
 static ps_prochandle_ops core_ops = {
    .release=  core_release,
    .p_pread=  core_read_data,
    .p_pwrite= core_write_data,
-   .get_lwp_regs= core_get_lwp_regs
+   .get_lwp_regs= core_get_lwp_regs,
+   .get_lwp_info= core_get_lwp_info
 };
 
 // read regs and create thread from NT_PRSTATUS entries from core file
@@ -539,52 +545,52 @@
       return false;
 
    // copy regs
-   memcpy(&newthr->regs, prstat->pr_reg, sizeof(struct user_regs_struct));
+   memcpy(&newthr->regs, &prstat->pr_reg, sizeof(struct reg));
 
    if (is_debug()) {
       print_debug("integer regset\n");
 #ifdef i386
       // print the regset
-      print_debug("\teax = 0x%x\n", newthr->regs.eax);
-      print_debug("\tebx = 0x%x\n", newthr->regs.ebx);
-      print_debug("\tecx = 0x%x\n", newthr->regs.ecx);
-      print_debug("\tedx = 0x%x\n", newthr->regs.edx);
-      print_debug("\tesp = 0x%x\n", newthr->regs.esp);
-      print_debug("\tebp = 0x%x\n", newthr->regs.ebp);
-      print_debug("\tesi = 0x%x\n", newthr->regs.esi);
-      print_debug("\tedi = 0x%x\n", newthr->regs.edi);
-      print_debug("\teip = 0x%x\n", newthr->regs.eip);
+      print_debug("\teax = 0x%x\n", newthr->regs.r_eax);
+      print_debug("\tebx = 0x%x\n", newthr->regs.r_ebx);
+      print_debug("\tecx = 0x%x\n", newthr->regs.r_ecx);
+      print_debug("\tedx = 0x%x\n", newthr->regs.r_edx);
+      print_debug("\tesp = 0x%x\n", newthr->regs.r_esp);
+      print_debug("\tebp = 0x%x\n", newthr->regs.r_ebp);
+      print_debug("\tesi = 0x%x\n", newthr->regs.r_esi);
+      print_debug("\tedi = 0x%x\n", newthr->regs.r_edi);
+      print_debug("\teip = 0x%x\n", newthr->regs.r_eip);
 #endif
 
 #if defined(amd64) || defined(x86_64)
       // print the regset
-      print_debug("\tr15 = 0x%lx\n", newthr->regs.r15);
-      print_debug("\tr14 = 0x%lx\n", newthr->regs.r14);
-      print_debug("\tr13 = 0x%lx\n", newthr->regs.r13);
-      print_debug("\tr12 = 0x%lx\n", newthr->regs.r12);
-      print_debug("\trbp = 0x%lx\n", newthr->regs.rbp);
-      print_debug("\trbx = 0x%lx\n", newthr->regs.rbx);
-      print_debug("\tr11 = 0x%lx\n", newthr->regs.r11);
-      print_debug("\tr10 = 0x%lx\n", newthr->regs.r10);
-      print_debug("\tr9 = 0x%lx\n", newthr->regs.r9);
-      print_debug("\tr8 = 0x%lx\n", newthr->regs.r8);
-      print_debug("\trax = 0x%lx\n", newthr->regs.rax);
-      print_debug("\trcx = 0x%lx\n", newthr->regs.rcx);
-      print_debug("\trdx = 0x%lx\n", newthr->regs.rdx);
-      print_debug("\trsi = 0x%lx\n", newthr->regs.rsi);
-      print_debug("\trdi = 0x%lx\n", newthr->regs.rdi);
-      print_debug("\torig_rax = 0x%lx\n", newthr->regs.orig_rax);
-      print_debug("\trip = 0x%lx\n", newthr->regs.rip);
-      print_debug("\tcs = 0x%lx\n", newthr->regs.cs);
-      print_debug("\teflags = 0x%lx\n", newthr->regs.eflags);
-      print_debug("\trsp = 0x%lx\n", newthr->regs.rsp);
-      print_debug("\tss = 0x%lx\n", newthr->regs.ss);
-      print_debug("\tfs_base = 0x%lx\n", newthr->regs.fs_base);
-      print_debug("\tgs_base = 0x%lx\n", newthr->regs.gs_base);
-      print_debug("\tds = 0x%lx\n", newthr->regs.ds);
-      print_debug("\tes = 0x%lx\n", newthr->regs.es);
-      print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
-      print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
+      print_debug("\tr15 = 0x%lx\n", newthr->regs.r_r15);
+      print_debug("\tr14 = 0x%lx\n", newthr->regs.r_r14);
+      print_debug("\tr13 = 0x%lx\n", newthr->regs.r_r13);
+      print_debug("\tr12 = 0x%lx\n", newthr->regs.r_r12);
+      print_debug("\trbp = 0x%lx\n", newthr->regs.r_rbp);
+      print_debug("\trbx = 0x%lx\n", newthr->regs.r_rbx);
+      print_debug("\tr11 = 0x%lx\n", newthr->regs.r_r11);
+      print_debug("\tr10 = 0x%lx\n", newthr->regs.r_r10);
+      print_debug("\tr9 = 0x%lx\n", newthr->regs.r_r9);
+      print_debug("\tr8 = 0x%lx\n", newthr->regs.r_r8);
+      print_debug("\trax = 0x%lx\n", newthr->regs.r_rax);
+      print_debug("\trcx = 0x%lx\n", newthr->regs.r_rcx);
+      print_debug("\trdx = 0x%lx\n", newthr->regs.r_rdx);
+      print_debug("\trsi = 0x%lx\n", newthr->regs.r_rsi);
+      print_debug("\trdi = 0x%lx\n", newthr->regs.r_rdi);
+      //print_debug("\torig_rax = 0x%lx\n", newthr->regs.orig_rax);
+      print_debug("\trip = 0x%lx\n", newthr->regs.r_rip);
+      print_debug("\tcs = 0x%lx\n", newthr->regs.r_cs);
+      //print_debug("\teflags = 0x%lx\n", newthr->regs.eflags);
+      print_debug("\trsp = 0x%lx\n", newthr->regs.r_rsp);
+      print_debug("\tss = 0x%lx\n", newthr->regs.r_ss);
+      //print_debug("\tfs_base = 0x%lx\n", newthr->regs.fs_base);
+      //print_debug("\tgs_base = 0x%lx\n", newthr->regs.gs_base);
+      //print_debug("\tds = 0x%lx\n", newthr->regs.ds);
+      //print_debug("\tes = 0x%lx\n", newthr->regs.es);
+      //print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
+      //print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
 #endif
    }
 
@@ -656,7 +662,7 @@
     * contains a set of saved /proc structures), and PT_LOAD (which
     * represents a memory mapping from the process's address space).
     *
-    * Difference b/w Solaris PT_NOTE and Bsd PT_NOTE:
+    * Difference b/w Solaris PT_NOTE and BSD PT_NOTE:
     *
     *     In Solaris there are two PT_NOTE segments the first PT_NOTE (if present)
     *     contains /proc structs in the pre-2.6 unstructured /proc format. the last
@@ -666,10 +672,10 @@
     *     integer register set among other stuff. For each LWP, we have one lwpstatus
     *     entry that has integer regset for that LWP.
     *
-    *     Bsd threads are actually 'clone'd processes. To support core analysis
-    *     of "multithreaded" process, Bsd creates more than one pstatus (called
+    *     Linux threads are actually 'clone'd processes. To support core analysis
+    *     of "multithreaded" process, Linux creates more than one pstatus (called
     *     "prstatus") entry in PT_NOTE. Each prstatus entry has integer regset for one
-    *     "thread". Please refer to Bsd kernel src file 'fs/binfmt_elf.c', in particular
+    *     "thread". Please refer to Linux kernel src file 'fs/binfmt_elf.c', in particular
     *     function "elf_core_dump".
     */
 
@@ -725,7 +731,7 @@
    return false;
 }
 
-// process segments from interpreter (ld.so or ld-bsd.so)
+// process segments from interpreter (ld-elf.so.1)
 static bool read_interp_segments(struct ps_prochandle* ph) {
    ELF_EHDR interp_ehdr;
 
@@ -826,7 +832,7 @@
 
    dyn.d_tag = DT_NULL;
    while (dyn.d_tag != DT_DEBUG) {
-      if (ps_pdread(ph, (psaddr_t) addr, &dyn, sizeof(ELF_DYN)) != PS_OK) {
+      if (ps_pread(ph, (psaddr_t) addr, &dyn, sizeof(ELF_DYN)) != PS_OK) {
          print_debug("can't read debug info from _DYNAMIC\n");
          return false;
       }
@@ -836,23 +842,27 @@
    // we have got Dyn entry with DT_DEBUG
    debug_base = dyn.d_un.d_ptr;
    // at debug_base we have struct r_debug. This has first link map in r_map field
-   if (ps_pdread(ph, (psaddr_t) debug_base + FIRST_LINK_MAP_OFFSET,
+   if (ps_pread(ph, (psaddr_t) debug_base + FIRST_LINK_MAP_OFFSET,
                  &first_link_map_addr, sizeof(uintptr_t)) != PS_OK) {
       print_debug("can't read first link map address\n");
       return false;
    }
 
    // read ld_base address from struct r_debug
-   if (ps_pdread(ph, (psaddr_t) debug_base + LD_BASE_OFFSET, &ld_base_addr,
+   // XXX: There is no r_ldbase member on BSD
+/*
+   if (ps_pread(ph, (psaddr_t) debug_base + LD_BASE_OFFSET, &ld_base_addr,
                  sizeof(uintptr_t)) != PS_OK) {
       print_debug("can't read ld base address\n");
       return false;
    }
    ph->core->ld_base_addr = ld_base_addr;
+*/
+   ph->core->ld_base_addr = 0;
 
    print_debug("interpreter base address is 0x%lx\n", ld_base_addr);
 
-   // now read segments from interp (i.e ld.so or ld-bsd.so)
+   // now read segments from interp (i.e ld-elf.so.1)
    if (read_interp_segments(ph) != true)
       return false;
 
@@ -870,26 +880,23 @@
       // address mentioned in shared object and the actual virtual base where runtime
       // linker loaded it. We use "base diff" in read_lib_segments call below.
 
-      if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_ADDR_OFFSET,
+      if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_ADDR_OFFSET,
                    &lib_base_diff, sizeof(uintptr_t)) != PS_OK) {
          print_debug("can't read shared object base address diff\n");
          return false;
       }
 
       // read address of the name
-      if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_NAME_OFFSET,
+      if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_NAME_OFFSET,
                     &lib_name_addr, sizeof(uintptr_t)) != PS_OK) {
          print_debug("can't read address of shared object name\n");
          return false;
       }
 
       // read name of the shared object
-      lib_name[0] = '\0';
-      if (lib_name_addr != 0 &&
-          read_string(ph, (uintptr_t) lib_name_addr, lib_name, sizeof(lib_name)) != true) {
+      if (read_string(ph, (uintptr_t) lib_name_addr, lib_name, sizeof(lib_name)) != true) {
          print_debug("can't read shared object name\n");
-         // don't let failure to read the name stop opening the file.  If something is really wrong
-         // it will fail later.
+         return false;
       }
 
       if (lib_name[0] != '\0') {
@@ -924,7 +931,7 @@
       }
 
       // read next link_map address
-      if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_NEXT_OFFSET,
+      if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_NEXT_OFFSET,
                         &link_map_addr, sizeof(uintptr_t)) != PS_OK) {
          print_debug("can't read next link in link_map\n");
          return false;
@@ -938,7 +945,6 @@
 struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
    ELF_EHDR core_ehdr;
    ELF_EHDR exec_ehdr;
-   ELF_EHDR lib_ehdr;
 
    struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle));
    if (ph == NULL) {
--- ./hotspot/agent/src/os/bsd/ps_proc.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/ps_proc.c	2011-04-22 22:28:31.000000000 -0700
@@ -22,20 +22,22 @@
  *
  */
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <sys/ptrace.h>
+#include <sys/param.h>
+#include <sys/user.h>
+#include <elf.h>
+#include <sys/elf_common.h>
+#include <sys/link_elf.h>
+#include <libutil.h>
 #include "libproc_impl.h"
-
-#if defined(x86_64) && !defined(amd64)
-#define amd64 1
-#endif
-
-#ifndef __WALL
-#define __WALL          0x40000000  // Copied from /usr/include/bsd/wait.h
-#endif
+#include "elfmacros.h"
 
 // This file has the libproc implementation specific to live process
 // For core files, refer to ps_core.c
@@ -50,253 +52,359 @@
 
 // read "size" bytes of data from "addr" within the target process.
 // unlike the standard ptrace() function, process_read_data() can handle
-// unaligned address - alignment check, if required, should be done
+// unaligned address - alignment check, if required, should be done 
 // before calling process_read_data.
 
 static bool process_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf, size_t size) {
-  long rslt;
+  int rslt;
   size_t i, words;
   uintptr_t end_addr = addr + size;
-  uintptr_t aligned_addr = align(addr, sizeof(long));
+  uintptr_t aligned_addr = align(addr, sizeof(int));
 
   if (aligned_addr != addr) {
     char *ptr = (char *)&rslt;
     errno = 0;
-    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+    rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
     if (errno) {
-      print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
+      print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
       return false;
     }
     for (; aligned_addr != addr; aligned_addr++, ptr++);
-    for (; ((intptr_t)aligned_addr % sizeof(long)) && aligned_addr < end_addr;
-        aligned_addr++)
+    for (; ((intptr_t)aligned_addr % sizeof(int)) && aligned_addr < end_addr; 
+        aligned_addr++) 
        *(buf++) = *(ptr++);
   }
 
-  words = (end_addr - aligned_addr) / sizeof(long);
+  words = (end_addr - aligned_addr) / sizeof(int);
 
-  // assert((intptr_t)aligned_addr % sizeof(long) == 0);
+  // assert((intptr_t)aligned_addr % sizeof(int) == 0);
   for (i = 0; i < words; i++) {
     errno = 0;
-    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+    rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
     if (errno) {
-      print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
+      print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
       return false;
     }
-    *(long *)buf = rslt;
-    buf += sizeof(long);
-    aligned_addr += sizeof(long);
+    *(int *)buf = rslt;
+    buf += sizeof(int);
+    aligned_addr += sizeof(int);
   }
 
   if (aligned_addr != end_addr) {
     char *ptr = (char *)&rslt;
     errno = 0;
-    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+    rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
     if (errno) {
-      print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
+      print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
       return false;
     }
-    for (; aligned_addr != end_addr; aligned_addr++)
+    for (; aligned_addr != end_addr; aligned_addr++) 
        *(buf++) = *(ptr++);
   }
   return true;
 }
 
 // null implementation for write
-static bool process_write_data(struct ps_prochandle* ph,
+static bool process_write_data(struct ps_prochandle* ph, 
                              uintptr_t addr, const char *buf , size_t size) {
   return false;
 }
 
-// "user" should be a pointer to a user_regs_struct
-static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct user_regs_struct *user) {
+// "user" should be a pointer to a reg
+static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct reg *user) {
   // we have already attached to all thread 'pid's, just use ptrace call
   // to get regset now. Note that we don't cache regset upfront for processes.
-// Bsd on x86 and sparc are different.  On x86 ptrace(PTRACE_GETREGS, ...)
-// uses pointer from 4th argument and ignores 3rd argument.  On sparc it uses
-// pointer from 3rd argument and ignores 4th argument
-#if defined(sparc) || defined(sparcv9)
-#define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, addr, data)
-#else
-#define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, data, addr)
-#endif
-
-#if defined(_LP64) && defined(PTRACE_GETREGS64)
-#define PTRACE_GETREGS_REQ PTRACE_GETREGS64
-#elif defined(PTRACE_GETREGS)
-#define PTRACE_GETREGS_REQ PTRACE_GETREGS
-#elif defined(PT_GETREGS)
-#define PTRACE_GETREGS_REQ PT_GETREGS
-#endif
-
-#ifdef PTRACE_GETREGS_REQ
- if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) {
+ if (ptrace(PT_GETREGS, pid, (caddr_t) user, 0) < 0) {
    print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
    return false;
  }
  return true;
-#else
- print_debug("ptrace(PTRACE_GETREGS, ...) not supported\n");
- return false;
-#endif
+}
+
+// fill in ptrace_lwpinfo for lid
+static bool process_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+  errno = 0;
+  ptrace(PT_LWPINFO, lwp_id, linfo, sizeof(struct ptrace_lwpinfo));
 
+  return (errno == 0)? true: false;
 }
 
 // attach to a process/thread specified by "pid"
 static bool ptrace_attach(pid_t pid) {
-  if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
+  if (ptrace(PT_ATTACH, pid, NULL, 0) < 0) {
     print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
     return false;
   } else {
     int ret;
     int status;
     do {
-      // Wait for debuggee to stop.
+      // Wait for debuggee to stop. 
       ret = waitpid(pid, &status, 0);
-      if (ret == -1 && errno == ECHILD) {
-        // try cloned process.
-        ret = waitpid(pid, &status, __WALL);
-      }
       if (ret >= 0) {
-        if (WIFSTOPPED(status)) {
-          // Debuggee stopped.
-          return true;
+	if (WIFSTOPPED(status)) {
+	  // Debuggee stopped.
+	  return true;
         } else {
-          print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
-          return false;
-        }
+    	  print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+	  return false;
+	}
       } else {
-        switch (errno) {
-          case EINTR:
+	switch (errno) {
+	  case EINTR: 
             continue;
-            break;
-          case ECHILD:
-            print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
-            break;
-          case EINVAL:
-            print_debug("waitpid() failed. Invalid options argument.\n");
-            break;
-          default:
-            print_debug("waitpid() failed. Unexpected error %d\n",errno);
+	    break;
+	  case ECHILD:
+    	    print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
+	    break;
+	  case EINVAL:
+    	    print_debug("waitpid() failed. Invalid options argument.\n");
+	    break;
+	  default:
+    	    print_debug("waitpid() failed. Unexpected error %d\n",errno);
         }
         return false;
-      }
+      } 
     } while(true);
-  }
-}
-
+  } 
+} 
+  
 // -------------------------------------------------------
 // functions for obtaining library information
 // -------------------------------------------------------
 
-/*
- * splits a string _str_ into substrings with delimiter _delim_ by replacing old * delimiters with _new_delim_ (ideally, '\0'). the address of each substring
- * is stored in array _ptrs_ as the return value. the maximum capacity of _ptrs_ * array is specified by parameter _n_.
- * RETURN VALUE: total number of substrings (always <= _n_)
- * NOTE: string _str_ is modified if _delim_!=_new_delim_
- */
-static int split_n_str(char * str, int n, char ** ptrs, char delim, char new_delim)
-{
-   int i;
-   for(i = 0; i < n; i++) ptrs[i] = NULL;
-   if (str == NULL || n < 1 ) return 0;
-
-   i = 0;
-
-   // skipping leading blanks
-   while(*str&&*str==delim) str++;
-
-   while(*str&&i<n){
-     ptrs[i++] = str;
-     while(*str&&*str!=delim) str++;
-     while(*str&&*str==delim) *(str++) = new_delim;
-   }
-
-   return i;
+// callback for read_thread_info
+static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
+  return add_thread_info(ph, pthread_id, lwp_id) != NULL;
 }
 
+#if defined(__FreeBSD__) && __FreeBSD_version < 701000
 /*
- * fgets without storing '\n' at the end of the string
+ * TEXT_START_ADDR from binutils/ld/emulparams/<arch_spec>.sh
+ * Not the most robust but good enough.
  */
-static char * fgets_no_cr(char * buf, int n, FILE *fp)
-{
-   char * rslt = fgets(buf, n, fp);
-   if (rslt && buf && *buf){
-       char *p = strchr(buf, '\0');
-       if (*--p=='\n') *p='\0';
-   }
-   return rslt;
-}
 
-// callback for read_thread_info
-static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
-  return add_thread_info(ph, pthread_id, lwp_id) != NULL;
+#if defined(amd64) || defined(x86_64)
+#define TEXT_START_ADDR 0x400000
+#elif defined(i386)
+#define TEXT_START_ADDR 0x8048000
+#else
+#error TEXT_START_ADDR not defined
+#endif
+
+#define BUF_SIZE (PATH_MAX + NAME_MAX + 1)
+
+uintptr_t linkmap_addr(struct ps_prochandle *ph) {
+  uintptr_t ehdr_addr, phdr_addr, dyn_addr, dmap_addr, lmap_addr;
+  ELF_EHDR ehdr;
+  ELF_PHDR *phdrs, *phdr;
+  ELF_DYN *dyns, *dyn;
+  struct r_debug dmap;
+  unsigned long hdrs_size;
+  unsigned int i;
+
+  /* read ELF_EHDR at TEXT_START_ADDR and validate */
+
+  ehdr_addr = (uintptr_t)TEXT_START_ADDR;
+
+  if (process_read_data(ph, ehdr_addr, (char *)&ehdr, sizeof(ehdr)) != true) {
+    print_debug("process_read_data failed for ehdr_addr %p\n", ehdr_addr);
+    return (0);
+  }
+
+  if (!IS_ELF(ehdr) ||
+        ehdr.e_ident[EI_CLASS] != ELF_TARG_CLASS ||
+        ehdr.e_ident[EI_DATA] != ELF_TARG_DATA ||
+        ehdr.e_ident[EI_VERSION] != EV_CURRENT ||
+        ehdr.e_phentsize != sizeof(ELF_PHDR) ||
+        ehdr.e_version != ELF_TARG_VER ||
+        ehdr.e_machine != ELF_TARG_MACH) {
+    print_debug("not an ELF_EHDR at %p\n", ehdr_addr);
+    return (0);
+  }
+
+  /* allocate space for all ELF_PHDR's and read */
+
+  phdr_addr = ehdr_addr + ehdr.e_phoff;
+  hdrs_size = ehdr.e_phnum * sizeof(ELF_PHDR);
+
+  if ((phdrs = malloc(hdrs_size)) == NULL)
+    return (0);
+
+  if (process_read_data(ph, phdr_addr, (char *)phdrs, hdrs_size) != true) {
+    print_debug("process_read_data failed for phdr_addr %p\n", phdr_addr);
+    return (0);
+  }
+
+  /* find PT_DYNAMIC section */
+
+  for (i = 0, phdr = phdrs; i < ehdr.e_phnum; i++, phdr++) {
+    if (phdr->p_type == PT_DYNAMIC)
+      break;
+  }
+
+  if (i >= ehdr.e_phnum) {
+    print_debug("PT_DYNAMIC section not found!\n");
+    free(phdrs);
+    return (0);
+  }
+
+  /* allocate space and read in ELF_DYN headers */
+
+  dyn_addr = phdr->p_vaddr;
+  hdrs_size = phdr->p_memsz;
+  free(phdrs);
+
+  if ((dyns = malloc(hdrs_size)) == NULL)
+    return (0);
+
+  if (process_read_data(ph, dyn_addr, (char *)dyns, hdrs_size) != true) {
+    print_debug("process_read_data failed for dyn_addr %p\n", dyn_addr);
+    free(dyns);
+    return (0);
+  }
+
+  /* find DT_DEBUG */
+  
+  dyn = dyns;
+  while (dyn->d_tag != DT_DEBUG && dyn->d_tag != DT_NULL) {
+    dyn++;
+  }
+
+  if (dyn->d_tag != DT_DEBUG) {
+    print_debug("failed to find DT_DEBUG\n");
+    free(dyns);
+    return (0);
+  }
+
+  /* read struct r_debug into dmap */
+
+  dmap_addr = (uintptr_t)dyn->d_un.d_ptr;
+  free(dyns);
+
+  if (process_read_data(ph, dmap_addr, (char *)&dmap, sizeof(dmap)) != true) {
+    print_debug("process_read_data failed for dmap_addr %p\n", dmap_addr);
+    return (0);
+  }
+
+  lmap_addr = (uintptr_t)dmap.r_map;
+
+  return (lmap_addr);
 }
+#endif // __FreeBSD__ && __FreeBSD_version < 701000
 
 static bool read_lib_info(struct ps_prochandle* ph) {
-  char fname[32];
-  char buf[256];
-  FILE *fp = NULL;
-
-  sprintf(fname, "/proc/%d/maps", ph->pid);
-  fp = fopen(fname, "r");
-  if (fp == NULL) {
-    print_debug("can't open /proc/%d/maps file\n", ph->pid);
-    return false;
+#if defined(__FreeBSD__) && __FreeBSD_version >= 701000
+  struct kinfo_vmentry *freep, *kve;
+  int i, cnt;
+
+  freep = kinfo_getvmmap(ph->pid, &cnt);
+  if (freep == NULL) {
+      print_debug("can't get vm map for pid\n", ph->pid);
+      return false;
   }
 
-  while(fgets_no_cr(buf, 256, fp)){
-    char * word[6];
-    int nwords = split_n_str(buf, 6, word, ' ', '\0');
-    if (nwords > 5 && find_lib(ph, word[5]) == false) {
-       intptr_t base;
-       lib_info* lib;
-#ifdef _LP64
-       sscanf(word[0], "%lx", &base);
-#else
-       sscanf(word[0], "%x", &base);
-#endif
-       if ((lib = add_lib_info(ph, word[5], (uintptr_t)base)) == NULL)
+  for (i = 0; i < cnt; i++) {
+    kve = &freep[i];
+    if ((kve->kve_flags & KVME_FLAG_COW) &&
+        kve->kve_path != NULL &&
+        strlen(kve->kve_path) > 0) {
+
+      if (find_lib(ph, kve->kve_path) == false) {
+        lib_info* lib;
+        if ((lib = add_lib_info(ph, kve->kve_path,
+                                (uintptr_t) kve->kve_start)) == NULL)
           continue; // ignore, add_lib_info prints error
 
-       // we don't need to keep the library open, symtab is already
-       // built. Only for core dump we need to keep the fd open.
-       close(lib->fd);
-       lib->fd = -1;
+        // we don't need to keep the library open, symtab is already
+        // built. Only for core dump we need to keep the fd open.
+        close(lib->fd);
+        lib->fd = -1;
+      }
     }
   }
-  fclose(fp);
+
+  free(freep);
+
   return true;
+#else
+  char *l_name;
+  struct link_map *lmap;
+  uintptr_t lmap_addr;
+
+  if ((l_name = malloc(BUF_SIZE)) == NULL)
+    return false;
+
+  if ((lmap = malloc(sizeof(*lmap))) == NULL) {
+    free(l_name);
+    return false;
+  }
+
+  lmap_addr = linkmap_addr(ph);
+
+  if (lmap_addr == 0) {
+    free(l_name);
+    free(lmap);
+    return false;
+  }
+
+  do {
+    if (process_read_data(ph, lmap_addr, (char *)lmap, sizeof(*lmap)) != true) {
+      print_debug("process_read_data failed for lmap_addr %p\n", lmap_addr);
+      free (l_name);
+      free (lmap);
+      return false;
+    }
+
+    if (process_read_data(ph, (uintptr_t)lmap->l_name, l_name,
+        BUF_SIZE) != true) {
+      print_debug("process_read_data failed for lmap->l_name %p\n",
+          lmap->l_name);
+      free (l_name);
+      free (lmap);
+      return false;
+    }
+
+    if (find_lib(ph, l_name) == false) {
+      lib_info* lib;
+      if ((lib = add_lib_info(ph, l_name,
+                              (uintptr_t) lmap->l_addr)) == NULL)
+        continue; // ignore, add_lib_info prints error
+
+      // we don't need to keep the library open, symtab is already
+      // built. Only for core dump we need to keep the fd open.
+      close(lib->fd);
+      lib->fd = -1;
+    }
+    lmap_addr = (uintptr_t)lmap->l_next;
+  } while (lmap->l_next != NULL);
+
+  free (l_name);
+  free (lmap);
+
+  return true;
+#endif
 }
 
 // detach a given pid
 static bool ptrace_detach(pid_t pid) {
-  if (pid && ptrace(PTRACE_DETACH, pid, NULL, NULL) < 0) {
+  if (pid && ptrace(PT_DETACH, pid, (caddr_t)1, 0) < 0) {
     print_debug("ptrace(PTRACE_DETACH, ..) failed for %d\n", pid);
     return false;
   } else {
     return true;
-  }
-}
-
-// detach all pids of a ps_prochandle
-static void detach_all_pids(struct ps_prochandle* ph) {
-  thread_info* thr = ph->threads;
-  while (thr) {
-     ptrace_detach(thr->lwp_id);
-     thr = thr->next;
-  }
+  } 
 }
 
 static void process_cleanup(struct ps_prochandle* ph) {
-  detach_all_pids(ph);
+  ptrace_detach(ph->pid);
 }
 
 static ps_prochandle_ops process_ops = {
   .release=  process_cleanup,
   .p_pread=  process_read_data,
   .p_pwrite= process_write_data,
-  .get_lwp_regs= process_get_lwp_regs
+  .get_lwp_regs= process_get_lwp_regs,
+  .get_lwp_info= process_get_lwp_info
 };
 
 // attach to the process. One and only one exposed stuff
@@ -323,21 +431,14 @@
   // read library info and symbol tables, must do this before attaching threads,
   // as the symbols in the pthread library will be used to figure out
   // the list of threads within the same process.
-  read_lib_info(ph);
-
+  if (read_lib_info(ph) != true) {
+     ptrace_detach(pid);
+     free(ph);
+     return NULL;
+  }
+ 
   // read thread info
   read_thread_info(ph, add_new_thread);
 
-  // attach to the threads
-  thr = ph->threads;
-  while (thr) {
-     // don't attach to the main thread again
-     if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id) != true) {
-        // even if one attach fails, we get return NULL
-        Prelease(ph);
-        return NULL;
-     }
-     thr = thr->next;
-  }
   return ph;
 }
--- ./hotspot/agent/src/os/bsd/salibelf.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/salibelf.c	2011-04-22 22:28:31.000000000 -0700
@@ -25,6 +25,7 @@
 #include "salibelf.h"
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 
 extern void print_debug(const char*,...);
 
--- ./hotspot/agent/src/os/bsd/symtab.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/symtab.c	2011-04-22 22:28:31.000000000 -0700
@@ -23,10 +23,10 @@
  */
 
 #include <unistd.h>
-#include <sys/procfs.h>
 #include <search.h>
 #include <stdlib.h>
 #include <string.h>
+#include "hsearch_r.h"
 #include "symtab.h"
 #include "salibelf.h"
 
@@ -53,276 +53,9 @@
   struct hsearch_data *hash_table;
 } symtab_t;
 
-
-// Directory that contains global debuginfo files.  In theory it
-// should be possible to change this, but in a Java environment there
-// is no obvious place to put a user interface to do it.  Maybe this
-// could be set with an environment variable.
-static const char debug_file_directory[] = "/usr/lib/debug";
-
-/* The CRC used in gnu_debuglink, retrieved from
-   http://sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html#Separate-Debug-Files. */
-unsigned int gnu_debuglink_crc32 (unsigned int crc,
-                                  unsigned char *buf, size_t len)
-{
-  static const unsigned int crc32_table[256] =
-    {
-      0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
-      0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
-      0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
-      0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
-      0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
-      0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
-      0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
-      0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-      0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
-      0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
-      0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
-      0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-      0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
-      0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
-      0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
-      0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-      0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
-      0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
-      0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
-      0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
-      0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
-      0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
-      0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
-      0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-      0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
-      0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
-      0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
-      0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
-      0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
-      0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
-      0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
-      0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-      0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
-      0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
-      0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
-      0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-      0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
-      0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
-      0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
-      0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-      0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
-      0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
-      0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
-      0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
-      0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
-      0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
-      0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
-      0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-      0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
-      0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
-      0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
-      0x2d02ef8d
-    };
-  unsigned char *end;
-
-  crc = ~crc & 0xffffffff;
-  for (end = buf + len; buf < end; ++buf)
-    crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
-  return ~crc & 0xffffffff;
-}
-
-/* Open a debuginfo file and check its CRC.  If it exists and the CRC
-   matches return its fd.  */
-static int
-open_debug_file (const char *pathname, unsigned int crc)
-{
-  unsigned int file_crc = 0;
-  unsigned char buffer[8 * 1024];
-
-  int fd = pathmap_open(pathname);
-
-  if (fd < 0)
-    return -1;
-
-  lseek(fd, 0, SEEK_SET);
-
-  for (;;) {
-    int len = read(fd, buffer, sizeof buffer);
-    if (len <= 0)
-      break;
-    file_crc = gnu_debuglink_crc32(file_crc, buffer, len);
-  }
-
-  if (crc == file_crc)
-    return fd;
-  else {
-    close(fd);
-    return -1;
-  }
-}
-
-/* Find an ELF section.  */
-static struct elf_section *find_section_by_name(char *name,
-                                                int fd,
-                                                ELF_EHDR *ehdr,
-                                                ELF_SHDR *shbuf,
-                                                struct elf_section *scn_cache)
-{
-  ELF_SHDR* cursct = NULL;
-  char *strtab;
-  int cnt;
-
-  if (scn_cache[ehdr->e_shstrndx].c_data == NULL) {
-    if ((scn_cache[ehdr->e_shstrndx].c_data
-         = read_section_data(fd, ehdr, cursct)) == NULL) {
-      return NULL;
-    }
-  }
-
-  strtab = scn_cache[ehdr->e_shstrndx].c_data;
-
-  for (cursct = shbuf, cnt = 0;
-       cnt < ehdr->e_shnum;
-       cnt++, cursct++) {
-    if (strcmp(cursct->sh_name + strtab, name) == 0) {
-      scn_cache[cnt].c_data = read_section_data(fd, ehdr, cursct);
-      return &scn_cache[cnt];
-    }
-  }
-
-  return NULL;
-}
-
-/* Look for a ".gnu_debuglink" section.  If one exists, try to open a
-   suitable debuginfo file.  */
-static int open_file_from_debug_link(const char *name,
-                                     int fd,
-                                     ELF_EHDR *ehdr,
-                                     ELF_SHDR *shbuf,
-                                     struct elf_section *scn_cache)
-{
-  int debug_fd;
-  struct elf_section *debug_link = find_section_by_name(".gnu_debuglink", fd, ehdr,
-                                                        shbuf, scn_cache);
-  if (debug_link == NULL)
-    return -1;
-  char *debug_filename = debug_link->c_data;
-  int offset = (strlen(debug_filename) + 4) >> 2;
-  static unsigned int crc;
-  crc = ((unsigned int*)debug_link->c_data)[offset];
-  char *debug_pathname = malloc(strlen(debug_filename)
-                                + strlen(name)
-                                + strlen(".debug/")
-                                + strlen(debug_file_directory)
-                                + 2);
-  strcpy(debug_pathname, name);
-  char *last_slash = strrchr(debug_pathname, '/');
-  if (last_slash == NULL)
-    return -1;
-
-  /* Look in the same directory as the object.  */
-  strcpy(last_slash+1, debug_filename);
-
-  debug_fd = open_debug_file(debug_pathname, crc);
-  if (debug_fd >= 0) {
-    free(debug_pathname);
-    return debug_fd;
-  }
-
-  /* Look in a subdirectory named ".debug".  */
-  strcpy(last_slash+1, ".debug/");
-  strcat(last_slash, debug_filename);
-
-  debug_fd = open_debug_file(debug_pathname, crc);
-  if (debug_fd >= 0) {
-    free(debug_pathname);
-    return debug_fd;
-  }
-
-  /* Look in /usr/lib/debug + the full pathname.  */
-  strcpy(debug_pathname, debug_file_directory);
-  strcat(debug_pathname, name);
-  last_slash = strrchr(debug_pathname, '/');
-  strcpy(last_slash+1, debug_filename);
-
-  debug_fd = open_debug_file(debug_pathname, crc);
-  if (debug_fd >= 0) {
-    free(debug_pathname);
-    return debug_fd;
-  }
-
-  free(debug_pathname);
-  return -1;
-}
-
-static struct symtab* build_symtab_internal(int fd, const char *filename, bool try_debuginfo);
-
-/* Look for a ".gnu_debuglink" section.  If one exists, try to open a
-   suitable debuginfo file and read a symbol table from it.  */
-static struct symtab *build_symtab_from_debug_link(const char *name,
-                                     int fd,
-                                     ELF_EHDR *ehdr,
-                                     ELF_SHDR *shbuf,
-                                     struct elf_section *scn_cache)
-{
-  fd = open_file_from_debug_link(name, fd, ehdr, shbuf, scn_cache);
-
-  if (fd >= 0) {
-    struct symtab *symtab = build_symtab_internal(fd, NULL, /* try_debuginfo */ false);
-    close(fd);
-    return symtab;
-  }
-
-  return NULL;
-}
-
-// Given a build_id, find the associated debuginfo file
-static char *
-build_id_to_debug_filename (size_t size, unsigned char *data)
-{
-  char *filename, *s;
-
-  filename = malloc(strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
-                    + 2 * size + (sizeof ".debug" - 1) + 1);
-  s = filename + sprintf (filename, "%s/.build-id/", debug_file_directory);
-  if (size > 0)
-    {
-      size--;
-      s += sprintf (s, "%02x", *data++);
-    }
-  if (size > 0)
-    *s++ = '/';
-  while (size-- > 0)
-    s += sprintf (s, "%02x", *data++);
-  strcpy (s, ".debug");
-
-  return filename;
-}
-
-// Read a build ID note.  Try to open any associated debuginfo file
-// and return its symtab
-static struct symtab* build_symtab_from_build_id(Elf64_Nhdr *note)
-{
-  int fd;
-  struct symtab *symtab = NULL;
-
-  unsigned char *bytes
-    = (unsigned char*)(note+1) + note->n_namesz;
-  unsigned char *filename
-    = (build_id_to_debug_filename (note->n_descsz, bytes));
-
-  fd = pathmap_open(filename);
-  if (fd >= 0) {
-    symtab = build_symtab_internal(fd, NULL, /* try_debuginfo */ false);
-    close(fd);
-  }
-  free(filename);
-
-  return symtab;
-}
-
-// read symbol table from given fd.  If try_debuginfo) is true, also
-// try to open an associated debuginfo file
-static struct symtab* build_symtab_internal(int fd, const char *filename, bool try_debuginfo) {
+// read symbol table from given fd.
+struct symtab* build_symtab(int fd) {
   ELF_EHDR ehdr;
-  char *names = NULL;
   struct symtab* symtab = NULL;
 
   // Reading of elf header
@@ -331,8 +64,9 @@
   ELF_SHDR* shbuf = NULL;
   ELF_SHDR* cursct = NULL;
   ELF_PHDR* phbuf = NULL;
-  ELF_PHDR* phdr = NULL;
-  int sym_section = SHT_DYNSYM;
+  int symtab_found = 0;
+  int dynsym_found = 0;
+  uint32_t symsection = SHT_SYMTAB;
 
   uintptr_t baseaddr = (uintptr_t)-1;
 
@@ -357,23 +91,30 @@
 
   for (cursct = shbuf, cnt = 0; cnt < ehdr.e_shnum; cnt++) {
     scn_cache[cnt].c_shdr = cursct;
-    if (cursct->sh_type == SHT_SYMTAB || cursct->sh_type == SHT_STRTAB
-        || cursct->sh_type == SHT_NOTE || cursct->sh_type == SHT_DYNSYM) {
+    if (cursct->sh_type == SHT_SYMTAB ||
+        cursct->sh_type == SHT_STRTAB ||
+        cursct->sh_type == SHT_DYNSYM) {
       if ( (scn_cache[cnt].c_data = read_section_data(fd, &ehdr, cursct)) == NULL) {
          goto quit;
       }
     }
-    if (cursct->sh_type == SHT_SYMTAB) {
-      // Full symbol table available so use that
-      sym_section = cursct->sh_type;
-    }
+
+    if (cursct->sh_type == SHT_SYMTAB)
+       symtab_found++;
+
+    if (cursct->sh_type == SHT_DYNSYM)
+       dynsym_found++;
+
     cursct++;
   }
 
+  if (!symtab_found && dynsym_found)
+     symsection = SHT_DYNSYM;
+
   for (cnt = 1; cnt < ehdr.e_shnum; cnt++) {
     ELF_SHDR *shdr = scn_cache[cnt].c_shdr;
 
-    if (shdr->sh_type == sym_section) {
+    if (shdr->sh_type == symsection) {
       ELF_SYM  *syms;
       int j, n, rslt;
       size_t size;
@@ -435,45 +176,6 @@
     }
   }
 
-  // Look for a separate debuginfo file.
-  if (try_debuginfo) {
-
-    // We prefer a debug symtab to an object's own symtab, so look in
-    // the debuginfo file.  We stash a copy of the old symtab in case
-    // there is no debuginfo.
-    struct symtab* prev_symtab = symtab;
-    symtab = NULL;
-
-#ifdef NT_GNU_BUILD_ID
-    // First we look for a Build ID
-    for (cursct = shbuf, cnt = 0;
-         symtab == NULL && cnt < ehdr.e_shnum;
-         cnt++) {
-      if (cursct->sh_type == SHT_NOTE) {
-        Elf64_Nhdr *note = (Elf64_Nhdr *)scn_cache[cnt].c_data;
-        if (note->n_type == NT_GNU_BUILD_ID) {
-          symtab = build_symtab_from_build_id(note);
-        }
-      }
-      cursct++;
-    }
-#endif
-
-    // Then, if that doesn't work, the debug link
-    if (symtab == NULL) {
-      symtab = build_symtab_from_debug_link(filename, fd, &ehdr, shbuf,
-                                            scn_cache);
-    }
-
-    // If we still haven't found a symtab, use the object's own symtab.
-    if (symtab != NULL) {
-      if (prev_symtab != NULL)
-        destroy_symtab(prev_symtab);
-    } else {
-      symtab = prev_symtab;
-    }
-  }
-
 quit:
   if (shbuf) free(shbuf);
   if (phbuf) free(phbuf);
@@ -488,11 +190,6 @@
   return symtab;
 }
 
-struct symtab* build_symtab(int fd, const char *filename) {
-  return build_symtab_internal(fd, filename, /* try_debuginfo */ true);
-}
-
-
 void destroy_symtab(struct symtab* symtab) {
   if (!symtab) return;
   if (symtab->strs) free(symtab->strs);
--- ./hotspot/agent/src/os/bsd/symtab.h	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/symtab.h	2011-04-22 22:28:31.000000000 -0700
@@ -32,7 +32,7 @@
 struct symtab;
 
 // build symbol table for a given ELF file descriptor
-struct symtab* build_symtab(int fd, const char *filename);
+struct symtab* build_symtab(int fd);
 
 // destroy the symbol table
 void destroy_symtab(struct symtab* symtab);
--- ./hotspot/agent/src/os/bsd/test.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/os/bsd/test.c	2011-04-22 22:28:31.000000000 -0700
@@ -44,7 +44,7 @@
       }
 
       default: {
-        printf("usage %s <pid> or %s <exec file> <core file>\n");
+        fprintf(stderr, "usage %s <pid> or %s <exec file> <core file>\n", argv[0], argv[0]);
         return 1;
       }
    }
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java	2011-05-26 17:24:32.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java	2011-04-22 22:28:31.000000000 -0700
@@ -28,6 +28,7 @@
 import java.net.*;
 import java.rmi.*;
 import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.*;
 import sun.jvm.hotspot.debugger.dbx.*;
 import sun.jvm.hotspot.debugger.proc.*;
 import sun.jvm.hotspot.debugger.remote.*;
@@ -337,6 +338,8 @@
                 setupDebuggerWin32();
             } else if (os.equals("linux")) {
                 setupDebuggerLinux();
+            } else if (os.equals("bsd")) {
+                setupDebuggerBsd();
             } else {
                 // Add support for more operating systems here
                 throw new DebuggerException("Operating system " + os + " not yet supported");
@@ -392,6 +395,10 @@
                 db = new HotSpotTypeDataBase(machDesc,
                 new LinuxVtblAccess(debugger, jvmLibNames),
                 debugger, jvmLibNames);
+            } else if (os.equals("bsd")) {
+                db = new HotSpotTypeDataBase(machDesc,
+                new BsdVtblAccess(debugger, jvmLibNames),
+                debugger, jvmLibNames);
             } else {
                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
             }
@@ -557,6 +564,8 @@
             setupJVMLibNamesWin32();
         } else if (os.equals("linux")) {
             setupJVMLibNamesLinux();
+        } else if (os.equals("bsd")) {
+            setupJVMLibNamesBsd();
         } else {
             throw new RuntimeException("Unknown OS type");
         }
@@ -638,6 +647,31 @@
         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
     }
 
+    //
+    // BSD
+    //
+
+    private void setupDebuggerBsd() {
+        setupJVMLibNamesBsd();
+
+        if (cpu.equals("x86")) {
+            machDesc = new MachineDescriptionIntelX86();
+        } else if (cpu.equals("amd64")) {
+            machDesc = new MachineDescriptionAMD64();
+        } else {
+            throw new DebuggerException("BSD only supported on x86/amd64");
+        }
+
+        BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
+        debugger = dbg;
+
+        attachDebugger();
+    }
+
+    private void setupJVMLibNamesBsd() {
+        jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
+    }
+
     /** Convenience routine which should be called by per-platform
       debugger setup. Should not be called when startupMode is
       REMOTE_MODE. */
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java	2011-05-26 17:25:12.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java	2011-04-22 22:28:31.000000000 -0700
@@ -29,6 +29,7 @@
 import java.rmi.*;
 import sun.jvm.hotspot.*;
 import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.*;
 import sun.jvm.hotspot.debugger.dbx.*;
 import sun.jvm.hotspot.debugger.proc.*;
 import sun.jvm.hotspot.debugger.cdbg.*;
@@ -516,6 +517,8 @@
                 setupDebuggerWin32();
             } else if (os.equals("linux")) {
                 setupDebuggerLinux();
+            } else if (os.equals("bsd")) {
+                setupDebuggerBsd();
             } else {
                 // Add support for more operating systems here
                 throw new DebuggerException("Operating system " + os + " not yet supported");
@@ -567,6 +570,9 @@
             } else if (os.equals("linux")) {
                 db = new HotSpotTypeDataBase(machDesc, new LinuxVtblAccess(debugger, jvmLibNames),
                 debugger, jvmLibNames);
+            } else if (os.equals("bsd")) {
+                db = new HotSpotTypeDataBase(machDesc, new BsdVtblAccess(debugger, jvmLibNames),
+                debugger, jvmLibNames);
             } else {
                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess implemented yet)");
             }
@@ -739,6 +745,8 @@
             setupJVMLibNamesWin32();
         } else if (os.equals("linux")) {
             setupJVMLibNamesLinux();
+        } else if (os.equals("bsd")) {
+            setupJVMLibNamesBsd();
         } else {
             throw new RuntimeException("Unknown OS type");
         }
@@ -822,6 +830,34 @@
         setupJVMLibNamesSolaris();
     }
 
+    //
+    // BSD
+    //
+
+    private void setupDebuggerBsd() {
+        setupJVMLibNamesBsd();
+
+        if (cpu.equals("x86")) {
+            machDesc = new MachineDescriptionIntelX86();
+        } else if (cpu.equals("amd64")) {
+            machDesc = new MachineDescriptionAMD64();
+        } else {
+            throw new DebuggerException("Bsd only supported on x86/amd64");
+        }
+
+        // Note we do not use a cache for the local debugger in server
+        // mode; it will be taken care of on the client side (once remote
+        // debugging is implemented).
+
+        debugger = new BsdDebuggerLocal(machDesc, !isServer);
+        attachDebugger();
+    }
+
+    private void setupJVMLibNamesBsd() {
+        // same as solaris
+        setupJVMLibNamesSolaris();
+    }
+
     /** Convenience routine which should be called by per-platform
       debugger setup. Should not be called when startupMode is
       REMOTE_MODE. */
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java	2011-04-22 22:28:32.000000000 -0700
@@ -30,10 +30,8 @@
 import sun.jvm.hotspot.debugger.cdbg.*;
 import sun.jvm.hotspot.debugger.x86.*;
 import sun.jvm.hotspot.debugger.amd64.*;
-import sun.jvm.hotspot.debugger.sparc.*;
 import sun.jvm.hotspot.debugger.bsd.x86.*;
 import sun.jvm.hotspot.debugger.bsd.amd64.*;
-import sun.jvm.hotspot.debugger.bsd.sparc.*;
 import sun.jvm.hotspot.utilities.*;
 
 class BsdCDebugger implements CDebugger {
@@ -99,13 +97,6 @@
        Address pc  = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
        if (pc == null) return null;
        return new BsdAMD64CFrame(dbg, rbp, pc);
-    } else if (cpu.equals("sparc")) {
-       SPARCThreadContext context = (SPARCThreadContext) thread.getContext();
-       Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
-       if (sp == null) return null;
-       Address pc  = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
-       if (pc == null) return null;
-       return new BsdSPARCCFrame(dbg, sp, pc, BsdDebuggerLocal.getAddressSize());
     } else {
        throw new DebuggerException(cpu + " is not yet supported");
     }
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java	2011-04-22 22:28:32.000000000 -0700
@@ -26,9 +26,7 @@
 
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.debugger.bsd.amd64.*;
-import sun.jvm.hotspot.debugger.bsd.ia64.*;
 import sun.jvm.hotspot.debugger.bsd.x86.*;
-import sun.jvm.hotspot.debugger.bsd.sparc.*;
 
 class BsdThreadContextFactory {
    static ThreadContext createThreadContext(BsdDebugger dbg) {
@@ -37,10 +35,6 @@
          return new BsdX86ThreadContext(dbg);
       } else if (cpu.equals("amd64")) {
          return new BsdAMD64ThreadContext(dbg);
-      } else if (cpu.equals("ia64")) {
-         return new BsdIA64ThreadContext(dbg);
-      } else if (cpu.equals("sparc")) {
-         return new BsdSPARCThreadContext(dbg);
       } else {
          throw new RuntimeException("cpu " + cpu + " is not yet supported");
       }
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/ia64/BsdIA64ThreadContext.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/ia64/BsdIA64ThreadContext.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.bsd.ia64;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.ia64.*;
-import sun.jvm.hotspot.debugger.bsd.*;
-
-public class BsdIA64ThreadContext extends IA64ThreadContext {
-  private BsdDebugger debugger;
-
-  public BsdIA64ThreadContext(BsdDebugger debugger) {
-    super();
-    this.debugger = debugger;
-  }
-
-  public void setRegisterAsAddress(int index, Address value) {
-    setRegister(index, debugger.getAddressValue(value));
-  }
-
-  public Address getRegisterAsAddress(int index) {
-    return debugger.newAddress(getRegister(index));
-  }
-}
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCCFrame.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCCFrame.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.bsd.sparc;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.sparc.*;
-import sun.jvm.hotspot.debugger.bsd.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.*;
-
-final public class BsdSPARCCFrame extends BasicCFrame {
-   // package/class internals only
-
-   public BsdSPARCCFrame(BsdDebugger dbg, Address sp, Address pc, int address_size) {
-      super(dbg.getCDebugger());
-      this.sp = sp;
-      this.pc = pc;
-      this.dbg = dbg;
-      this.address_size=address_size;
-      if (address_size==8) SPARC_STACK_BIAS = 0x7ff;
-      else SPARC_STACK_BIAS = 0x0;
-   }
-
-   // override base class impl to avoid ELF parsing
-   public ClosestSymbol closestSymbolToPC() {
-      // try native lookup in debugger.
-      return dbg.lookup(dbg.getAddressValue(pc()));
-   }
-
-   public Address pc() {
-      return     pc;
-   }
-
-   public Address localVariableBase() {
-      return sp;
-   }
-
-   public CFrame sender() {
-      if (sp == null) {
-        return null;
-      }
-
-      Address nextSP = sp.getAddressAt( SPARCThreadContext.R_SP * address_size + SPARC_STACK_BIAS);
-      if (nextSP == null) {
-        return null;
-      }
-      Address nextPC  = sp.getAddressAt(SPARCThreadContext.R_O7 * address_size + SPARC_STACK_BIAS);
-      if (nextPC == null) {
-        return null;
-      }
-      return new BsdSPARCCFrame(dbg, nextSP, nextPC,address_size);
-   }
-
-   public static int SPARC_STACK_BIAS;
-   private static int address_size;
-   private Address pc;
-   private Address sp;
-   private BsdDebugger dbg;
-}
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCThreadContext.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/sparc/BsdSPARCThreadContext.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.bsd.sparc;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.sparc.*;
-import sun.jvm.hotspot.debugger.bsd.*;
-
-public class BsdSPARCThreadContext extends SPARCThreadContext {
-  private BsdDebugger debugger;
-
-  public BsdSPARCThreadContext(BsdDebugger debugger) {
-    super();
-    this.debugger = debugger;
-  }
-
-  public void setRegisterAsAddress(int index, Address value) {
-    setRegister(index, debugger.getAddressValue(value));
-  }
-
-  public Address getRegisterAsAddress(int index) {
-    return debugger.newAddress(getRegister(index));
-  }
-}
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	2011-05-26 17:26:46.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	2011-04-22 22:28:32.000000000 -0700
@@ -37,6 +37,8 @@
 import sun.jvm.hotspot.runtime.linux_ia64.LinuxIA64JavaThreadPDAccess;
 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
 import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
+import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
+import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
 import sun.jvm.hotspot.utilities.*;
 
 public class Threads {
@@ -90,7 +92,12 @@
             } else if (cpu.equals("sparc")) {
                 access = new LinuxSPARCJavaThreadPDAccess();
             }
-
+        } else if (os.equals("bsd")) {
+            if (cpu.equals("x86")) {
+                access = new BsdX86JavaThreadPDAccess();
+            } else if (cpu.equals("amd64")) {
+                access = new BsdAMD64JavaThreadPDAccess();
+            }
         }
 
         if (access == null) {
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd/BsdSignals.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd/BsdSignals.java	2011-04-22 22:28:32.000000000 -0700
@@ -28,37 +28,36 @@
   private static String[] signalNames = {
     "",           /* No signal 0 */
     "SIGHUP",     /* hangup */
-    "SIGINT",     /* interrupt (rubout) */
-    "SIGQUIT",    /* quit (ASCII FS) */
-    "SIGILL",     /* illegal instruction (not reset when caught) */
+    "SIGINT",     /* interrupt */
+    "SIGQUIT",    /* quit */
+    "SIGILL",     /* illegal instr. (not reset when caught) */
     "SIGTRAP",    /* trace trap (not reset when caught) */
-    "SIGABRT",    /* used by abort, replace SIGIOT in the future */
-    "SIGIOT",
-    "SIGBUS",
+    "SIGABRT",    /* abort() */
+    "SIGEMT",     /* EMT instruction */
     "SIGFPE",     /* floating point exception */
     "SIGKILL",    /* kill (cannot be caught or ignored) */
-    "SIGUSR1",    /* user defined signal 1 */
+    "SIGBUS",     /* bus error */
     "SIGSEGV",    /* segmentation violation */
-    "SIGUSR2",    /* user defined signal 2 */
+    "SIGSYS",     /* non-existent system call invoked */
     "SIGPIPE",    /* write on a pipe with no one to read it */
     "SIGALRM",    /* alarm clock */
     "SIGTERM",    /* software termination signal from kill */
-    "SIGSTKFLT",
-    "SIGCHLD",    /* child status change alias */
-    "SIGCONT",    /* stopped process has been continued */
-    "SIGSTOP",    /* stop (cannot be caught or ignored) */
-    "SIGTSTP",    /* user stop requested from tty */
-    "SIGTTIN",    /* background tty read attempted */
-    "SIGTTOU",    /* background tty write attempted */
-    "SIGURG",     /* urgent socket condition */
-    "SIGXCPU",    /* exceeded cpu limit */
+    "SIGURG",     /* urgent condition on IO channel */
+    "SIGSTOP",    /* sendable stop signal not from tty */
+    "SIGTSTP",    /* stop signal from tty */
+    "SIGCONT",    /* continue a stopped process */
+    "SIGCHLD",    /* to parent on child stop or exit */
+    "SIGTTIN",    /* to readers pgrp upon background tty read */
+    "SIGTTOU",    /* like TTIN if (tp->t_local&LTOSTOP) */
+    "SIGIO",      /* input/output possible signal */
+    "SIGXCPU",    /* exceeded CPU time limit */
     "SIGXFSZ",    /* exceeded file size limit */
-    "SIGVTALRM",  /* virtual timer expired */
-    "SIGPROF",    /* profiling timer expired */
-    "SIGWINCH",   /* window size change */
-    "SIGPOLL",    /* pollable event occured */
-    "SIGPWR",     /* power-fail restart */
-    "SIGSYS"
+    "SIGVTALRM",  /* virtual time alarm */
+    "SIGPROF",    /* profiling time alarm */
+    "SIGWINCH",   /* window size changes */
+    "SIGINFO",    /* information request */
+    "SIGUSR1",    /* user defined signal 1 */
+    "SIGUSR2"     /* user defined signal 2 */
   };
 
   public static String getSignalName(int sigNum) {
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_ia64/BsdIA64JavaThreadPDAccess.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_ia64/BsdIA64JavaThreadPDAccess.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.runtime.bsd_ia64;
-
-import java.io.*;
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.ia64.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.runtime.ia64.*;
-import sun.jvm.hotspot.types.*;
-import sun.jvm.hotspot.utilities.*;
-
-public class BsdIA64JavaThreadPDAccess implements JavaThreadPDAccess {
-  // private static AddressField  lastJavaPCField;
-  // private static AddressField  lastJavaFPField;
-  private static AddressField  lastJavaIFrameField;
-  private static AddressField  osThreadField;
-
-  // Field from OSThread
-  private static CIntegerField osThreadPThreadIDField;
-
-  // This is currently unneeded but is being kept in case we change
-  // the currentFrameGuess algorithm
-  private static final long GUESS_SCAN_RANGE = 128 * 1024;
-
-  static {
-    VM.registerVMInitializedObserver(new Observer() {
-        public void update(Observable o, Object data) {
-          initialize(VM.getVM().getTypeDataBase());
-        }
-      });
-  }
-
-  private static synchronized void initialize(TypeDataBase db) {
-    Type type = db.lookupType("JavaThread");
-
-    lastJavaIFrameField     = type.getAddressField("_last_Java_iframe");
-    osThreadField           = type.getAddressField("_osthread");
-
-    type = db.lookupType("OSThread");
-    osThreadPThreadIDField   = type.getCIntegerField("_pthread_id");
-  }
-
-  public    Address getLastJavaIFrame(Address addr) {
-    return lastJavaIFrameField.getValue(addr);
-  }
-
-
-  public    Address getBaseOfStackPointer(Address addr) {
-    return null;
-  }
-
-  public Address getLastJavaFP(Address addr) {
-    return null; // Not in 1.4.1
-  }
-
-  public    Address getLastJavaPC(Address addr) {
-    return null; // Not in 1.4.1
-  }
-
-  public boolean isInterpretedFrame() {
-
-    // In 1.4.1 there are only interpreted frames
-    // and there is no pc
-    return true;
-  }
-
-  public    Frame getLastFramePD(JavaThread thread, Address addr) {
-    // The thread is the JavaThread that contains "this"
-    // so we don't need any new accessor at the JavaThread level
-    Address iframe = getLastJavaIFrame(addr);
-    Address pc = thread.getLastJavaPC();
-    if (iframe == null) {
-      return null; // no information
-    }
-    return new IA64Frame(thread.getLastJavaSP(), iframe, pc);
-  }
-
-  public    RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
-    return new IA64RegisterMap(thread, updateMap);
-  }
-
-  public    Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
-    return getLastFramePD(thread, addr);
-  }
-
-  public    void printThreadIDOn(Address addr, PrintStream tty) {
-    tty.print(getThreadProxy(addr));
-  }
-
-  public    void printInfoOn(Address threadAddr, PrintStream tty) {
-    tty.print("Thread id: ");
-    printThreadIDOn(threadAddr, tty);
-    tty.println("\nLastJavaIFrame: " + getLastJavaIFrame(threadAddr));
-  }
-
-  public    Address getLastSP(Address addr) {
-    ThreadProxy t = getThreadProxy(addr);
-    IA64ThreadContext context = (IA64ThreadContext) t.getContext();
-    return context.getRegisterAsAddress(IA64ThreadContext.SP);
-  }
-
-  public    ThreadProxy getThreadProxy(Address addr) {
-    // Addr is the address of the JavaThread.
-    // Fetch the OSThread (for now and for simplicity, not making a
-    // separate "OSThread" class in this package)
-    Address osThreadAddr = osThreadField.getValue(addr);
-    // Get the address of the _pthread_id from the OSThread
-    Address pthreadIdAddr = osThreadAddr.addOffsetTo(osThreadPThreadIDField.getOffset());
-
-    JVMDebugger debugger = VM.getVM().getDebugger();
-    return debugger.getThreadForIdentifierAddress(pthreadIdAddr);
-  }
-}
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_sparc/BsdSPARCJavaThreadPDAccess.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_sparc/BsdSPARCJavaThreadPDAccess.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.runtime.bsd_sparc;
-
-import java.io.*;
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.sparc.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.runtime.sparc.*;
-import sun.jvm.hotspot.types.*;
-import sun.jvm.hotspot.utilities.*;
-
-public class BsdSPARCJavaThreadPDAccess implements JavaThreadPDAccess {
-  private static AddressField baseOfStackPointerField;
-  private static AddressField postJavaStateField;
-  private static AddressField osThreadField;
-  private static int          isPC;
-  private static int          hasFlushed;
-
-  // Field from OSThread
-  private static CIntegerField osThreadThreadIDField;
-
-  static {
-    VM.registerVMInitializedObserver(new Observer() {
-        public void update(Observable o, Object data) {
-          initialize(VM.getVM().getTypeDataBase());
-        }
-      });
-  }
-
-  private static synchronized void initialize(TypeDataBase db) {
-    Type type = db.lookupType("JavaThread");
-    Type anchorType = db.lookupType("JavaFrameAnchor");
-
-    osThreadField           = type.getAddressField("_osthread");
-    hasFlushed              = db.lookupIntConstant("JavaFrameAnchor::flushed").intValue();
-
-    type = db.lookupType("OSThread");
-    osThreadThreadIDField   = type.getCIntegerField("_thread_id");
-  }
-
-  public    Address getLastJavaFP(Address addr) {
-        return null;
-
-  }
-
-  public    Address getLastJavaPC(Address addr) {
-    return null;
-  }
-
-  public Address getBaseOfStackPointer(Address addr) {
-    return baseOfStackPointerField.getValue(addr);
-  }
-
-  public Frame getLastFramePD(JavaThread thread, Address addr) {
-
-    // This assert doesn't work in the debugging case for threads
-    // which are running Java code and which haven't re-entered the
-    // runtime (e.g., through a Method.invoke() or otherwise). They
-    // haven't yet "decached" their last Java stack pointer to the
-    // thread.
-
-    //    if (Assert.ASSERTS_ENABLED) {
-    //      Assert.that(hasLastJavaFrame(), "must have last_Java_sp() when suspended");
-    //      // FIXME: add assertion about flushing register windows for runtime system
-    //      // (not appropriate for debugging system, though, unless at safepoin t)
-    //    }
-
-    // FIXME: I don't think this is necessary, but might be useful
-    // while debugging
-    if (thread.getLastJavaSP() == null) {
-      return null;
-    }
-
-    // sparc does a lazy window flush. The _flags field of the JavaFrameAnchor
-    // encodes whether the windows have flushed. Whenever the windows have flushed
-    // there will be a last_Java_pc.
-    // In a relective system we'd have to  do something to force the thread to flush
-    // its windows and give us the pc (or the younger_sp so we can find it ourselves)
-    // In a debugger situation (process or core) the flush should have happened and
-    // so if we don't have the younger sp we can find it
-    //
-    if (thread.getLastJavaPC() != null) {
-      return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), thread.getLastJavaPC());
-    } else {
-      Frame top = getCurrentFrameGuess(thread, addr);
-      return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()),
-                            SPARCFrame.biasSP(SPARCFrame.findYoungerSP(top.getSP(), thread.getLastJavaSP())),
-                            false);
-    }
-
-
-  }
-
-  public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
-    return new SPARCRegisterMap(thread, updateMap);
-  }
-
-  public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
-    ThreadProxy t = getThreadProxy(addr);
-    SPARCThreadContext context = (SPARCThreadContext) t.getContext();
-    // For now, let's see what happens if we do a similar thing to
-    // what the runtime code does. I suspect this may cause us to lose
-    // the top frame from the stack.
-    Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
-    Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_PC);
-
-    if ((sp == null) || (pc == null)) {
-      // Problems (have not hit this case so far, but would be bad to continue if we did)
-      return null;
-    }
-
-    return new SPARCFrame(sp, pc);
-  }
-
-
-  public void printThreadIDOn(Address addr, PrintStream tty) {
-    tty.print(getThreadProxy(addr));
-  }
-
-  public Address getLastSP(Address addr) {
-    ThreadProxy t = getThreadProxy(addr);
-    SPARCThreadContext context = (SPARCThreadContext) t.getContext();
-    return SPARCFrame.unBiasSP(context.getRegisterAsAddress(SPARCThreadContext.R_SP));
-  }
-
-  public void printInfoOn(Address threadAddr, PrintStream tty) {
-  }
-
-  public ThreadProxy getThreadProxy(Address addr) {
-    // Fetch the OSThread (for now and for simplicity, not making a
-    // separate "OSThread" class in this package)
-    Address osThreadAddr = osThreadField.getValue(addr);
-    // Get the address of the thread ID from the OSThread
-    Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
-
-    JVMDebugger debugger = VM.getVM().getDebugger();
-    return debugger.getThreadForIdentifierAddress(tidAddr);
-  }
-
-
-}
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_x86/BsdSignals.java	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_x86/BsdSignals.java	2011-04-22 22:28:32.000000000 -0700
@@ -28,37 +28,36 @@
   private static String[] signalNames = {
     "",           /* No signal 0 */
     "SIGHUP",     /* hangup */
-    "SIGINT",     /* interrupt (rubout) */
-    "SIGQUIT",    /* quit (ASCII FS) */
-    "SIGILL",     /* illegal instruction (not reset when caught) */
+    "SIGINT",     /* interrupt */
+    "SIGQUIT",    /* quit */
+    "SIGILL",     /* illegal instr. (not reset when caught) */
     "SIGTRAP",    /* trace trap (not reset when caught) */
-    "SIGABRT",    /* used by abort, replace SIGIOT in the future */
-    "SIGIOT",
-    "SIGBUS",
+    "SIGABRT",    /* abort() */
+    "SIGEMT",     /* EMT instruction */
     "SIGFPE",     /* floating point exception */
     "SIGKILL",    /* kill (cannot be caught or ignored) */
-    "SIGUSR1",    /* user defined signal 1 */
+    "SIGBUS",     /* bus error */
     "SIGSEGV",    /* segmentation violation */
-    "SIGUSR2",    /* user defined signal 2 */
+    "SIGSYS",     /* non-existent system call invoked */
     "SIGPIPE",    /* write on a pipe with no one to read it */
     "SIGALRM",    /* alarm clock */
     "SIGTERM",    /* software termination signal from kill */
-    "SIGSTKFLT",
-    "SIGCHLD",    /* child status change alias */
-    "SIGCONT",    /* stopped process has been continued */
-    "SIGSTOP",    /* stop (cannot be caught or ignored) */
-    "SIGTSTP",    /* user stop requested from tty */
-    "SIGTTIN",    /* background tty read attempted */
-    "SIGTTOU",    /* background tty write attempted */
-    "SIGURG",     /* urgent socket condition */
-    "SIGXCPU",    /* exceeded cpu limit */
+    "SIGURG",     /* urgent condition on IO channel */
+    "SIGSTOP",    /* sendable stop signal not from tty */
+    "SIGTSTP",    /* stop signal from tty */
+    "SIGCONT",    /* continue a stopped process */
+    "SIGCHLD",    /* to parent on child stop or exit */
+    "SIGTTIN",    /* to readers pgrp upon background tty read */
+    "SIGTTOU",    /* like TTIN if (tp->t_local&LTOSTOP) */
+    "SIGIO",      /* input/output possible signal */
+    "SIGXCPU",    /* exceeded CPU time limit */
     "SIGXFSZ",    /* exceeded file size limit */
-    "SIGVTALRM",  /* virtual timer expired */
-    "SIGPROF",    /* profiling timer expired */
-    "SIGWINCH",   /* window size change */
-    "SIGPOLL",    /* pollable event occured */
-    "SIGPWR",     /* power-fail restart */
-    "SIGSYS"
+    "SIGVTALRM",  /* virtual time alarm */
+    "SIGPROF",    /* profiling time alarm */
+    "SIGWINCH",   /* window size changes */
+    "SIGINFO",    /* information request */
+    "SIGUSR1",    /* user defined signal 1 */
+    "SIGUSR2"     /* user defined signal 2 */
   };
 
   public static String getSignalName(int sigNum) {
--- ./hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java	2011-05-26 17:27:16.000000000 -0700
+++ ./hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java	2011-04-22 22:28:33.000000000 -0700
@@ -37,6 +37,14 @@
       return "solaris";
     } else if (os.equals("Linux")) {
       return "linux";
+    } else if (os.equals("FreeBSD")) {
+      return "bsd";
+    } else if (os.equals("NetBSD")) {
+      return "bsd";
+    } else if (os.equals("OpenBSD")) {
+      return "bsd";
+    } else if (os.equals("Darwin")) {
+      return "bsd";
     } else if (os.startsWith("Windows")) {
       return "win32";
     } else {
--- ./hotspot/make/Makefile	2011-05-26 17:27:30.000000000 -0700
+++ ./hotspot/make/Makefile	2011-04-22 22:28:33.000000000 -0700
@@ -323,28 +323,28 @@
 ifneq ($(OSNAME),windows)
   ifeq ($(ZERO_BUILD), true)
     ifeq ($(SHARK_BUILD), true)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(SHARK_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_SERVER_DIR)/%.so:       $(SHARK_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
     else
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(ZERO_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_SERVER_DIR)/%.so:       $(ZERO_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
     endif
   else
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(C1_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(C2_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_CLIENT_DIR)/%.so:       $(C1_DIR)/%.so
+$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.so:    $(C1_DIR)/%.so
+$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_SERVER_DIR)/%.so:       $(C2_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.so:    $(C2_DIR)/%.so
+$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
   endif
 endif
--- ./hotspot/make/bsd/Makefile	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/Makefile	2011-05-07 21:53:43.000000000 -0700
@@ -39,11 +39,11 @@
 # One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
 # an architecture that differs from the target architecture, as long
 # as the bootstrap jdk runs under the same flavor of OS as the target
-# (i.e., if the target is bsd, point to a jdk that runs on a bsd
+# (i.e., if the target is linux, point to a jdk that runs on a linux
 # box).  In order to use such a bootstrap jdk, set the make variable
 # REMOTE to the desired remote command mechanism, e.g.,
 #
-#    make REMOTE="rsh -l me myotherbsdbox"
+#    make REMOTE="rsh -l me myotherlinuxbox"
 
 # Along with VM, Serviceability Agent (SA) is built for SA/JDI binding.
 # JDI binding on SA produces two binaries:
@@ -94,7 +94,7 @@
 #
 # We only do this on SunOS variants, for a couple of reasons:
 #  * It is extremely rare that source trees exist on other systems
-#  * It has been claimed that the Bsd automounter is flakey, so
+#  * It has been claimed that the Linux automounter is flakey, so
 #    changing GAMMADIR in a way that exercises the automounter could
 #    prove to be a source of unreliability in the build process.
 # Obviously, this Makefile is only relevant on SunOS boxes to begin
@@ -226,11 +226,12 @@
 
 checks: check_os_version check_j2se_version
 
-# We do not want people accidentally building on old systems (e.g. Bsd 2.2.x,
+# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
 # Solaris 2.5.1, 2.6).
 # Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
 
-SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7%
+#SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7%
+DISABLE_HOTSPOT_OS_VERSION_CHECK = ok
 OS_VERSION := $(shell uname -r)
 EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
 
--- ./hotspot/make/bsd/makefiles/buildtree.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/buildtree.make	2011-04-22 22:28:33.000000000 -0700
@@ -321,10 +321,11 @@
 	[ -n "$$JAVA_HOME" ] && { echo ": \$${JAVA_HOME:=$${JAVA_HOME}}"; }; \
 	{ \
 	echo "LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
+	echo "DYLD_LIBRARY_PATH=.:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
 	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
 	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
 	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
-	echo "export JAVA_HOME LD_LIBRARY_PATH CLASSPATH HOTSPOT_BUILD_USER"; \
+	echo "export JAVA_HOME LD_LIBRARY_PATH DYLD_LIBRARY_PATH CLASSPATH HOTSPOT_BUILD_USER"; \
 	) > $@
 
 env.csh: env.sh
@@ -389,6 +390,7 @@
 	echo '#!/bin/sh'; \
 	$(BUILDTREE_COMMENT); \
 	echo '. ./env.sh'; \
+	echo "exit 0;"; \
 	echo "if [ \"$(CROSS_COMPILE_ARCH)\" != \"\" ]; then { $(CROSS_COMPILING_MSG); exit 0; }; fi"; \
 	echo "if [ -z \$$JAVA_HOME ]; then { $(NO_JAVA_HOME_MSG); exit 0; }; fi"; \
 	echo "if ! \$${JAVA_HOME}/bin/java $(JAVA_FLAG) -fullversion 2>&1 > /dev/null"; \
--- ./hotspot/make/bsd/makefiles/cscope.make	1969-12-31 16:00:00.000000000 -0800
+++ ./hotspot/make/bsd/makefiles/cscope.make	2011-04-22 22:28:33.000000000 -0700
@@ -0,0 +1,160 @@
+#
+# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code 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 General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+#
+# The cscope.out file is made in the current directory and spans the entire
+# source tree.
+#
+# Things to note:
+#	1. We use relative names for cscope.
+#	2. We *don't* remove the old cscope.out file, because cscope is smart
+#	   enough to only build what has changed.  It can be confused, however,
+#	   if files are renamed or removed, so it may be necessary to manually
+#	   remove cscope.out if a lot of reorganization has occurred.
+#
+
+include $(GAMMADIR)/make/scm.make
+
+NAWK	= awk
+RM	= rm -f
+HG	= hg
+CS_TOP	= ../..
+
+CSDIRS	= $(CS_TOP)/src $(CS_TOP)/build
+CSINCS	= $(CSDIRS:%=-I%)
+
+CSCOPE		= cscope
+CSCOPE_FLAGS	= -b
+
+# Allow .java files to be added from the environment (CSCLASSES=yes).
+ifdef	CSCLASSES
+ADDCLASSES=	-o -name '*.java'
+endif
+
+# Adding CClassHeaders also pushes the file count of a full workspace up about
+# 200 files (these files also don't exist in a new workspace, and thus will
+# cause the recreation of the database as they get created, which might seem
+# a little confusing).  Thus allow these files to be added from the environment
+# (CSHEADERS=yes).
+ifndef	CSHEADERS
+RMCCHEADERS=	-o -name CClassHeaders
+endif
+
+# Use CS_GENERATED=x to include auto-generated files in the build directories.
+ifdef	CS_GENERATED
+CS_ADD_GENERATED	= -o -name '*.incl'
+else
+CS_PRUNE_GENERATED	= -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?'
+endif
+
+# OS-specific files for other systems are excluded by default.  Use CS_OS=yes
+# to include platform-specific files for other platforms.
+ifndef	CS_OS
+CS_OS		= linux macos solaris win32 bsd
+CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS}))
+endif
+
+# Processor-specific files for other processors are excluded by default.  Use
+# CS_CPU=x to include platform-specific files for other platforms.
+ifndef	CS_CPU
+CS_CPU		= i486 sparc amd64 ia64
+CS_PRUNE_CPU	= $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU}))
+endif
+
+# What files should we include?  A simple rule might be just those files under
+# SCCS control, however this would miss files we create like the opcodes and
+# CClassHeaders.  The following attempts to find everything that is *useful*.
+# (.del files are created by sccsrm, demo directories contain many .java files
+# that probably aren't useful for development, and the pkgarchive may contain
+# duplicates of files within the source hierarchy).
+
+# Directories to exclude.
+CS_PRUNE_STD	= $(SCM_DIRS) \
+		  -o -name '.del-*' \
+		  -o -name '*demo' \
+		  -o -name pkgarchive
+
+CS_PRUNE	= $(CS_PRUNE_STD) \
+		  $(CS_PRUNE_OS) \
+		  $(CS_PRUNE_CPU) \
+		  $(CS_PRUNE_GENERATED) \
+		  $(RMCCHEADERS)
+
+# File names to include.
+CSFILENAMES	= -name '*.[ch]pp' \
+		  -o -name '*.[Ccshlxy]' \
+		  $(CS_ADD_GENERATED) \
+		  -o -name '*.il' \
+		  -o -name '*.cc' \
+		  -o -name '*[Mm]akefile*' \
+		  -o -name '*.gmk' \
+		  -o -name '*.make' \
+		  -o -name '*.ad' \
+		  $(ADDCLASSES)
+
+.PRECIOUS:	cscope.out
+
+cscope cscope.out: cscope.files FORCE
+	$(CSCOPE) $(CSCOPE_FLAGS)
+
+# The .raw file is reordered here in an attempt to make cscope display the most
+# relevant files first.
+cscope.files: .cscope.files.raw
+	echo "$(CSINCS)" > $@
+	-egrep -v "\.java|\/make\/"	$< >> $@
+	-fgrep ".java"			$< >> $@
+	-fgrep "/make/"		$< >> $@
+
+.cscope.files.raw:  .nametable.files
+	-find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \
+	    -type f \( $(CSFILENAMES) \) -print > $@
+
+cscope.clean:  nametable.clean
+	-$(RM) cscope.out cscope.files .cscope.files.raw
+
+TAGS:  cscope.files FORCE
+	egrep -v '^-|^$$' $< | etags --members -
+
+TAGS.clean:  nametable.clean
+	-$(RM) TAGS
+
+# .nametable.files and .nametable.files.tmp are used to determine if any files
+# were added to/deleted from/renamed in the workspace.  If not, then there's
+# normally no need to rebuild the cscope database. To force a rebuild of
+# the cscope database: gmake nametable.clean.
+.nametable.files:  .nametable.files.tmp
+	( cmp -s $@ $< ) || ( cp $< $@ )
+	-$(RM) $<
+
+# `hg status' is slightly faster than `hg fstatus'. Both are
+# quite a bit slower on an NFS mounted file system, so this is
+# really geared towards repos on local file systems.
+.nametable.files.tmp:
+	-$(HG) fstatus -acmn > $@
+nametable.clean:
+	-$(RM) .nametable.files .nametable.files.tmp
+
+FORCE:
+
+.PHONY:		cscope cscope.clean TAGS.clean nametable.clean FORCE
--- ./hotspot/make/bsd/makefiles/defs.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/defs.make	2011-04-22 22:28:33.000000000 -0700
@@ -72,8 +72,8 @@
   HS_ARCH            = sparc
 endif
 
-# x86_64
-ifeq ($(ARCH), x86_64) 
+# amd64
+ifeq ($(ARCH), amd64) 
   ifeq ($(ARCH_DATA_MODEL), 64)
     ARCH_DATA_MODEL = 64
     MAKE_ARGS       += LP64=1
@@ -85,17 +85,27 @@
     PLATFORM        = bsd-i586
     VM_PLATFORM     = bsd_i486
     HS_ARCH         = x86
-    # We have to reset ARCH to i686 since SRCARCH relies on it
-    ARCH            = i686   
+    # We have to reset ARCH to i386 since SRCARCH relies on it
+    ARCH            = i386   
   endif
 endif
 
-# i686
-ifeq ($(ARCH), i686)
-  ARCH_DATA_MODEL  = 32
-  PLATFORM         = bsd-i586
-  VM_PLATFORM      = bsd_i486
-  HS_ARCH          = x86
+# i386
+ifeq ($(ARCH), i386)
+  ifeq ($(ARCH_DATA_MODEL), 64)
+    ARCH_DATA_MODEL = 64
+    MAKE_ARGS       += LP64=1
+    PLATFORM        = bsd-amd64
+    VM_PLATFORM     = bsd_amd64
+    HS_ARCH         = x86
+    # We have to reset ARCH to amd64 since SRCARCH relies on it
+    ARCH            = amd64
+  else
+    ARCH_DATA_MODEL  = 32
+    PLATFORM         = bsd-i586
+    VM_PLATFORM      = bsd_i486
+    HS_ARCH          = x86
+  endif
 endif
 
 # ARM
@@ -116,39 +126,45 @@
 
 JDK_INCLUDE_SUBDIR=bsd
 
+# Library suffix
+OS_VENDOR:=$(shell uname -s)
+ifeq ($(OS_VENDOR),Darwin)
+  LIBRARY_SUFFIX=dylib
+else
+  LIBRARY_SUFFIX=so
+endif
+
 # FIXUP: The subdirectory for a debug build is NOT the same on all platforms
 VM_DEBUG=jvmg
 
 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 
 # client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
 
 ifndef BUILD_CLIENT_ONLY
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
 endif
 
 ifneq ($(ZERO_BUILD), true)
   ifeq ($(ARCH_DATA_MODEL), 32)
     EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
     EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so 
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
   endif
 endif
 
 # Serviceability Binaries
 # No SA Support for PPC, IA64, ARM or zero
-ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so \
-                        $(EXPORT_LIB_DIR)/sa-jdi.jar 
-ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so \
-                        $(EXPORT_LIB_DIR)/sa-jdi.jar 
-ADD_SA_BINARIES/ppc   = 
-ADD_SA_BINARIES/ia64  = 
-ADD_SA_BINARIES/arm   = 
-ADD_SA_BINARIES/zero  = 
+ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                        $(EXPORT_LIB_DIR)/sa-jdi.jar
+ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                        $(EXPORT_LIB_DIR)/sa-jdi.jar
+ADD_SA_BINARIES/ppc   =
+ADD_SA_BINARIES/ia64  =
+ADD_SA_BINARIES/arm   =
+ADD_SA_BINARIES/zero  =
 
 EXPORT_LIST += $(ADD_SA_BINARIES/$(HS_ARCH))
-
-
--- ./hotspot/make/bsd/makefiles/gcc.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/gcc.make	2011-05-12 21:07:19.000000000 -0700
@@ -22,24 +22,28 @@
 #  
 #
 
+OS_VENDOR = $(shell uname -s)
+
 #------------------------------------------------------------------------
 # CC, CPP & AS
 
 # When cross-compiling the ALT_COMPILER_PATH points
 # to the cross-compilation toolset
 ifdef CROSS_COMPILE_ARCH
+CXX = $(ALT_COMPILER_PATH)/g++
 CPP = $(ALT_COMPILER_PATH)/g++
 CC  = $(ALT_COMPILER_PATH)/gcc
 HOSTCPP = g++
 HOSTCC  = gcc
 else
-CPP = g++
-CC  = gcc
+CXX ?= g++
+CPP = $(CXX)
+CC  ?= gcc
 HOSTCPP = $(CPP)
-HOSTCC  = $(CC)
+HOSTCC  = $(CPP)
 endif
 
-AS  = $(CC) -c
+AS   = $(CC) -c -x assembler-with-cpp
 
 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
 # prints the numbers (e.g. "2.95", "3.2.1")
@@ -77,7 +81,7 @@
 CFLAGS += $(VM_PICFLAG)
 CFLAGS += -fno-rtti
 CFLAGS += -fno-exceptions
-CFLAGS += -D_REENTRANT
+CFLAGS += -pthread
 CFLAGS += -fcheck-new
 # version 4 and above support fvisibility=hidden (matches jni_x86.h file)
 # except 4.1.2 gives pointless warnings that can't be disabled (afaik)
@@ -91,10 +95,12 @@
 ARCHFLAG/ia64    =
 ARCHFLAG/sparc   = -m32 -mcpu=v9
 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
-ARCHFLAG/arm     =  -fsigned-char
 ARCHFLAG/zero    = $(ZERO_ARCHFLAG)
-ifndef E500V2
-ARCHFLAG/ppc     =  -mcpu=powerpc
+
+# Darwin-specific build flags
+ifeq ($(OS_VENDOR), Darwin)
+  # Ineffecient 16-byte stack re-alignment on Darwin/IA32
+  ARCHFLAG/i486 += -mstackrealign
 endif
 
 CFLAGS     += $(ARCHFLAG)
@@ -139,6 +145,11 @@
 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
 # Special cases
 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
+# XXXDARWIN: for _dyld_bind_fully_image_containing_address
+ifeq ($(OS_VENDOR), Darwin)
+  CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
+endif
+
 
 # The flags to use for an Optimized g++ build
 OPT_CFLAGS += -O3
@@ -184,28 +195,40 @@
 LFLAGS += -Wl,-relax
 endif
 
-# Enable linker optimization
-LFLAGS += -Xlinker -O1
-
-# If this is a --hash-style=gnu system, use --hash-style=both
-#   The gnu .hash section won't work on some Bsd systems like SuSE 10.
-_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
-ifneq ($(_HAS_HASH_STYLE_GNU),)
-  LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
-endif
-LFLAGS += $(LDFLAGS_HASH_STYLE)
-
 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 MAPFLAG = -Xlinker --version-script=FILENAME
 
-# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
-SONAMEFLAG = -Xlinker -soname=SONAME
+#
+# Shared Library
+#
+ifeq ($(OS_VENDOR), Darwin)
+  # Standard linker flags
+  LFLAGS +=
+
+  # Darwin doesn't use ELF and doesn't support version scripts
+  LDNOMAP = true
+
+  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
+  SONAMEFLAG =
+
+  # Build shared library
+  SHARED_FLAG = -dynamiclib $(VM_PICFLAG)
 
-# Build shared library
-SHARED_FLAG = -shared
+  # Keep symbols even they are not used
+  #AOUT_FLAGS += -Xlinker -export-dynamic
+else
+  # Enable linker optimization
+  LFLAGS += -Xlinker -O1
+
+  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
+  SONAMEFLAG = -Xlinker -soname=SONAME
 
-# Keep symbols even they are not used
-AOUT_FLAGS += -Xlinker -export-dynamic
+  # Build shared library
+  SHARED_FLAG = -shared $(VM_PICFLAG)
+
+  # Keep symbols even they are not used
+  AOUT_FLAGS += -Xlinker -export-dynamic
+endif
 
 #------------------------------------------------------------------------
 # Debug flags
--- ./hotspot/make/bsd/makefiles/jsig.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/jsig.make	2011-04-22 22:28:33.000000000 -0700
@@ -25,11 +25,16 @@
 # Rules to build signal interposition library, used by vm.make
 
 # libjsig[_g].so: signal interposition library
-JSIG = jsig
-LIBJSIG = lib$(JSIG).so
+JSIG   = jsig
+JSIG_G = $(JSIG)$(G_SUFFIX)
 
-JSIG_G    = $(JSIG)$(G_SUFFIX)
-LIBJSIG_G = lib$(JSIG_G).so
+ifeq ($(OS_VENDOR), Darwin)
+  LIBJSIG   = lib$(JSIG).dylib
+  LIBJSIG_G = lib$(JSIG_G).dylib
+else
+  LIBJSIG   = lib$(JSIG).so
+  LIBJSIG_G = lib$(JSIG_G).so
+endif
 
 JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
 
@@ -42,7 +47,7 @@
 # cause problems with interposing. See CR: 6466665
 # LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
 
-LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE)
+LFLAGS_JSIG += -D_GNU_SOURCE -pthread $(LDFLAGS_HASH_STYLE)
 
 # DEBUG_BINARIES overrides everything, use full -g debug information
 ifeq ($(DEBUG_BINARIES), true)
@@ -52,7 +57,7 @@
 $(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
 	@echo Making signal interposition lib...
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
-                         $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $< -ldl
+                         $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $<
 	$(QUIETLY) [ -f $(LIBJSIG_G) ] || { ln -s $@ $(LIBJSIG_G); }
 
 install_jsig: $(LIBJSIG)
--- ./hotspot/make/bsd/makefiles/launcher.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/launcher.make	2011-04-22 22:28:33.000000000 -0700
@@ -50,7 +50,7 @@
   LIBS_LAUNCHER             += $(STATIC_STDCXX) $(LIBS)
 else
   LAUNCHER.o                 = launcher.o
-  LFLAGS_LAUNCHER           += -L `pwd`
+  LFLAGS_LAUNCHER           += -L`pwd`
   LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
 endif
 
--- ./hotspot/make/bsd/makefiles/sa.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/sa.make	2011-04-23 12:15:44.000000000 -0700
@@ -45,8 +45,8 @@
 
 # gnumake 3.78.1 does not accept the *s that
 # are in AGENT_FILES1 and AGENT_FILES2, so use the shell to expand them
-AGENT_FILES1 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES1))
-AGENT_FILES2 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES2))
+AGENT_FILES1 := $(shell /bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES1))
+AGENT_FILES2 := $(shell /bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES2))
 
 AGENT_FILES1_LIST := $(GENERATED)/agent1.classes.list
 AGENT_FILES2_LIST := $(GENERATED)/agent2.classes.list
--- ./hotspot/make/bsd/makefiles/saproc.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/saproc.make	2011-04-22 22:28:33.000000000 -0700
@@ -25,23 +25,34 @@
 # Rules to build serviceability agent library, used by vm.make
 
 # libsaproc[_g].so: serviceability agent
-
-SAPROC = saproc
-LIBSAPROC = lib$(SAPROC).so
-
+SAPROC   = saproc
 SAPROC_G = $(SAPROC)$(G_SUFFIX)
-LIBSAPROC_G = lib$(SAPROC_G).so
+
+ifeq ($(OS_VENDOR), Darwin)
+  LIBSAPROC   = lib$(SAPROC).dylib
+  LIBSAPROC_G = lib$(SAPROC_G).dylib
+else
+  LIBSAPROC   = lib$(SAPROC).so
+  LIBSAPROC_G = lib$(SAPROC_G).so
+endif
 
 AGENT_DIR = $(GAMMADIR)/agent
 
 SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)
 
+ifeq ($(OS_VENDOR), FreeBSD)
 SASRCFILES = $(SASRCDIR)/salibelf.c                   \
              $(SASRCDIR)/symtab.c                     \
              $(SASRCDIR)/libproc_impl.c               \
              $(SASRCDIR)/ps_proc.c                    \
              $(SASRCDIR)/ps_core.c                    \
+             $(SASRCDIR)/hsearch_r.c                  \
              $(SASRCDIR)/BsdDebuggerLocal.c
+SALIBS = -lutil -lthread_db
+else
+SASRCFILES = $(SASRCDIR)/StubDebuggerLocal.c
+SALIBS = 
+endif
 
 SAMAPFILE = $(SASRCDIR)/mapfile
 
@@ -62,7 +73,10 @@
 endif
 
 
-SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) $(LDFLAGS_HASH_STYLE)
+ifneq ($(OS_VENDOR), Darwin)
+SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE))
+endif
+SA_LFLAGS += $(LDFLAGS_HASH_STYLE)
 
 $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
 	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
@@ -75,12 +89,12 @@
 	           -I$(SASRCDIR)                                        \
 	           -I$(GENERATED)                                       \
 	           -I$(BOOT_JAVA_HOME)/include                          \
-	           -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family)    \
+	           -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \
 	           $(SASRCFILES)                                        \
 	           $(SA_LFLAGS)                                         \
 	           $(SA_DEBUG_CFLAGS)                                   \
 	           -o $@                                                \
-	           -lthread_db
+	           $(SALIBS)
 	$(QUIETLY) [ -f $(LIBSAPROC_G) ] || { ln -s $@ $(LIBSAPROC_G); }
 
 install_saproc: $(BUILDLIBSAPROC)
--- ./hotspot/make/bsd/makefiles/vm.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/vm.make	2011-05-14 23:15:36.000000000 -0700
@@ -92,6 +92,10 @@
   ${JRE_VERSION}     \
   ${VM_DISTRO}
 
+ifdef DEFAULT_LIBPATH
+CPPFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
+endif
+
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 CFLAGS += $(CFLAGS_WARN/BYFILE)
 
@@ -104,9 +108,11 @@
 
 # Don't set excutable bit on stack segment
 # the same could be done by separate execstack command
+ifneq ($(OS_VENDOR), Darwin)
 LFLAGS += -Xlinker -z -Xlinker noexecstack
+endif
 
-LIBS += -lm -ldl -lpthread
+LIBS += -lm -pthread
 
 # By default, link the *.o into the library, not the executable.
 LINK_INTO$(LINK_INTO) = LIBJVM
@@ -120,9 +126,15 @@
 #----------------------------------------------------------------------
 # JVM
 
-JVM      = jvm
-LIBJVM   = lib$(JVM).so
-LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
+JVM    = jvm
+ifeq ($(OS_VENDOR), Darwin)
+  LIBJVM   = lib$(JVM).dylib
+  LIBJVM_G = lib$(JVM)$(G_SUFFIX).dylib
+  CFLAGS  += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
+else
+  LIBJVM   = lib$(JVM).so
+  LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
+endif
 
 SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt
 
@@ -213,15 +225,7 @@
 vm.def: $(Res_Files) $(Obj_Files)
 	sh $(GAMMADIR)/make/bsd/makefiles/build_vm_def.sh *.o > $@
 
-ifeq ($(SHARK_BUILD), true)
-  STATIC_CXX = false
-else
-  ifeq ($(ZERO_LIBARCH), ppc64)
-    STATIC_CXX = false
-  else
-    STATIC_CXX = true
-  endif
-endif
+STATIC_CXX = false
 
 ifeq ($(LINK_INTO),AOUT)
   LIBJVM.o                 =
@@ -233,14 +237,21 @@
   LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
   LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
 
+  ifeq ($(OS_VENDOR), Darwin)
+    LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/.
+    LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/..
+    LFLAGS_VM += -Xlinker -install_name -Xlinker @rpath/$(@F)
+  endif
+
   # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
   # get around library dependency and compatibility issues. Must use gcc not
   # g++ to link.
   ifeq ($(STATIC_CXX), true)
     LFLAGS_VM              += $(STATIC_LIBGCC)
     LIBS_VM                += $(STATIC_STDCXX)
+    LINK_VM                = $(LINK_LIB.c)
   else
-    LIBS_VM                += -lstdc++
+    LINK_VM                = $(LINK_LIB.CC)
   endif
 
   LIBS_VM                  += $(LIBS)
@@ -253,7 +264,6 @@
   LIBS_VM   += $(LLVM_LIBS)
 endif
 
-LINK_VM = $(LINK_LIB.c)
 
 # rule for building precompiled header
 $(PRECOMPILED_HEADER):
@@ -281,11 +291,6 @@
 LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
 endif
 
-# With more recent Redhat releases (or the cutting edge version Fedora), if
-# SEBsd is configured to be enabled, the runtime linker will fail to apply
-# the text relocation to libjvm.so considering that it is built as a non-PIC
-# DSO. To workaround that, we run chcon to libjvm.so after it is built. See 
-# details in bug 6538311.
 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
 	$(QUIETLY) {                                                    \
 	    echo Linking vm...;                                         \
@@ -295,17 +300,6 @@
 	    $(LINK_LIB.CC/POST_HOOK)                                    \
 	    rm -f $@.1; ln -s $@ $@.1;                                  \
 	    [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \
-            if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then                    \
-	      if [ -x /usr/sbin/sebsdenabled ] ; then                 \
-	        /usr/sbin/sebsdenabled;                               \
-                if [ $$? = 0 ] ; then					\
-		  /usr/bin/chcon -t textrel_shlib_t $@;                 \
-		  if [ $$? != 0 ]; then                                 \
-		    echo "ERROR: Cannot chcon $@";			\
-		  fi							\
-	        fi							\
-	      fi                                                        \
-            fi 								\
 	}
 
 DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
--- ./hotspot/make/bsd/makefiles/zeroshark.make	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/makefiles/zeroshark.make	2011-04-22 22:28:33.000000000 -0700
@@ -40,4 +40,23 @@
   CFLAGS += -D_LP64=1
 endif
 
+# Specify the path to the FFI headers
+ifdef ALT_PACKAGE_PATH
+  PACKAGE_PATH = $(ALT_PACKAGE_PATH)
+else
+  ifeq ($(OS_VENDOR),Apple)
+    PACKAGE_PATH = /opt/local
+  else
+    ifeq ($(OS_VENDOR),NetBSD)
+      PACKAGE_PATH = /usr/pkg
+      LIBS += -Wl,-R${PACKAGE_PATH}/lib
+    else
+      PACKAGE_PATH = /usr/local
+    endif
+  endif
+endif
+
+CFLAGS += -I$(PACKAGE_PATH)/include
+LIBS += -L$(PACKAGE_PATH)/lib -lffi
+
 OPT_CFLAGS/compactingPermGenGen.o = -O1
--- ./hotspot/make/bsd/platform_amd64	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_amd64	2011-04-22 22:28:33.000000000 -0700
@@ -12,4 +12,4 @@
 
 compiler = gcc
 
-sysdefs = -DBSD -D_GNU_SOURCE -DAMD64
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64
--- ./hotspot/make/bsd/platform_amd64.suncc	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_amd64.suncc	2011-04-22 22:28:33.000000000 -0700
@@ -14,4 +14,4 @@
 
 gnu_dis_arch = amd64
 
-sysdefs = -DBSD -DSPARC_WORKS -D_GNU_SOURCE -DAMD64
+sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DAMD64
--- ./hotspot/make/bsd/platform_arm	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_arm	1969-12-31 16:00:00.000000000 -0800
@@ -1,17 +0,0 @@
-os_family = bsd
-
-arch = arm
-
-arch_model = arm
-
-os_arch = bsd_arm
-
-os_arch_model = bsd_arm
-
-lib_arch = arm
-
-compiler = gcc
-
-gnu_dis_arch = arm
-
-sysdefs = -DBSD -D_GNU_SOURCE -DARM
--- ./hotspot/make/bsd/platform_i486	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_i486	2011-04-22 22:28:33.000000000 -0700
@@ -12,4 +12,4 @@
 
 compiler = gcc
 
-sysdefs = -DBSD -D_GNU_SOURCE -DIA32
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA32
--- ./hotspot/make/bsd/platform_i486.suncc	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_i486.suncc	2011-04-22 22:28:33.000000000 -0700
@@ -14,4 +14,4 @@
 
 gnu_dis_arch = i386
 
-sysdefs = -DBSD -DSPARC_WORKS -D_GNU_SOURCE -DIA32
+sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DIA32
--- ./hotspot/make/bsd/platform_ia64	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_ia64	2011-04-22 22:28:33.000000000 -0700
@@ -10,6 +10,6 @@
 
 gnu_dis_arch = ia64
 
-sysdefs = -DBSD -D_GNU_SOURCE -DIA64 -DCC_INTERP
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA64 -DCC_INTERP
 
 mark_style = alignment
--- ./hotspot/make/bsd/platform_ppc	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_ppc	1969-12-31 16:00:00.000000000 -0800
@@ -1,17 +0,0 @@
-os_family = bsd
-
-arch = ppc
-
-arch_model = ppc
-
-os_arch = bsd_ppc
-
-os_arch_model = bsd_ppc
-
-lib_arch = ppc
-
-compiler = gcc
-
-gnu_dis_arch = ppc
-
-sysdefs = -DBSD -D_GNU_SOURCE -DPPC
--- ./hotspot/make/bsd/platform_sparc	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_sparc	2011-04-22 22:28:33.000000000 -0700
@@ -12,4 +12,4 @@
 
 compiler = gcc
 
-sysdefs = -DBSD -D_GNU_SOURCE -DSPARC
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC
--- ./hotspot/make/bsd/platform_sparcv9	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_sparcv9	2011-04-22 22:28:33.000000000 -0700
@@ -12,4 +12,4 @@
 
 compiler = gcc
 
-sysdefs = -DBSD -D_GNU_SOURCE -DSPARC
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC
--- ./hotspot/make/bsd/platform_zero.in	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/make/bsd/platform_zero.in	2011-04-22 22:28:33.000000000 -0700
@@ -14,4 +14,4 @@
 
 gnu_dis_arch = zero
 
-sysdefs = -DBSD -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\"
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\"
--- ./hotspot/make/cscope.make	2011-05-26 17:27:31.000000000 -0700
+++ ./hotspot/make/cscope.make	2011-05-07 23:28:29.000000000 -0700
@@ -63,7 +63,7 @@
 # space-separated list of identifiers to include only those systems.
 ifdef	CS_OS
 CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',\
-		    $(filter-out ${CS_OS},linux macos solaris windows))
+		    $(filter-out ${CS_OS},bsd linux macos solaris windows))
 endif
 
 # CPU-specific files for all processors are included by default.  Set CS_CPU 
--- ./hotspot/make/defs.make	2011-05-26 17:27:31.000000000 -0700
+++ ./hotspot/make/defs.make	2011-04-22 22:28:33.000000000 -0700
@@ -118,13 +118,23 @@
 # Windows should have OS predefined
 ifeq ($(OS),)
   OS   := $(shell uname -s)
+  ifneq ($(findstring BSD,$(OS)),)
+    OS=bsd
+  endif
+  ifeq ($(OS), Darwin)
+    OS=bsd
+  endif
   HOST := $(shell uname -n)
 endif
 
-# If not SunOS and not Linux, assume Windows
+# If not SunOS, not Linux and not BSD, assume Windows
 ifneq ($(OS), Linux)
   ifneq ($(OS), SunOS)
-    OSNAME=windows
+    ifneq ($(OS), bsd)
+      OSNAME=windows
+    else
+      OSNAME=bsd
+    endif
   else
     OSNAME=solaris
   endif
--- ./hotspot/make/linux/makefiles/defs.make	2011-05-26 17:27:34.000000000 -0700
+++ ./hotspot/make/linux/makefiles/defs.make	2011-04-22 22:28:33.000000000 -0700
@@ -116,33 +116,36 @@
 
 JDK_INCLUDE_SUBDIR=linux
 
+# Library suffix
+LIBRARY_SUFFIX=so
+
 # FIXUP: The subdirectory for a debug build is NOT the same on all platforms
 VM_DEBUG=jvmg
 
 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 
 # client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
 
 ifndef BUILD_CLIENT_ONLY
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
 endif
 
 ifneq ($(ZERO_BUILD), true)
   ifeq ($(ARCH_DATA_MODEL), 32)
     EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
     EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so 
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
   endif
 endif
 
 # Serviceability Binaries
 # No SA Support for PPC, IA64, ARM or zero
-ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so \
+ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
                         $(EXPORT_LIB_DIR)/sa-jdi.jar 
-ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so \
+ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
                         $(EXPORT_LIB_DIR)/sa-jdi.jar 
 ADD_SA_BINARIES/ppc   = 
 ADD_SA_BINARIES/ia64  = 
--- ./hotspot/make/sa.files	2011-05-26 17:27:40.000000000 -0700
+++ ./hotspot/make/sa.files	2011-04-22 22:28:33.000000000 -0700
@@ -50,6 +50,9 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/compiler/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \
@@ -95,6 +98,9 @@
 AGENT_FILES2 = \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd_amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd_x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/ia64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/linux/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/linux_amd64/*.java \
--- ./hotspot/make/solaris/makefiles/defs.make	2011-05-26 17:27:42.000000000 -0700
+++ ./hotspot/make/solaris/makefiles/defs.make	2011-04-22 22:28:33.000000000 -0700
@@ -61,34 +61,37 @@
 
 JDK_INCLUDE_SUBDIR=solaris
 
+# Library suffix
+LIBRARY_SUFFIX=so
+
 # FIXUP: The subdirectory for a debug build is NOT the same on all platforms
 VM_DEBUG=jvmg
 
 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 
-# client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so
+# client and server subdirectories have symbolic links to ../libjsig.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
 
 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
 ifneq ($(BUILD_CLIENT_ONLY),true)
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.so
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.so
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX)
 endif
 ifeq ($(ARCH_DATA_MODEL), 32)
   EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so 
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.so 
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.so
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.so
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.so
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.$(LIBRARY_SUFFIX)
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX)
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX)
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX)
   ifneq ($(BUILD_CLIENT_ONLY), true)
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.so
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.so
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX)
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX)
   endif
 endif
 
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX)
 EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar 
--- ./hotspot/make/templates/bsd-header	2011-05-26 17:27:52.000000000 -0700
+++ ./hotspot/make/templates/bsd-header	1969-12-31 16:00:00.000000000 -0800
@@ -1,28 +0,0 @@
-Copyright (c) %YEARS%, Oracle and/or its affiliates. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-  - Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
-
-  - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
-
-  - Neither the name of Oracle nor the names of its
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- ./hotspot/make/windows/makefiles/defs.make	2011-05-26 17:27:54.000000000 -0700
+++ ./hotspot/make/windows/makefiles/defs.make	2011-04-22 22:28:33.000000000 -0700
@@ -109,6 +109,9 @@
 
 JDK_INCLUDE_SUBDIR=win32
 
+# Library suffix
+LIBRARY_SUFFIX=dll
+
 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
 # and added to MAKE_ARGS list in $(GAMMADIR)/make/defs.make.
 
@@ -172,26 +175,26 @@
 
 EXPORT_SERVER_DIR = $(EXPORT_JRE_BIN_DIR)/server
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.dll
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.$(LIBRARY_SUFFIX)
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.pdb
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.map
 EXPORT_LIST += $(EXPORT_LIB_DIR)/jvm.lib
 ifeq ($(ARCH_DATA_MODEL), 32)
   EXPORT_CLIENT_DIR = $(EXPORT_JRE_BIN_DIR)/client
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.dll
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.$(LIBRARY_SUFFIX)
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.pdb
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.map
   # kernel vm
   EXPORT_KERNEL_DIR = $(EXPORT_JRE_BIN_DIR)/kernel
   EXPORT_LIST += $(EXPORT_KERNEL_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.dll
+  EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.$(LIBRARY_SUFFIX)
   EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.pdb
   EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.map
 endif
 
 ifeq ($(BUILD_WIN_SA), 1)
-  EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.dll
+  EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.$(LIBRARY_SUFFIX)
   EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.pdb
   EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.map
   EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar
--- ./hotspot/src/cpu/sparc/vm/globals_sparc.hpp	2011-05-26 17:28:09.000000000 -0700
+++ ./hotspot/src/cpu/sparc/vm/globals_sparc.hpp	2011-04-22 22:28:33.000000000 -0700
@@ -70,7 +70,11 @@
 define_pd_global(bool, RewriteBytecodes,     true);
 define_pd_global(bool, RewriteFrequentPairs, true);
 
+#ifdef _ALLBSD_SOURCE
+define_pd_global(bool, UseMembar,            true);
+#else
 define_pd_global(bool, UseMembar,            false);
+#endif
 
 // GC Ergo Flags
 define_pd_global(intx, CMSYoungGenPerWorker, 16*M);  // default max size of CMS young gen, per GC worker thread
--- ./hotspot/src/cpu/x86/vm/bytes_x86.hpp	2011-05-26 17:28:20.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/bytes_x86.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -81,6 +81,9 @@
 #ifdef TARGET_OS_ARCH_windows_x86
 # include "bytes_windows_x86.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "bytes_bsd_x86.inline.hpp"
+#endif
 
 
 #endif // CPU_X86_VM_BYTES_X86_HPP
--- ./hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	2011-05-26 17:28:22.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	2011-04-23 12:09:38.000000000 -0700
@@ -480,8 +480,8 @@
   // Fetch the exception from TLS and clear out exception related thread state
   __ get_thread(rsi);
   __ movptr(rax, Address(rsi, JavaThread::exception_oop_offset()));
-  __ movptr(Address(rsi, JavaThread::exception_oop_offset()), (int32_t)NULL_WORD);
-  __ movptr(Address(rsi, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD);
+  __ movptr(Address(rsi, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD);
+  __ movptr(Address(rsi, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD);
 
   __ bind(_unwind_handler_entry);
   __ verify_not_null_oop(rax);
--- ./hotspot/src/cpu/x86/vm/copy_x86.hpp	2011-05-26 17:28:24.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/copy_x86.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_ARCH_windows_x86
 # include "copy_windows_x86.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "copy_bsd_x86.inline.hpp"
+#endif
 
 
 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
--- ./hotspot/src/cpu/x86/vm/globals_x86.hpp	2011-05-26 17:28:28.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/globals_x86.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -70,7 +70,11 @@
 define_pd_global(bool, RewriteBytecodes,     true);
 define_pd_global(bool, RewriteFrequentPairs, true);
 
+#ifdef _ALLBSD_SOURCE
+define_pd_global(bool, UseMembar,            true);
+#else
 define_pd_global(bool, UseMembar,            false);
+#endif
 
 // GC Ergo Flags
 define_pd_global(intx, CMSYoungGenPerWorker, 64*M);  // default max size of CMS young gen, per GC worker thread
--- ./hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp	2011-05-26 17:28:28.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -45,6 +45,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 // Implementation of InterpreterMacroAssembler
@@ -1144,7 +1147,7 @@
   int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
   set_mdp_data_at(mdp, recvr_offset, receiver);
   int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
-  movptr(reg2, (int32_t)DataLayout::counter_increment);
+  movptr(reg2, (intptr_t)DataLayout::counter_increment);
   set_mdp_data_at(mdp, count_offset, reg2);
   if (start_row > 0) {
     jmp(done);
@@ -1287,7 +1290,7 @@
     test_method_data_pointer(mdp, profile_continue);
 
     // Build the base (index * per_case_size_in_bytes()) + case_array_offset_in_bytes()
-    movptr(reg2, (int32_t)in_bytes(MultiBranchData::per_case_size()));
+    movptr(reg2, (intptr_t)in_bytes(MultiBranchData::per_case_size()));
     // index is positive and so should have correct value if this code were
     // used on 64bits
     imulptr(index, reg2);
--- ./hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp	2011-05-26 17:28:29.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -45,6 +45,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 // Implementation of InterpreterMacroAssembler
--- ./hotspot/src/cpu/x86/vm/jni_x86.h	2011-05-26 17:28:32.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/jni_x86.h	2011-04-22 22:28:34.000000000 -0700
@@ -26,7 +26,7 @@
 #ifndef _JAVASOFT_JNI_MD_H_
 #define _JAVASOFT_JNI_MD_H_
 
-#if defined(SOLARIS) || defined(LINUX)
+#if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
 
 #if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2)
   #define JNIEXPORT     __attribute__((visibility("default")))
--- ./hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	2011-05-26 17:28:34.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
--- ./hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	2011-05-26 17:28:35.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
--- ./hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp	2011-05-26 17:28:35.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Implementation of the platform-specific part of StubRoutines - for
 // a description of how to extend it, see the stubRoutines.hpp file.
--- ./hotspot/src/cpu/x86/vm/stubRoutines_x86_64.cpp	2011-05-26 17:28:36.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/stubRoutines_x86_64.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Implementation of the platform-specific part of StubRoutines - for
 // a description of how to extend it, see the stubRoutines.hpp file.
--- ./hotspot/src/cpu/x86/vm/vm_version_x86.cpp	2011-05-26 17:28:37.000000000 -0700
+++ ./hotspot/src/cpu/x86/vm/vm_version_x86.cpp	2011-05-27 00:00:43.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 int VM_Version::_cpu;
--- ./hotspot/src/cpu/zero/vm/bytes_zero.hpp	2011-05-26 17:28:41.000000000 -0700
+++ ./hotspot/src/cpu/zero/vm/bytes_zero.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -168,6 +168,9 @@
 #ifdef TARGET_OS_ARCH_linux_zero
 # include "bytes_linux_zero.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "bytes_bsd_zero.inline.hpp"
+#endif
 
 #endif // VM_LITTLE_ENDIAN
 
--- ./hotspot/src/cpu/zero/vm/globals_zero.hpp	2011-05-26 17:28:44.000000000 -0700
+++ ./hotspot/src/cpu/zero/vm/globals_zero.hpp	2011-04-23 12:09:38.000000000 -0700
@@ -52,7 +52,11 @@
 define_pd_global(bool,  RewriteBytecodes,     true);
 define_pd_global(bool,  RewriteFrequentPairs, true);
 
+#ifdef _ALLBSD_SOURCE
+define_pd_global(bool,  UseMembar,            true);
+#else
 define_pd_global(bool,  UseMembar,            false);
+#endif
 
 // GC Ergo Flags
 define_pd_global(intx, CMSYoungGenPerWorker, 16*M);  // default max size of CMS young gen, per GC worker thread
--- ./hotspot/src/cpu/zero/vm/interp_masm_zero.cpp	2011-05-26 17:28:45.000000000 -0700
+++ ./hotspot/src/cpu/zero/vm/interp_masm_zero.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -40,5 +40,8 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // This file is intentionally empty
--- ./hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp	2011-05-26 17:28:49.000000000 -0700
+++ ./hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -43,6 +43,9 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
--- ./hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp	2011-05-26 17:28:49.000000000 -0700
+++ ./hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -30,3 +30,6 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
--- ./hotspot/src/cpu/zero/vm/vm_version_zero.cpp	2011-05-26 17:28:51.000000000 -0700
+++ ./hotspot/src/cpu/zero/vm/vm_version_zero.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -32,5 +32,8 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "os_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // This file is intentionally empty
--- ./hotspot/src/os/bsd/vm/attachListener_bsd.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/attachListener_bsd.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -337,6 +337,15 @@
 
     // get the credentials of the peer and check the effective uid/guid
     // - check with jeff on this.
+#ifdef _ALLBSD_SOURCE
+    uid_t puid;
+    gid_t pgid;
+    if (::getpeereid(s, &puid, &pgid) != 0) {
+      int res;
+      RESTARTABLE(::close(s), res);
+      continue;
+    }
+#else
     struct ucred cred_info;
     socklen_t optlen = sizeof(cred_info);
     if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
@@ -344,10 +353,13 @@
       RESTARTABLE(::close(s), res);
       continue;
     }
+    uid_t puid = cred_info.uid;
+    gid_t pgid = cred_info.gid;
+#endif
     uid_t euid = geteuid();
     gid_t egid = getegid();
 
-    if (cred_info.uid != euid || cred_info.gid != egid) {
+    if (puid != euid || pgid != egid) {
       int res;
       RESTARTABLE(::close(s), res);
       continue;
@@ -467,16 +479,13 @@
   if (init_at_startup() || is_initialized()) {
     return false;               // initialized at startup or already initialized
   }
-  char fn[PATH_MAX+1];
-  sprintf(fn, ".attach_pid%d", os::current_process_id());
+  char path[PATH_MAX + 1];
   int ret;
-  struct stat64 st;
-  RESTARTABLE(::stat64(fn, &st), ret);
-  if (ret == -1) {
-    snprintf(fn, sizeof(fn), "%s/.attach_pid%d",
-             os::get_temp_directory(), os::current_process_id());
-    RESTARTABLE(::stat64(fn, &st), ret);
-  }
+  struct stat st;
+
+  snprintf(path, PATH_MAX + 1, "%s/.attach_pid%d",
+           os::get_temp_directory(), os::current_process_id());
+  RESTARTABLE(::stat(path, &st), ret);
   if (ret == 0) {
     // simple check to avoid starting the attach mechanism when
     // a bogus user creates the file
--- ./hotspot/src/os/bsd/vm/globals_bsd.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/globals_bsd.hpp	2011-05-13 21:09:51.000000000 -0700
@@ -47,7 +47,7 @@
 // Defines Bsd-specific default values. The flags are available on all
 // platforms, but they may have different default values on other platforms.
 //
-define_pd_global(bool, UseLargePages, true);
+define_pd_global(bool, UseLargePages, false);
 define_pd_global(bool, UseLargePagesIndividualAllocation, false);
 define_pd_global(bool, UseOSErrorReporting, false);
 define_pd_global(bool, UseThreadPriorities, true) ;
--- ./hotspot/src/os/bsd/vm/jsig.c	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/jsig.c	2011-04-22 22:28:34.000000000 -0700
@@ -35,10 +35,7 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
-
-#define bool int
-#define true 1
-#define false 0
+#include <stdbool.h>
 
 #define MAXSIGNUM 32
 #define MASK(sig) ((unsigned int)1 << sig)
@@ -143,7 +140,8 @@
 }
 
 sa_handler_t sigset(int sig, sa_handler_t disp) {
-  return set_signal(sig, disp, true);
+  printf("sigset() is not supported by BSD");
+  exit(0);
  }
 
 static int call_os_sigaction(int sig, const struct sigaction  *act,
--- ./hotspot/src/os/bsd/vm/jvm_bsd.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/jvm_bsd.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -141,38 +141,31 @@
   "ILL",        SIGILL,         /* Illegal instruction (ANSI).  */
   "TRAP",       SIGTRAP,        /* Trace trap (POSIX).  */
   "ABRT",       SIGABRT,        /* Abort (ANSI).  */
-  "IOT",        SIGIOT,         /* IOT trap (4.2 BSD).  */
-  "BUS",        SIGBUS,         /* BUS error (4.2 BSD).  */
+  "EMT",	SIGEMT,		/* EMT trap  */
   "FPE",        SIGFPE,         /* Floating-point exception (ANSI).  */
   "KILL",       SIGKILL,        /* Kill, unblockable (POSIX).  */
-  "USR1",       SIGUSR1,        /* User-defined signal 1 (POSIX).  */
+  "BUS",	SIGBUS,		/* BUS error (4.2 BSD).  */
   "SEGV",       SIGSEGV,        /* Segmentation violation (ANSI).  */
-  "USR2",       SIGUSR2,        /* User-defined signal 2 (POSIX).  */
+  "SYS",	SIGSYS,		/* Bad system call. Only on some Bsden! */
   "PIPE",       SIGPIPE,        /* Broken pipe (POSIX).  */
   "ALRM",       SIGALRM,        /* Alarm clock (POSIX).  */
   "TERM",       SIGTERM,        /* Termination (ANSI).  */
-#ifdef SIGSTKFLT
-  "STKFLT",     SIGSTKFLT,      /* Stack fault.  */
-#endif
-  "CLD",        SIGCLD,         /* Same as SIGCHLD (System V).  */
-  "CHLD",       SIGCHLD,        /* Child status has changed (POSIX).  */
-  "CONT",       SIGCONT,        /* Continue (POSIX).  */
+  "URG",	SIGURG,		/* Urgent condition on socket (4.2 BSD).  */
   "STOP",       SIGSTOP,        /* Stop, unblockable (POSIX).  */
   "TSTP",       SIGTSTP,        /* Keyboard stop (POSIX).  */
+  "CONT",	SIGCONT,	/* Continue (POSIX).  */
+  "CHLD",	SIGCHLD,	/* Child status has changed (POSIX).  */
   "TTIN",       SIGTTIN,        /* Background read from tty (POSIX).  */
   "TTOU",       SIGTTOU,        /* Background write to tty (POSIX).  */
-  "URG",        SIGURG,         /* Urgent condition on socket (4.2 BSD).  */
+  "IO",		SIGIO,		/* I/O now possible (4.2 BSD).  */
   "XCPU",       SIGXCPU,        /* CPU limit exceeded (4.2 BSD).  */
   "XFSZ",       SIGXFSZ,        /* File size limit exceeded (4.2 BSD).  */
   "VTALRM",     SIGVTALRM,      /* Virtual alarm clock (4.2 BSD).  */
   "PROF",       SIGPROF,        /* Profiling alarm clock (4.2 BSD).  */
   "WINCH",      SIGWINCH,       /* Window size change (4.3 BSD, Sun).  */
-  "POLL",       SIGPOLL,        /* Pollable event occurred (System V).  */
-  "IO",         SIGIO,          /* I/O now possible (4.2 BSD).  */
-  "PWR",        SIGPWR,         /* Power failure restart (System V).  */
-#ifdef SIGSYS
-  "SYS",        SIGSYS          /* Bad system call. Only on some Bsden! */
-#endif
+  "INFO",	SIGINFO,	/* Information request.  */
+  "USR1",	SIGUSR1,	/* User-defined signal 1 (POSIX).  */
+  "USR2",	SIGUSR2		/* User-defined signal 2 (POSIX).  */
   };
 
 JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
--- ./hotspot/src/os/bsd/vm/jvm_bsd.h	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/jvm_bsd.h	2011-04-22 22:28:34.000000000 -0700
@@ -54,7 +54,11 @@
 #define AGENT_ONATTACH_SYMBOLS  {"Agent_OnAttach"}
 
 #define JNI_LIB_PREFIX "lib"
+#ifdef __APPLE__
+#define JNI_LIB_SUFFIX ".dylib"
+#else
 #define JNI_LIB_SUFFIX ".so"
+#endif
 
 // Hack: MAXPATHLEN is 4095 on some Bsd and 4096 on others. This may
 //       cause problems if JVM and the rest of JDK are built on different
@@ -93,6 +97,20 @@
 #define SHUTDOWN2_SIGNAL SIGINT
 #define SHUTDOWN3_SIGNAL SIGTERM
 
+#ifndef SIGRTMIN
+#ifdef __OpenBSD__
+#define SIGRTMIN	1
+#else
+#define SIGRTMIN	33
+#endif
+#endif
+#ifndef SIGRTMAX
+#ifdef __OpenBSD__
+#define SIGRTMAX	31
+#else
+#define SIGRTMAX	63
+#endif
+#endif
 #endif /* JVM_MD_H */
 
 // Reconciliation History
--- ./hotspot/src/os/bsd/vm/osThread_bsd.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/osThread_bsd.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -49,8 +49,8 @@
 
 void OSThread::pd_initialize() {
   assert(this != NULL, "check");
-  _thread_id        = 0;
-  _pthread_id       = 0;
+  _thread_id        = NULL;
+  _pthread_id       = NULL;
   _siginfo = NULL;
   _ucontext = NULL;
   _expanding_stack = 0;
--- ./hotspot/src/os/bsd/vm/osThread_bsd.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/osThread_bsd.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -39,6 +39,12 @@
 
  private:
 
+#ifdef _ALLBSD_SOURCE
+  // _thread_id and _pthread_id are the same on BSD
+  // keep both to minimize code divergence in os_bsd.cpp
+  pthread_t _thread_id;
+  pthread_t _pthread_id;
+#else
   // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
   // thread has a unique thread_id (BsdThreads or NPTL). It can be used
   // to access /proc.
@@ -47,6 +53,7 @@
   // _pthread_id is the pthread id, which is used by library calls
   // (e.g. pthread_kill).
   pthread_t _pthread_id;
+#endif
 
   sigset_t _caller_sigmask; // Caller's signal mask
 
@@ -56,12 +63,18 @@
   sigset_t  caller_sigmask() const       { return _caller_sigmask; }
   void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
 
+#ifdef _ALLBSD_SOURCE
+  pthread_t thread_id() const {
+    return _thread_id;
+  }
+#else
   pid_t thread_id() const {
     return _thread_id;
   }
+#endif
 #ifndef PRODUCT
   // Used for debugging, return a unique integer for each thread.
-  int thread_identifier() const   { return _thread_id; }
+  intptr_t thread_identifier() const   { return (intptr_t)_pthread_id; }
 #endif
 #ifdef ASSERT
   // We expect no reposition failures so kill vm if we get one.
@@ -70,9 +83,15 @@
     return false;
   }
 #endif // ASSERT
+#ifdef _ALLBSD_SOURCE
+  void set_thread_id(pthread_t id) {
+    _thread_id = id;
+  }
+#else
   void set_thread_id(pid_t id) {
     _thread_id = id;
   }
+#endif
   pthread_t pthread_id() const {
     return _pthread_id;
   }
--- ./hotspot/src/os/bsd/vm/os_bsd.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/os_bsd.cpp	2011-05-20 20:04:01.000000000 -0700
@@ -22,8 +22,6 @@
  *
  */
 
-# define __STDC_FORMAT_MACROS
-
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
@@ -110,21 +108,42 @@
 # include <sys/utsname.h>
 # include <sys/socket.h>
 # include <sys/wait.h>
+# include <time.h>
 # include <pwd.h>
 # include <poll.h>
 # include <semaphore.h>
 # include <fcntl.h>
 # include <string.h>
+#ifdef _ALLBSD_SOURCE
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#else
 # include <syscall.h>
 # include <sys/sysinfo.h>
 # include <gnu/libc-version.h>
+#endif
 # include <sys/ipc.h>
 # include <sys/shm.h>
+#ifndef __APPLE__
 # include <link.h>
+#endif
 # include <stdint.h>
 # include <inttypes.h>
 # include <sys/ioctl.h>
 
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+# include <elf.h>
+#endif
+
+#ifdef __APPLE__
+#include <mach/mach.h> // semaphore_* API
+#include <mach-o/dyld.h>
+#endif
+
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
 #define MAX_PATH    (2 * K)
 
 // for timer info max values which include all bits
@@ -136,19 +155,25 @@
 // global variables
 julong os::Bsd::_physical_memory = 0;
 
+#ifndef _ALLBSD_SOURCE
 address   os::Bsd::_initial_thread_stack_bottom = NULL;
 uintptr_t os::Bsd::_initial_thread_stack_size   = 0;
+#endif
 
 int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
+#ifndef _ALLBSD_SOURCE
 int (*os::Bsd::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
 Mutex* os::Bsd::_createThread_lock = NULL;
+#endif
 pthread_t os::Bsd::_main_thread;
 int os::Bsd::_page_size = -1;
+#ifndef _ALLBSD_SOURCE
 bool os::Bsd::_is_floating_stack = false;
 bool os::Bsd::_is_NPTL = false;
 bool os::Bsd::_supports_fast_thread_cpu_time = false;
 const char * os::Bsd::_glibc_version = NULL;
 const char * os::Bsd::_libpthread_version = NULL;
+#endif
 
 static jlong initial_time_count=0;
 
@@ -166,8 +191,6 @@
 static int SR_signum = SIGUSR2;
 sigset_t SR_sigset;
 
-/* Used to protect dlsym() calls */
-static pthread_mutex_t dl_mutex;
 
 ////////////////////////////////////////////////////////////////////////////////
 // utility functions
@@ -180,11 +203,16 @@
 }
 
 julong os::Bsd::available_memory() {
+#ifdef _ALLBSD_SOURCE
+  // XXXBSD: this is just a stopgap implementation
+  return physical_memory() >> 2;
+#else
   // values in struct sysinfo are "unsigned long"
   struct sysinfo si;
   sysinfo(&si);
 
   return (julong)si.freeram * si.mem_unit;
+#endif
 }
 
 julong os::physical_memory() {
@@ -232,6 +260,7 @@
 }
 
 
+#ifndef _ALLBSD_SOURCE
 #ifndef SYS_gettid
 // i386: 224, ia64: 1105, amd64: 186, sparc 143
 #ifdef __ia64__
@@ -246,6 +275,7 @@
 #error define gettid for the arch
 #endif
 #endif
+#endif
 
 // Cpu architecture string
 #if   defined(ZERO)
@@ -271,6 +301,7 @@
 #endif
 
 
+#ifndef _ALLBSD_SOURCE
 // pid_t gettid()
 //
 // Returns the kernel thread id of the currently running thread. Kernel
@@ -297,7 +328,48 @@
 static const char *unstable_chroot_error = "/proc file system not found.\n"
                      "Java may be unstable running multithreaded in a chroot "
                      "environment on Bsd when /proc filesystem is not mounted.";
+#endif
+
+#ifdef _ALLBSD_SOURCE
+void os::Bsd::initialize_system_info() {
+  int mib[2];
+  size_t len;
+  int cpu_val;
+  u_long mem_val;
+
+  /* get processors count via hw.ncpus sysctl */
+  mib[0] = CTL_HW;
+  mib[1] = HW_NCPU;
+  len = sizeof(cpu_val);
+  if (sysctl(mib, 2, &cpu_val, &len, NULL, 0) != -1 && cpu_val >= 1) {
+       set_processor_count(cpu_val);
+  }
+  else {
+       set_processor_count(1);   // fallback
+  }
 
+  /* get physical memory via hw.usermem sysctl (hw.usermem is used
+   * instead of hw.physmem because we need size of allocatable memory
+   */
+  mib[0] = CTL_HW;
+  mib[1] = HW_USERMEM;
+  len = sizeof(mem_val);
+  if (sysctl(mib, 2, &mem_val, &len, NULL, 0) != -1)
+       _physical_memory = mem_val;
+  else
+       _physical_memory = 256*1024*1024;       // fallback (XXXBSD?)
+
+#ifdef __OpenBSD__
+  {
+       // limit _physical_memory memory view on OpenBSD since
+       // datasize rlimit restricts us anyway.
+       struct rlimit limits;
+       getrlimit(RLIMIT_DATA, &limits);
+       _physical_memory = MIN2(_physical_memory, (julong)limits.rlim_cur);
+  }
+#endif
+}
+#else
 void os::Bsd::initialize_system_info() {
   set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
   if (processor_count() == 1) {
@@ -314,6 +386,7 @@
   _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE);
   assert(processor_count() > 0, "bsd error");
 }
+#endif
 
 void os::init_system_properties_values() {
 //  char arch[12];
@@ -357,9 +430,7 @@
  *        ...
  *        7: The default directories, normally /lib and /usr/lib.
  */
-#if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390))
-#define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
-#else
+#ifndef DEFAULT_LIBPATH
 #define DEFAULT_LIBPATH "/lib:/usr/lib"
 #endif
 
@@ -438,7 +509,11 @@
          * should always exist (until the legacy problem cited above is
          * addressed).
          */
+#ifdef __APPLE__
+        char *v = getenv("DYLD_LIBRARY_PATH");
+#else
         char *v = getenv("LD_LIBRARY_PATH");
+#endif
         if (v != NULL) {
             char *t = ld_library_path;
             /* That's +1 for the colon and +1 for the trailing '\0' */
@@ -597,6 +672,7 @@
   }
 }
 
+#ifndef _ALLBSD_SOURCE
 //////////////////////////////////////////////////////////////////////////////
 // detecting pthread library
 
@@ -760,6 +836,7 @@
   }
   return false;
 }
+#endif
 
 //////////////////////////////////////////////////////////////////////////////
 // create new thread
@@ -768,6 +845,9 @@
 
 // check if it's safe to start a new thread
 static bool _thread_safety_check(Thread* thread) {
+#ifdef _ALLBSD_SOURCE
+    return true;
+#else
   if (os::Bsd::is_BsdThreads() && !os::Bsd::is_floating_stack()) {
     // Fixed stack BsdThreads (SuSE Bsd/x86, and some versions of Redhat)
     //   Heap is mmap'ed at lower end of memory space. Thread stacks are
@@ -801,6 +881,7 @@
     //   here, that means enough space has been reserved for stack.
     return true;
   }
+#endif
 }
 
 // Thread start routine for all newly created threads
@@ -828,6 +909,10 @@
     return NULL;
   }
 
+#ifdef _ALLBSD_SOURCE
+  // thread_id is pthread_id on BSD
+  osthread->set_thread_id(::pthread_self());
+#else
   // thread_id is kernel thread id (similar to Solaris LWP id)
   osthread->set_thread_id(os::Bsd::gettid());
 
@@ -837,6 +922,7 @@
       thread->set_lgrp_id(lgrp_id);
     }
   }
+#endif
   // initialize signal mask for this thread
   os::Bsd::hotspot_sigmask(thread);
 
@@ -919,17 +1005,22 @@
     // let pthread_create() pick the default value.
   }
 
+#ifndef _ALLBSD_SOURCE
   // glibc guard page
   pthread_attr_setguardsize(&attr, os::Bsd::default_guard_size(thr_type));
+#endif
 
   ThreadState state;
 
   {
+
+#ifndef _ALLBSD_SOURCE
     // Serialize thread creation if we are running with fixed stack BsdThreads
     bool lock = os::Bsd::is_BsdThreads() && !os::Bsd::is_floating_stack();
     if (lock) {
       os::Bsd::createThread_lock()->lock_without_safepoint_check();
     }
+#endif
 
     pthread_t tid;
     int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
@@ -943,7 +1034,9 @@
       // Need to clean up stuff we've allocated so far
       thread->set_osthread(NULL);
       delete osthread;
+#ifndef _ALLBSD_SOURCE
       if (lock) os::Bsd::createThread_lock()->unlock();
+#endif
       return false;
     }
 
@@ -959,9 +1052,11 @@
       }
     }
 
+#ifndef _ALLBSD_SOURCE
     if (lock) {
       os::Bsd::createThread_lock()->unlock();
     }
+#endif
   }
 
   // Aborted due to thread limit being reached
@@ -999,7 +1094,11 @@
   }
 
   // Store pthread info into the OSThread
+#ifdef _ALLBSD_SOURCE
+  osthread->set_thread_id(::pthread_self());
+#else
   osthread->set_thread_id(os::Bsd::gettid());
+#endif
   osthread->set_pthread_id(::pthread_self());
 
   // initialize floating point control register
@@ -1010,6 +1109,7 @@
 
   thread->set_osthread(osthread);
 
+#ifndef _ALLBSD_SOURCE
   if (UseNUMA) {
     int lgrp_id = os::numa_get_group_id();
     if (lgrp_id != -1) {
@@ -1036,6 +1136,7 @@
     os::Bsd::manually_expand_stack(jt, addr);
     osthread->clear_expanding_stack();
   }
+#endif
 
   // initialize signal mask for this thread
   // and save the caller's signal mask
@@ -1094,6 +1195,7 @@
 //////////////////////////////////////////////////////////////////////////////
 // initial thread
 
+#ifndef _ALLBSD_SOURCE
 // Check if current thread is the initial thread, similar to Solaris thr_main.
 bool os::Bsd::is_initial_thread(void) {
   char dummy;
@@ -1330,6 +1432,7 @@
   _initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size());
   _initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
 }
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 // time support
@@ -1351,9 +1454,7 @@
   return (1000 * 1000);
 }
 
-// For now, we say that bsd does not support vtime.  I have no idea
-// whether it can actually be made to (DLD, 9/13/05).
-
+// XXX: For now, code this as if BSD does not support vtime.
 bool os::supports_vtime() { return false; }
 bool os::enable_vtime()   { return false; }
 bool os::vtime_enabled()  { return false; }
@@ -1373,6 +1474,21 @@
 #define CLOCK_MONOTONIC (1)
 #endif
 
+#ifdef __APPLE__
+void os::Bsd::clock_init() {
+	// XXXDARWIN: Investigate replacement monotonic clock
+}
+#elif defined(_ALLBSD_SOURCE)
+void os::Bsd::clock_init() {
+  struct timespec res;
+  struct timespec tp;
+  if (::clock_getres(CLOCK_MONOTONIC, &res) == 0 &&
+      ::clock_gettime(CLOCK_MONOTONIC, &tp)  == 0) {
+    // yes, monotonic clock is supported
+    _clock_gettime = ::clock_gettime;
+  }
+}
+#else
 void os::Bsd::clock_init() {
   // we do dlopen's in this particular order due to bug in bsd
   // dynamical loader (see 6348968) leading to crash on exit
@@ -1408,7 +1524,9 @@
     }
   }
 }
+#endif
 
+#ifndef _ALLBSD_SOURCE
 #ifndef SYS_clock_getres
 
 #if defined(IA32) || defined(AMD64)
@@ -1449,6 +1567,7 @@
     _pthread_getcpuclockid = pthread_getcpuclockid_func;
   }
 }
+#endif
 
 jlong os::javaTimeNanos() {
   if (Bsd::supports_monotonic_clock()) {
@@ -1617,7 +1736,14 @@
 
 // DLL functions
 
-const char* os::dll_file_extension() { return ".so"; }
+#define JNI_LIB_PREFIX "lib"
+#ifdef __APPLE__
+#define JNI_LIB_SUFFIX ".dylib"
+#else
+#define JNI_LIB_SUFFIX ".so"
+#endif
+
+const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; }
 
 // This must be hard coded because it's the system's temporary
 // directory not the java application's temp directory, ala java.io.tmpdir.
@@ -1637,13 +1763,13 @@
   const size_t pnamelen = pname ? strlen(pname) : 0;
 
   // Quietly truncate on buffer overflow.  Should be an error.
-  if (pnamelen + strlen(fname) + 10 > (size_t) buflen) {
+  if (pnamelen + strlen(fname) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) {
       *buffer = '\0';
       return;
   }
 
   if (pnamelen == 0) {
-    snprintf(buffer, buflen, "lib%s.so", fname);
+    snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname);
   } else if (strchr(pname, *os::path_separator()) != NULL) {
     int n;
     char** pelements = split_path(pname, &n);
@@ -1652,7 +1778,8 @@
       if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
         continue; // skip the empty path values
       }
-      snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname);
+      snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX,
+          pelements[i], fname);
       if (file_exists(buffer)) {
         break;
       }
@@ -1667,7 +1794,7 @@
       FREE_C_HEAP_ARRAY(char*, pelements);
     }
   } else {
-    snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
+    snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname);
   }
 }
 
@@ -1717,6 +1844,23 @@
   return false;
 }
 
+#ifdef _ALLBSD_SOURCE
+// ported from solaris version
+bool os::dll_address_to_library_name(address addr, char* buf,
+                                     int buflen, int* offset) {
+  Dl_info dlinfo;
+
+  if (dladdr((void*)addr, &dlinfo)){
+     if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname);
+     if (offset) *offset = addr - (address)dlinfo.dli_fbase;
+     return true;
+  } else {
+     if (buf) buf[0] = '\0';
+     if (offset) *offset = -1;
+     return false;
+  }
+}
+#else
 struct _address_to_library_name {
   address addr;          // input : memory address
   size_t  buflen;        //         size of fname
@@ -1791,11 +1935,27 @@
      return false;
   }
 }
+#endif
 
   // Loads .dll/.so and
   // in case of error it checks if .dll/.so was built for the
   // same architecture as Hotspot is running on
+ 
+#ifdef __APPLE__
+void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
+  void * result= ::dlopen(filename, RTLD_LAZY);
+  if (result != NULL) {
+    // Successful loading
+    return result;
+  }
 
+  // Read system error message into ebuf
+  ::strncpy(ebuf, ::dlerror(), ebuflen-1);
+  ebuf[ebuflen-1]='\0';
+
+  return NULL;
+}
+#else
 void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
 {
   void * result= ::dlopen(filename, RTLD_LAZY);
@@ -1848,6 +2008,26 @@
   #define EM_486          6               /* Intel 80486 */
   #endif
 
+  #ifndef EM_MIPS_RS3_LE
+  #define EM_MIPS_RS3_LE  10              /* MIPS */
+  #endif
+
+  #ifndef EM_PPC64
+  #define EM_PPC64        21              /* PowerPC64 */
+  #endif
+
+  #ifndef EM_S390
+  #define EM_S390         22              /* IBM System/390 */
+  #endif
+
+  #ifndef EM_IA_64
+  #define EM_IA_64        50              /* HP/Intel IA-64 */ 
+  #endif
+
+  #ifndef EM_X86_64
+  #define EM_X86_64       62              /* AMD x86-64 */ 
+  #endif
+
   static const arch_t arch_array[]={
     {EM_386,         EM_386,     ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
     {EM_486,         EM_386,     ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
@@ -1951,17 +2131,11 @@
 
   return NULL;
 }
+#endif /* !__APPLE__ */
 
-/*
- * glibc-2.0 libdl is not MT safe.  If you are building with any glibc,
- * chances are you might want to run the generated bits against glibc-2.0
- * libdl.so, so always use locking for any version of glibc.
- */
+// XXX: Do we need a lock around this as per Linux?
 void* os::dll_lookup(void* handle, const char* name) {
-  pthread_mutex_lock(&dl_mutex);
-  void* res = dlsym(handle, name);
-  pthread_mutex_unlock(&dl_mutex);
-  return res;
+  return dlsym(handle, name);
 }
 
 
@@ -1984,7 +2158,51 @@
 
 void os::print_dll_info(outputStream *st) {
    st->print_cr("Dynamic libraries:");
-
+#ifdef _ALLBSD_SOURCE
+#ifdef RTLD_DI_LINKMAP
+    Dl_info dli;
+    void *handle;
+    Link_map *map;
+    Link_map *p;
+
+    if (!dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli)) {
+        st->print_cr("Error: Cannot print dynamic libraries.");
+        return;
+    }
+    handle = dlopen(dli.dli_fname, RTLD_LAZY);
+    if (handle == NULL) {
+        st->print_cr("Error: Cannot print dynamic libraries.");
+        return;
+    }
+    dlinfo(handle, RTLD_DI_LINKMAP, &map);
+    if (map == NULL) {
+        st->print_cr("Error: Cannot print dynamic libraries.");
+        return;
+    }
+
+    while (map->l_prev != NULL)
+        map = map->l_prev;
+
+    while (map != NULL) {
+        st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name);
+        map = map->l_next;
+    }
+
+    dlclose(handle);
+#elif defined(__APPLE__)
+    uint32_t count;
+    uint32_t i;
+
+    count = _dyld_image_count();
+    for (i = 1; i < count; i++) {
+        const char *name = _dyld_get_image_name(i);
+        intptr_t slide = _dyld_get_image_vmaddr_slide(i);
+        st->print_cr(PTR_FORMAT " \t%s", slide, name);
+    }
+#else
+   st->print_cr("Error: Cannot print dynamic libraries.");
+#endif
+#else
    char fname[32];
    pid_t pid = os::Bsd::gettid();
 
@@ -1993,6 +2211,7 @@
    if (!_print_ascii_file(fname, st)) {
      st->print("Can not get library information for pid = %d\n", pid);
    }
+#endif
 }
 
 
@@ -2027,6 +2246,7 @@
   st->print(name.machine);
   st->cr();
 
+#ifndef _ALLBSD_SOURCE
   // Print warning if unsafe chroot environment detected
   if (unsafe_chroot_detected) {
     st->print("WARNING!! ");
@@ -2041,6 +2261,7 @@
      st->print("(%s stack)", os::Bsd::is_floating_stack() ? "floating" : "fixed");
   }
   st->cr();
+#endif
 
   // rlimit
   st->print("rlimit:");
@@ -2066,6 +2287,7 @@
   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
   else st->print("%d", rlim.rlim_cur);
 
+#ifndef _ALLBSD_SOURCE
   st->print(", AS ");
   getrlimit(RLIMIT_AS, &rlim);
   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
@@ -2078,11 +2300,7 @@
   os::loadavg(loadavg, 3);
   st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
   st->cr();
-
-  // meminfo
-  st->print("\n/proc/meminfo:\n");
-  _print_ascii_file("/proc/meminfo", st);
-  st->cr();
+#endif
 }
 
 void os::print_memory_info(outputStream* st) {
@@ -2090,18 +2308,27 @@
   st->print("Memory:");
   st->print(" %dk page", os::vm_page_size()>>10);
 
+#ifndef _ALLBSD_SOURCE
   // values in struct sysinfo are "unsigned long"
   struct sysinfo si;
   sysinfo(&si);
+#endif
 
   st->print(", physical " UINT64_FORMAT "k",
             os::physical_memory() >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             os::available_memory() >> 10);
+#ifndef _ALLBSD_SOURCE
   st->print(", swap " UINT64_FORMAT "k",
             ((jlong)si.totalswap * si.mem_unit) >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             ((jlong)si.freeswap * si.mem_unit) >> 10);
+#endif
+  st->cr();
+
+  // meminfo
+  st->print("\n/proc/meminfo:\n");
+  _print_ascii_file("/proc/meminfo", st);
   st->cr();
 }
 
@@ -2342,19 +2569,29 @@
 static volatile jint pending_signals[NSIG+1] = { 0 };
 
 // Bsd(POSIX) specific hand shaking semaphore.
+#ifdef __APPLE__
+static semaphore_t sig_sem;
+#define SEM_INIT(sem, value)	semaphore_create(mach_task_self(), &sem, SYNC_POLICY_FIFO, value)
+#define SEM_WAIT(sem)		semaphore_wait(sem);
+#define SEM_POST(sem)		semaphore_signal(sem);
+#else
 static sem_t sig_sem;
+#define SEM_INIT(sem, value)	sem_init(&sem, 0, value)
+#define SEM_WAIT(sem)		sem_wait(&sem);
+#define SEM_POST(sem)		sem_post(&sem);
+#endif
 
 void os::signal_init_pd() {
   // Initialize signal structures
   ::memset((void*)pending_signals, 0, sizeof(pending_signals));
 
   // Initialize signal semaphore
-  ::sem_init(&sig_sem, 0, 0);
+  ::SEM_INIT(sig_sem, 0);
 }
 
 void os::signal_notify(int sig) {
   Atomic::inc(&pending_signals[sig]);
-  ::sem_post(&sig_sem);
+  ::SEM_POST(sig_sem);
 }
 
 static int check_pending_signals(bool wait) {
@@ -2376,7 +2613,7 @@
     do {
       thread->set_suspend_equivalent();
       // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self()
-      ::sem_wait(&sig_sem);
+      ::SEM_WAIT(sig_sem);
 
       // were we externally suspended while we were waiting?
       threadIsSuspended = thread->handle_special_suspend_equivalent_condition();
@@ -2387,7 +2624,7 @@
         // while suspended because that would surprise the thread that
         // suspended us.
         //
-        ::sem_post(&sig_sem);
+        ::SEM_POST(sig_sem);
 
         thread->java_suspend_self();
       }
@@ -2431,10 +2668,10 @@
     return;
   }
 
-  char buf[PATH_MAX+1];
+  char buf[PATH_MAX + 1];
   int num = Atomic::add(1, &cnt);
 
-  snprintf(buf, sizeof(buf), "%s/hs-vm-%d-%d",
+  snprintf(buf, PATH_MAX + 1, "%s/hs-vm-%d-%d",
            os::get_temp_directory(), os::current_process_id(), num);
   unlink(buf);
 
@@ -2460,11 +2697,17 @@
 //       problem.
 bool os::commit_memory(char* addr, size_t size, bool exec) {
   int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
+#ifdef __OpenBSD__
+  // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
+  return ::mprotect(addr, size, prot) == 0;
+#else
   uintptr_t res = (uintptr_t) ::mmap(addr, size, prot,
                                    MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
   return res != (uintptr_t) MAP_FAILED;
+#endif
 }
 
+#ifndef _ALLBSD_SOURCE
 // Define MAP_HUGETLB here so we can build HotSpot on old systems.
 #ifndef MAP_HUGETLB
 #define MAP_HUGETLB 0x40000
@@ -2474,9 +2717,11 @@
 #ifndef MADV_HUGEPAGE
 #define MADV_HUGEPAGE 14
 #endif
+#endif
 
 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
                        bool exec) {
+#ifndef _ALLBSD_SOURCE
   if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
     int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
     uintptr_t res =
@@ -2485,16 +2730,19 @@
                          -1, 0);
     return res != (uintptr_t) MAP_FAILED;
   }
+#endif
 
   return commit_memory(addr, size, exec);
 }
 
 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
+#ifndef _ALLBSD_SOURCE
   if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
     // We don't check the return value: madvise(MADV_HUGEPAGE) may not
     // be supported or the memory may already be backed by huge pages.
     ::madvise(addr, bytes, MADV_HUGEPAGE);
   }
+#endif
 }
 
 void os::free_memory(char *addr, size_t bytes) {
@@ -2502,36 +2750,27 @@
 }
 
 void os::numa_make_global(char *addr, size_t bytes) {
-  Bsd::numa_interleave_memory(addr, bytes);
 }
 
 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
-  Bsd::numa_tonode_memory(addr, bytes, lgrp_hint);
 }
 
 bool os::numa_topology_changed()   { return false; }
 
 size_t os::numa_get_groups_num() {
-  int max_node = Bsd::numa_max_node();
-  return max_node > 0 ? max_node + 1 : 1;
+  return 1;
 }
 
 int os::numa_get_group_id() {
-  int cpu_id = Bsd::sched_getcpu();
-  if (cpu_id != -1) {
-    int lgrp_id = Bsd::get_node_by_cpu(cpu_id);
-    if (lgrp_id != -1) {
-      return lgrp_id;
-    }
-  }
   return 0;
 }
 
 size_t os::numa_get_leaf_groups(int *ids, size_t size) {
-  for (size_t i = 0; i < size; i++) {
-    ids[i] = i;
+  if (size > 0) {
+    ids[0] = 0;
+    return 1;
   }
-  return size;
+  return 0;
 }
 
 bool os::get_page_info(char *start, page_info* info) {
@@ -2542,6 +2781,7 @@
   return end;
 }
 
+#ifndef _ALLBSD_SOURCE
 // Something to do with the numa-aware allocator needs these symbols
 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
 extern "C" JNIEXPORT void numa_error(char *where) { }
@@ -2645,98 +2885,26 @@
 os::Bsd::numa_tonode_memory_func_t os::Bsd::_numa_tonode_memory;
 os::Bsd::numa_interleave_memory_func_t os::Bsd::_numa_interleave_memory;
 unsigned long* os::Bsd::_numa_all_nodes;
+#endif
 
 bool os::uncommit_memory(char* addr, size_t size) {
+#ifdef __OpenBSD__
+  // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
+  return ::mprotect(addr, size, PROT_NONE) == 0;
+#else
   uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
                 MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
   return res  != (uintptr_t) MAP_FAILED;
+#endif
 }
 
-// Bsd uses a growable mapping for the stack, and if the mapping for
-// the stack guard pages is not removed when we detach a thread the
-// stack cannot grow beyond the pages where the stack guard was
-// mapped.  If at some point later in the process the stack expands to
-// that point, the Bsd kernel cannot expand the stack any further
-// because the guard pages are in the way, and a segfault occurs.
-//
-// However, it's essential not to split the stack region by unmapping
-// a region (leaving a hole) that's already part of the stack mapping,
-// so if the stack mapping has already grown beyond the guard pages at
-// the time we create them, we have to truncate the stack mapping.
-// So, we need to know the extent of the stack mapping when
-// create_stack_guard_pages() is called.
-
-// Find the bounds of the stack mapping.  Return true for success.
-//
-// We only need this for stacks that are growable: at the time of
-// writing thread stacks don't use growable mappings (i.e. those
-// creeated with MAP_GROWSDOWN), and aren't marked "[stack]", so this
-// only applies to the main thread.
-
-static
-bool get_stack_bounds(uintptr_t *bottom, uintptr_t *top) {
-
-  char buf[128];
-  int fd, sz;
-
-  if ((fd = ::open("/proc/self/maps", O_RDONLY)) < 0) {
-    return false;
-  }
-
-  const char kw[] = "[stack]";
-  const int kwlen = sizeof(kw)-1;
-
-  // Address part of /proc/self/maps couldn't be more than 128 bytes
-  while ((sz = os::get_line_chars(fd, buf, sizeof(buf))) > 0) {
-     if (sz > kwlen && ::memcmp(buf+sz-kwlen, kw, kwlen) == 0) {
-        // Extract addresses
-        if (sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, bottom, top) == 2) {
-           uintptr_t sp = (uintptr_t) __builtin_frame_address(0);
-           if (sp >= *bottom && sp <= *top) {
-              ::close(fd);
-              return true;
-           }
-        }
-     }
-  }
-
- ::close(fd);
-  return false;
-}
-
-
-// If the (growable) stack mapping already extends beyond the point
-// where we're going to put our guard pages, truncate the mapping at
-// that point by munmap()ping it.  This ensures that when we later
-// munmap() the guard pages we don't leave a hole in the stack
-// mapping. This only affects the main/initial thread, but guard
-// against future OS changes
 bool os::create_stack_guard_pages(char* addr, size_t size) {
-  uintptr_t stack_extent, stack_base;
-  bool chk_bounds = NOT_DEBUG(os::Bsd::is_initial_thread()) DEBUG_ONLY(true);
-  if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
-      assert(os::Bsd::is_initial_thread(),
-           "growable stack in non-initial thread");
-    if (stack_extent < (uintptr_t)addr)
-      ::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent);
-  }
-
   return os::commit_memory(addr, size);
 }
 
 // If this is a growable mapping, remove the guard pages entirely by
-// munmap()ping them.  If not, just call uncommit_memory(). This only
-// affects the main/initial thread, but guard against future OS changes
+// munmap()ping them.  If not, just call uncommit_memory().
 bool os::remove_stack_guard_pages(char* addr, size_t size) {
-  uintptr_t stack_extent, stack_base;
-  bool chk_bounds = NOT_DEBUG(os::Bsd::is_initial_thread()) DEBUG_ONLY(true);
-  if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
-      assert(os::Bsd::is_initial_thread(),
-           "growable stack in non-initial thread");
-
-    return ::munmap(addr, size) == 0;
-  }
-
   return os::uncommit_memory(addr, size);
 }
 
@@ -2838,6 +3006,7 @@
 
 bool os::Bsd::hugetlbfs_sanity_check(bool warn, size_t page_size) {
   bool result = false;
+#ifndef _ALLBSD_SOURCE
   void *p = mmap (NULL, page_size, PROT_READ|PROT_WRITE,
                   MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB,
                   -1, 0);
@@ -2869,6 +3038,7 @@
   if (warn) {
     warning("HugeTLBFS is not supported by the operating system.");
   }
+#endif
 
   return result;
 }
@@ -2915,6 +3085,7 @@
 static size_t _large_page_size = 0;
 
 void os::large_page_init() {
+#ifndef _ALLBSD_SOURCE
   if (!UseLargePages) {
     UseHugeTLBFS = false;
     UseSHM = false;
@@ -2992,11 +3163,14 @@
   UseLargePages = UseHugeTLBFS || UseSHM;
 
   set_coredump_filter();
+#endif
 }
 
+#ifndef _ALLBSD_SOURCE
 #ifndef SHM_HUGETLB
 #define SHM_HUGETLB 04000
 #endif
+#endif
 
 char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
   // "exec" is passed in but not used.  Creating the shared image for
@@ -3014,7 +3188,11 @@
 
   // Create a large shared memory region to attach to based on size.
   // Currently, size is the total size of the heap
+#ifndef _ALLBSD_SOURCE
   int shmid = shmget(key, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
+#else
+  int shmid = shmget(key, bytes, IPC_CREAT|SHM_R|SHM_W);
+#endif
   if (shmid == -1) {
      // Possible reasons for shmget failure:
      // 1. shmmax is too small for Java heap.
@@ -3167,7 +3345,7 @@
 }
 
 size_t os::read(int fd, void *buf, unsigned int nBytes) {
-  return ::read(fd, buf, nBytes);
+  RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
 }
 
 // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation.
@@ -3303,6 +3481,44 @@
 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
 
+#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
+int os::java_to_os_priority[MaxPriority + 1] = {
+  19,              // 0 Entry should never be used
+
+   0,              // 1 MinPriority
+   3,              // 2
+   6,              // 3
+
+   10,              // 4
+   15,              // 5 NormPriority
+   18,              // 6
+
+   21,              // 7
+   25,              // 8
+   28,              // 9 NearMaxPriority
+
+   31              // 10 MaxPriority
+};
+#elif defined(__APPLE__)
+/* Using Mach high-level priority assignments */
+int os::java_to_os_priority[MaxPriority + 1] = {
+   0,              // 0 Entry should never be used (MINPRI_USER)
+
+  27,              // 1 MinPriority
+  28,              // 2
+  29,              // 3
+
+  30,              // 4
+  31,              // 5 NormPriority (BASEPRI_DEFAULT)
+  32,              // 6
+
+  33,              // 7
+  34,              // 8
+  35,              // 9 NearMaxPriority
+
+  36               // 10 MaxPriority
+};
+#else
 int os::java_to_os_priority[MaxPriority + 1] = {
   19,              // 0 Entry should never be used
 
@@ -3320,6 +3536,7 @@
 
   -5               // 10 MaxPriority
 };
+#endif
 
 static int prio_init() {
   if (ThreadPriorityPolicy == 1) {
@@ -3339,8 +3556,28 @@
 OSReturn os::set_native_priority(Thread* thread, int newpri) {
   if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK;
 
+#ifdef __OpenBSD__
+  // OpenBSD pthread_setprio starves low priority threads
+  return OS_OK;
+#elif defined(__FreeBSD__)
+  int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri);
+#elif defined(__APPLE__) || defined(__NetBSD__)
+  struct sched_param sp;
+  int policy;
+  pthread_t self = pthread_self();
+
+  if (pthread_getschedparam(self, &policy, &sp) != 0)
+    return OS_ERR;
+
+  sp.sched_priority = newpri;
+  if (pthread_setschedparam(self, policy, &sp) != 0)
+    return OS_ERR;
+
+  return OS_OK;
+#else
   int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri);
   return (ret == 0) ? OS_OK : OS_ERR;
+#endif
 }
 
 OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
@@ -3350,7 +3587,17 @@
   }
 
   errno = 0;
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
+  *priority_ptr = pthread_getprio(thread->osthread()->pthread_id());
+#elif defined(__APPLE__) || defined(__NetBSD__)
+  int policy;
+  struct sched_param sp;
+
+  pthread_getschedparam(pthread_self(), &policy, &sp);
+  *priority_ptr = sp.sched_priority;
+#else
   *priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
+#endif
   return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR);
 }
 
@@ -3460,7 +3707,7 @@
   /* Get signal number to use for suspend/resume */
   if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) {
     int sig = ::strtol(s, 0, 10);
-    if (sig > 0 || sig < _NSIG) {
+    if (sig > 0 || sig < NSIG) {
         SR_signum = sig;
     }
   }
@@ -3804,6 +4051,28 @@
     set_signal_handler(SIGFPE, true);
     set_signal_handler(SIGXFSZ, true);
 
+#if defined(__APPLE__)
+    // In Mac OS X 10.4, CrashReporter will write a crash log for all 'fatal' signals, including
+    // signals caught and handled by the JVM. To work around this, we reset the mach task
+    // signal handler that's placed on our process by CrashReporter. This disables
+    // CrashReporter-based reporting.
+    //
+    // This work-around is not necessary for 10.5+, as CrashReporter no longer intercedes
+    // on caught fatal signals.
+    //
+    // Additionally, gdb installs both standard BSD signal handlers, and mach exception
+    // handlers. By replacing the existing task exception handler, we disable gdb's mach
+    // exception handling, while leaving the standard BSD signal handlers functional.
+    kern_return_t kr;
+    kr = task_set_exception_ports(mach_task_self(),
+        EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC,
+        MACH_PORT_NULL,
+        EXCEPTION_STATE_IDENTITY,
+        MACHINE_THREAD_STATE);
+
+    assert(kr == KERN_SUCCESS, "could not set mach task signal handler");
+#endif
+
     if (libjsig_is_loaded) {
       // Tell libjsig jvm finishes setting signal handlers
       (*end_signal_setting)();
@@ -3824,6 +4093,7 @@
   }
 }
 
+#ifndef _ALLBSD_SOURCE
 // This is the fastest way to get thread cpu time on Bsd.
 // Returns cpu time (user+sys) for any thread, not only for current.
 // POSIX compliant clocks are implemented in the kernels 2.6.16+.
@@ -3838,6 +4108,7 @@
 
   return (tp.tv_sec * SEC_IN_NANOSECS) + tp.tv_nsec;
 }
+#endif
 
 /////
 // glibc on Bsd platform uses non-documented flag
@@ -4059,13 +4330,13 @@
 
   _initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
 
-  clock_tics_per_sec = sysconf(_SC_CLK_TCK);
+  clock_tics_per_sec = CLK_TCK;
 
   init_random(1234567);
 
   ThreadCritical::initialize();
 
-  Bsd::set_page_size(sysconf(_SC_PAGESIZE));
+  Bsd::set_page_size(getpagesize());
   if (Bsd::page_size() == -1) {
     fatal(err_msg("os_bsd.cpp: os::init: sysconf failed (%s)",
                   strerror(errno)));
@@ -4079,7 +4350,16 @@
 
   Bsd::clock_init();
   initial_time_count = os::elapsed_counter();
-  pthread_mutex_init(&dl_mutex, NULL);
+
+#ifdef __APPLE__
+  // XXXDARWIN
+  // Work around the unaligned VM callbacks in hotspot's
+  // sharedRuntime. The callbacks don't use SSE2 instructions, and work on
+  // Linux, Solaris, and FreeBSD. On Mac OS X, dyld (rightly so) enforces
+  // alignment when doing symbol lookup. To work around this, we force early
+  // binding of all symbols now, thus binding when alignment is known-good.
+  _dyld_bind_fully_image_containing_address((const void *) &os::init);
+#endif
 }
 
 // To install functions for atexit system call
@@ -4092,7 +4372,9 @@
 // this is called _after_ the global arguments have been parsed
 jint os::init_2(void)
 {
+#ifndef _ALLBSD_SOURCE
   Bsd::fast_thread_clock_init();
+#endif
 
   // Allocate a single page and mark it as readable for safepoint polling
   address polling_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
@@ -4150,6 +4432,7 @@
   JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes,
         vm_page_size()));
 
+#ifndef _ALLBSD_SOURCE
   Bsd::capture_initial_stack(JavaThread::stack_size_at_create());
 
   Bsd::libpthread_init();
@@ -4189,6 +4472,7 @@
       UseNUMA = true;
     }
   }
+#endif
 
   if (MaxFDLimit) {
     // set the number of file descriptors to max. print out error
@@ -4200,6 +4484,14 @@
         perror("os::init_2 getrlimit failed");
     } else {
       nbr_files.rlim_cur = nbr_files.rlim_max;
+      
+#ifdef __APPLE__
+      // Darwin returns RLIM_INFINITY for rlim_max, but fails with EINVAL if
+      // you attempt to use RLIM_INFINITY. As per setrlimit(2), OPEN_MAX must
+      // be used instead
+      nbr_files.rlim_cur = MIN(OPEN_MAX, nbr_files.rlim_cur);
+#endif
+
       status = setrlimit(RLIMIT_NOFILE, &nbr_files);
       if (status != 0) {
         if (PrintMiscellaneous && (Verbose || WizardMode))
@@ -4208,8 +4500,10 @@
     }
   }
 
+#ifndef _ALLBSD_SOURCE
   // Initialize lock used to serialize thread creation (see os::create_thread)
   Bsd::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false));
+#endif
 
   // at-exit methods are called in the reverse order of their registration.
   // atexit functions are called on return from main or as a result of a
@@ -4253,11 +4547,15 @@
 };
 
 int os::active_processor_count() {
+#ifdef _ALLBSD_SOURCE
+  return _processor_count;
+#else
   // Bsd doesn't yet have a (official) notion of processor sets,
   // so just return the number of online processors.
   int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
   assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
   return online_cpus;
+#endif
 }
 
 bool os::distribute_processes(uint length, uint* distribution) {
@@ -4299,6 +4597,9 @@
 
 int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime)
 {
+#ifdef _ALLBSD_SOURCE
+  return pthread_cond_timedwait(_cond, _mutex, _abstime);
+#else
    if (is_NPTL()) {
       return pthread_cond_timedwait(_cond, _mutex, _abstime);
    } else {
@@ -4314,6 +4615,7 @@
 #endif // IA64
       return status;
    }
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -4461,14 +4763,14 @@
   int o_delete = (oflag & O_DELETE);
   oflag = oflag & ~O_DELETE;
 
-  fd = ::open64(path, oflag, mode);
+  fd = ::open(path, oflag, mode);
   if (fd == -1) return -1;
 
   //If the open succeeded, the file might still be a directory
   {
-    struct stat64 buf64;
-    int ret = ::fstat64(fd, &buf64);
-    int st_mode = buf64.st_mode;
+    struct stat buf;
+    int ret = ::fstat(fd, &buf);
+    int st_mode = buf.st_mode;
 
     if (ret != -1) {
       if ((st_mode & S_IFMT) == S_IFDIR) {
@@ -4525,17 +4827,17 @@
   if (!rewrite_existing) {
     oflags |= O_EXCL;
   }
-  return ::open64(path, oflags, S_IREAD | S_IWRITE);
+  return ::open(path, oflags, S_IREAD | S_IWRITE);
 }
 
 // return current position of file pointer
 jlong os::current_file_offset(int fd) {
-  return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR);
+  return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
 }
 
 // move file pointer to the specified offset
 jlong os::seek_to_file_offset(int fd, jlong offset) {
-  return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET);
+  return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
 }
 
 // This code originates from JDK's sysAvailable
@@ -4544,10 +4846,10 @@
 int os::available(int fd, jlong *bytes) {
   jlong cur, end;
   int mode;
-  struct stat64 buf64;
+  struct stat buf;
 
-  if (::fstat64(fd, &buf64) >= 0) {
-    mode = buf64.st_mode;
+  if (::fstat(fd, &buf) >= 0) {
+    mode = buf.st_mode;
     if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
       /*
       * XXX: is the following call interruptible? If so, this might
@@ -4561,11 +4863,11 @@
       }
     }
   }
-  if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) {
+  if ((cur = ::lseek(fd, 0L, SEEK_CUR)) == -1) {
     return 0;
-  } else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) {
+  } else if ((end = ::lseek(fd, 0L, SEEK_END)) == -1) {
     return 0;
-  } else if (::lseek64(fd, cur, SEEK_SET) == -1) {
+  } else if (::lseek(fd, cur, SEEK_SET) == -1) {
     return 0;
   }
   *bytes = end - cur;
@@ -4573,12 +4875,17 @@
 }
 
 int os::socket_available(int fd, jint *pbytes) {
-  // Bsd doc says EINTR not returned, unlike Solaris
-  int ret = ::ioctl(fd, FIONREAD, pbytes);
+   if (fd < 0)
+     return OS_OK;
+
+   int ret;
 
-  //%% note ioctl can return 0 when successful, JVM_SocketAvailable
-  // is expected to return 0 on failure and 1 on success to the jdk.
-  return (ret < 0) ? 0 : 1;
+   RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
+
+   //%% note ioctl can return 0 when successful, JVM_SocketAvailable
+   // is expected to return 0 on failure and 1 on success to the jdk.
+
+   return (ret == OS_ERR) ? 0 : 1;
 }
 
 // Map a block of memory.
@@ -4628,6 +4935,7 @@
   return munmap(addr, bytes) == 0;
 }
 
+#ifndef _ALLBSD_SOURCE
 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time);
 
 static clockid_t thread_cpu_clockid(Thread* thread) {
@@ -4639,6 +4947,7 @@
   assert(rc == 0, "pthread_getcpuclockid is expected to return 0 code");
   return clockid;
 }
+#endif
 
 // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
 // are used by JVM M&M and JVMTI to get user+sys or user CPU time
@@ -4648,39 +4957,71 @@
 // the fast estimate available on the platform.
 
 jlong os::current_thread_cpu_time() {
+#ifdef __APPLE__
+  return os::thread_cpu_time(Thread::current(), true /* user + sys */);
+#elif !defined(_ALLBSD_SOURCE)
   if (os::Bsd::supports_fast_thread_cpu_time()) {
     return os::Bsd::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID);
   } else {
     // return user + sys since the cost is the same
     return slow_thread_cpu_time(Thread::current(), true /* user + sys */);
   }
+#endif
 }
 
 jlong os::thread_cpu_time(Thread* thread) {
+#ifndef _ALLBSD_SOURCE
   // consistent with what current_thread_cpu_time() returns
   if (os::Bsd::supports_fast_thread_cpu_time()) {
     return os::Bsd::fast_thread_cpu_time(thread_cpu_clockid(thread));
   } else {
     return slow_thread_cpu_time(thread, true /* user + sys */);
   }
+#endif
 }
 
 jlong os::current_thread_cpu_time(bool user_sys_cpu_time) {
+#ifdef __APPLE__
+  return os::thread_cpu_time(Thread::current(), user_sys_cpu_time);
+#elif !defined(_ALLBSD_SOURCE)
   if (user_sys_cpu_time && os::Bsd::supports_fast_thread_cpu_time()) {
     return os::Bsd::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID);
   } else {
     return slow_thread_cpu_time(Thread::current(), user_sys_cpu_time);
   }
+#endif
 }
 
 jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
+#ifdef __APPLE__
+  struct thread_basic_info tinfo;
+  mach_msg_type_number_t tcount = THREAD_INFO_MAX;
+  kern_return_t kr;
+  mach_port_t mach_thread;
+
+  mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
+  kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
+  if (kr != KERN_SUCCESS)
+    return -1;
+
+  if (user_sys_cpu_time) {
+    jlong nanos;
+    nanos = ((jlong) tinfo.system_time.seconds + tinfo.user_time.seconds) * (jlong)1000000000;
+    nanos += ((jlong) tinfo.system_time.microseconds + (jlong) tinfo.user_time.microseconds) * (jlong)1000;
+    return nanos;
+  } else {
+    return ((jlong)tinfo.user_time.seconds * 1000000000) + ((jlong)tinfo.user_time.microseconds * (jlong)1000);
+  }
+#elif !defined(_ALLBSD_SOURCE)
   if (user_sys_cpu_time && os::Bsd::supports_fast_thread_cpu_time()) {
     return os::Bsd::fast_thread_cpu_time(thread_cpu_clockid(thread));
   } else {
     return slow_thread_cpu_time(thread, user_sys_cpu_time);
   }
+#endif
 }
 
+#ifndef _ALLBSD_SOURCE
 //
 //  -1 on error.
 //
@@ -4770,6 +5111,7 @@
     return (jlong)user_time * (1000000000 / clock_tics_per_sec);
   }
 }
+#endif
 
 void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
   info_ptr->max_value = ALL_64_BITS;       // will not wrap in less than 64 bits
@@ -4786,7 +5128,13 @@
 }
 
 bool os::is_thread_cpu_time_supported() {
+#ifdef __APPLE__
+  return true;
+#elif defined(_ALLBSD_SOURCE)
+  return false;
+#else
   return true;
+#endif
 }
 
 // System loadavg support.  Returns -1 if load average cannot be obtained.
@@ -4881,7 +5229,7 @@
 // abstime will be the absolute timeout time
 // TODO: replace compute_abstime() with unpackTime()
 
-static struct timespec* compute_abstime(timespec* abstime, jlong millis) {
+static struct timespec* compute_abstime(struct timespec* abstime, jlong millis) {
   if (millis < 0)  millis = 0;
   struct timeval now;
   int status = gettimeofday(&now, NULL);
@@ -4933,7 +5281,7 @@
         status = pthread_cond_wait(_cond, _mutex);
         // for some reason, under 2.7 lwp_cond_wait() may return ETIME ...
         // Treat this the same as if the wait was interrupted
-        if (status == ETIME) { status = EINTR; }
+        if (status == ETIMEDOUT) { status = EINTR; } 
         assert_status(status == 0 || status == EINTR, status, "cond_wait");
      }
      -- _nParked ;
@@ -4991,10 +5339,10 @@
       pthread_cond_init (_cond, NULL) ;
     }
     assert_status(status == 0 || status == EINTR ||
-                  status == ETIME || status == ETIMEDOUT,
+		  status == ETIMEDOUT, 
                   status, "cond_timedwait");
     if (!FilterSpuriousWakeups) break ;                 // previous semantics
-    if (status == ETIME || status == ETIMEDOUT) break ;
+    if (status == ETIMEDOUT) break ; 
     // We consume and ignore EINTR and spurious wakeups.
   }
   --_nParked ;
@@ -5086,7 +5434,7 @@
  * years from "now".
  */
 
-static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) {
+static void unpackTime(struct timespec* absTime, bool isAbsolute, jlong time) {
   assert (time > 0, "convertTime");
 
   struct timeval now;
@@ -5146,7 +5494,7 @@
   }
 
   // Next, demultiplex/decode time arguments
-  timespec absTime;
+  struct timespec absTime;
   if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all
     return;
   }
@@ -5200,7 +5548,7 @@
     }
   }
   assert_status(status == 0 || status == EINTR ||
-                status == ETIME || status == ETIMEDOUT,
+                status == ETIMEDOUT, 
                 status, "cond_timedwait");
 
 #ifdef ASSERT
@@ -5243,14 +5591,12 @@
 }
 
 
+/* Darwin has no "environ" in a dynamic library. */
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char** environ;
-
-#ifndef __NR_fork
-#define __NR_fork IA32_ONLY(2) IA64_ONLY(not defined) AMD64_ONLY(57)
-#endif
-
-#ifndef __NR_execve
-#define __NR_execve IA32_ONLY(11) IA64_ONLY(1033) AMD64_ONLY(59)
 #endif
 
 // Run the specified command in a separate process. Return its exit value,
@@ -5265,8 +5611,7 @@
   // separate process to execve. Make a direct syscall to fork process.
   // On IA64 there's no fork syscall, we have to use fork() and hope for
   // the best...
-  pid_t pid = NOT_IA64(syscall(__NR_fork);)
-              IA64_ONLY(fork();)
+  pid_t pid = fork();
 
   if (pid < 0) {
     // fork failed
@@ -5282,8 +5627,7 @@
     // in the new process, so make a system call directly.
     // IA64 should use normal execve() from glibc to match the glibc fork()
     // above.
-    NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);)
-    IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);)
+    execve("/bin/sh", (char* const*)argv, environ);
 
     // execve failed
     _exit(-1);
--- ./hotspot/src/os/bsd/vm/os_bsd.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/os_bsd.hpp	2011-05-07 21:53:43.000000000 -0700
@@ -30,6 +30,12 @@
 /* pthread_getattr_np comes with BsdThreads-0.9-7 on RedHat 7.1 */
 typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
 
+#ifdef __APPLE__
+// Mac OS X doesn't support clock_gettime. Stub out the type, it is
+// unused
+typedef int clockid_t;
+#endif
+
 class Bsd {
   friend class os;
 
@@ -50,6 +56,7 @@
   static int sigflags[MAXSIGNUM];
 
   static int (*_clock_gettime)(clockid_t, struct timespec *);
+#ifndef _ALLBSD_SOURCE
   static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
 
   static address   _initial_thread_stack_bottom;
@@ -61,6 +68,7 @@
   static bool _is_floating_stack;
   static bool _is_NPTL;
   static bool _supports_fast_thread_cpu_time;
+#endif
 
   static GrowableArray<int>* _cpu_to_node;
 
@@ -68,21 +76,27 @@
 
   static julong _physical_memory;
   static pthread_t _main_thread;
+#ifndef _ALLBSD_SOURCE
   static Mutex* _createThread_lock;
+#endif
   static int _page_size;
 
   static julong available_memory();
   static julong physical_memory() { return _physical_memory; }
   static void initialize_system_info();
 
+#ifndef _ALLBSD_SOURCE
   static void set_glibc_version(const char *s)      { _glibc_version = s; }
   static void set_libpthread_version(const char *s) { _libpthread_version = s; }
+#endif
 
   static bool supports_variable_stack_size();
 
+#ifndef _ALLBSD_SOURCE
   static void set_is_NPTL()                   { _is_NPTL = true;  }
   static void set_is_BsdThreads()           { _is_NPTL = false; }
   static void set_is_floating_stack()         { _is_floating_stack = true; }
+#endif
 
   static void rebuild_cpu_to_node_map();
   static GrowableArray<int>* cpu_to_node()    { return _cpu_to_node; }
@@ -90,19 +104,27 @@
   static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
 
  public:
+
   static void init_thread_fpu_state();
+#ifndef _ALLBSD_SOURCE
   static int  get_fpu_control_word();
   static void set_fpu_control_word(int fpu_control);
+#endif
   static pthread_t main_thread(void)                                { return _main_thread; }
+
+#ifndef _ALLBSD_SOURCE
   // returns kernel thread id (similar to LWP id on Solaris), which can be
   // used to access /proc
   static pid_t gettid();
   static void set_createThread_lock(Mutex* lk)                      { _createThread_lock = lk; }
   static Mutex* createThread_lock(void)                             { return _createThread_lock; }
+#endif
   static void hotspot_sigmask(Thread* thread);
 
+#ifndef _ALLBSD_SOURCE
   static address   initial_thread_stack_bottom(void)                { return _initial_thread_stack_bottom; }
   static uintptr_t initial_thread_stack_size(void)                  { return _initial_thread_stack_size; }
+#endif
   static bool is_initial_thread(void);
 
   static int page_size(void)                                        { return _page_size; }
@@ -139,6 +161,7 @@
   static struct sigaction *get_chained_signal_action(int sig);
   static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
 
+#ifndef _ALLBSD_SOURCE
   // GNU libc and libpthread version strings
   static const char *glibc_version()          { return _glibc_version; }
   static const char *libpthread_version()     { return _libpthread_version; }
@@ -154,6 +177,7 @@
   static void libpthread_init();
   static bool libnuma_init();
   static void* libnuma_dlsym(void* handle, const char* name);
+#endif
   // Minimum stack size a thread can be created with (allowing
   // the VM to completely create the thread and enter user code)
   static size_t min_stack_allowed;
@@ -162,17 +186,21 @@
   static size_t default_stack_size(os::ThreadType thr_type);
   static size_t default_guard_size(os::ThreadType thr_type);
 
+#ifndef _ALLBSD_SOURCE
   static void capture_initial_stack(size_t max_size);
 
   // Stack overflow handling
   static bool manually_expand_stack(JavaThread * t, address addr);
   static int max_register_window_saves_before_flushing();
+#endif
 
   // Real-time clock functions
   static void clock_init(void);
 
+#ifndef _ALLBSD_SOURCE
   // fast POSIX clocks support
   static void fast_thread_clock_init(void);
+#endif
 
   static bool supports_monotonic_clock() {
     return _clock_gettime != NULL;
@@ -182,6 +210,7 @@
     return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
   }
 
+#ifndef _ALLBSD_SOURCE
   static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
     return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
   }
@@ -191,6 +220,7 @@
   }
 
   static jlong fast_thread_cpu_time(clockid_t clockid);
+#endif
 
   // Stack repair handling
 
--- ./hotspot/src/os/bsd/vm/os_bsd.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/os_bsd.inline.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -94,7 +94,15 @@
 
 inline bool os::allocate_stack_guard_pages() {
   assert(uses_stack_guard_pages(), "sanity check");
+#if !defined(__FreeBSD__) || __FreeBSD__ < 5
+  // Since FreeBSD 4 uses malloc() for allocating the thread stack
+  // there is no need to do anything extra to allocate the guard pages
+  return false;
+#else
+  // FreeBSD 5+ uses mmap MAP_STACK for allocating the thread stacks.
+  // Must 'allocate' them or guard pages are ignored.
   return true;
+#endif
 }
 
 
@@ -126,7 +134,7 @@
 }
 
 inline jlong os::lseek(int fd, jlong offset, int whence) {
-  return (jlong) ::lseek64(fd, offset, whence);
+  return (jlong) ::lseek(fd, offset, whence);
 }
 
 inline int os::fsync(int fd) {
@@ -138,7 +146,7 @@
 }
 
 inline int os::ftruncate(int fd, jlong length) {
-  return ::ftruncate64(fd, length);
+  return ::ftruncate(fd, length);
 }
 
 inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
@@ -191,11 +199,11 @@
 }
 
 inline int os::close(int fd) {
-  return ::close(fd);
+  RESTARTABLE_RETURN_INT(::close(fd));
 }
 
 inline int os::socket_close(int fd) {
-  return ::close(fd);
+  RESTARTABLE_RETURN_INT(::close(fd));
 }
 
 inline int os::socket(int domain, int type, int protocol) {
@@ -260,9 +268,9 @@
   // fetch it's value, this cast is safe for now. The java.net group
   // may need and want to change this interface someday if socklen_t goes
   // to 64 bits on some platform that we support.
-  // Bsd doc says this can't return EINTR, unlike accept() on Solaris
 
-  return ::accept(fd, him, (socklen_t *)len);
+  // At least OpenBSD and FreeBSD can return EINTR from accept.
+  RESTARTABLE_RETURN_INT(::accept(fd, him, (socklen_t *)len));
 }
 
 inline int os::recvfrom(int fd, char *buf, int nBytes, int flags,
--- ./hotspot/src/os/bsd/vm/perfMemory_bsd.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os/bsd/vm/perfMemory_bsd.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -248,7 +248,7 @@
 
   char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize);
 
-  // POSIX interface to getpwuid_r is used on BSD
+  // POSIX interface to getpwuid_r is used on LINUX
   struct passwd* p;
   int result = getpwuid_r(uid, &pwent, pwbuf, (size_t)bufsize, &p);
 
--- ./hotspot/src/os/linux/vm/os_linux.cpp	2011-05-26 17:28:57.000000000 -0700
+++ ./hotspot/src/os/linux/vm/os_linux.cpp	2011-05-20 20:03:59.000000000 -0700
@@ -22,8 +22,6 @@
  *
  */
 
-# define __STDC_FORMAT_MACROS
-
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
--- ./hotspot/src/os/posix/launcher/java_md.c	2011-05-26 17:28:59.000000000 -0700
+++ ./hotspot/src/os/posix/launcher/java_md.c	2011-04-22 22:28:34.000000000 -0700
@@ -41,14 +41,21 @@
 #include "version_comp.h"
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <pthread.h>
 #else
 #include <thread.h>
 #endif
 
+#ifdef __APPLE__
+#define JVM_DLL "libjvm.dylib"
+#define JAVA_DLL "libjava.dylib"
+#define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
+#else
 #define JVM_DLL "libjvm.so"
 #define JAVA_DLL "libjava.so"
+#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
+#endif
 
 #ifndef GAMMA   /* launcher.make defines ARCH */
 /*
@@ -423,10 +430,10 @@
        * If not on Solaris, assume only a single LD_LIBRARY_PATH
        * variable.
        */
-      runpath = getenv("LD_LIBRARY_PATH");
+      runpath = getenv(LD_LIBRARY_PATH);
 #endif /* __sun */
 
-#ifdef __linux
+#if defined(__linux)
       /*
        * On linux, if a binary is running as sgid or suid, glibc sets
        * LD_LIBRARY_PATH to the empty string for security purposes.  (In
@@ -442,6 +449,22 @@
       if((getgid() != getegid()) || (getuid() != geteuid()) ) {
         return;
       }
+#elif _ALLBSD_SOURCE
+      /*
+       * On BSD, if a binary is running as sgid or suid, libc sets
+       * LD_LIBRARY_PATH to the empty string for security purposes.  (In
+       * contrast, on Solaris the LD_LIBRARY_PATH variable for a
+       * privileged binary does not lose its settings; but the dynamic
+       * linker does apply more scrutiny to the path.) The launcher uses
+       * the value of LD_LIBRARY_PATH to prevent an exec loop.
+       * Therefore, if we are running sgid or suid, this function's
+       * setting of LD_LIBRARY_PATH will be ineffective and we should
+       * return from the function now.  Getting the right libraries to
+       * be found must be handled through other mechanisms.
+       */
+      if(issetugid()) {
+        return;
+      }
 #endif
 
       /* runpath contains current effective LD_LIBRARY_PATH setting */
@@ -450,7 +473,7 @@
       new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) +
                               2*strlen(jrepath) + 2*strlen(arch) +
                               strlen(jvmpath) + 52);
-      newpath = new_runpath + strlen("LD_LIBRARY_PATH=");
+      newpath = new_runpath + strlen(LD_LIBRARY_PATH "=");
 
 
       /*
@@ -465,7 +488,7 @@
 
         /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */
 
-        sprintf(new_runpath, "LD_LIBRARY_PATH="
+        sprintf(new_runpath, LD_LIBRARY_PATH "="
                 "%s:"
                 "%s/lib/%s:"
                 "%s/../lib/%s",
@@ -792,7 +815,7 @@
 jboolean
 GetApplicationHome(char *buf, jint bufsize)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     char *execname = GetExecname();
     if (execname) {
         strncpy(buf, execname, bufsize-1);
@@ -1175,7 +1198,7 @@
 
 #endif /* __sun && i586 */
 
-#if defined(__linux__) && defined(i586)
+#if (defined(__linux__) || defined(_ALLBSD_SOURCE)) && defined(i586)
 
 /*
  * A utility method for asking the CPU about itself.
@@ -1452,6 +1475,39 @@
 
 #endif /* __linux__ && i586 */
 
+#if defined(_ALLBSD_SOURCE) && defined(i586)
+
+/* The definition of a server-class machine for bsd-i586 */
+jboolean
+bsd_i586_ServerClassMachine(void) {
+  jboolean            result            = JNI_FALSE;
+  /* How big is a server class machine? */
+  const unsigned long server_processors = 2UL;
+  const uint64_t      server_memory     = 2UL * GB;
+  /*
+   * We seem not to get our full complement of memory.
+   *     We allow some part (1/8?) of the memory to be "missing",
+   *     based on the sizes of DIMMs, and maybe graphics cards.
+   */
+  const uint64_t      missing_memory    = 256UL * MB;
+  const uint64_t      actual_memory     = physical_memory();
+
+  /* Is this a server class machine? */
+  if (actual_memory >= (server_memory - missing_memory)) {
+    const unsigned long actual_processors = physical_processors();
+    if (actual_processors >= server_processors) {
+      result = JNI_TRUE;
+    }
+  }
+  if (_launcher_debug) {
+    printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
+           (result == JNI_TRUE ? "true" : "false"));
+  }
+  return result;
+}
+
+#endif /* _ALLBSD_SOURCE && i586 */
+
 /* Dispatch to the platform-specific definition of "server-class" */
 jboolean
 ServerClassMachine(void) {
@@ -1466,6 +1522,8 @@
   result = solaris_i586_ServerClassMachine();
 #elif defined(__linux__) && defined(i586)
   result = linux_i586_ServerClassMachine();
+#elif defined(_ALLBSD_SOURCE) && defined(i586)
+  result = bsd_i586_ServerClassMachine();
 #else
   if (_launcher_debug) {
     printf("ServerClassMachine: returns default value of %s\n",
@@ -1821,7 +1879,7 @@
 int
 ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
     int rslt;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     pthread_t tid;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
--- ./hotspot/src/os/posix/launcher/launcher.script	2011-05-26 17:28:59.000000000 -0700
+++ ./hotspot/src/os/posix/launcher/launcher.script	2011-04-22 22:28:34.000000000 -0700
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
--- ./hotspot/src/os_cpu/bsd_sparc/vm/assembler_bsd_sparc.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/assembler_bsd_sparc.cpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/assembler.hpp"
-#include "assembler_sparc.inline.hpp"
-#include "runtime/os.hpp"
-#include "runtime/threadLocalStorage.hpp"
-
-#include <asm-sparc/traps.h>
-
-void MacroAssembler::read_ccr_trap(Register ccr_save) {
-  // No implementation
-  breakpoint_trap();
-}
-
-void MacroAssembler::write_ccr_trap(Register ccr_save, Register scratch1, Register scratch2) {
-  // No implementation
-  breakpoint_trap();
-}
-
-void MacroAssembler::flush_windows_trap() { trap(SP_TRAP_FWIN); }
-void MacroAssembler::clean_windows_trap() { trap(SP_TRAP_CWIN); }
-
-// Use software breakpoint trap until we figure out how to do this on Bsd
-void MacroAssembler::get_psr_trap()       { trap(SP_TRAP_SBPT); }
-void MacroAssembler::set_psr_trap()       { trap(SP_TRAP_SBPT); }
--- ./hotspot/src/os_cpu/bsd_sparc/vm/atomic_bsd_sparc.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/atomic_bsd_sparc.inline.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_ATOMIC_BSD_SPARC_INLINE_HPP
-#define OS_CPU_BSD_SPARC_VM_ATOMIC_BSD_SPARC_INLINE_HPP
-
-#include "orderAccess_bsd_sparc.inline.hpp"
-#include "runtime/atomic.hpp"
-#include "runtime/os.hpp"
-#include "vm_version_sparc.hpp"
-
-// Implementation of class atomic
-
-inline void Atomic::store    (jbyte    store_value, jbyte*    dest) { *dest = store_value; }
-inline void Atomic::store    (jshort   store_value, jshort*   dest) { *dest = store_value; }
-inline void Atomic::store    (jint     store_value, jint*     dest) { *dest = store_value; }
-inline void Atomic::store    (jlong    store_value, jlong*    dest) { *dest = store_value; }
-inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
-inline void Atomic::store_ptr(void*    store_value, void*     dest) { *(void**)dest = store_value; }
-
-inline void Atomic::store    (jbyte    store_value, volatile jbyte*    dest) { *dest = store_value; }
-inline void Atomic::store    (jshort   store_value, volatile jshort*   dest) { *dest = store_value; }
-inline void Atomic::store    (jint     store_value, volatile jint*     dest) { *dest = store_value; }
-inline void Atomic::store    (jlong    store_value, volatile jlong*    dest) { *dest = store_value; }
-inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
-inline void Atomic::store_ptr(void*    store_value, volatile void*     dest) { *(void* volatile *)dest = store_value; }
-
-inline void Atomic::inc    (volatile jint*     dest) { (void)add    (1, dest); }
-inline void Atomic::inc_ptr(volatile intptr_t* dest) { (void)add_ptr(1, dest); }
-inline void Atomic::inc_ptr(volatile void*     dest) { (void)add_ptr(1, dest); }
-
-inline void Atomic::dec    (volatile jint*     dest) { (void)add    (-1, dest); }
-inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
-inline void Atomic::dec_ptr(volatile void*     dest) { (void)add_ptr(-1, dest); }
-
-inline jlong Atomic::load(volatile jlong* src) { return *src; }
-
-inline jint     Atomic::add    (jint     add_value, volatile jint*     dest) {
-  intptr_t rv;
-  __asm__ volatile(
-    "1: \n\t"
-    " ld     [%2], %%o2\n\t"
-    " add    %1, %%o2, %%o3\n\t"
-    " cas    [%2], %%o2, %%o3\n\t"
-    " cmp    %%o2, %%o3\n\t"
-    " bne    1b\n\t"
-    "  nop\n\t"
-    " add    %1, %%o2, %0\n\t"
-    : "=r" (rv)
-    : "r" (add_value), "r" (dest)
-    : "memory", "o2", "o3");
-  return rv;
-}
-
-inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
-  intptr_t rv;
-#ifdef _LP64
-  __asm__ volatile(
-    "1: \n\t"
-    " ldx    [%2], %%o2\n\t"
-    " add    %0, %%o2, %%o3\n\t"
-    " casx   [%2], %%o2, %%o3\n\t"
-    " cmp    %%o2, %%o3\n\t"
-    " bne    %%xcc, 1b\n\t"
-    "  nop\n\t"
-    " add    %0, %%o2, %0\n\t"
-    : "=r" (rv)
-    : "r" (add_value), "r" (dest)
-    : "memory", "o2", "o3");
-#else
-  __asm__ volatile(
-    "1: \n\t"
-    " ld     [%2], %%o2\n\t"
-    " add    %1, %%o2, %%o3\n\t"
-    " cas    [%2], %%o2, %%o3\n\t"
-    " cmp    %%o2, %%o3\n\t"
-    " bne    1b\n\t"
-    "  nop\n\t"
-    " add    %1, %%o2, %0\n\t"
-    : "=r" (rv)
-    : "r" (add_value), "r" (dest)
-    : "memory", "o2", "o3");
-#endif // _LP64
-  return rv;
-}
-
-inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
-  return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest);
-}
-
-
-inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
-  intptr_t rv = exchange_value;
-  __asm__ volatile(
-    " swap   [%2],%1\n\t"
-    : "=r" (rv)
-    : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
-    : "memory");
-  return rv;
-}
-
-inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
-  intptr_t rv = exchange_value;
-#ifdef _LP64
-  __asm__ volatile(
-    "1:\n\t"
-    " mov    %1, %%o3\n\t"
-    " ldx    [%2], %%o2\n\t"
-    " casx   [%2], %%o2, %%o3\n\t"
-    " cmp    %%o2, %%o3\n\t"
-    " bne    %%xcc, 1b\n\t"
-    "  nop\n\t"
-    " mov    %%o2, %0\n\t"
-    : "=r" (rv)
-    : "r" (exchange_value), "r" (dest)
-    : "memory", "o2", "o3");
-#else
-  __asm__ volatile(
-    "swap    [%2],%1\n\t"
-    : "=r" (rv)
-    : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
-    : "memory");
-#endif // _LP64
-  return rv;
-}
-
-inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
-  return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
-}
-
-
-inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
-  jint rv;
-  __asm__ volatile(
-    " cas    [%2], %3, %0"
-    : "=r" (rv)
-    : "0" (exchange_value), "r" (dest), "r" (compare_value)
-    : "memory");
-  return rv;
-}
-
-inline jlong    Atomic::cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value) {
-#ifdef _LP64
-  jlong rv;
-  __asm__ volatile(
-    " casx   [%2], %3, %0"
-    : "=r" (rv)
-    : "0" (exchange_value), "r" (dest), "r" (compare_value)
-    : "memory");
-  return rv;
-#else
-  assert(VM_Version::v9_instructions_work(), "cas only supported on v9");
-  volatile jlong_accessor evl, cvl, rv;
-  evl.long_value = exchange_value;
-  cvl.long_value = compare_value;
-
-  __asm__ volatile(
-    " sllx   %2, 32, %2\n\t"
-    " srl    %3, 0,  %3\n\t"
-    " or     %2, %3, %2\n\t"
-    " sllx   %5, 32, %5\n\t"
-    " srl    %6, 0,  %6\n\t"
-    " or     %5, %6, %5\n\t"
-    " casx   [%4], %5, %2\n\t"
-    " srl    %2, 0, %1\n\t"
-    " srlx   %2, 32, %0\n\t"
-    : "=r" (rv.words[0]), "=r" (rv.words[1])
-    : "r"  (evl.words[0]), "r" (evl.words[1]), "r" (dest), "r" (cvl.words[0]), "r" (cvl.words[1])
-    : "memory");
-
-  return rv.long_value;
-#endif
-}
-
-inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
-  intptr_t rv;
-#ifdef _LP64
-  __asm__ volatile(
-    " casx    [%2], %3, %0"
-    : "=r" (rv)
-    : "0" (exchange_value), "r" (dest), "r" (compare_value)
-    : "memory");
-#else
-  __asm__ volatile(
-    " cas     [%2], %3, %0"
-    : "=r" (rv)
-    : "0" (exchange_value), "r" (dest), "r" (compare_value)
-    : "memory");
-#endif // _LP64
-  return rv;
-}
-
-inline void*    Atomic::cmpxchg_ptr(void*    exchange_value, volatile void*     dest, void*    compare_value) {
-  return (void*)cmpxchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest, (intptr_t)compare_value);
-}
-
-#endif // OS_CPU_BSD_SPARC_VM_ATOMIC_BSD_SPARC_INLINE_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.ad	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.ad	1969-12-31 16:00:00.000000000 -0800
@@ -1,27 +0,0 @@
-//
-// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
-// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-//
-// This code is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License version 2 only, as
-// published by the Free Software Foundation.
-//
-// This code 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 General Public License
-// version 2 for more details (a copy is included in the LICENSE file that
-// accompanied this code).
-//
-// You should have received a copy of the GNU General Public License version
-// 2 along with this work; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-// or visit www.oracle.com if you need additional information or have any
-// questions.
-//
-
-//
-//
-
-// SPARC Bsd Architecture Description File
--- ./hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.s	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/bsd_sparc.s	1969-12-31 16:00:00.000000000 -0800
@@ -1,105 +0,0 @@
-#
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code 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 General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-    # Prototype: int SafeFetch32 (int * adr, int ErrValue)
-    # The "ld" at Fetch32 is potentially faulting instruction.
-    # If the instruction traps the trap handler will arrange
-    # for control to resume at Fetch32Resume.  
-    # By convention with the trap handler we ensure there is a non-CTI
-    # instruction in the trap shadow.  
-        
-
-    .globl  SafeFetch32, Fetch32PFI, Fetch32Resume
-    .globl  SafeFetchN
-    .align  32
-    .type    SafeFetch32,@function
-SafeFetch32:        
-    mov     %o0, %g1
-    mov     %o1, %o0
-Fetch32PFI:
-    # <-- Potentially faulting instruction
-    ld      [%g1], %o0         
-Fetch32Resume:
-    nop
-    retl
-    nop
-
-    .globl  SafeFetchN, FetchNPFI, FetchNResume
-    .type    SafeFetchN,@function
-    .align  32
-SafeFetchN:
-    mov     %o0, %g1
-    mov     %o1, %o0
-FetchNPFI:
-    ldn     [%g1], %o0
-FetchNResume:
-    nop
-    retl
-    nop
-
-    # Possibilities:
-    # -- membar
-    # -- CAS (SP + BIAS, G0, G0)
-    # -- wr %g0, %asi
-
-    .globl SpinPause
-    .type   SpinPause,@function
-    .align  32
-SpinPause:      
-    retl
-    mov %g0, %o0
-
-   .globl _Copy_conjoint_jlongs_atomic
-   .type   _Copy_conjoint_jlongs_atomic,@function
-_Copy_conjoint_jlongs_atomic:
-        cmp     %o0, %o1
-	bleu    4f
-	sll     %o2, 3, %o4
-        ba      2f
-   1:
-	subcc   %o4, 8, %o4
-	std     %o2, [%o1]
-	add     %o0, 8, %o0
-	add     %o1, 8, %o1
-   2:
-	bge,a   1b
-	ldd     [%o0], %o2
-	ba      5f
-        nop
-   3:
-	std     %o2, [%o1+%o4]
-   4:
-	subcc   %o4, 8, %o4
-	bge,a   3b
-	ldd     [%o0+%o4], %o2
-   5:      
-	retl
-	nop
-
-
-    .globl _flush_reg_windows
-    .align 32
- _flush_reg_windows:
-        ta 0x03
-        retl
-        mov     %fp, %o0
--- ./hotspot/src/os_cpu/bsd_sparc/vm/globals_bsd_sparc.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/globals_bsd_sparc.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_GLOBALS_BSD_SPARC_HPP
-#define OS_CPU_BSD_SPARC_VM_GLOBALS_BSD_SPARC_HPP
-
-//
-// Sets the default values for platform dependent flags used by the
-// runtime system.  (see globals.hpp)
-//
-
-define_pd_global(uintx, JVMInvokeMethodSlack,    12288);
-define_pd_global(intx, CompilerThreadStackSize,  0);
-
-// Only used on 64 bit platforms
-define_pd_global(uintx, HeapBaseMinAddress,      4*G);
-// Only used on 64 bit Windows platforms
-define_pd_global(bool, UseVectoredExceptions, false);
-
-#endif // OS_CPU_BSD_SPARC_VM_GLOBALS_BSD_SPARC_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/orderAccess_bsd_sparc.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/orderAccess_bsd_sparc.inline.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_ORDERACCESS_BSD_SPARC_INLINE_HPP
-#define OS_CPU_BSD_SPARC_VM_ORDERACCESS_BSD_SPARC_INLINE_HPP
-
-#include "runtime/orderAccess.hpp"
-#include "vm_version_sparc.hpp"
-
-// Implementation of class OrderAccess.
-
-// Assume TSO.
-
-inline void OrderAccess::loadload()   { acquire(); }
-inline void OrderAccess::storestore() { release(); }
-inline void OrderAccess::loadstore()  { acquire(); }
-inline void OrderAccess::storeload()  { fence(); }
-
-inline void OrderAccess::acquire() {
-  __asm__ volatile ("nop" : : :);
-}
-
-inline void OrderAccess::release() {
-  jint* local_dummy = (jint*)&local_dummy;
-  __asm__ volatile("stw %%g0, [%0]" : : "r" (local_dummy) : "memory");
-}
-
-inline void OrderAccess::fence() {
-  __asm__ volatile ("membar  #StoreLoad" : : :);
-}
-
-inline jbyte    OrderAccess::load_acquire(volatile jbyte*   p) { return *p; }
-inline jshort   OrderAccess::load_acquire(volatile jshort*  p) { return *p; }
-inline jint     OrderAccess::load_acquire(volatile jint*    p) { return *p; }
-inline jlong    OrderAccess::load_acquire(volatile jlong*   p) { return *p; }
-inline jubyte   OrderAccess::load_acquire(volatile jubyte*  p) { return *p; }
-inline jushort  OrderAccess::load_acquire(volatile jushort* p) { return *p; }
-inline juint    OrderAccess::load_acquire(volatile juint*   p) { return *p; }
-inline julong   OrderAccess::load_acquire(volatile julong*  p) { return *p; }
-inline jfloat   OrderAccess::load_acquire(volatile jfloat*  p) { return *p; }
-inline jdouble  OrderAccess::load_acquire(volatile jdouble* p) { return *p; }
-
-inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t*   p) { return *p; }
-inline void*    OrderAccess::load_ptr_acquire(volatile void*       p) { return *(void* volatile *)p; }
-inline void*    OrderAccess::load_ptr_acquire(const volatile void* p) { return *(void* const volatile *)p; }
-
-inline void     OrderAccess::release_store(volatile jbyte*   p, jbyte   v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jshort*  p, jshort  v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jint*    p, jint    v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jlong*   p, jlong   v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jubyte*  p, jubyte  v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jushort* p, jushort v) { *p = v; }
-inline void     OrderAccess::release_store(volatile juint*   p, juint   v) { *p = v; }
-inline void     OrderAccess::release_store(volatile julong*  p, julong  v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jfloat*  p, jfloat  v) { *p = v; }
-inline void     OrderAccess::release_store(volatile jdouble* p, jdouble v) { *p = v; }
-
-inline void     OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { *p = v; }
-inline void     OrderAccess::release_store_ptr(volatile void*     p, void*    v) { *(void* volatile *)p = v; }
-
-inline void     OrderAccess::store_fence(jbyte*   p, jbyte   v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jshort*  p, jshort  v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jint*    p, jint    v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jlong*   p, jlong   v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jubyte*  p, jubyte  v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jushort* p, jushort v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(juint*   p, juint   v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(julong*  p, julong  v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jfloat*  p, jfloat  v) { *p = v; fence(); }
-inline void     OrderAccess::store_fence(jdouble* p, jdouble v) { *p = v; fence(); }
-
-inline void     OrderAccess::store_ptr_fence(intptr_t* p, intptr_t v) { *p = v; fence(); }
-inline void     OrderAccess::store_ptr_fence(void**    p, void*    v) { *p = v; fence(); }
-
-inline void     OrderAccess::release_store_fence(volatile jbyte*   p, jbyte   v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jshort*  p, jshort  v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jint*    p, jint    v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jlong*   p, jlong   v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jubyte*  p, jubyte  v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jushort* p, jushort v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile juint*   p, juint   v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile julong*  p, julong  v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jfloat*  p, jfloat  v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { *p = v; fence(); }
-
-inline void     OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) { *p = v; fence(); }
-inline void     OrderAccess::release_store_ptr_fence(volatile void*     p, void*    v) { *(void* volatile *)p = v; fence(); }
-
-#endif // OS_CPU_BSD_SPARC_VM_ORDERACCESS_BSD_SPARC_INLINE_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.cpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,758 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-// no precompiled headers
-#include "assembler_sparc.inline.hpp"
-#include "classfile/classLoader.hpp"
-#include "classfile/systemDictionary.hpp"
-#include "classfile/vmSymbols.hpp"
-#include "code/icBuffer.hpp"
-#include "code/vtableStubs.hpp"
-#include "interpreter/interpreter.hpp"
-#include "jvm_bsd.h"
-#include "memory/allocation.inline.hpp"
-#include "mutex_bsd.inline.hpp"
-#include "nativeInst_sparc.hpp"
-#include "os_share_bsd.hpp"
-#include "prims/jniFastGetField.hpp"
-#include "prims/jvm.h"
-#include "prims/jvm_misc.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/extendedPC.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/interfaceSupport.hpp"
-#include "runtime/java.hpp"
-#include "runtime/javaCalls.hpp"
-#include "runtime/mutexLocker.hpp"
-#include "runtime/osThread.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/timer.hpp"
-#include "thread_bsd.inline.hpp"
-#include "utilities/events.hpp"
-#include "utilities/vmError.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-#ifdef COMPILER2
-#include "opto/runtime.hpp"
-#endif
-
-
-// Bsd/Sparc has rather obscure naming of registers in sigcontext
-// different between 32 and 64 bits
-#ifdef _LP64
-#define SIG_PC(x) ((x)->sigc_regs.tpc)
-#define SIG_NPC(x) ((x)->sigc_regs.tnpc)
-#define SIG_REGS(x) ((x)->sigc_regs)
-#else
-#define SIG_PC(x) ((x)->si_regs.pc)
-#define SIG_NPC(x) ((x)->si_regs.npc)
-#define SIG_REGS(x) ((x)->si_regs)
-#endif
-
-// those are to reference registers in sigcontext
-enum {
-  CON_G0 = 0,
-  CON_G1,
-  CON_G2,
-  CON_G3,
-  CON_G4,
-  CON_G5,
-  CON_G6,
-  CON_G7,
-  CON_O0,
-  CON_O1,
-  CON_O2,
-  CON_O3,
-  CON_O4,
-  CON_O5,
-  CON_O6,
-  CON_O7,
-};
-
-static inline void set_cont_address(sigcontext* ctx, address addr) {
-  SIG_PC(ctx)  = (intptr_t)addr;
-  SIG_NPC(ctx) = (intptr_t)(addr+4);
-}
-
-// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
-// currently interrupted by SIGPROF.
-// os::Solaris::fetch_frame_from_ucontext() tries to skip nested
-// signal frames. Currently we don't do that on Bsd, so it's the
-// same as os::fetch_frame_from_context().
-ExtendedPC os::Bsd::fetch_frame_from_ucontext(Thread* thread,
-                                                ucontext_t* uc,
-                                                intptr_t** ret_sp,
-                                                intptr_t** ret_fp) {
-  assert(thread != NULL, "just checking");
-  assert(ret_sp != NULL, "just checking");
-  assert(ret_fp != NULL, "just checking");
-
-  return os::fetch_frame_from_context(uc, ret_sp, ret_fp);
-}
-
-ExtendedPC os::fetch_frame_from_context(void* ucVoid,
-                                        intptr_t** ret_sp,
-                                        intptr_t** ret_fp) {
-  ucontext_t* uc = (ucontext_t*) ucVoid;
-  ExtendedPC  epc;
-
-  if (uc != NULL) {
-    epc = ExtendedPC(os::Bsd::ucontext_get_pc(uc));
-    if (ret_sp) {
-      *ret_sp = os::Bsd::ucontext_get_sp(uc);
-    }
-    if (ret_fp) {
-      *ret_fp = os::Bsd::ucontext_get_fp(uc);
-    }
-  } else {
-    // construct empty ExtendedPC for return value checking
-    epc = ExtendedPC(NULL);
-    if (ret_sp) {
-      *ret_sp = (intptr_t*) NULL;
-    }
-    if (ret_fp) {
-      *ret_fp = (intptr_t*) NULL;
-    }
-  }
-
-  return epc;
-}
-
-frame os::fetch_frame_from_context(void* ucVoid) {
-  intptr_t* sp;
-  intptr_t* fp;
-  ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
-  return frame(sp, fp, epc.pc());
-}
-
-frame os::get_sender_for_C_frame(frame* fr) {
-  return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
-}
-
-frame os::current_frame() {
-  fprintf(stderr, "current_frame()");
-
-  intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()();
-  frame myframe(sp, frame::unpatchable,
-                CAST_FROM_FN_PTR(address, os::current_frame));
-  if (os::is_first_C_frame(&myframe)) {
-    // stack is not walkable
-    return frame(NULL, frame::unpatchable, NULL);
-  } else {
-    return os::get_sender_for_C_frame(&myframe);
-  }
-}
-
-address os::current_stack_pointer() {
-  register void *sp __asm__ ("sp");
-  return (address)sp;
-}
-
-static void current_stack_region(address* bottom, size_t* size) {
-  if (os::Bsd::is_initial_thread()) {
-    // initial thread needs special handling because pthread_getattr_np()
-    // may return bogus value.
-    *bottom = os::Bsd::initial_thread_stack_bottom();
-    *size = os::Bsd::initial_thread_stack_size();
-  } else {
-    pthread_attr_t attr;
-
-    int rslt = pthread_getattr_np(pthread_self(), &attr);
-
-    // JVM needs to know exact stack location, abort if it fails
-    if (rslt != 0) {
-      if (rslt == ENOMEM) {
-        vm_exit_out_of_memory(0, "pthread_getattr_np");
-      } else {
-        fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
-      }
-    }
-
-    if (pthread_attr_getstack(&attr, (void**)bottom, size) != 0) {
-      fatal("Can not locate current stack attributes!");
-    }
-
-    pthread_attr_destroy(&attr);
-  }
-  assert(os::current_stack_pointer() >= *bottom &&
-         os::current_stack_pointer() < *bottom + *size, "just checking");
-}
-
-address os::current_stack_base() {
-  address bottom;
-  size_t size;
-  current_stack_region(&bottom, &size);
-  return bottom + size;
-}
-
-size_t os::current_stack_size() {
-  // stack size includes normal stack and HotSpot guard pages
-  address bottom;
-  size_t size;
-  current_stack_region(&bottom, &size);
-  return size;
-}
-
-char* os::non_memory_address_word() {
-  // Must never look like an address returned by reserve_memory,
-  // even in its subfields (as defined by the CPU immediate fields,
-  // if the CPU splits constants across multiple instructions).
-  // On SPARC, 0 != %hi(any real address), because there is no
-  // allocation in the first 1Kb of the virtual address space.
-  return (char*) 0;
-}
-
-void os::initialize_thread() {}
-
-void os::print_context(outputStream *st, void *context) {
-  if (context == NULL) return;
-
-  ucontext_t* uc = (ucontext_t*)context;
-  sigcontext* sc = (sigcontext*)context;
-  st->print_cr("Registers:");
-
-  st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT
-               " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT,
-               SIG_REGS(sc).u_regs[CON_G1],
-               SIG_REGS(sc).u_regs[CON_G2],
-               SIG_REGS(sc).u_regs[CON_G3],
-               SIG_REGS(sc).u_regs[CON_G4]);
-  st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT
-               " G7=" INTPTR_FORMAT " Y=" INTPTR_FORMAT,
-               SIG_REGS(sc).u_regs[CON_G5],
-               SIG_REGS(sc).u_regs[CON_G6],
-               SIG_REGS(sc).u_regs[CON_G7],
-               SIG_REGS(sc).y);
-  st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT
-               " O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT,
-               SIG_REGS(sc).u_regs[CON_O0],
-               SIG_REGS(sc).u_regs[CON_O1],
-               SIG_REGS(sc).u_regs[CON_O2],
-               SIG_REGS(sc).u_regs[CON_O3]);
-  st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT
-               " O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT,
-               SIG_REGS(sc).u_regs[CON_O4],
-               SIG_REGS(sc).u_regs[CON_O5],
-               SIG_REGS(sc).u_regs[CON_O6],
-               SIG_REGS(sc).u_regs[CON_O7]);
-
-
-  intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
-  st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT
-               " L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT,
-               sp[L0->sp_offset_in_saved_window()],
-               sp[L1->sp_offset_in_saved_window()],
-               sp[L2->sp_offset_in_saved_window()],
-               sp[L3->sp_offset_in_saved_window()]);
-  st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT
-               " L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT,
-               sp[L4->sp_offset_in_saved_window()],
-               sp[L5->sp_offset_in_saved_window()],
-               sp[L6->sp_offset_in_saved_window()],
-               sp[L7->sp_offset_in_saved_window()]);
-  st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT
-               " I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT,
-               sp[I0->sp_offset_in_saved_window()],
-               sp[I1->sp_offset_in_saved_window()],
-               sp[I2->sp_offset_in_saved_window()],
-               sp[I3->sp_offset_in_saved_window()]);
-  st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT
-               " I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT,
-               sp[I4->sp_offset_in_saved_window()],
-               sp[I5->sp_offset_in_saved_window()],
-               sp[I6->sp_offset_in_saved_window()],
-               sp[I7->sp_offset_in_saved_window()]);
-
-  st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT,
-               SIG_PC(sc),
-               SIG_NPC(sc));
-  st->cr();
-  st->cr();
-
-  st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
-  print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
-  st->cr();
-
-  // Note: it may be unsafe to inspect memory near pc. For example, pc may
-  // point to garbage if entry point in an nmethod is corrupted. Leave
-  // this at the end, and hope for the best.
-  address pc = os::Bsd::ucontext_get_pc(uc);
-  st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
-  print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
-}
-
-
-void os::print_register_info(outputStream *st, void *context) {
-  if (context == NULL) return;
-
-  ucontext_t *uc = (ucontext_t*)context;
-  intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
-
-  st->print_cr("Register to memory mapping:");
-  st->cr();
-
-  // this is only for the "general purpose" registers
-  st->print("G1="); print_location(st, SIG_REGS(sc).u_regs[CON__G1]);
-  st->print("G2="); print_location(st, SIG_REGS(sc).u_regs[CON__G2]);
-  st->print("G3="); print_location(st, SIG_REGS(sc).u_regs[CON__G3]);
-  st->print("G4="); print_location(st, SIG_REGS(sc).u_regs[CON__G4]);
-  st->print("G5="); print_location(st, SIG_REGS(sc).u_regs[CON__G5]);
-  st->print("G6="); print_location(st, SIG_REGS(sc).u_regs[CON__G6]);
-  st->print("G7="); print_location(st, SIG_REGS(sc).u_regs[CON__G7]);
-  st->cr();
-
-  st->print("O0="); print_location(st, SIG_REGS(sc).u_regs[CON__O0]);
-  st->print("O1="); print_location(st, SIG_REGS(sc).u_regs[CON__O1]);
-  st->print("O2="); print_location(st, SIG_REGS(sc).u_regs[CON__O2]);
-  st->print("O3="); print_location(st, SIG_REGS(sc).u_regs[CON__O3]);
-  st->print("O4="); print_location(st, SIG_REGS(sc).u_regs[CON__O4]);
-  st->print("O5="); print_location(st, SIG_REGS(sc).u_regs[CON__O5]);
-  st->print("O6="); print_location(st, SIG_REGS(sc).u_regs[CON__O6]);
-  st->print("O7="); print_location(st, SIG_REGS(sc).u_regs[CON__O7]);
-  st->cr();
-
-  st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]);
-  st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]);
-  st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]);
-  st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]);
-  st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]);
-  st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]);
-  st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]);
-  st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]);
-  st->cr();
-
-  st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]);
-  st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]);
-  st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]);
-  st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]);
-  st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]);
-  st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]);
-  st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]);
-  st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]);
-  st->cr();
-}
-
-
-address os::Bsd::ucontext_get_pc(ucontext_t* uc) {
-  return (address) SIG_PC((sigcontext*)uc);
-}
-
-intptr_t* os::Bsd::ucontext_get_sp(ucontext_t *uc) {
-  return (intptr_t*)
-    ((intptr_t)SIG_REGS((sigcontext*)uc).u_regs[CON_O6] + STACK_BIAS);
-}
-
-// not used on Sparc
-intptr_t* os::Bsd::ucontext_get_fp(ucontext_t *uc) {
-  ShouldNotReachHere();
-  return NULL;
-}
-
-// Utility functions
-
-extern "C" void Fetch32PFI();
-extern "C" void Fetch32Resume();
-extern "C" void FetchNPFI();
-extern "C" void FetchNResume();
-
-inline static bool checkPrefetch(sigcontext* uc, address pc) {
-  if (pc == (address) Fetch32PFI) {
-    set_cont_address(uc, address(Fetch32Resume));
-    return true;
-  }
-  if (pc == (address) FetchNPFI) {
-    set_cont_address(uc, address(FetchNResume));
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkOverflow(sigcontext* uc,
-                                 address pc,
-                                 address addr,
-                                 JavaThread* thread,
-                                 address* stub) {
-  // check if fault address is within thread stack
-  if (addr < thread->stack_base() &&
-      addr >= thread->stack_base() - thread->stack_size()) {
-    // stack overflow
-    if (thread->in_stack_yellow_zone(addr)) {
-      thread->disable_stack_yellow_zone();
-      if (thread->thread_state() == _thread_in_Java) {
-        // Throw a stack overflow exception.  Guard pages will be reenabled
-        // while unwinding the stack.
-        *stub =
-          SharedRuntime::continuation_for_implicit_exception(thread,
-                                                             pc,
-                                                             SharedRuntime::STACK_OVERFLOW);
-      } else {
-        // Thread was in the vm or native code.  Return and try to finish.
-        return true;
-      }
-    } else if (thread->in_stack_red_zone(addr)) {
-      // Fatal red zone violation.  Disable the guard pages and fall through
-      // to handle_unexpected_exception way down below.
-      thread->disable_stack_red_zone();
-      tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
-    } else {
-      // Accessing stack address below sp may cause SEGV if current
-      // thread has MAP_GROWSDOWN stack. This should only happen when
-      // current thread was created by user code with MAP_GROWSDOWN flag
-      // and then attached to VM. See notes in os_bsd.cpp.
-      if (thread->osthread()->expanding_stack() == 0) {
-        thread->osthread()->set_expanding_stack();
-        if (os::Bsd::manually_expand_stack(thread, addr)) {
-          thread->osthread()->clear_expanding_stack();
-          return true;
-        }
-        thread->osthread()->clear_expanding_stack();
-      } else {
-        fatal("recursive segv. expanding stack.");
-      }
-    }
-  }
-  return false;
-}
-
-inline static bool checkPollingPage(address pc, address fault, address* stub) {
-  if (fault == os::get_polling_page()) {
-    *stub = SharedRuntime::get_poll_stub(pc);
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkByteBuffer(address pc, address* stub) {
-  // BugId 4454115: A read from a MappedByteBuffer can fault
-  // here if the underlying file has been truncated.
-  // Do not crash the VM in such a case.
-  CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-  nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
-  if (nm != NULL && nm->has_unsafe_access()) {
-    *stub = StubRoutines::handler_for_unsafe_access();
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkVerifyOops(address pc, address fault, address* stub) {
-  if (pc >= MacroAssembler::_verify_oop_implicit_branch[0]
-      && pc <  MacroAssembler::_verify_oop_implicit_branch[1] ) {
-    *stub     =  MacroAssembler::_verify_oop_implicit_branch[2];
-    warning("fixed up memory fault in +VerifyOops at address "
-            INTPTR_FORMAT, fault);
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkFPFault(address pc, int code,
-                                JavaThread* thread, address* stub) {
-  if (code == FPE_INTDIV || code == FPE_FLTDIV) {
-    *stub =
-      SharedRuntime::
-      continuation_for_implicit_exception(thread,
-                                          pc,
-                                          SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkNullPointer(address pc, intptr_t fault,
-                                    JavaThread* thread, address* stub) {
-  if (!MacroAssembler::needs_explicit_null_check(fault)) {
-    // Determination of interpreter/vtable stub/compiled code null
-    // exception
-    *stub =
-      SharedRuntime::
-      continuation_for_implicit_exception(thread, pc,
-                                          SharedRuntime::IMPLICIT_NULL);
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkFastJNIAccess(address pc, address* stub) {
-  address addr = JNI_FastGetField::find_slowcase_pc(pc);
-  if (addr != (address)-1) {
-    *stub = addr;
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkSerializePage(JavaThread* thread, address addr) {
-  return os::is_memory_serialize_page(thread, addr);
-}
-
-inline static bool checkZombie(sigcontext* uc, address* pc, address* stub) {
-  if (nativeInstruction_at(*pc)->is_zombie()) {
-    // zombie method (ld [%g0],%o7 instruction)
-    *stub = SharedRuntime::get_handle_wrong_method_stub();
-
-    // At the stub it needs to look like a call from the caller of this
-    // method (not a call from the segv site).
-    *pc = (address)SIG_REGS(uc).u_regs[CON_O7];
-    return true;
-  }
-  return false;
-}
-
-inline static bool checkICMiss(sigcontext* uc, address* pc, address* stub) {
-#ifdef COMPILER2
-  if (nativeInstruction_at(*pc)->is_ic_miss_trap()) {
-#ifdef ASSERT
-#ifdef TIERED
-    CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
-    assert(cb->is_compiled_by_c2(), "Wrong compiler");
-#endif // TIERED
-#endif // ASSERT
-    // Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken.
-    *stub = SharedRuntime::get_ic_miss_stub();
-    // At the stub it needs to look like a call from the caller of this
-    // method (not a call from the segv site).
-    *pc = (address)SIG_REGS(uc).u_regs[CON_O7];
-    return true;
-  }
-#endif  // COMPILER2
-  return false;
-}
-
-extern "C" JNIEXPORT int
-JVM_handle_bsd_signal(int sig,
-                        siginfo_t* info,
-                        void* ucVoid,
-                        int abort_if_unrecognized) {
-  // in fact this isn't ucontext_t* at all, but struct sigcontext*
-  // but Bsd porting layer uses ucontext_t, so to minimize code change
-  // we cast as needed
-  ucontext_t* ucFake = (ucontext_t*) ucVoid;
-  sigcontext* uc = (sigcontext*)ucVoid;
-
-  Thread* t = ThreadLocalStorage::get_thread_slow();
-
-  SignalHandlerMark shm(t);
-
-  // Note: it's not uncommon that JNI code uses signal/sigset to install
-  // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
-  // or have a SIGILL handler when detecting CPU type). When that happens,
-  // JVM_handle_bsd_signal() might be invoked with junk info/ucVoid. To
-  // avoid unnecessary crash when libjsig is not preloaded, try handle signals
-  // that do not require siginfo/ucontext first.
-
-  if (sig == SIGPIPE || sig == SIGXFSZ) {
-    // allow chained handler to go first
-    if (os::Bsd::chained_handler(sig, info, ucVoid)) {
-      return true;
-    } else {
-      if (PrintMiscellaneous && (WizardMode || Verbose)) {
-        char buf[64];
-        warning("Ignoring %s - see bugs 4229104 or 646499219",
-                os::exception_name(sig, buf, sizeof(buf)));
-      }
-      return true;
-    }
-  }
-
-  JavaThread* thread = NULL;
-  VMThread* vmthread = NULL;
-  if (os::Bsd::signal_handlers_are_installed) {
-    if (t != NULL ){
-      if(t->is_Java_thread()) {
-        thread = (JavaThread*)t;
-      }
-      else if(t->is_VM_thread()){
-        vmthread = (VMThread *)t;
-      }
-    }
-  }
-
-  // decide if this trap can be handled by a stub
-  address stub = NULL;
-  address pc = NULL;
-  address npc = NULL;
-
-  //%note os_trap_1
-  if (info != NULL && uc != NULL && thread != NULL) {
-    pc = address(SIG_PC(uc));
-    npc = address(SIG_NPC(uc));
-
-    // Check to see if we caught the safepoint code in the
-    // process of write protecting the memory serialization page.
-    // It write enables the page immediately after protecting it
-    // so we can just return to retry the write.
-    if ((sig == SIGSEGV) && checkSerializePage(thread, (address)info->si_addr)) {
-      // Block current thread until the memory serialize page permission restored.
-      os::block_on_serialize_page_trap();
-      return 1;
-    }
-
-    if (checkPrefetch(uc, pc)) {
-      return 1;
-    }
-
-    // Handle ALL stack overflow variations here
-    if (sig == SIGSEGV) {
-      if (checkOverflow(uc, pc, (address)info->si_addr, thread, &stub)) {
-        return 1;
-      }
-    }
-
-    if (sig == SIGBUS &&
-        thread->thread_state() == _thread_in_vm &&
-        thread->doing_unsafe_access()) {
-      stub = StubRoutines::handler_for_unsafe_access();
-    }
-
-    if (thread->thread_state() == _thread_in_Java) {
-      do {
-        // Java thread running in Java code => find exception handler if any
-        // a fault inside compiled code, the interpreter, or a stub
-
-        if ((sig == SIGSEGV) && checkPollingPage(pc, (address)info->si_addr, &stub)) {
-          break;
-        }
-
-        if ((sig == SIGBUS) && checkByteBuffer(pc, &stub)) {
-          break;
-        }
-
-        if ((sig == SIGSEGV || sig == SIGBUS) &&
-            checkVerifyOops(pc, (address)info->si_addr, &stub)) {
-          break;
-        }
-
-        if ((sig == SIGSEGV) && checkZombie(uc, &pc, &stub)) {
-          break;
-        }
-
-        if ((sig == SIGILL) && checkICMiss(uc, &pc, &stub)) {
-          break;
-        }
-
-        if ((sig == SIGFPE) && checkFPFault(pc, info->si_code, thread, &stub)) {
-          break;
-        }
-
-        if ((sig == SIGSEGV) &&
-            checkNullPointer(pc, (intptr_t)info->si_addr, thread, &stub)) {
-          break;
-        }
-      } while (0);
-
-      // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
-      // and the heap gets shrunk before the field access.
-      if ((sig == SIGSEGV) || (sig == SIGBUS)) {
-        checkFastJNIAccess(pc, &stub);
-      }
-    }
-
-    if (stub != NULL) {
-      // save all thread context in case we need to restore it
-      thread->set_saved_exception_pc(pc);
-      thread->set_saved_exception_npc(npc);
-      set_cont_address(uc, stub);
-      return true;
-    }
-  }
-
-  // signal-chaining
-  if (os::Bsd::chained_handler(sig, info, ucVoid)) {
-    return true;
-  }
-
-  if (!abort_if_unrecognized) {
-    // caller wants another chance, so give it to him
-    return false;
-  }
-
-  if (pc == NULL && uc != NULL) {
-    pc = os::Bsd::ucontext_get_pc((ucontext_t*)uc);
-  }
-
-  // unmask current signal
-  sigset_t newset;
-  sigemptyset(&newset);
-  sigaddset(&newset, sig);
-  sigprocmask(SIG_UNBLOCK, &newset, NULL);
-
-  VMError err(t, sig, pc, info, ucVoid);
-  err.report_and_die();
-
-  ShouldNotReachHere();
-}
-
-void os::Bsd::init_thread_fpu_state(void) {
-  // Nothing to do
-}
-
-int os::Bsd::get_fpu_control_word() {
-  return 0;
-}
-
-void os::Bsd::set_fpu_control_word(int fpu) {
-  // nothing
-}
-
-bool os::is_allocatable(size_t bytes) {
-#ifdef _LP64
-  return true;
-#else
-  if (bytes < 2 * G) {
-    return true;
-  }
-
-  char* addr = reserve_memory(bytes, NULL);
-
-  if (addr != NULL) {
-    release_memory(addr, bytes);
-  }
-
-  return addr != NULL;
-#endif // _LP64
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// thread stack
-
-size_t os::Bsd::min_stack_allowed  = 128 * K;
-
-// pthread on Ubuntu is always in floating stack mode
-bool os::Bsd::supports_variable_stack_size() {  return true; }
-
-// return default stack size for thr_type
-size_t os::Bsd::default_stack_size(os::ThreadType thr_type) {
-  // default stack size (compiler thread needs larger stack)
-  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
-  return s;
-}
-
-size_t os::Bsd::default_guard_size(os::ThreadType thr_type) {
-  // Creating guard page is very expensive. Java thread has HotSpot
-  // guard page, only enable glibc guard page for non-Java threads.
-  return (thr_type == java_thread ? 0 : page_size());
-}
--- ./hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/os_bsd_sparc.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_OS_BSD_SPARC_HPP
-#define OS_CPU_BSD_SPARC_VM_OS_BSD_SPARC_HPP
-
-  //
-  // NOTE: we are back in class os here, not Bsd
-  //
-  static jint  (*atomic_xchg_func)        (jint,  volatile jint*);
-  static jint  (*atomic_cmpxchg_func)     (jint,  volatile jint*,  jint);
-  static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
-  static jint  (*atomic_add_func)         (jint,  volatile jint*);
-
-  static jint  atomic_xchg_bootstrap        (jint,  volatile jint*);
-  static jint  atomic_cmpxchg_bootstrap     (jint,  volatile jint*,  jint);
-  static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
-  static jint  atomic_add_bootstrap         (jint,  volatile jint*);
-
-  static void setup_fpu() {}
-
-  static bool is_allocatable(size_t bytes);
-
-  // Used to register dynamic code cache area with the OS
-  // Note: Currently only used in 64 bit Windows implementations
-  static bool register_code_area(char *low, char *high) { return true; }
-
-#endif // OS_CPU_BSD_SPARC_VM_OS_BSD_SPARC_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/prefetch_bsd_sparc.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/prefetch_bsd_sparc.inline.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_PREFETCH_BSD_SPARC_INLINE_HPP
-#define OS_CPU_BSD_SPARC_VM_PREFETCH_BSD_SPARC_INLINE_HPP
-
-#include "runtime/prefetch.hpp"
-
-#if defined(COMPILER2) || defined(_LP64)
-
-inline void Prefetch::read(void *loc, intx interval) {
-  __asm__ volatile("prefetch [%0+%1], 0" : : "r" (loc), "r" (interval) : "memory" );
-}
-
-inline void Prefetch::write(void *loc, intx interval) {
-  __asm__ volatile("prefetch [%0+%1], 2" : : "r" (loc), "r" (interval) : "memory" );
-}
-
-#else
-
-inline void Prefetch::read (void *loc, intx interval) {}
-inline void Prefetch::write(void *loc, intx interval) {}
-
-#endif
-
-#endif // OS_CPU_BSD_SPARC_VM_PREFETCH_BSD_SPARC_INLINE_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.cpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/threadLocalStorage.hpp"
-#include "thread_bsd.inline.hpp"
-
-void ThreadLocalStorage::generate_code_for_get_thread() {
-}
-
-void ThreadLocalStorage::pd_init() {
-   // Nothing to do
-}
-
-void ThreadLocalStorage::pd_set_thread(Thread* thread) {
-  os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
-}
--- ./hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/threadLS_bsd_sparc.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_THREADLS_BSD_SPARC_HPP
-#define OS_CPU_BSD_SPARC_VM_THREADLS_BSD_SPARC_HPP
-
-public:
-  static Thread* thread() {
-    return (Thread*) os::thread_local_storage_at(thread_index());
-  }
-
-#endif // OS_CPU_BSD_SPARC_VM_THREADLS_BSD_SPARC_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.cpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/frame.inline.hpp"
-#include "thread_bsd.inline.hpp"
-
-// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
-// currently interrupted by SIGPROF
-bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
-                                                     void* ucontext,
-                                                     bool isInJava) {
-  assert(Thread::current() == this, "caller must be current thread");
-  assert(this->is_Java_thread(), "must be JavaThread");
-
-  JavaThread* jt = (JavaThread *)this;
-
-  if (!isInJava) {
-    // make_walkable flushes register windows and grabs last_Java_pc
-    // which can not be done if the ucontext sp matches last_Java_sp
-    // stack walking utilities assume last_Java_pc set if marked flushed
-    jt->frame_anchor()->make_walkable(jt);
-  }
-
-  // If we have a walkable last_Java_frame, then we should use it
-  // even if isInJava == true. It should be more reliable than
-  // ucontext info.
-  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
-    *fr_addr = jt->pd_last_frame();
-    return true;
-  }
-
-  ucontext_t* uc = (ucontext_t*) ucontext;
-
-  // At this point, we don't have a walkable last_Java_frame, so
-  // we try to glean some information out of the ucontext.
-  intptr_t* ret_sp;
-  ExtendedPC addr =
-    os::fetch_frame_from_context(uc, &ret_sp,
-                                 NULL /* ret_fp only used on X86 */);
-  if (addr.pc() == NULL || ret_sp == NULL) {
-    // ucontext wasn't useful
-    return false;
-  }
-
-  // we were running Java code when SIGPROF came in
-  if (isInJava) {
-    // If we have a last_Java_sp, then the SIGPROF signal caught us
-    // right when we were transitioning from _thread_in_Java to a new
-    // JavaThreadState. We use last_Java_sp instead of the sp from
-    // the ucontext since it should be more reliable.
-    if (jt->has_last_Java_frame()) {
-      ret_sp = jt->last_Java_sp();
-    }
-    // Implied else: we don't have a last_Java_sp so we use what we
-    // got from the ucontext.
-
-    frame ret_frame(ret_sp, frame::unpatchable, addr.pc());
-    if (!ret_frame.safe_for_sender(jt)) {
-      // nothing else to try if the frame isn't good
-      return false;
-    }
-    *fr_addr = ret_frame;
-    return true;
-  }
-
-  // At this point, we know we weren't running Java code. We might
-  // have a last_Java_sp, but we don't have a walkable frame.
-  // However, we might still be able to construct something useful
-  // if the thread was running native code.
-  if (jt->has_last_Java_frame()) {
-    assert(!jt->frame_anchor()->walkable(), "case covered above");
-
-    if (jt->thread_state() == _thread_in_native) {
-      frame ret_frame(jt->last_Java_sp(), frame::unpatchable, addr.pc());
-      if (!ret_frame.safe_for_sender(jt)) {
-        // nothing else to try if the frame isn't good
-        return false;
-      }
-      *fr_addr = ret_frame;
-      return true;
-    }
-  }
-
-  // nothing else to try
-  return false;
-}
-
-void JavaThread::cache_global_variables() { }
-
--- ./hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/thread_bsd_sparc.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP
-#define OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP
-
-private:
-
-  void pd_initialize() {
-    _anchor.clear();
-    _base_of_stack_pointer        = NULL;
-  }
-
-  frame pd_last_frame() {
-    assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
-    assert(_anchor.walkable(), "thread has not dumped its register windows yet");
-
-    assert(_anchor.last_Java_pc() != NULL, "Ack no pc!");
-    return frame(last_Java_sp(), frame::unpatchable, _anchor.last_Java_pc());
-  }
-
-  // Sometimes the trap handler needs to record both PC and NPC.
-  // This is a SPARC-specific companion to Thread::set_saved_exception_pc.
-  address _saved_exception_npc;
-
-  // In polling_page_safepoint_handler_blob(s) we have to tail call other
-  // blobs without blowing any registers.  A tail call requires some
-  // register to jump with and we can't blow any registers, so it must
-  // be restored in the delay slot.  'restore' cannot be used as it
-  // will chop the heads off of 64-bit %o registers in the 32-bit
-  // build.  Instead we reload the registers using G2_thread and this
-  // location.  Must be 64bits in the 32-bit LION build.
-  jdouble _o_reg_temps[6];
-
-  // a stack pointer older than any java frame stack pointer.  It is
-  // used to validate stack pointers in frame::next_younger_sp (it
-  // provides the upper bound in the range check).  This is necessary
-  // on Solaris/SPARC since the ucontext passed to a signal handler is
-  // sometimes corrupt and we need a way to check the extracted sp.
-  intptr_t* _base_of_stack_pointer;
-
-public:
-
-  static int o_reg_temps_offset_in_bytes() { return offset_of(JavaThread, _o_reg_temps); }
-
-#ifndef _LP64
-  address o_reg_temps(int i) { return (address)&_o_reg_temps[i]; }
-#endif
-
-  static int saved_exception_npc_offset_in_bytes() { return offset_of(JavaThread,_saved_exception_npc); }
-
-  address  saved_exception_npc()             { return _saved_exception_npc; }
-  void set_saved_exception_npc(address a)    { _saved_exception_npc = a; }
-
-
-public:
-
-  intptr_t* base_of_stack_pointer() { return _base_of_stack_pointer; }
-
-  void set_base_of_stack_pointer(intptr_t* base_sp) {
-    _base_of_stack_pointer = base_sp;
-  }
-
-  void record_base_of_stack_pointer() {
-    intptr_t *sp = (intptr_t *)(((intptr_t)StubRoutines::Sparc::flush_callers_register_windows_func()()));
-    intptr_t *ysp;
-    while((ysp = (intptr_t*)sp[FP->sp_offset_in_saved_window()]) != NULL) {
-      sp = (intptr_t *)((intptr_t)ysp + STACK_BIAS);
-    }
-    _base_of_stack_pointer = sp;
-  }
-
-  bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext,
-    bool isInJava);
-
-  // These routines are only used on cpu architectures that
-  // have separate register stacks (Itanium).
-  static bool register_stack_overflow() { return false; }
-  static void enable_register_stack_guard() {}
-  static void disable_register_stack_guard() {}
-
-#endif // OS_CPU_BSD_SPARC_VM_THREAD_BSD_SPARC_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/vmStructs_bsd_sparc.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/vmStructs_bsd_sparc.hpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef OS_CPU_BSD_SPARC_VM_VMSTRUCTS_BSD_SPARC_HPP
-#define OS_CPU_BSD_SPARC_VM_VMSTRUCTS_BSD_SPARC_HPP
-
-// These are the OS and CPU-specific fields, types and integer
-// constants required by the Serviceability Agent. This file is
-// referenced by vmStructs.cpp.
-
-#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \
-                                                                                                                                     \
-  /******************************/                                                                                                   \
-  /* Threads (NOTE: incomplete) */                                                                                                   \
-  /******************************/                                                                                                   \
-                                                                                                                                     \
-  nonstatic_field(JavaThread,                  _base_of_stack_pointer,                        intptr_t*)                             \
-  nonstatic_field(OSThread,                    _thread_id,                                    pid_t)                                 \
-  nonstatic_field(OSThread,                    _pthread_id,                                   pthread_t)                             \
-  /* This must be the last entry, and must be present */                                                                             \
-  last_entry()
-
-
-#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type, last_entry) \
-                                                                          \
-  /**********************/                                                \
-  /* POSIX Thread IDs */                                                  \
-  /**********************/                                                \
-                                                                          \
-  declare_integer_type(pid_t)                                             \
-  declare_unsigned_integer_type(pthread_t)                                \
-                                                                          \
-  /* This must be the last entry, and must be present */                  \
-  last_entry()
-
-
-#define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \
-                                                                        \
-  /************************/                                            \
-  /* JavaThread constants */                                            \
-  /************************/                                            \
-                                                                        \
-  declare_constant(JavaFrameAnchor::flushed)                            \
-                                                                        \
-  /* This must be the last entry, and must be present */                \
-  last_entry()
-
-#define VM_LONG_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \
-                                                                        \
-  /* This must be the last entry, and must be present */                \
-  last_entry()
-
-#endif // OS_CPU_BSD_SPARC_VM_VMSTRUCTS_BSD_SPARC_HPP
--- ./hotspot/src/os_cpu/bsd_sparc/vm/vm_version_bsd_sparc.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_sparc/vm/vm_version_bsd_sparc.cpp	1969-12-31 16:00:00.000000000 -0800
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/os.hpp"
-#include "vm_version_sparc.hpp"
-
-static bool detect_niagara() {
-  char cpu[128];
-  bool rv = false;
-
-  FILE* fp = fopen("/proc/cpuinfo", "r");
-  if (fp == NULL) {
-    return rv;
-  }
-
-  while (!feof(fp)) {
-    if (fscanf(fp, "cpu\t\t: %100[^\n]", &cpu) == 1) {
-      if (strstr(cpu, "Niagara") != NULL) {
-        rv = true;
-      }
-      break;
-    }
-  }
-
-  fclose(fp);
-
-  return rv;
-}
-
-int VM_Version::platform_features(int features) {
-  // Default to generic v9
-  features = generic_v9_m;
-
-  if (detect_niagara()) {
-    NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Detected Bsd on Niagara");)
-    features = niagara1_m;
-  }
-
-  return features;
-}
--- ./hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s	2011-04-22 22:28:34.000000000 -0700
@@ -21,6 +21,17 @@
 # questions.
 # 
 
+ 
+#ifdef __APPLE__
+# Darwin uses _ prefixed global symbols
+#define SYMBOL(s) _ ## s
+#define ELF_TYPE(name, description)
+#else
+#define SYMBOL(s) s
+#define ELF_TYPE(name, description) .type name,description
+#endif
+
+	.globl SYMBOL(fixcw)
 	
         # NOTE WELL!  The _Copy functions are called directly
 	# from server-compiler-generated code via CallLeafNoFP,
@@ -28,42 +39,62 @@
 	# point or use it in the same manner as does the server
 	# compiler.
 	
-        .globl _Copy_conjoint_bytes
-        .globl _Copy_arrayof_conjoint_bytes
-        .globl _Copy_conjoint_jshorts_atomic
-	.globl _Copy_arrayof_conjoint_jshorts
-        .globl _Copy_conjoint_jints_atomic
-        .globl _Copy_arrayof_conjoint_jints
-	.globl _Copy_conjoint_jlongs_atomic
-	.globl _mmx_Copy_arrayof_conjoint_jshorts
+        .globl SYMBOL(_Copy_conjoint_bytes)
+        .globl SYMBOL(_Copy_arrayof_conjoint_bytes)
+        .globl SYMBOL(_Copy_conjoint_jshorts_atomic)
+	.globl SYMBOL(_Copy_arrayof_conjoint_jshorts)
+        .globl SYMBOL(_Copy_conjoint_jints_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jints)
+	.globl SYMBOL(_Copy_conjoint_jlongs_atomic)
+	.globl SYMBOL(_mmx_Copy_arrayof_conjoint_jshorts)
 
-        .globl _Atomic_cmpxchg_long
-        .globl _Atomic_move_long
+        .globl SYMBOL(_Atomic_cmpxchg_long)
+        .globl SYMBOL(_Atomic_move_long)
 
 	.text
 
-        .globl  SafeFetch32, Fetch32PFI, Fetch32Resume
-        .globl  SafeFetchN
+# Support for void os::Solaris::init_thread_fpu_state() in os_solaris_i486.cpp
+# Set fpu to 53 bit precision.  This happens too early to use a stub.
+# ported from solaris_x86_32.s
+#ifdef __APPLE__
+        .align   4
+#else
+	.align   16
+#endif
+SYMBOL(fixcw):
+	pushl    $0x27f
+	fldcw    0(%esp)
+	popl     %eax
+	ret
+
+#ifdef __APPLE__
+        .align   4
+#else
+        .align   16
+#endif
+
+        .globl  SYMBOL(SafeFetch32), SYMBOL(Fetch32PFI), SYMBOL(Fetch32Resume)
+        .globl  SYMBOL(SafeFetchN)
         ## TODO: avoid exposing Fetch32PFI and Fetch32Resume.
         ## Instead, the signal handler would call a new SafeFetchTriage(FaultingEIP)
         ## routine to vet the address.  If the address is the faulting LD then
         ## SafeFetchTriage() would return the resume-at EIP, otherwise null.
-	.type    SafeFetch32,@function
+	ELF_TYPE(SafeFetch32,@function)
         .p2align 4,,15
-SafeFetch32:
-SafeFetchN:
+SYMBOL(SafeFetch32):
+SYMBOL(SafeFetchN):
          movl    0x8(%esp), %eax
          movl    0x4(%esp), %ecx
-Fetch32PFI:
+SYMBOL(Fetch32PFI):
          movl    (%ecx), %eax
-Fetch32Resume:
+SYMBOL(Fetch32Resume):
          ret
 
 
-        .globl  SpinPause
-	.type   SpinPause,@function
+        .globl  SYMBOL(SpinPause)
+	ELF_TYPE(SpinPause,@function)
         .p2align 4,,15
-SpinPause:
+SYMBOL(SpinPause):
         rep
         nop
         movl    $1, %eax
@@ -73,8 +104,8 @@
         #                                       void* to,
         #                                       size_t count)
         .p2align 4,,15
-	.type    _Copy_conjoint_bytes,@function
-_Copy_conjoint_bytes:
+	ELF_TYPE(_Copy_conjoint_bytes,@function)
+SYMBOL(_Copy_conjoint_bytes):
         pushl    %esi
         movl     4+12(%esp),%ecx      # count
         pushl    %edi
@@ -181,8 +212,8 @@
         #
         # Same as _Copy_conjoint_bytes, except no source alignment check.
         .p2align 4,,15
-	.type    _Copy_arrayof_conjoint_bytes,@function
-_Copy_arrayof_conjoint_bytes:
+	ELF_TYPE(_Copy_arrayof_conjoint_bytes,@function)
+SYMBOL(_Copy_arrayof_conjoint_bytes):
         pushl    %esi
         movl     4+12(%esp),%ecx      # count
         pushl    %edi
@@ -269,8 +300,8 @@
         #                                                void* to,
         #                                                size_t count)
         .p2align 4,,15
-	.type    _Copy_conjoint_jshorts_atomic,@function
-_Copy_conjoint_jshorts_atomic:
+	ELF_TYPE(_Copy_conjoint_jshorts_atomic,@function)
+SYMBOL(_Copy_conjoint_jshorts_atomic):
         pushl    %esi
         movl     4+12(%esp),%ecx      # count
         pushl    %edi
@@ -356,8 +387,8 @@
         #                                                 void* to,
         #                                                 size_t count)
         .p2align 4,,15
-	.type    _Copy_arrayof_conjoint_jshorts,@function
-_Copy_arrayof_conjoint_jshorts:
+	ELF_TYPE(_Copy_arrayof_conjoint_jshorts,@function)
+SYMBOL(_Copy_arrayof_conjoint_jshorts):
         pushl    %esi
         movl     4+12(%esp),%ecx      # count
         pushl    %edi
@@ -433,10 +464,10 @@
         # Equivalent to
         #   arrayof_conjoint_jints
         .p2align 4,,15
-	.type    _Copy_conjoint_jints_atomic,@function
-	.type    _Copy_arrayof_conjoint_jints,@function
-_Copy_conjoint_jints_atomic:
-_Copy_arrayof_conjoint_jints:
+	ELF_TYPE(_Copy_conjoint_jints_atomic,@function)
+	ELF_TYPE(_Copy_arrayof_conjoint_jints,@function)
+SYMBOL(_Copy_conjoint_jints_atomic):
+SYMBOL(_Copy_arrayof_conjoint_jints):
         pushl    %esi
         movl     4+12(%esp),%ecx      # count
         pushl    %edi
@@ -498,7 +529,7 @@
         #
         # count treated as signed
         #
-        # if (from > to) {
+        # // if (from > to) {
         #   while (--count >= 0) {
         #     *to++ = *from++;
         #   }
@@ -508,8 +539,8 @@
         #   }
         # }
         .p2align 4,,15
-	.type    _Copy_conjoint_jlongs_atomic,@function
-_Copy_conjoint_jlongs_atomic:
+	ELF_TYPE(_Copy_conjoint_jlongs_atomic,@function)
+SYMBOL(_Copy_conjoint_jlongs_atomic):
         movl     4+8(%esp),%ecx       # count
         movl     4+0(%esp),%eax       # from
         movl     4+4(%esp),%edx       # to
@@ -537,8 +568,8 @@
         #                                                 void* to,
         #                                                 size_t count)
         .p2align 4,,15
-	.type    _mmx_Copy_arrayof_conjoint_jshorts,@function
-_mmx_Copy_arrayof_conjoint_jshorts:
+	ELF_TYPE(_mmx_Copy_arrayof_conjoint_jshorts,@function)
+SYMBOL(_mmx_Copy_arrayof_conjoint_jshorts):
         pushl    %esi
         movl     4+12(%esp),%ecx
         pushl    %edi
@@ -636,8 +667,8 @@
         #                                   bool is_MP)
         #
         .p2align 4,,15
-	.type    _Atomic_cmpxchg_long,@function
-_Atomic_cmpxchg_long:
+	ELF_TYPE(_Atomic_cmpxchg_long,@function)
+SYMBOL(_Atomic_cmpxchg_long):
                                    #  8(%esp) : return PC
         pushl    %ebx              #  4(%esp) : old %ebx
         pushl    %edi              #  0(%esp) : old %edi
--- ./hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s	2011-04-22 22:28:34.000000000 -0700
@@ -21,6 +21,14 @@
 # questions.
 #
 
+#ifdef __APPLE__
+# Darwin uses _ prefixed global symbols
+#define SYMBOL(s) _ ## s
+#define ELF_TYPE(name, description)
+#else
+#define SYMBOL(s) s
+#define ELF_TYPE(name, description) .type name,description
+#endif
 
         # NOTE WELL!  The _Copy functions are called directly
 	# from server-compiler-generated code via CallLeafNoFP,
@@ -28,42 +36,54 @@
 	# point or use it in the same manner as does the server
 	# compiler.
 	
-        .globl _Copy_arrayof_conjoint_bytes
-	.globl _Copy_arrayof_conjoint_jshorts
-        .globl _Copy_conjoint_jshorts_atomic
-        .globl _Copy_arrayof_conjoint_jints
-        .globl _Copy_conjoint_jints_atomic
-        .globl _Copy_arrayof_conjoint_jlongs
-        .globl _Copy_conjoint_jlongs_atomic
+        .globl SYMBOL(_Copy_arrayof_conjoint_bytes)
+	.globl SYMBOL(_Copy_arrayof_conjoint_jshorts)
+        .globl SYMBOL(_Copy_conjoint_jshorts_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jints)
+        .globl SYMBOL(_Copy_conjoint_jints_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jlongs)
+        .globl SYMBOL(_Copy_conjoint_jlongs_atomic)
 
 	.text
 
-        .globl SafeFetch32, Fetch32PFI, Fetch32Resume
+        .globl SYMBOL(SafeFetch32), SYMBOL(Fetch32PFI), SYMBOL(Fetch32Resume)
+#ifdef __APPLE__
+        .align  4
+#else
         .align  16
-        .type   SafeFetch32,@function
+#endif
+        ELF_TYPE(SafeFetch32,@function)
         // Prototype: int SafeFetch32 (int * Adr, int ErrValue) 
-SafeFetch32:
+SYMBOL(SafeFetch32):
         movl    %esi, %eax
-Fetch32PFI:
+SYMBOL(Fetch32PFI):
         movl    (%rdi), %eax
-Fetch32Resume:
+SYMBOL(Fetch32Resume):
         ret
 
-        .globl SafeFetchN, FetchNPFI, FetchNResume
+        .globl SYMBOL(SafeFetchN), SYMBOL(FetchNPFI), SYMBOL(FetchNResume)
+#ifdef __APPLE__
+        .align  4
+#else
         .align  16
-        .type   SafeFetchN,@function
+#endif
+        ELF_TYPE(SafeFetchN,@function)
         // Prototype: intptr_t SafeFetchN (intptr_t * Adr, intptr_t ErrValue) 
-SafeFetchN:
+SYMBOL(SafeFetchN):
         movq    %rsi, %rax
-FetchNPFI:
+SYMBOL(FetchNPFI):
         movq    (%rdi), %rax
-FetchNResume:
+SYMBOL(FetchNResume):
         ret
 
-        .globl SpinPause
-        .align 16
-        .type  SpinPause,@function
-SpinPause:
+        .globl SYMBOL(SpinPause)
+#ifdef __APPLE__
+        .align  4
+#else
+        .align  16
+#endif
+        ELF_TYPE(SpinPause,@function)
+SYMBOL(SpinPause):
         rep
         nop
         movq   $1, %rax
@@ -77,8 +97,8 @@
         # rdx - count, treated as ssize_t
         #
         .p2align 4,,15
-	.type    _Copy_arrayof_conjoint_bytes,@function
-_Copy_arrayof_conjoint_bytes:
+	ELF_TYPE(_Copy_arrayof_conjoint_bytes,@function)
+SYMBOL(_Copy_arrayof_conjoint_bytes):
         movq     %rdx,%r8             # byte count
         shrq     $3,%rdx              # qword count
         cmpq     %rdi,%rsi
@@ -179,10 +199,10 @@
         # rdx - count, treated as ssize_t
         #
         .p2align 4,,15
-	.type    _Copy_arrayof_conjoint_jshorts,@function
-	.type    _Copy_conjoint_jshorts_atomic,@function
-_Copy_arrayof_conjoint_jshorts:
-_Copy_conjoint_jshorts_atomic:
+	ELF_TYPE(_Copy_arrayof_conjoint_jshorts,@function)
+	ELF_TYPE(_Copy_conjoint_jshorts_atomic,@function)
+SYMBOL(_Copy_arrayof_conjoint_jshorts):
+SYMBOL(_Copy_conjoint_jshorts_atomic):
         movq     %rdx,%r8             # word count
         shrq     $2,%rdx              # qword count
         cmpq     %rdi,%rsi
@@ -269,10 +289,10 @@
         # rdx - count, treated as ssize_t
         #
         .p2align 4,,15
-	.type    _Copy_arrayof_conjoint_jints,@function
-	.type    _Copy_conjoint_jints_atomic,@function
-_Copy_arrayof_conjoint_jints:
-_Copy_conjoint_jints_atomic:
+	ELF_TYPE(_Copy_arrayof_conjoint_jints,@function)
+	ELF_TYPE(_Copy_conjoint_jints_atomic,@function)
+SYMBOL(_Copy_arrayof_conjoint_jints):
+SYMBOL(_Copy_conjoint_jints_atomic):
         movq     %rdx,%r8             # dword count
         shrq     %rdx                 # qword count
         cmpq     %rdi,%rsi
@@ -348,10 +368,10 @@
         # rdx - count, treated as ssize_t
         #
         .p2align 4,,15
-	.type    _Copy_arrayof_conjoint_jlongs,@function
-	.type    _Copy_conjoint_jlongs_atomic,@function
-_Copy_arrayof_conjoint_jlongs:
-_Copy_conjoint_jlongs_atomic:
+	ELF_TYPE(_Copy_arrayof_conjoint_jlongs,@function)
+	ELF_TYPE(_Copy_conjoint_jlongs_atomic,@function)
+SYMBOL(_Copy_arrayof_conjoint_jlongs):
+SYMBOL(_Copy_conjoint_jlongs_atomic):
         cmpq     %rdi,%rsi
         leaq     -8(%rdi,%rdx,8),%rax # from + count*8 - 8
         jbe      acl_CopyRight
--- ./hotspot/src/os_cpu/bsd_x86/vm/bytes_bsd_x86.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/bytes_bsd_x86.inline.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -25,7 +25,33 @@
 #ifndef OS_CPU_BSD_X86_VM_BYTES_BSD_X86_INLINE_HPP
 #define OS_CPU_BSD_X86_VM_BYTES_BSD_X86_INLINE_HPP
 
+#ifndef _ALLBSD_SOURCE
 #include <byteswap.h>
+#endif
+
+#ifdef __APPLE__
+#include <libkern/OSByteOrder.h>
+#endif
+
+#if defined(AMD64)
+#  if defined(__APPLE__)
+#    define bswap_16(x)	OSSwapInt16(x)
+#    define bswap_32(x)	OSSwapInt32(x)
+#    define bswap_64(x)	OSSwapInt64(x)
+#  elif defined(__OpenBSD__)
+#    define bswap_16(x)	swap16(x)
+#    define bswap_32(x)	swap32(x)
+#    define bswap_64(x)	swap64(x)
+#  elif defined(__NetBSD__)
+#    define bswap_16(x)	bswap16(x)
+#    define bswap_32(x)	bswap32(x)
+#    define bswap_64(x)	bswap64(x)
+#  else
+#    define bswap_16(x) __bswap16(x)
+#    define bswap_32(x) __bswap32(x)
+#    define bswap_64(x) __bswap64(x)
+#  endif
+#endif
 
 // Efficient swapping of data bytes from Java byte
 // ordering to native byte ordering and vice versa.
--- ./hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -25,9 +25,10 @@
 #ifndef OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP
 #define OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP
 
+//
 // Sets the default values for platform dependent flags used by the runtime system.
 // (see globals.hpp)
-
+//
 define_pd_global(bool, DontYieldALot,            false);
 #ifdef AMD64
 define_pd_global(intx, ThreadStackSize,          1024); // 0 => use system default
@@ -41,11 +42,12 @@
 #endif // AMD64
 
 define_pd_global(intx, CompilerThreadStackSize,  0);
+define_pd_global(intx, SurvivorRatio,            8);
 
-define_pd_global(uintx,JVMInvokeMethodSlack,     8192);
+define_pd_global(uintx, JVMInvokeMethodSlack,    8192);
 
 // Only used on 64 bit platforms
-define_pd_global(uintx,HeapBaseMinAddress,       2*G);
+define_pd_global(uintx, HeapBaseMinAddress,      2*G);
 // Only used on 64 bit Windows platforms
 define_pd_global(bool, UseVectoredExceptions,    false);
 
--- ./hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -78,23 +78,202 @@
 # include <sys/wait.h>
 # include <pwd.h>
 # include <poll.h>
+#ifndef __OpenBSD__
 # include <ucontext.h>
-# include <fpu_control.h>
+#endif
+
+#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__) && !defined(__NetBSD__)
+# include <pthread_np.h>
+#endif
 
 #ifdef AMD64
-#define REG_SP REG_RSP
-#define REG_PC REG_RIP
-#define REG_FP REG_RBP
 #define SPELL_REG_SP "rsp"
 #define SPELL_REG_FP "rbp"
 #else
-#define REG_SP REG_UESP
-#define REG_PC REG_EIP
-#define REG_FP REG_EBP
 #define SPELL_REG_SP "esp"
 #define SPELL_REG_FP "ebp"
 #endif // AMD64
 
+#ifdef __FreeBSD__
+# define context_trapno uc_mcontext.mc_trapno
+# ifdef AMD64
+#  define context_pc uc_mcontext.mc_rip
+#  define context_sp uc_mcontext.mc_rsp
+#  define context_fp uc_mcontext.mc_rbp
+#  define context_rip uc_mcontext.mc_rip
+#  define context_rsp uc_mcontext.mc_rsp
+#  define context_rbp uc_mcontext.mc_rbp
+#  define context_rax uc_mcontext.mc_rax
+#  define context_rbx uc_mcontext.mc_rbx
+#  define context_rcx uc_mcontext.mc_rcx
+#  define context_rdx uc_mcontext.mc_rdx
+#  define context_rsi uc_mcontext.mc_rsi
+#  define context_rdi uc_mcontext.mc_rdi
+#  define context_r8  uc_mcontext.mc_r8
+#  define context_r9  uc_mcontext.mc_r9
+#  define context_r10 uc_mcontext.mc_r10
+#  define context_r11 uc_mcontext.mc_r11
+#  define context_r12 uc_mcontext.mc_r12
+#  define context_r13 uc_mcontext.mc_r13
+#  define context_r14 uc_mcontext.mc_r14
+#  define context_r15 uc_mcontext.mc_r15
+#  define context_flags uc_mcontext.mc_flags
+#  define context_err uc_mcontext.mc_err
+# else
+#  define context_pc uc_mcontext.mc_eip
+#  define context_sp uc_mcontext.mc_esp
+#  define context_fp uc_mcontext.mc_ebp
+#  define context_eip uc_mcontext.mc_eip
+#  define context_esp uc_mcontext.mc_esp
+#  define context_eax uc_mcontext.mc_eax
+#  define context_ebx uc_mcontext.mc_ebx
+#  define context_ecx uc_mcontext.mc_ecx
+#  define context_edx uc_mcontext.mc_edx
+#  define context_ebp uc_mcontext.mc_ebp
+#  define context_esi uc_mcontext.mc_esi
+#  define context_edi uc_mcontext.mc_edi
+#  define context_eflags uc_mcontext.mc_eflags
+#  define context_trapno uc_mcontext.mc_trapno
+# endif
+#endif
+
+#ifdef __APPLE__ 
+# if __DARWIN_UNIX03 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+  // 10.5 UNIX03 member name prefixes
+  #define DU3_PREFIX(s, m) __ ## s.__ ## m
+# else
+  #define DU3_PREFIX(s, m) s ## . ## m
+# endif
+
+# ifdef AMD64
+#  define context_pc context_rip
+#  define context_sp context_rsp
+#  define context_fp context_rbp
+#  define context_rip uc_mcontext->DU3_PREFIX(ss,rip)
+#  define context_rsp uc_mcontext->DU3_PREFIX(ss,rsp)
+#  define context_rax uc_mcontext->DU3_PREFIX(ss,rax)
+#  define context_rbx uc_mcontext->DU3_PREFIX(ss,rbx)
+#  define context_rcx uc_mcontext->DU3_PREFIX(ss,rcx)
+#  define context_rdx uc_mcontext->DU3_PREFIX(ss,rdx)
+#  define context_rbp uc_mcontext->DU3_PREFIX(ss,rbp)
+#  define context_rsi uc_mcontext->DU3_PREFIX(ss,rsi)
+#  define context_rdi uc_mcontext->DU3_PREFIX(ss,rdi)
+#  define context_r8  uc_mcontext->DU3_PREFIX(ss,r8)
+#  define context_r9  uc_mcontext->DU3_PREFIX(ss,r9)
+#  define context_r10 uc_mcontext->DU3_PREFIX(ss,r10)
+#  define context_r11 uc_mcontext->DU3_PREFIX(ss,r11)
+#  define context_r12 uc_mcontext->DU3_PREFIX(ss,r12)
+#  define context_r13 uc_mcontext->DU3_PREFIX(ss,r13)
+#  define context_r14 uc_mcontext->DU3_PREFIX(ss,r14)
+#  define context_r15 uc_mcontext->DU3_PREFIX(ss,r15)
+#  define context_flags uc_mcontext->DU3_PREFIX(ss,rflags)
+#  define context_trapno uc_mcontext->DU3_PREFIX(es,trapno)
+#  define context_err uc_mcontext->DU3_PREFIX(es,err)
+# else
+#  define context_pc context_eip
+#  define context_sp context_esp
+#  define context_fp context_ebp
+#  define context_eip uc_mcontext->DU3_PREFIX(ss,eip)
+#  define context_esp uc_mcontext->DU3_PREFIX(ss,esp)
+#  define context_eax uc_mcontext->DU3_PREFIX(ss,eax)
+#  define context_ebx uc_mcontext->DU3_PREFIX(ss,ebx)
+#  define context_ecx uc_mcontext->DU3_PREFIX(ss,ecx)
+#  define context_edx uc_mcontext->DU3_PREFIX(ss,edx)
+#  define context_ebp uc_mcontext->DU3_PREFIX(ss,ebp)
+#  define context_esi uc_mcontext->DU3_PREFIX(ss,esi)
+#  define context_edi uc_mcontext->DU3_PREFIX(ss,edi)
+#  define context_eflags uc_mcontext->DU3_PREFIX(ss,eflags)
+#  define context_trapno uc_mcontext->DU3_PREFIX(es,trapno)
+# endif
+#endif
+
+#ifdef __OpenBSD__
+# define context_trapno sc_trapno
+# ifdef AMD64
+#  define context_pc sc_rip
+#  define context_sp sc_rsp
+#  define context_fp sc_rbp
+#  define context_rip sc_rip
+#  define context_rsp sc_rsp
+#  define context_rbp sc_rbp
+#  define context_rax sc_rax
+#  define context_rbx sc_rbx
+#  define context_rcx sc_rcx
+#  define context_rdx sc_rdx
+#  define context_rsi sc_rsi
+#  define context_rdi sc_rdi
+#  define context_r8  sc_r8
+#  define context_r9  sc_r9
+#  define context_r10 sc_r10
+#  define context_r11 sc_r11
+#  define context_r12 sc_r12
+#  define context_r13 sc_r13
+#  define context_r14 sc_r14
+#  define context_r15 sc_r15
+#  define context_flags sc_rflags
+#  define context_err sc_err
+# else
+#  define context_pc sc_eip
+#  define context_sp sc_esp
+#  define context_fp sc_ebp
+#  define context_eip sc_eip
+#  define context_esp sc_esp
+#  define context_eax sc_eax
+#  define context_ebx sc_ebx
+#  define context_ecx sc_ecx
+#  define context_edx sc_edx
+#  define context_ebp sc_ebp
+#  define context_esi sc_esi
+#  define context_edi sc_edi
+#  define context_eflags sc_eflags
+#  define context_trapno sc_trapno
+# endif
+#endif
+
+#ifdef __NetBSD__
+# define context_trapno uc_mcontext.__gregs[_REG_TRAPNO]
+# ifdef AMD64
+#  define __register_t __greg_t
+#  define context_pc uc_mcontext.__gregs[_REG_RIP]
+#  define context_sp uc_mcontext.__gregs[_REG_URSP]
+#  define context_fp uc_mcontext.__gregs[_REG_RBP]
+#  define context_rip uc_mcontext.__gregs[_REG_RIP]
+#  define context_rsp uc_mcontext.__gregs[_REG_URSP]
+#  define context_rax uc_mcontext.__gregs[_REG_RAX]
+#  define context_rbx uc_mcontext.__gregs[_REG_RBX]
+#  define context_rcx uc_mcontext.__gregs[_REG_RCX]
+#  define context_rdx uc_mcontext.__gregs[_REG_RDX]
+#  define context_rbp uc_mcontext.__gregs[_REG_RBP]
+#  define context_rsi uc_mcontext.__gregs[_REG_RSI]
+#  define context_rdi uc_mcontext.__gregs[_REG_RDI]
+#  define context_r8  uc_mcontext.__gregs[_REG_R8]
+#  define context_r9  uc_mcontext.__gregs[_REG_R9]
+#  define context_r10 uc_mcontext.__gregs[_REG_R10]
+#  define context_r11 uc_mcontext.__gregs[_REG_R11]
+#  define context_r12 uc_mcontext.__gregs[_REG_R12]
+#  define context_r13 uc_mcontext.__gregs[_REG_R13]
+#  define context_r14 uc_mcontext.__gregs[_REG_R14]
+#  define context_r15 uc_mcontext.__gregs[_REG_R15]
+#  define context_flags uc_mcontext.__gregs[_REG_RFL]
+#  define context_err uc_mcontext.__gregs[_REG_ERR]
+# else
+#  define context_pc uc_mcontext.__gregs[_REG_EIP]
+#  define context_sp uc_mcontext.__gregs[_REG_UESP]
+#  define context_fp uc_mcontext.__gregs[_REG_EBP]
+#  define context_eip uc_mcontext.__gregs[_REG_EIP]
+#  define context_esp uc_mcontext.__gregs[_REG_UESP]
+#  define context_eax uc_mcontext.__gregs[_REG_EAX]
+#  define context_ebx uc_mcontext.__gregs[_REG_EBX]
+#  define context_ecx uc_mcontext.__gregs[_REG_ECX]
+#  define context_edx uc_mcontext.__gregs[_REG_EDX]
+#  define context_ebp uc_mcontext.__gregs[_REG_EBP]
+#  define context_esi uc_mcontext.__gregs[_REG_ESI]
+#  define context_edi uc_mcontext.__gregs[_REG_EDI]
+#  define context_eflags uc_mcontext.__gregs[_REG_EFL]
+#  define context_trapno uc_mcontext.__gregs[_REG_TRAPNO]
+# endif
+#endif
+
 address os::current_stack_pointer() {
 #ifdef SPARC_WORKS
   register void *esp;
@@ -119,15 +298,15 @@
 }
 
 address os::Bsd::ucontext_get_pc(ucontext_t * uc) {
-  return (address)uc->uc_mcontext.gregs[REG_PC];
+  return (address)uc->context_pc;
 }
 
 intptr_t* os::Bsd::ucontext_get_sp(ucontext_t * uc) {
-  return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
+  return (intptr_t*)uc->context_sp;
 }
 
 intptr_t* os::Bsd::ucontext_get_fp(ucontext_t * uc) {
-  return (intptr_t*)uc->uc_mcontext.gregs[REG_FP];
+  return (intptr_t*)uc->context_fp;
 }
 
 // For Forte Analyzer AsyncGetCallTrace profiling support - thread
@@ -279,18 +458,18 @@
     pc = (address) os::Bsd::ucontext_get_pc(uc);
 
     if (pc == (address) Fetch32PFI) {
-       uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ;
+       uc->context_pc = intptr_t(Fetch32Resume) ;
        return 1 ;
     }
 #ifdef AMD64
     if (pc == (address) FetchNPFI) {
-       uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ;
+       uc->context_pc = intptr_t (FetchNResume) ;
        return 1 ;
     }
 #endif // AMD64
 
     // Handle ALL stack overflow variations here
-    if (sig == SIGSEGV) {
+    if (sig == SIGSEGV || sig == SIGBUS) {
       address addr = (address) info->si_addr;
 
       // check if fault address is within thread stack
@@ -312,6 +491,7 @@
           // to handle_unexpected_exception way down below.
           thread->disable_stack_red_zone();
           tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
+#ifndef _ALLBSD_SOURCE
         } else {
           // Accessing stack address below sp may cause SEGV if current
           // thread has MAP_GROWSDOWN stack. This should only happen when
@@ -327,6 +507,7 @@
           } else {
              fatal("recursive segv. expanding stack.");
           }
+#endif
         }
       }
     }
@@ -335,9 +516,16 @@
       // Java thread running in Java code => find exception handler if any
       // a fault inside compiled code, the interpreter, or a stub
 
-      if (sig == SIGSEGV && os::is_poll_address((address)info->si_addr)) {
+      if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
         stub = SharedRuntime::get_poll_stub(pc);
+#if defined(__APPLE__) && !defined(AMD64)
+      // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
+      // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
+      // being called, so only do so if the implicit NULL check is not necessary.
+      } else if (sig == SIGBUS && MacroAssembler::needs_explicit_null_check((int)info->si_addr)) {
+#else
       } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
+#endif
         // BugId 4454115: A read from a MappedByteBuffer can fault
         // here if the underlying file has been truncated.
         // Do not crash the VM in such a case.
@@ -358,6 +546,28 @@
                                               pc,
                                               SharedRuntime::
                                               IMPLICIT_DIVIDE_BY_ZERO);
+#ifdef __APPLE__
+      } else if (sig == SIGFPE && info->si_code == FPE_NOOP) {
+        int op = pc[0];
+
+        // Skip REX
+        if ((pc[0] & 0xf0) == 0x40) {
+          op = pc[1];
+        } else {
+          op = pc[0];
+        }
+
+        // Check for IDIV
+        if (op == 0xF7) {
+          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime:: IMPLICIT_DIVIDE_BY_ZERO);
+        } else {
+          // TODO: handle more cases if we are using other x86 instructions
+          //   that can generate SIGFPE signal.
+          tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
+          fatal("please update this code.");
+        }
+#endif /* __APPLE__ */
+
 #else
       if (sig == SIGFPE /* && info->si_code == FPE_INTDIV */) {
         // HACK: si_code does not work on bsd 2.2.12-20!!!
@@ -385,7 +595,7 @@
           fatal("please update this code.");
         }
 #endif // AMD64
-      } else if (sig == SIGSEGV &&
+      } else if ((sig == SIGSEGV || sig == SIGBUS) &&
                !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {
           // Determination of interpreter/vtable stub/compiled code null exception
           stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
@@ -409,7 +619,7 @@
     // process of write protecting the memory serialization page.
     // It write enables the page immediately after protecting it
     // so we can just return to retry the write.
-    if ((sig == SIGSEGV) &&
+    if ((sig == SIGSEGV || sig == SIGBUS) &&
         os::is_memory_serialize_page(thread, (address) info->si_addr)) {
       // Block current thread until the memory serialize page permission restored.
       os::block_on_serialize_page_trap();
@@ -430,7 +640,7 @@
   // Furthermore, a false-positive should be harmless.
   if (UnguardOnExecutionViolation > 0 &&
       (sig == SIGSEGV || sig == SIGBUS) &&
-      uc->uc_mcontext.gregs[REG_TRAPNO] == trap_page_fault) {
+      uc->context_trapno == trap_page_fault) {
     int page_size = os::vm_page_size();
     address addr = (address) info->si_addr;
     address pc = os::Bsd::ucontext_get_pc(uc);
@@ -500,7 +710,7 @@
     // save all thread context in case we need to restore it
     if (thread != NULL) thread->set_saved_exception_pc(pc);
 
-    uc->uc_mcontext.gregs[REG_PC] = (greg_t)stub;
+    uc->context_pc = (intptr_t)stub;
     return true;
   }
 
@@ -530,13 +740,24 @@
   ShouldNotReachHere();
 }
 
+#ifdef _ALLBSD_SOURCE
+// From solaris_i486.s ported to bsd_i486.s
+extern "C" void fixcw();
+#endif
+
 void os::Bsd::init_thread_fpu_state(void) {
 #ifndef AMD64
+# ifdef _ALLBSD_SOURCE
+  // Set fpu to 53 bit precision. This happens too early to use a stub.
+  fixcw();
+# else
   // set fpu to 53 bit precision
   set_fpu_control_word(0x27f);
+# endif
 #endif // !AMD64
 }
 
+#ifndef _ALLBSD_SOURCE
 int os::Bsd::get_fpu_control_word(void) {
 #ifdef AMD64
   return 0;
@@ -552,11 +773,12 @@
   _FPU_SETCW(fpu_control);
 #endif // !AMD64
 }
+#endif
 
 // Check that the bsd kernel version is 2.4 or higher since earlier
 // versions do not support SSE without patches.
 bool os::supports_sse() {
-#ifdef AMD64
+#if defined(AMD64) || defined(_ALLBSD_SOURCE)
   return true;
 #else
   struct utsname uts;
@@ -610,6 +832,9 @@
 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
 #endif
 
+#ifdef _ALLBSD_SOURCE
+bool os::Bsd::supports_variable_stack_size() { return true; }
+#else
 // Test if pthread library can support variable thread stack size. BsdThreads
 // in fixed stack mode allocates 2M fixed slot for each thread. BsdThreads
 // in floating stack mode and NPTL support variable stack size.
@@ -646,6 +871,7 @@
 #endif
   }
 }
+#endif
 #endif // AMD64
 
 // return default stack size for thr_type
@@ -699,6 +925,41 @@
 //    pthread_attr_getstack()
 
 static void current_stack_region(address * bottom, size_t * size) {
+#ifdef __APPLE__
+  pthread_t self = pthread_self();
+  void *stacktop = pthread_get_stackaddr_np(self);
+  *size = pthread_get_stacksize_np(self);
+  *bottom = (address) stacktop - *size;
+#elif defined(__OpenBSD__)
+  stack_t ss;
+  int rslt = pthread_stackseg_np(pthread_self(), &ss);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt));
+
+  *bottom = (address)((char *)ss.ss_sp - ss.ss_size);
+  *size   = ss.ss_size;
+#elif defined(_ALLBSD_SOURCE)
+  pthread_attr_t attr;
+
+  int rslt = pthread_attr_init(&attr);
+
+  // JVM needs to know exact stack location, abort if it fails
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_init failed with err = %d", rslt));
+
+  rslt = pthread_attr_get_np(pthread_self(), &attr);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_get_np failed with err = %d", rslt));
+
+  if (pthread_attr_getstackaddr(&attr, (void **)bottom) != 0 ||
+    pthread_attr_getstacksize(&attr, size) != 0) {
+    fatal("Can not locate current stack attributes!");
+  }
+
+  pthread_attr_destroy(&attr);
+#else
   if (os::Bsd::is_initial_thread()) {
      // initial thread needs special handling because pthread_getattr_np()
      // may return bogus value.
@@ -725,6 +986,7 @@
      pthread_attr_destroy(&attr);
 
   }
+#endif
   assert(os::current_stack_pointer() >= *bottom &&
          os::current_stack_pointer() < *bottom + *size, "just checking");
 }
@@ -753,46 +1015,44 @@
   ucontext_t *uc = (ucontext_t*)context;
   st->print_cr("Registers:");
 #ifdef AMD64
-  st->print(  "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
-  st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
-  st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]);
-  st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]);
-  st->cr();
-  st->print(  "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]);
-  st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]);
-  st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]);
-  st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]);
-  st->cr();
-  st->print(  "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]);
-  st->print(", R9 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R9]);
-  st->print(", R10=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R10]);
-  st->print(", R11=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R11]);
-  st->cr();
-  st->print(  "R12=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R12]);
-  st->print(", R13=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R13]);
-  st->print(", R14=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R14]);
-  st->print(", R15=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R15]);
-  st->cr();
-  st->print(  "RIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RIP]);
-  st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]);
-  st->print(", CSGSFS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_CSGSFS]);
-  st->print(", ERR=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_ERR]);
-  st->cr();
-  st->print("  TRAPNO=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_TRAPNO]);
-#else
-  st->print(  "EAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EAX]);
-  st->print(", EBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EBX]);
-  st->print(", ECX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_ECX]);
-  st->print(", EDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EDX]);
-  st->cr();
-  st->print(  "ESP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_UESP]);
-  st->print(", EBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EBP]);
-  st->print(", ESI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_ESI]);
-  st->print(", EDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EDI]);
-  st->cr();
-  st->print(  "EIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EIP]);
-  st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]);
-  st->print(", CR2=" INTPTR_FORMAT, uc->uc_mcontext.cr2);
+  st->print(  "RAX=" INTPTR_FORMAT, uc->context_rax);
+  st->print(", RBX=" INTPTR_FORMAT, uc->context_rbx);
+  st->print(", RCX=" INTPTR_FORMAT, uc->context_rcx);
+  st->print(", RDX=" INTPTR_FORMAT, uc->context_rdx);
+  st->cr();
+  st->print(  "RSP=" INTPTR_FORMAT, uc->context_rsp);
+  st->print(", RBP=" INTPTR_FORMAT, uc->context_rbp);
+  st->print(", RSI=" INTPTR_FORMAT, uc->context_rsi);
+  st->print(", RDI=" INTPTR_FORMAT, uc->context_rdi);
+  st->cr();
+  st->print(  "R8 =" INTPTR_FORMAT, uc->context_r8);
+  st->print(", R9 =" INTPTR_FORMAT, uc->context_r9);
+  st->print(", R10=" INTPTR_FORMAT, uc->context_r10);
+  st->print(", R11=" INTPTR_FORMAT, uc->context_r11);
+  st->cr();
+  st->print(  "R12=" INTPTR_FORMAT, uc->context_r12);
+  st->print(", R13=" INTPTR_FORMAT, uc->context_r13);
+  st->print(", R14=" INTPTR_FORMAT, uc->context_r14);
+  st->print(", R15=" INTPTR_FORMAT, uc->context_r15);
+  st->cr();
+  st->print(  "RIP=" INTPTR_FORMAT, uc->context_rip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_flags);
+  st->print(", ERR=" INTPTR_FORMAT, uc->context_err);
+  st->cr();
+  st->print("  TRAPNO=" INTPTR_FORMAT, uc->context_trapno);
+#else
+  st->print(  "EAX=" INTPTR_FORMAT, uc->context_eax);
+  st->print(", EBX=" INTPTR_FORMAT, uc->context_ebx);
+  st->print(", ECX=" INTPTR_FORMAT, uc->context_ecx);
+  st->print(", EDX=" INTPTR_FORMAT, uc->context_edx);
+  st->cr();
+  st->print(  "ESP=" INTPTR_FORMAT, uc->context_esp);
+  st->print(", EBP=" INTPTR_FORMAT, uc->context_ebp);
+  st->print(", ESI=" INTPTR_FORMAT, uc->context_esi);
+  st->print(", EDI=" INTPTR_FORMAT, uc->context_edi);
+  st->cr();
+  st->print(  "EIP=" INTPTR_FORMAT, uc->context_eip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_eflags);
 #endif // AMD64
   st->cr();
   st->cr();
@@ -825,31 +1085,31 @@
   // this is only for the "general purpose" registers
 
 #ifdef AMD64
-  st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]);
-  st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]);
-  st->print("RCX="); print_location(st, uc->uc_mcontext.gregs[REG_RCX]);
-  st->print("RDX="); print_location(st, uc->uc_mcontext.gregs[REG_RDX]);
-  st->print("RSP="); print_location(st, uc->uc_mcontext.gregs[REG_RSP]);
-  st->print("RBP="); print_location(st, uc->uc_mcontext.gregs[REG_RBP]);
-  st->print("RSI="); print_location(st, uc->uc_mcontext.gregs[REG_RSI]);
-  st->print("RDI="); print_location(st, uc->uc_mcontext.gregs[REG_RDI]);
-  st->print("R8 ="); print_location(st, uc->uc_mcontext.gregs[REG_R8]);
-  st->print("R9 ="); print_location(st, uc->uc_mcontext.gregs[REG_R9]);
-  st->print("R10="); print_location(st, uc->uc_mcontext.gregs[REG_R10]);
-  st->print("R11="); print_location(st, uc->uc_mcontext.gregs[REG_R11]);
-  st->print("R12="); print_location(st, uc->uc_mcontext.gregs[REG_R12]);
-  st->print("R13="); print_location(st, uc->uc_mcontext.gregs[REG_R13]);
-  st->print("R14="); print_location(st, uc->uc_mcontext.gregs[REG_R14]);
-  st->print("R15="); print_location(st, uc->uc_mcontext.gregs[REG_R15]);
-#else
-  st->print("EAX="); print_location(st, uc->uc_mcontext.gregs[REG_EAX]);
-  st->print("EBX="); print_location(st, uc->uc_mcontext.gregs[REG_EBX]);
-  st->print("ECX="); print_location(st, uc->uc_mcontext.gregs[REG_ECX]);
-  st->print("EDX="); print_location(st, uc->uc_mcontext.gregs[REG_EDX]);
-  st->print("ESP="); print_location(st, uc->uc_mcontext.gregs[REG_ESP]);
-  st->print("EBP="); print_location(st, uc->uc_mcontext.gregs[REG_EBP]);
-  st->print("ESI="); print_location(st, uc->uc_mcontext.gregs[REG_ESI]);
-  st->print("EDI="); print_location(st, uc->uc_mcontext.gregs[REG_EDI]);
+  st->print("RAX="); print_location(st, uc->context_rax);
+  st->print("RBX="); print_location(st, uc->context_rbx);
+  st->print("RCX="); print_location(st, uc->context_rcx);
+  st->print("RDX="); print_location(st, uc->context_rdx);
+  st->print("RSP="); print_location(st, uc->context_rsp);
+  st->print("RBP="); print_location(st, uc->context_rbp);
+  st->print("RSI="); print_location(st, uc->context_rsi);
+  st->print("RDI="); print_location(st, uc->context_rdi);
+  st->print("R8 ="); print_location(st, uc->context_r8);
+  st->print("R9 ="); print_location(st, uc->context_r9);
+  st->print("R10="); print_location(st, uc->context_r10);
+  st->print("R11="); print_location(st, uc->context_r11);
+  st->print("R12="); print_location(st, uc->context_r12);
+  st->print("R13="); print_location(st, uc->context_r13);
+  st->print("R14="); print_location(st, uc->context_r14);
+  st->print("R15="); print_location(st, uc->context_r15);
+#else
+  st->print("EAX="); print_location(st, uc->context_eax);
+  st->print("EBX="); print_location(st, uc->context_ebx);
+  st->print("ECX="); print_location(st, uc->context_ecx);
+  st->print("EDX="); print_location(st, uc->context_edx);
+  st->print("ESP="); print_location(st, uc->context_esp);
+  st->print("EBP="); print_location(st, uc->context_ebp);
+  st->print("ESI="); print_location(st, uc->context_esi);
+  st->print("EDI="); print_location(st, uc->context_edi);
 #endif // AMD64
 
   st->cr();
--- ./hotspot/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -30,8 +30,10 @@
 #ifndef AMD64
   // map stack pointer to thread pointer - see notes in threadLS_bsd_x86.cpp
   #define SP_BITLENGTH  32
+#ifndef PAGE_SHIFT
   #define PAGE_SHIFT    12
   #define PAGE_SIZE     (1UL << PAGE_SHIFT)
+#endif
   static Thread* _sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)];
 #endif // !AMD64
 
--- ./hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -34,7 +34,7 @@
   /******************************/                                                                                                   \
   /* Threads (NOTE: incomplete) */                                                                                                   \
   /******************************/                                                                                                   \
-  nonstatic_field(OSThread,                      _thread_id,                                      pid_t)                             \
+  nonstatic_field(OSThread,                      _thread_id,                                      pthread_t)                             \
   nonstatic_field(OSThread,                      _pthread_id,                                     pthread_t)                         \
   /* This must be the last entry, and must be present */                                                                             \
   last_entry()
--- ./hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.inline.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -31,136 +31,455 @@
 #include "runtime/os.hpp"
 #include "vm_version_zero.hpp"
 
-// Implementation of class atomic
-
-#ifdef M68K
+#include <sys/types.h>
+#ifdef __NetBSD__
+#include <sys/atomic.h>
+#elif __FreeBSD__
+
+#include <sys/types.h>
+#ifndef SPARC
+#include <machine/atomic.h>
+#else
 
 /*
- * __m68k_cmpxchg
+ * On FreeBSD/sparc64, <machine/atomic.h> pulls in <machine/cpufunc.h>
+ * which includes definitions which cause conflicts with various
+ * definitions within HotSpot source.  To avoid that, pull in those
+ * definitions verbatim instead of including the header.  Yuck.
+ */
+
+/*-
+ * Copyright (c) 1998 Doug Rabson.
+ * Copyright (c) 2001 Jake Burkholder.
+ * All rights reserved.
  *
- * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
- * Returns newval on success and oldval if no exchange happened.
- * This implementation is processor specific and works on
- * 68020 68030 68040 and 68060.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
- * It will not work on ColdFire, 68000 and 68010 since they lack the CAS
- * instruction.
- * Using a kernelhelper would be better for arch complete implementation.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  */
 
-static inline int __m68k_cmpxchg(int oldval, int newval, volatile int *ptr) {
-  int ret;
-  __asm __volatile ("cas%.l %0,%2,%1"
-                   : "=d" (ret), "+m" (*(ptr))
-                   : "d" (newval), "0" (oldval));
-  return ret;
-}
-
-/* Perform an atomic compare and swap: if the current value of `*PTR'
-   is OLDVAL, then write NEWVAL into `*PTR'.  Return the contents of
-   `*PTR' before the operation.*/
-static inline int m68k_compare_and_swap(volatile int *ptr,
-                                        int oldval,
-                                        int newval) {
-  for (;;) {
-      int prev = *ptr;
-      if (prev != oldval)
-        return prev;
-
-      if (__m68k_cmpxchg (prev, newval, ptr) == newval)
-        // Success.
-        return prev;
-
-      // We failed even though prev == oldval.  Try again.
-    }
-}
-
-/* Atomically add an int to memory.  */
-static inline int m68k_add_and_fetch(volatile int *ptr, int add_value) {
-  for (;;) {
-      // Loop until success.
-
-      int prev = *ptr;
-
-      if (__m68k_cmpxchg (prev, prev + add_value, ptr) == prev + add_value)
-        return prev + add_value;
-    }
-}
-
-/* Atomically write VALUE into `*PTR' and returns the previous
-   contents of `*PTR'.  */
-static inline int m68k_lock_test_and_set(volatile int *ptr, int newval) {
-  for (;;) {
-      // Loop until success.
-      int prev = *ptr;
-
-      if (__m68k_cmpxchg (prev, newval, ptr) == prev)
-        return prev;
-    }
-}
-#endif // M68K
+#include <machine/asi.h>
 
-#ifdef ARM
+/*
+ * Membar operand macros for use in other macros when # is a special
+ * character.  Keep these in sync with what the hardware expects.
+ */
+#define	M_LoadLoad	(0)
+#define	M_StoreLoad	(1)
+#define	M_LoadStore	(2)
+#define	M_StoreStore	(3)
+
+#define	CMASK_SHIFT	(4)
+#define	MMASK_SHIFT	(0)
+
+#define	CMASK_GEN(bit)	((1 << (bit)) << CMASK_SHIFT)
+#define	MMASK_GEN(bit)	((1 << (bit)) << MMASK_SHIFT)
+
+#define	LoadLoad	MMASK_GEN(M_LoadLoad)
+#define	StoreLoad	MMASK_GEN(M_StoreLoad)
+#define	LoadStore	MMASK_GEN(M_LoadStore)
+#define	StoreStore	MMASK_GEN(M_StoreStore)
+
+#define	casa(rs1, rs2, rd, asi) ({					\
+	u_int __rd = (uint32_t)(rd);					\
+	__asm __volatile("casa [%2] %3, %4, %0"				\
+	    : "+r" (__rd), "=m" (*rs1)					\
+	    : "r" (rs1), "n" (asi), "r" (rs2), "m" (*rs1));		\
+	__rd;								\
+})
+
+#define	casxa(rs1, rs2, rd, asi) ({					\
+	u_long __rd = (uint64_t)(rd);					\
+	__asm __volatile("casxa [%2] %3, %4, %0"			\
+	    : "+r" (__rd), "=m" (*rs1)					\
+	    : "r" (rs1), "n" (asi), "r" (rs2), "m" (*rs1));		\
+	__rd;								\
+})
+
+#define	membar(mask) do {						\
+	__asm __volatile("membar %0" : : "n" (mask) : "memory");	\
+} while (0)
+
+#ifdef _KERNEL
+#define	__ASI_ATOMIC	ASI_N
+#else
+#define	__ASI_ATOMIC	ASI_P
+#endif
+
+#define mb()	__asm__ __volatile__ ("membar #MemIssue": : :"memory")
+#define wmb()	mb()
+#define rmb()	mb()
 
 /*
- * __kernel_cmpxchg
+ * Various simple arithmetic on memory which is atomic in the presence
+ * of interrupts and multiple processors.  See atomic(9) for details.
+ * Note that efficient hardware support exists only for the 32 and 64
+ * bit variants; the 8 and 16 bit versions are not provided and should
+ * not be used in MI code.
  *
- * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
- * Return zero if *ptr was changed or non-zero if no exchange happened.
- * The C flag is also set if *ptr was changed to allow for assembly
- * optimization in the calling code.
+ * This implementation takes advantage of the fact that the sparc64
+ * cas instruction is both a load and a store.  The loop is often coded
+ * as follows:
  *
+ *	do {
+ *		expect = *p;
+ *		new = expect + 1;
+ *	} while (cas(p, expect, new) != expect);
+ *
+ * which performs an unnnecessary load on each iteration that the cas
+ * operation fails.  Modified as follows:
+ *
+ *	expect = *p;
+ *	for (;;) {
+ *		new = expect + 1;
+ *		result = cas(p, expect, new);
+ *		if (result == expect)
+ *			break;
+ *		expect = result;
+ *	}
+ *
+ * the return value of cas is used to avoid the extra reload.
+ *
+ * The memory barriers provided by the acq and rel variants are intended
+ * to be sufficient for use of relaxed memory ordering.  Due to the
+ * suggested assembly syntax of the membar operands containing a #
+ * character, they cannot be used in macros.  The cmask and mmask bits
+ * are hard coded in machine/cpufunc.h and used here through macros.
+ * Hopefully sun will choose not to change the bit numbers.
  */
 
-typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
-#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0)
+#define	itype(sz)	uint ## sz ## _t
 
+#define	atomic_cas_32(p, e, s)	casa(p, e, s, __ASI_ATOMIC)
+#define	atomic_cas_64(p, e, s)	casxa(p, e, s, __ASI_ATOMIC)
 
+#define	atomic_cas(p, e, s, sz)						\
+	atomic_cas_ ## sz(p, e, s)
 
-/* Perform an atomic compare and swap: if the current value of `*PTR'
-   is OLDVAL, then write NEWVAL into `*PTR'.  Return the contents of
-   `*PTR' before the operation.*/
-static inline int arm_compare_and_swap(volatile int *ptr,
-                                       int oldval,
-                                       int newval) {
-  for (;;) {
-      int prev = *ptr;
-      if (prev != oldval)
-        return prev;
+#define	atomic_cas_acq(p, e, s, sz) ({					\
+	itype(sz) v;							\
+	v = atomic_cas(p, e, s, sz);					\
+	membar(LoadLoad | LoadStore);					\
+	v;								\
+})
+
+#define	atomic_cas_rel(p, e, s, sz) ({					\
+	itype(sz) v;							\
+	membar(LoadStore | StoreStore);					\
+	v = atomic_cas(p, e, s, sz);					\
+	v;								\
+})
+
+#define	atomic_op(p, op, v, sz) ({					\
+	itype(sz) e, r, s;						\
+	for (e = *(volatile itype(sz) *)p;; e = r) {			\
+		s = e op v;						\
+		r = atomic_cas_ ## sz(p, e, s);				\
+		if (r == e)						\
+			break;						\
+	}								\
+	e;								\
+})
+
+#define	atomic_op_acq(p, op, v, sz) ({					\
+	itype(sz) t;							\
+	t = atomic_op(p, op, v, sz);					\
+	membar(LoadLoad | LoadStore);					\
+	t;								\
+})
+
+#define	atomic_op_rel(p, op, v, sz) ({					\
+	itype(sz) t;							\
+	membar(LoadStore | StoreStore);					\
+	t = atomic_op(p, op, v, sz);					\
+	t;								\
+})
+
+#define	atomic_load(p, sz)						\
+	atomic_cas(p, 0, 0, sz)
+
+#define	atomic_load_acq(p, sz) ({					\
+	itype(sz) v;							\
+	v = atomic_load(p, sz);						\
+	membar(LoadLoad | LoadStore);					\
+	v;								\
+})
+
+#define	atomic_load_clear(p, sz) ({					\
+	itype(sz) e, r;							\
+	for (e = *(volatile itype(sz) *)p;; e = r) {			\
+		r = atomic_cas(p, e, 0, sz);				\
+		if (r == e)						\
+			break;						\
+	}								\
+	e;								\
+})
+
+#define	atomic_store(p, v, sz) do {					\
+	itype(sz) e, r;							\
+	for (e = *(volatile itype(sz) *)p;; e = r) {			\
+		r = atomic_cas(p, e, v, sz);				\
+		if (r == e)						\
+			break;						\
+	}								\
+} while (0)
+
+#define	atomic_store_rel(p, v, sz) do {					\
+	membar(LoadStore | StoreStore);					\
+	atomic_store(p, v, sz);						\
+} while (0)
+
+#define	ATOMIC_GEN(name, ptype, vtype, atype, sz)			\
+									\
+static __inline vtype							\
+atomic_add_ ## name(volatile ptype p, atype v)				\
+{									\
+	return ((vtype)atomic_op(p, +, v, sz));				\
+}									\
+static __inline vtype							\
+atomic_add_acq_ ## name(volatile ptype p, atype v)			\
+{									\
+	return ((vtype)atomic_op_acq(p, +, v, sz));			\
+}									\
+static __inline vtype							\
+atomic_add_rel_ ## name(volatile ptype p, atype v)			\
+{									\
+	return ((vtype)atomic_op_rel(p, +, v, sz));			\
+}									\
+									\
+static __inline int							\
+atomic_cmpset_ ## name(volatile ptype p, vtype e, vtype s)		\
+{									\
+	return (((vtype)atomic_cas(p, e, s, sz)) == e);			\
+}									\
+static __inline int							\
+atomic_cmpset_acq_ ## name(volatile ptype p, vtype e, vtype s)		\
+{									\
+	return (((vtype)atomic_cas_acq(p, e, s, sz)) == e);		\
+}									\
+static __inline int							\
+atomic_cmpset_rel_ ## name(volatile ptype p, vtype e, vtype s)		\
+{									\
+	return (((vtype)atomic_cas_rel(p, e, s, sz)) == e);		\
+}									\
+									\
+static __inline vtype							\
+atomic_load_ ## name(volatile ptype p)					\
+{									\
+	return ((vtype)atomic_cas(p, 0, 0, sz));			\
+}									\
+static __inline vtype							\
+atomic_load_acq_ ## name(volatile ptype p)				\
+{									\
+	return ((vtype)atomic_cas_acq(p, 0, 0, sz));			\
+}									\
+									\
+static __inline void							\
+atomic_store_ ## name(volatile ptype p, vtype v)			\
+{									\
+	atomic_store(p, v, sz);						\
+}									\
+static __inline void							\
+atomic_store_rel_ ## name(volatile ptype p, vtype v)			\
+{									\
+	atomic_store_rel(p, v, sz);					\
+}
 
-      if (__kernel_cmpxchg (prev, newval, ptr) == 0)
-        // Success.
-        return prev;
+inline jlong Atomic::load(volatile jlong* src) {
+  volatile jlong dest;
+  os::atomic_copy64(src, &dest);
+  return dest;
+}
 
-      // We failed even though prev == oldval.  Try again.
-    }
+inline void Atomic::store(jlong store_value, jlong* dest) {
+  os::atomic_copy64((volatile jlong*)&store_value, (volatile jlong*)dest);
 }
 
-/* Atomically add an int to memory.  */
-static inline int arm_add_and_fetch(volatile int *ptr, int add_value) {
-  for (;;) {
-      // Loop until a __kernel_cmpxchg succeeds.
+inline void Atomic::store(jlong store_value, volatile jlong* dest) {
+  os::atomic_copy64((volatile jlong*)&store_value, dest);
+}
 
-      int prev = *ptr;
+ATOMIC_GEN(int, u_int *, u_int, u_int, 32);
+ATOMIC_GEN(32, uint32_t *, uint32_t, uint32_t, 32);
 
-      if (__kernel_cmpxchg (prev, prev + add_value, ptr) == 0)
-        return prev + add_value;
-    }
-}
+ATOMIC_GEN(long, u_long *, u_long, u_long, 64);
+ATOMIC_GEN(64, uint64_t *, uint64_t, uint64_t, 64);
 
-/* Atomically write VALUE into `*PTR' and returns the previous
-   contents of `*PTR'.  */
-static inline int arm_lock_test_and_set(volatile int *ptr, int newval) {
-  for (;;) {
-      // Loop until a __kernel_cmpxchg succeeds.
-      int prev = *ptr;
+ATOMIC_GEN(ptr, uintptr_t *, uintptr_t, uintptr_t, 64);
 
-      if (__kernel_cmpxchg (prev, newval, ptr) == 0)
-        return prev;
-    }
+#define	atomic_fetchadd_int	atomic_add_int
+#define	atomic_fetchadd_32	atomic_add_32
+#define	atomic_fetchadd_long	atomic_add_long
+
+#undef ATOMIC_GEN
+#undef atomic_cas
+#undef atomic_cas_acq
+#undef atomic_cas_rel
+#undef atomic_op
+#undef atomic_op_acq
+#undef atomic_op_rel
+#undef atomic_load_acq
+#undef atomic_store_rel
+#undef atomic_load_clear
+#endif
+
+static __inline __attribute__((__always_inline__))
+unsigned int atomic_add_int_nv(volatile unsigned int* dest, unsigned int add_value)
+{
+  atomic_add_acq_int(dest, add_value);
+  return *dest;
+}
+
+static __inline __attribute__((__always_inline__))
+uintptr_t atomic_add_ptr_nv(volatile intptr_t* dest, intptr_t add_value)
+{
+  atomic_add_acq_ptr((volatile uintptr_t*) dest, (uintptr_t) add_value);
+  return *((volatile uintptr_t*) dest);
+}
+
+static __inline __attribute__((__always_inline__))
+unsigned int
+atomic_swap_uint(volatile unsigned int *dest, unsigned int exchange_value)
+{
+  jint prev = *dest;
+  atomic_store_rel_int(dest, exchange_value);
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+void *
+atomic_swap_ptr(volatile void *dest, void *exchange_value)
+{
+  void *prev = *(void **)dest;
+  atomic_store_rel_ptr((volatile uintptr_t*) dest, (uintptr_t) exchange_value);
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+unsigned int
+atomic_cas_uint(volatile unsigned int *dest, unsigned int compare_value,
+  unsigned int exchange_value)
+{
+  unsigned int prev = *dest;
+  atomic_cmpset_acq_int(dest, compare_value, exchange_value);
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+unsigned long
+atomic_cas_ulong(volatile unsigned long *dest, unsigned long compare_value,
+  unsigned long exchange_value)
+{
+  unsigned long prev = *dest;
+  atomic_cmpset_acq_long(dest, compare_value, exchange_value);
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+void *
+atomic_cas_ptr(volatile void *dest, void *compare_value, void *exchange_value)
+{
+  void *prev = *(void **)dest;
+  atomic_cmpset_acq_ptr((volatile uintptr_t*) dest, (uintptr_t) compare_value, (uintptr_t) exchange_value);
+  return prev;
+}
+
+#elif defined(__APPLE__)
+
+#include <libkern/OSAtomic.h>
+
+static __inline __attribute__((__always_inline__))
+unsigned int
+atomic_add_int_nv(volatile unsigned int *target, int delta) {
+  return (unsigned int) OSAtomicAdd32Barrier(delta, (volatile int32_t *) target);
+}
+
+static __inline __attribute__((__always_inline__))
+void *
+atomic_add_ptr_nv(volatile void *target, ssize_t delta) {
+#ifdef __LP64__
+  return (void *) OSAtomicAdd64Barrier(delta, (volatile int64_t *) target);
+#else
+  return (void *) OSAtomicAdd32Barrier(delta, (volatile int32_t *) target);
+#endif
+}
+
+
+static __inline __attribute__((__always_inline__))
+unsigned int
+atomic_swap_uint(volatile unsigned int *dest, unsigned int exchange_value)
+{
+  /* No xchg support in OSAtomic */
+  unsigned int prev;
+  do {
+    prev = *dest;
+  } while (!OSAtomicCompareAndSwapIntBarrier((int) prev, (int) exchange_value, (volatile int *) dest));
+
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+void *
+atomic_swap_ptr(volatile void *dest, void *exchange_value)
+{
+  /* No xchg support in OSAtomic */
+  void *prev;
+  do {
+    prev = *((void * volatile *) dest);
+  } while (!OSAtomicCompareAndSwapPtrBarrier(prev, exchange_value, (void * volatile *) dest));
+
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+unsigned int
+atomic_cas_uint(volatile unsigned int *dest, unsigned int compare_value,
+  unsigned int exchange_value)
+{
+  unsigned int prev = *dest;
+  OSAtomicCompareAndSwapIntBarrier(compare_value, exchange_value, (volatile int *) dest);
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+unsigned long
+atomic_cas_ulong(volatile unsigned long *dest, unsigned long compare_value,
+  unsigned long exchange_value)
+{
+  unsigned long prev = *dest;
+  OSAtomicCompareAndSwapLongBarrier(compare_value, exchange_value, (volatile long *) dest);
+  return prev;
+}
+
+static __inline __attribute__((__always_inline__))
+void *
+atomic_cas_ptr(volatile void *dest, void *compare_value, void *exchange_value)
+{
+  void *prev = *(void **)dest;
+  OSAtomicCompareAndSwapPtrBarrier(compare_value, exchange_value, (void * volatile *) dest);
+  return prev;
 }
-#endif // ARM
+
+
+#endif
 
 inline void Atomic::store(jint store_value, volatile jint* dest) {
   *dest = store_value;
@@ -171,27 +490,11 @@
 }
 
 inline jint Atomic::add(jint add_value, volatile jint* dest) {
-#ifdef ARM
-  return arm_add_and_fetch(dest, add_value);
-#else
-#ifdef M68K
-  return m68k_add_and_fetch(dest, add_value);
-#else
-  return __sync_add_and_fetch(dest, add_value);
-#endif // M68K
-#endif // ARM
+  return (jint)atomic_add_int_nv((volatile unsigned int*) dest, add_value);
 }
 
 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
-#ifdef ARM
-  return arm_add_and_fetch(dest, add_value);
-#else
-#ifdef M68K
-  return m68k_add_and_fetch(dest, add_value);
-#else
-  return __sync_add_and_fetch(dest, add_value);
-#endif // M68K
-#endif // ARM
+  return (intptr_t)atomic_add_ptr_nv(dest, add_value);
 }
 
 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) {
@@ -223,95 +526,43 @@
 }
 
 inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
-#ifdef ARM
-  return arm_lock_test_and_set(dest, exchange_value);
-#else
-#ifdef M68K
-  return m68k_lock_test_and_set(dest, exchange_value);
-#else
-  // __sync_lock_test_and_set is a bizarrely named atomic exchange
-  // operation.  Note that some platforms only support this with the
-  // limitation that the only valid value to store is the immediate
-  // constant 1.  There is a test for this in JNI_CreateJavaVM().
-  return __sync_lock_test_and_set (dest, exchange_value);
-#endif // M68K
-#endif // ARM
+  return (jint)atomic_swap_uint((volatile u_int *)dest, (u_int)exchange_value);
 }
 
 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
                                  volatile intptr_t* dest) {
-#ifdef ARM
-  return arm_lock_test_and_set(dest, exchange_value);
-#else
-#ifdef M68K
-  return m68k_lock_test_and_set(dest, exchange_value);
-#else
-  return __sync_lock_test_and_set (dest, exchange_value);
-#endif // M68K
-#endif // ARM
+  return (intptr_t)atomic_swap_ptr((volatile void *)dest,
+    (void *)exchange_value);
 }
 
 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
-  return (void *) xchg_ptr((intptr_t) exchange_value,
-                           (volatile intptr_t*) dest);
+  return atomic_swap_ptr(dest, exchange_value);
 }
 
 inline jint Atomic::cmpxchg(jint exchange_value,
                             volatile jint* dest,
                             jint compare_value) {
-#ifdef ARM
-  return arm_compare_and_swap(dest, compare_value, exchange_value);
-#else
-#ifdef M68K
-  return m68k_compare_and_swap(dest, compare_value, exchange_value);
-#else
-  return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
-#endif // M68K
-#endif // ARM
+  return atomic_cas_uint((volatile u_int *)dest, compare_value, exchange_value);
 }
 
 inline jlong Atomic::cmpxchg(jlong exchange_value,
                              volatile jlong* dest,
                              jlong compare_value) {
-
-  return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
+  return atomic_cas_ulong((volatile u_long *)dest, compare_value,
+    exchange_value);
 }
 
 inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value,
                                     volatile intptr_t* dest,
                                     intptr_t compare_value) {
-#ifdef ARM
-  return arm_compare_and_swap(dest, compare_value, exchange_value);
-#else
-#ifdef M68K
-  return m68k_compare_and_swap(dest, compare_value, exchange_value);
-#else
-  return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
-#endif // M68K
-#endif // ARM
+  return (intptr_t)atomic_cas_ptr((volatile void *)dest, (void *)compare_value,
+      (void *)exchange_value);
 }
 
 inline void* Atomic::cmpxchg_ptr(void* exchange_value,
                                  volatile void* dest,
                                  void* compare_value) {
-
-  return (void *) cmpxchg_ptr((intptr_t) exchange_value,
-                              (volatile intptr_t*) dest,
-                              (intptr_t) compare_value);
-}
-
-inline jlong Atomic::load(volatile jlong* src) {
-  volatile jlong dest;
-  os::atomic_copy64(src, &dest);
-  return dest;
-}
-
-inline void Atomic::store(jlong store_value, jlong* dest) {
-  os::atomic_copy64((volatile jlong*)&store_value, (volatile jlong*)dest);
-}
-
-inline void Atomic::store(jlong store_value, volatile jlong* dest) {
-  os::atomic_copy64((volatile jlong*)&store_value, dest);
+  return atomic_cas_ptr((volatile void *)dest, compare_value, exchange_value);
 }
 
 #endif // OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_INLINE_HPP
--- ./hotspot/src/os_cpu/bsd_zero/vm/bytes_bsd_zero.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_zero/vm/bytes_bsd_zero.inline.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -28,18 +28,25 @@
 // Efficient swapping of data bytes from Java byte
 // ordering to native byte ordering and vice versa.
 
-#include <byteswap.h>
+#ifdef __APPLE__
+#include <libkern/OSByteOrder.h>
+#define bswap16(x) OSSwapInt16(x)
+#define bswap32(x) OSSwapInt32(x)
+#define bswap64(x) OSSwapInt64(x)
+#else
+#  include <sys/endian.h>
+#endif
 
 inline u2 Bytes::swap_u2(u2 x) {
-  return bswap_16(x);
+  return bswap16(x);
 }
 
 inline u4 Bytes::swap_u4(u4 x) {
-  return bswap_32(x);
+  return bswap32(x);
 }
 
 inline u8 Bytes::swap_u8(u8 x) {
-  return bswap_64(x);
+  return bswap64(x);
 }
 
 #endif // OS_CPU_BSD_ZERO_VM_BYTES_BSD_ZERO_INLINE_HPP
--- ./hotspot/src/os_cpu/bsd_zero/vm/orderAccess_bsd_zero.inline.hpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_zero/vm/orderAccess_bsd_zero.inline.hpp	2011-04-22 22:28:34.000000000 -0700
@@ -46,7 +46,12 @@
 
 #else // ARM
 
+#ifdef __APPLE__
+#include <libkern/OSAtomic.h>
+#define FULL_MEM_BARRIER OSMemoryBarrier()
+#else
 #define FULL_MEM_BARRIER __sync_synchronize()
+#endif // __APPLE__
 
 #ifdef PPC
 
--- ./hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	2011-05-29 11:28:24.000000000 -0700
+++ ./hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	2011-04-22 22:28:34.000000000 -0700
@@ -23,6 +23,10 @@
  *
  */
 
+#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__) && !defined(__NetBSD__)
+# include <pthread_np.h> /* For pthread_attr_get_np */
+#endif
+
 // no precompiled headers
 #include "assembler_zero.inline.hpp"
 #include "classfile/classLoader.hpp"
@@ -179,6 +183,7 @@
           thread->disable_stack_red_zone();
           ShouldNotCallThis();
         }
+#ifndef _ALLBSD_SOURCE
         else {
           // Accessing stack address below sp may cause SEGV if
           // current thread has MAP_GROWSDOWN stack. This should
@@ -197,6 +202,7 @@
             fatal("recursive segv. expanding stack.");
           }
         }
+#endif
       }
     }
 
@@ -264,6 +270,7 @@
   // Nothing to do
 }
 
+#ifndef _ALLBSD_SOURCE
 int os::Bsd::get_fpu_control_word() {
   ShouldNotCallThis();
 }
@@ -271,6 +278,7 @@
 void os::Bsd::set_fpu_control_word(int fpu) {
   ShouldNotCallThis();
 }
+#endif
 
 bool os::is_allocatable(size_t bytes) {
 #ifdef _LP64
@@ -315,6 +323,48 @@
 }
 
 static void current_stack_region(address *bottom, size_t *size) {
+  address stack_bottom;
+  address stack_top;
+  size_t stack_bytes;
+
+#ifdef __APPLE__
+  pthread_t self = pthread_self();
+  stack_top = (address) pthread_get_stackaddr_np(self);
+  stack_bytes = pthread_get_stacksize_np(self);
+  stack_bottom = stack_top - stack_bytes;
+#elif defined(__OpenBSD__)
+  stack_t ss;
+  int rslt = pthread_stackseg_np(pthread_self(), &ss);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt));
+
+  stack_top = (address) ss.ss_sp;
+  stack_bytes  = ss.ss_size;
+  stack_bottom = stacktop - stack_bytes;
+#elif defined(_ALLBSD_SOURCE)
+  pthread_attr_t attr;
+
+  int rslt = pthread_attr_init(&attr);
+
+  // JVM needs to know exact stack location, abort if it fails
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_init failed with err = %d", rslt));
+
+  rslt = pthread_attr_get_np(pthread_self(), &attr);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_get_np failed with err = %d", rslt));
+
+  if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 ||
+      pthread_attr_getstacksize(&attr, &stack_bytes) != 0) {
+    fatal("Can not locate current stack attributes!");
+  }
+
+  pthread_attr_destroy(&attr);
+
+  stack_top = stack_bottom + stack_bytes;
+#else /* Linux */
   pthread_attr_t attr;
   int res = pthread_getattr_np(pthread_self(), &attr);
   if (res != 0) {
@@ -326,13 +376,11 @@
     }
   }
 
-  address stack_bottom;
-  size_t stack_bytes;
   res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes);
   if (res != 0) {
     fatal(err_msg("pthread_attr_getstack failed with errno = %d", res));
   }
-  address stack_top = stack_bottom + stack_bytes;
+  stack_top = stack_bottom + stack_bytes;
 
   // The block of memory returned by pthread_attr_getstack() includes
   // guard pages where present.  We need to trim these off.
@@ -374,6 +422,7 @@
 
     stack_bottom = stack_top - stack_bytes;
   }
+#endif
 
   assert(os::current_stack_pointer() >= stack_bottom, "should do");
   assert(os::current_stack_pointer() < stack_top, "should do");
--- ./hotspot/src/share/vm/adlc/adlc.hpp	2011-05-26 17:30:48.000000000 -0700
+++ ./hotspot/src/share/vm/adlc/adlc.hpp	2011-04-22 22:28:35.000000000 -0700
@@ -67,9 +67,9 @@
 #endif
 #endif // _WIN32
 
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
   #include <inttypes.h>
-#endif // LINUX
+#endif // LINUX || _ALLBSD_SOURCE
 
 // Macros
 #define uint32 unsigned int
--- ./hotspot/src/share/vm/c1/c1_globals.hpp	2011-05-26 17:31:05.000000000 -0700
+++ ./hotspot/src/share/vm/c1/c1_globals.hpp	2011-04-22 22:28:35.000000000 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c1_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c1_globals_bsd.hpp"
+#endif
 
 //
 // Defines all global flags used by the client compiler.
--- ./hotspot/src/share/vm/classfile/classLoader.cpp	2011-05-26 17:31:23.000000000 -0700
+++ ./hotspot/src/share/vm/classfile/classLoader.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -68,6 +68,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 // Entry points in zip.dll for loading zip/jar file entries
--- ./hotspot/src/share/vm/classfile/javaClasses.cpp	2011-05-26 17:31:26.000000000 -0700
+++ ./hotspot/src/share/vm/classfile/javaClasses.cpp	2011-05-20 20:03:59.000000000 -0700
@@ -56,6 +56,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 static bool find_field(instanceKlass* ik,
                        Symbol* name_symbol, Symbol* signature_symbol,
@@ -1110,7 +1113,7 @@
     }
     nmethod* nm = method->code();
     if (WizardMode && nm != NULL) {
-      sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm);
+      sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm);
     }
   }
 
--- ./hotspot/src/share/vm/code/stubs.hpp	2011-05-26 17:31:37.000000000 -0700
+++ ./hotspot/src/share/vm/code/stubs.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // The classes in this file provide a simple framework for the
 // management of little pieces of machine code - or stubs -
--- ./hotspot/src/share/vm/compiler/disassembler.hpp	2011-05-26 17:31:39.000000000 -0700
+++ ./hotspot/src/share/vm/compiler/disassembler.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 class decode_env;
 
--- ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp	2011-05-26 17:31:41.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 elapsedTimer CMSAdaptiveSizePolicy::_concurrent_timer;
 elapsedTimer CMSAdaptiveSizePolicy::_STW_timer;
 
--- ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	2011-05-26 17:31:42.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -50,6 +50,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // ConcurrentMarkSweepPolicy methods
--- ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp	2011-05-26 17:31:45.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 class ConcurrentMarkSweepGeneration;
 class CMSCollector;
--- ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeBlockDictionary.cpp	2011-05-26 17:31:45.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeBlockDictionary.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -33,6 +33,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifndef PRODUCT
 Mutex* FreeBlockDictionary::par_lock() const {
--- ./hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	2011-05-26 17:31:49.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 bool DirtyCardQueue::apply_closure(CardTableEntryClosure* cl,
                                    bool consume,
--- ./hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	2011-05-26 17:31:54.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	2011-05-07 21:53:41.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap,
                                                  int max_covered_regions) :
--- ./hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	2011-05-26 17:31:58.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 PtrQueue::PtrQueue(PtrQueueSet* qset, bool perm, bool active) :
   _qset(qset), _buf(NULL), _index(0), _active(active),
--- ./hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	2011-05-26 17:32:04.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -38,6 +38,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 bool
 ParMarkBitMap::initialize(MemRegion covered_region)
--- ./hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp	2011-05-26 17:32:10.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // PSVirtualSpace
 
--- ./hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	2011-05-26 17:32:16.000000000 -0700
+++ ./hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment) {
--- ./hotspot/src/share/vm/gc_interface/collectedHeap.cpp	2011-05-26 17:32:18.000000000 -0700
+++ ./hotspot/src/share/vm/gc_interface/collectedHeap.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 #ifdef ASSERT
--- ./hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp	2011-05-26 17:32:18.000000000 -0700
+++ ./hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -43,6 +43,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Inline allocation implementations.
 
--- ./hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	2011-05-26 17:32:19.000000000 -0700
+++ ./hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	2011-05-20 20:03:59.000000000 -0700
@@ -56,6 +56,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // This file contains the platform-independent parts
 // of the abstract interpreter and the abstract interpreter generator.
--- ./hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp	2011-05-26 17:32:19.000000000 -0700
+++ ./hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp	2011-04-23 12:09:38.000000000 -0700
@@ -65,6 +65,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
 
 
 // no precompiled headers
--- ./hotspot/src/share/vm/interpreter/bytecodeTracer.cpp	2011-05-26 17:32:21.000000000 -0700
+++ ./hotspot/src/share/vm/interpreter/bytecodeTracer.cpp	2011-05-27 00:00:43.000000000 -0700
@@ -92,7 +92,7 @@
       // the incoming method.  We could lose a line of trace output.
       // This is acceptable in a debug-only feature.
       st->cr();
-      st->print("[%d] ", (int) Thread::current()->osthread()->thread_id());
+      st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
       method->print_name(st);
       st->cr();
       _current_method = method();
@@ -106,7 +106,7 @@
     }
     _code = code;
      int bci = bcp - method->code_base();
-    st->print("[%d] ", (int) Thread::current()->osthread()->thread_id());
+    st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
     if (Verbose) {
       st->print("%8d  %4d  " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
            BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
--- ./hotspot/src/share/vm/interpreter/interpreterRuntime.hpp	2011-05-26 17:32:22.000000000 -0700
+++ ./hotspot/src/share/vm/interpreter/interpreterRuntime.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -41,6 +41,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // The InterpreterRuntime is called by the interpreter for everything
 // that cannot/should not be dealt with in assembly and needs C support.
--- ./hotspot/src/share/vm/interpreter/linkResolver.cpp	2011-05-26 17:32:23.000000000 -0700
+++ ./hotspot/src/share/vm/interpreter/linkResolver.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -52,6 +52,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //------------------------------------------------------------------------------------------------------------------------
 // Implementation of FieldAccessInfo
--- ./hotspot/src/share/vm/memory/allocation.cpp	2011-05-26 17:32:26.000000000 -0700
+++ ./hotspot/src/share/vm/memory/allocation.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 void* CHeapObj::operator new(size_t size){
   return (void *) AllocateHeap(size, "CHeapObj-new");
--- ./hotspot/src/share/vm/memory/collectorPolicy.cpp	2011-05-26 17:32:28.000000000 -0700
+++ ./hotspot/src/share/vm/memory/collectorPolicy.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
--- ./hotspot/src/share/vm/memory/defNewGeneration.cpp	2011-05-26 17:32:29.000000000 -0700
+++ ./hotspot/src/share/vm/memory/defNewGeneration.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -48,6 +48,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // DefNewGeneration functions.
--- ./hotspot/src/share/vm/memory/gcLocker.hpp	2011-05-26 17:32:30.000000000 -0700
+++ ./hotspot/src/share/vm/memory/gcLocker.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -41,6 +41,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 // The direct lock/unlock calls do not force a collection if an unlock
 // decrements the count to zero. Avoid calling these if at all possible.
--- ./hotspot/src/share/vm/memory/genMarkSweep.cpp	2011-05-26 17:32:31.000000000 -0700
+++ ./hotspot/src/share/vm/memory/genMarkSweep.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -55,6 +55,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 void GenMarkSweep::invoke_at_safepoint(int level, ReferenceProcessor* rp,
   bool clear_all_softrefs) {
--- ./hotspot/src/share/vm/memory/resourceArea.cpp	2011-05-26 17:32:34.000000000 -0700
+++ ./hotspot/src/share/vm/memory/resourceArea.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //------------------------------ResourceMark-----------------------------------
 debug_only(int ResourceArea::_warned;)      // to suppress multiple warnings
--- ./hotspot/src/share/vm/memory/resourceArea.hpp	2011-05-26 17:32:34.000000000 -0700
+++ ./hotspot/src/share/vm/memory/resourceArea.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // The resource area holds temporary data structures in the VM.
 // The actual allocation areas are thread local. Typical usage:
--- ./hotspot/src/share/vm/memory/space.hpp	2011-05-26 17:32:35.000000000 -0700
+++ ./hotspot/src/share/vm/memory/space.hpp	2011-04-22 22:28:36.000000000 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // A space is an abstraction for the "storage units" backing
 // up the generation abstraction. It includes specific
--- ./hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	2011-05-26 17:32:36.000000000 -0700
+++ ./hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -38,6 +38,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Thread-Local Edens support
 
--- ./hotspot/src/share/vm/memory/universe.cpp	2011-05-26 17:32:36.000000000 -0700
+++ ./hotspot/src/share/vm/memory/universe.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -89,6 +89,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp"
--- ./hotspot/src/share/vm/oops/constantPoolKlass.cpp	2011-05-26 17:32:40.000000000 -0700
+++ ./hotspot/src/share/vm/oops/constantPoolKlass.cpp	2011-05-20 20:03:59.000000000 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
--- ./hotspot/src/share/vm/oops/constantPoolOop.cpp	2011-05-26 17:32:40.000000000 -0700
+++ ./hotspot/src/share/vm/oops/constantPoolOop.cpp	2011-04-23 12:09:38.000000000 -0700
@@ -1332,7 +1332,7 @@
       }
       case JVM_CONSTANT_Long: {
         u8 val = Bytes::get_Java_u8(bytes);
-        printf("long         "INT64_FORMAT, *(jlong *) &val);
+        printf("long         "INT64_FORMAT, (int64_t) *(jlong *) &val);
         ent_size = 8;
         idx++; // Long takes two cpool slots
         break;
--- ./hotspot/src/share/vm/oops/instanceKlass.cpp	2011-05-26 17:32:41.000000000 -0700
+++ ./hotspot/src/share/vm/oops/instanceKlass.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -60,6 +60,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
--- ./hotspot/src/share/vm/oops/markOop.cpp	2011-05-26 17:32:44.000000000 -0700
+++ ./hotspot/src/share/vm/oops/markOop.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -33,6 +33,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 void markOopDesc::print_on(outputStream* st) const {
--- ./hotspot/src/share/vm/oops/oop.cpp	2011-05-26 17:32:47.000000000 -0700
+++ ./hotspot/src/share/vm/oops/oop.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 bool always_do_update_barrier = false;
 
--- ./hotspot/src/share/vm/oops/oopsHierarchy.cpp	2011-05-26 17:32:48.000000000 -0700
+++ ./hotspot/src/share/vm/oops/oopsHierarchy.cpp	2011-04-22 22:28:36.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifdef CHECK_UNHANDLED_OOPS
 
--- ./hotspot/src/share/vm/opto/c2_globals.hpp	2011-05-26 17:32:52.000000000 -0700
+++ ./hotspot/src/share/vm/opto/c2_globals.hpp	2011-05-12 20:54:44.000000000 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c2_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c2_globals_bsd.hpp"
+#endif
 
 //
 // Defines all globals flags used by the server compiler.
--- ./hotspot/src/share/vm/prims/forte.cpp	2011-05-26 17:33:09.000000000 -0700
+++ ./hotspot/src/share/vm/prims/forte.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -640,6 +640,11 @@
 // Method to let libcollector know about a dynamically loaded function.
 // Because it is weakly bound, the calls become NOP's when the library
 // isn't present.
+#ifdef __APPLE__
+// XXXDARWIN: Link errors occur even when __attribute__((weak_import))
+// is added
+#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) (0)
+#else
 void    collector_func_load(char* name,
                             void* null_argument_1,
                             void* null_argument_2,
@@ -650,6 +655,7 @@
 #pragma weak collector_func_load
 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
         ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
+#endif // __APPLE__
 #endif // !_WINDOWS
 
 } // end extern "C"
--- ./hotspot/src/share/vm/prims/jni.cpp	2011-05-26 17:33:09.000000000 -0700
+++ ./hotspot/src/share/vm/prims/jni.cpp	2011-05-07 21:53:42.000000000 -0700
@@ -91,6 +91,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 static jint CurrentVersion = JNI_VERSION_1_6;
 
--- ./hotspot/src/share/vm/prims/jvm.cpp	2011-05-26 17:33:10.000000000 -0700
+++ ./hotspot/src/share/vm/prims/jvm.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -72,6 +72,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "jvm_windows.h"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 
 #include <errno.h>
 
--- ./hotspot/src/share/vm/prims/jvm.h	2011-05-26 17:33:10.000000000 -0700
+++ ./hotspot/src/share/vm/prims/jvm.h	2011-04-23 12:09:39.000000000 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "jvm_windows.h"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 
 #ifndef _JAVASOFT_JVM_H_
 #define _JAVASOFT_JVM_H_
--- ./hotspot/src/share/vm/prims/jvmtiEnv.cpp	2011-05-26 17:33:12.000000000 -0700
+++ ./hotspot/src/share/vm/prims/jvmtiEnv.cpp	2011-05-07 21:53:42.000000000 -0700
@@ -68,6 +68,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 
--- ./hotspot/src/share/vm/prims/jvmtiImpl.cpp	2011-05-26 17:33:15.000000000 -0700
+++ ./hotspot/src/share/vm/prims/jvmtiImpl.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -54,6 +54,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // class JvmtiAgentThread
--- ./hotspot/src/share/vm/prims/nativeLookup.cpp	2011-05-26 17:33:19.000000000 -0700
+++ ./hotspot/src/share/vm/prims/nativeLookup.cpp	2011-04-23 12:09:39.000000000 -0700
@@ -49,6 +49,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 static void mangle_name_on(outputStream* st, Symbol* name, int begin, int end) {
--- ./hotspot/src/share/vm/runtime/arguments.cpp	2011-05-26 17:33:21.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/arguments.cpp	2011-05-12 20:54:44.000000000 -0700
@@ -55,6 +55,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
 #endif
--- ./hotspot/src/share/vm/runtime/atomic.cpp	2011-05-26 17:33:21.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/atomic.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -33,6 +33,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "atomic_linux_x86.inline.hpp"
 #endif
@@ -51,6 +54,12 @@
 #ifdef TARGET_OS_ARCH_windows_x86
 # include "atomic_windows_x86.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "atomic_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "atomic_bsd_zero.inline.hpp"
+#endif
 
 jbyte Atomic::cmpxchg(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) {
   assert(sizeof(jbyte) == 1, "assumption.");
--- ./hotspot/src/share/vm/runtime/fprofiler.hpp	2011-05-26 17:33:24.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/fprofiler.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // a simple flat profiler for Java
 
--- ./hotspot/src/share/vm/runtime/globals.hpp	2011-05-26 17:33:25.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/globals.hpp	2011-05-27 00:00:44.000000000 -0700
@@ -50,6 +50,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "globals_bsd.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "globals_linux_x86.hpp"
 #endif
@@ -74,6 +77,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "globals_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "globals_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "globals_bsd_zero.hpp"
+#endif
 #ifdef COMPILER1
 #ifdef TARGET_ARCH_x86
 # include "c1_globals_x86.hpp"
@@ -96,6 +105,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c1_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c1_globals_bsd.hpp"
+#endif
 #endif
 #ifdef COMPILER2
 #ifdef TARGET_ARCH_x86
@@ -116,6 +128,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c2_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c2_globals_bsd.hpp"
+#endif
 #endif
 #ifdef SHARK
 #ifdef TARGET_ARCH_zero
--- ./hotspot/src/share/vm/runtime/handles.cpp	2011-05-26 17:33:25.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/handles.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -38,6 +38,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifdef ASSERT
 oop* HandleArea::allocate_handle(oop obj) {
--- ./hotspot/src/share/vm/runtime/handles.inline.hpp	2011-05-26 17:33:25.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/handles.inline.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // these inline functions are in a separate file to break an include cycle
 // between Thread and Handle
--- ./hotspot/src/share/vm/runtime/interfaceSupport.hpp	2011-05-26 17:33:26.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/interfaceSupport.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Wrapper for all entry points to the virtual machine.
 // The HandleMarkCleaner is a faster version of HandleMark.
@@ -115,6 +118,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "interfaceSupport_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "interfaceSupport_bsd.hpp"
+#endif
 
 };
 
--- ./hotspot/src/share/vm/runtime/java.cpp	2011-05-26 17:33:26.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/java.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -85,6 +85,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
--- ./hotspot/src/share/vm/runtime/javaCalls.cpp	2011-05-26 17:33:27.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/javaCalls.cpp	2011-05-07 21:53:42.000000000 -0700
@@ -48,6 +48,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // -----------------------------------------------------
 // Implementation of JavaCallWrapper
--- ./hotspot/src/share/vm/runtime/javaCalls.hpp	2011-05-26 17:33:27.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/javaCalls.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -54,6 +54,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // A JavaCallWrapper is constructed before each JavaCall and destructed after the call.
 // Its purpose is to allocate/deallocate a new handle block and to save/restore the last
--- ./hotspot/src/share/vm/runtime/javaFrameAnchor.hpp	2011-05-26 17:33:27.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/javaFrameAnchor.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -50,6 +50,13 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
+
 //
 // An object for encapsulating the machine/os dependent part of a JavaThread frame state
 //
--- ./hotspot/src/share/vm/runtime/jniHandles.cpp	2011-05-26 17:33:27.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/jniHandles.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 JNIHandleBlock* JNIHandles::_global_handles       = NULL;
--- ./hotspot/src/share/vm/runtime/memprofiler.cpp	2011-05-26 17:33:28.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/memprofiler.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -46,6 +46,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifndef PRODUCT
 
--- ./hotspot/src/share/vm/runtime/mutex.cpp	2011-05-26 17:33:28.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/mutex.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -39,6 +39,10 @@
 # include "mutex_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "mutex_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 // o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
 //
--- ./hotspot/src/share/vm/runtime/mutexLocker.cpp	2011-05-26 17:33:28.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/mutexLocker.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Mutexes used in the VM (see comment in mutexLocker.hpp):
 //
--- ./hotspot/src/share/vm/runtime/mutexLocker.hpp	2011-05-26 17:33:29.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/mutexLocker.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // Mutexes used in the VM.
 
--- ./hotspot/src/share/vm/runtime/objectMonitor.cpp	2011-05-26 17:33:29.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/objectMonitor.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -50,6 +50,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #if defined(__GNUC__) && !defined(IA64)
   // Need to inhibit inlining for older versions of GCC to avoid build-time failures
--- ./hotspot/src/share/vm/runtime/os.cpp	2011-05-26 17:33:29.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/os.cpp	2011-04-23 12:09:39.000000000 -0700
@@ -60,6 +60,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 # include <signal.h>
 
@@ -116,7 +120,11 @@
     assert(false, "Failed localtime_pd");
     return NULL;
   }
+#if defined(_ALLBSD_SOURCE)
+  const time_t zone = (time_t) time_struct.tm_gmtoff;
+#else
   const time_t zone = timezone;
+#endif
 
   // If daylight savings time is in effect,
   // we are 1 hour East of our time zone
@@ -384,6 +392,13 @@
     if (_native_java_library == NULL) {
       vm_exit_during_initialization("Unable to load native library", ebuf);
     }
+
+#if defined(__OpenBSD__)
+    // Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so
+    // ignore errors
+    dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "net");
+    dll_load(buffer, ebuf, sizeof(ebuf));
+#endif
   }
   static jboolean onLoaded = JNI_FALSE;
   if (onLoaded) {
--- ./hotspot/src/share/vm/runtime/os.hpp	2011-05-26 17:33:29.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/os.hpp	2011-05-12 20:54:45.000000000 -0700
@@ -30,6 +30,9 @@
 #include "runtime/extendedPC.hpp"
 #include "runtime/handles.hpp"
 #include "utilities/top.hpp"
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 #ifdef TARGET_OS_FAMILY_linux
 # include "jvm_linux.h"
 #endif
@@ -39,6 +42,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "jvm_windows.h"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 
 // os defines the interface to operating system; this includes traditional
 // OS services (time, I/O) as well as other functionality with system-
@@ -672,6 +678,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "os_linux_x86.hpp"
 #endif
@@ -696,6 +705,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "os_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "os_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "os_bsd_zero.hpp"
+#endif
 
 
   // debugging support (mostly used by debug.cpp but also fatal error handler)
--- ./hotspot/src/share/vm/runtime/osThread.hpp	2011-05-26 17:33:30.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/osThread.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -109,6 +109,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "osThread_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "osThread_bsd.hpp"
+#endif
 
 };
 
--- ./hotspot/src/share/vm/runtime/safepoint.cpp	2011-05-26 17:33:33.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/safepoint.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -78,6 +78,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
 #include "gc_implementation/shared/concurrentGCThread.hpp"
--- ./hotspot/src/share/vm/runtime/synchronizer.cpp	2011-05-26 17:33:37.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/synchronizer.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -51,6 +51,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #if defined(__GNUC__) && !defined(IA64)
   // Need to inhibit inlining for older versions of GCC to avoid build-time failures
--- ./hotspot/src/share/vm/runtime/task.cpp	2011-05-26 17:33:37.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/task.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -39,6 +39,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 int PeriodicTask::_num_tasks = 0;
 PeriodicTask* PeriodicTask::_tasks[PeriodicTask::max_tasks];
--- ./hotspot/src/share/vm/runtime/thread.cpp	2011-05-26 17:33:37.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/thread.cpp	2011-05-27 00:00:44.000000000 -0700
@@ -89,6 +89,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
--- ./hotspot/src/share/vm/runtime/thread.hpp	2011-05-26 17:33:37.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/thread.hpp	2011-05-27 00:00:44.000000000 -0700
@@ -1610,6 +1610,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "thread_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "thread_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "thread_bsd_zero.hpp"
+#endif
 
 
  public:
--- ./hotspot/src/share/vm/runtime/threadLocalStorage.cpp	2011-05-26 17:33:38.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/threadLocalStorage.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -36,6 +36,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 // static member initialization
 int ThreadLocalStorage::_thread_index = -1;
--- ./hotspot/src/share/vm/runtime/threadLocalStorage.hpp	2011-05-26 17:33:38.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/threadLocalStorage.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -68,6 +68,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "threadLS_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "threadLS_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "threadLS_bsd_zero.hpp"
+#endif
 
 
  public:
--- ./hotspot/src/share/vm/runtime/timer.cpp	2011-05-26 17:33:38.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/timer.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 void elapsedTimer::add(elapsedTimer t) {
--- ./hotspot/src/share/vm/runtime/virtualspace.cpp	2011-05-26 17:33:39.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/virtualspace.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 // ReservedSpace
--- ./hotspot/src/share/vm/runtime/vmStructs.cpp	2011-05-26 17:33:40.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/vmStructs.cpp	2011-05-27 00:00:44.000000000 -0700
@@ -125,6 +125,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "vmStructs_linux_x86.hpp"
 #endif
@@ -149,6 +152,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "vmStructs_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "vmStructs_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "vmStructs_bsd_zero.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/cmsPermGen.hpp"
 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
--- ./hotspot/src/share/vm/runtime/vmThread.cpp	2011-05-26 17:33:40.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/vmThread.cpp	2011-05-07 21:53:42.000000000 -0700
@@ -46,6 +46,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 HS_DTRACE_PROBE_DECL3(hotspot, vmops__request, char *, uintptr_t, int);
 HS_DTRACE_PROBE_DECL3(hotspot, vmops__begin, char *, uintptr_t, int);
--- ./hotspot/src/share/vm/runtime/vmThread.hpp	2011-05-26 17:33:40.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/vmThread.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // Prioritized queue of VM operations.
--- ./hotspot/src/share/vm/runtime/vm_operations.cpp	2011-05-26 17:33:40.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/vm_operations.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -45,6 +45,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #define VM_OP_NAME_INITIALIZE(name) #name,
 
--- ./hotspot/src/share/vm/runtime/vm_version.cpp	2011-05-26 17:33:41.000000000 -0700
+++ ./hotspot/src/share/vm/runtime/vm_version.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -166,7 +166,8 @@
 
 #define OS       LINUX_ONLY("linux")             \
                  WINDOWS_ONLY("windows")         \
-                 SOLARIS_ONLY("solaris")
+                 SOLARIS_ONLY("solaris")         \
+                 BSD_ONLY("bsd")
 
 #ifdef ZERO
 #define CPU      ZERO_LIBARCH
--- ./hotspot/src/share/vm/utilities/accessFlags.cpp	2011-05-26 17:33:55.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/accessFlags.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -34,6 +34,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 void AccessFlags::atomic_set_bits(jint bits) {
--- ./hotspot/src/share/vm/utilities/array.cpp	2011-05-26 17:33:55.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/array.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -34,6 +34,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 #ifdef ASSERT
--- ./hotspot/src/share/vm/utilities/bitMap.cpp	2011-05-26 17:33:56.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/bitMap.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 BitMap::BitMap(bm_word_t* map, idx_t size_in_bits) :
--- ./hotspot/src/share/vm/utilities/debug.cpp	2011-05-26 17:33:57.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/debug.cpp	2011-05-12 20:54:45.000000000 -0700
@@ -62,6 +62,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifndef ASSERT
 #  ifdef _DEBUG
--- ./hotspot/src/share/vm/utilities/elf.hpp	1969-12-31 16:00:00.000000000 -0800
+++ ./hotspot/src/share/vm/utilities/elf.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -0,0 +1,2605 @@
+/* This file defines standard ELF types, structures, and macros.
+   Copyright (C) 1995-2003,2004,2005,2006 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef __ELF_HPP
+#define	__ELF_HPP 1
+
+__BEGIN_DECLS
+
+/* Standard ELF types.  */
+
+#include <stdint.h>
+
+/* Type for a 16-bit quantity.  */
+typedef uint16_t Elf32_Half;
+typedef uint16_t Elf64_Half;
+
+/* Types for signed and unsigned 32-bit quantities.  */
+typedef uint32_t Elf32_Word;
+typedef	int32_t  Elf32_Sword;
+typedef uint32_t Elf64_Word;
+typedef	int32_t  Elf64_Sword;
+
+/* Types for signed and unsigned 64-bit quantities.  */
+typedef uint64_t Elf32_Xword;
+typedef	int64_t  Elf32_Sxword;
+typedef uint64_t Elf64_Xword;
+typedef	int64_t  Elf64_Sxword;
+
+/* Type of addresses.  */
+typedef uint32_t Elf32_Addr;
+typedef uint64_t Elf64_Addr;
+
+/* Type of file offsets.  */
+typedef uint32_t Elf32_Off;
+typedef uint64_t Elf64_Off;
+
+/* Type for section indices, which are 16-bit quantities.  */
+typedef uint16_t Elf32_Section;
+typedef uint16_t Elf64_Section;
+
+/* Type for version symbol information.  */
+typedef Elf32_Half Elf32_Versym;
+typedef Elf64_Half Elf64_Versym;
+
+
+/* The ELF file header.  This appears at the start of every ELF file.  */
+
+#define EI_NIDENT (16)
+
+typedef struct
+{
+  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
+  Elf32_Half	e_type;			/* Object file type */
+  Elf32_Half	e_machine;		/* Architecture */
+  Elf32_Word	e_version;		/* Object file version */
+  Elf32_Addr	e_entry;		/* Entry point virtual address */
+  Elf32_Off	e_phoff;		/* Program header table file offset */
+  Elf32_Off	e_shoff;		/* Section header table file offset */
+  Elf32_Word	e_flags;		/* Processor-specific flags */
+  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
+  Elf32_Half	e_phentsize;		/* Program header table entry size */
+  Elf32_Half	e_phnum;		/* Program header table entry count */
+  Elf32_Half	e_shentsize;		/* Section header table entry size */
+  Elf32_Half	e_shnum;		/* Section header table entry count */
+  Elf32_Half	e_shstrndx;		/* Section header string table index */
+} Elf32_Ehdr;
+
+typedef struct
+{
+  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
+  Elf64_Half	e_type;			/* Object file type */
+  Elf64_Half	e_machine;		/* Architecture */
+  Elf64_Word	e_version;		/* Object file version */
+  Elf64_Addr	e_entry;		/* Entry point virtual address */
+  Elf64_Off	e_phoff;		/* Program header table file offset */
+  Elf64_Off	e_shoff;		/* Section header table file offset */
+  Elf64_Word	e_flags;		/* Processor-specific flags */
+  Elf64_Half	e_ehsize;		/* ELF header size in bytes */
+  Elf64_Half	e_phentsize;		/* Program header table entry size */
+  Elf64_Half	e_phnum;		/* Program header table entry count */
+  Elf64_Half	e_shentsize;		/* Section header table entry size */
+  Elf64_Half	e_shnum;		/* Section header table entry count */
+  Elf64_Half	e_shstrndx;		/* Section header string table index */
+} Elf64_Ehdr;
+
+/* Fields in the e_ident array.  The EI_* macros are indices into the
+   array.  The macros under each EI_* macro are the values the byte
+   may have.  */
+
+#define EI_MAG0		0		/* File identification byte 0 index */
+#define ELFMAG0		0x7f		/* Magic number byte 0 */
+
+#define EI_MAG1		1		/* File identification byte 1 index */
+#define ELFMAG1		'E'		/* Magic number byte 1 */
+
+#define EI_MAG2		2		/* File identification byte 2 index */
+#define ELFMAG2		'L'		/* Magic number byte 2 */
+
+#define EI_MAG3		3		/* File identification byte 3 index */
+#define ELFMAG3		'F'		/* Magic number byte 3 */
+
+/* Conglomeration of the identification bytes, for easy testing as a word.  */
+#define	ELFMAG		"\177ELF"
+#define	SELFMAG		4
+
+#define EI_CLASS	4		/* File class byte index */
+#define ELFCLASSNONE	0		/* Invalid class */
+#define ELFCLASS32	1		/* 32-bit objects */
+#define ELFCLASS64	2		/* 64-bit objects */
+#define ELFCLASSNUM	3
+
+#define EI_DATA		5		/* Data encoding byte index */
+#define ELFDATANONE	0		/* Invalid data encoding */
+#define ELFDATA2LSB	1		/* 2's complement, little endian */
+#define ELFDATA2MSB	2		/* 2's complement, big endian */
+#define ELFDATANUM	3
+
+#define EI_VERSION	6		/* File version byte index */
+					/* Value must be EV_CURRENT */
+
+#define EI_OSABI	7		/* OS ABI identification */
+#define ELFOSABI_NONE		0	/* UNIX System V ABI */
+#define ELFOSABI_SYSV		0	/* Alias.  */
+#define ELFOSABI_HPUX		1	/* HP-UX */
+#define ELFOSABI_NETBSD		2	/* NetBSD.  */
+#define ELFOSABI_LINUX		3	/* Linux.  */
+#define ELFOSABI_SOLARIS	6	/* Sun Solaris.  */
+#define ELFOSABI_AIX		7	/* IBM AIX.  */
+#define ELFOSABI_IRIX		8	/* SGI Irix.  */
+#define ELFOSABI_FREEBSD	9	/* FreeBSD.  */
+#define ELFOSABI_TRU64		10	/* Compaq TRU64 UNIX.  */
+#define ELFOSABI_MODESTO	11	/* Novell Modesto.  */
+#define ELFOSABI_OPENBSD	12	/* OpenBSD.  */
+#define ELFOSABI_ARM		97	/* ARM */
+#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
+
+#define EI_ABIVERSION	8		/* ABI version */
+
+#define EI_PAD		9		/* Byte index of padding bytes */
+
+/* Legal values for e_type (object file type).  */
+
+#define ET_NONE		0		/* No file type */
+#define ET_REL		1		/* Relocatable file */
+#define ET_EXEC		2		/* Executable file */
+#define ET_DYN		3		/* Shared object file */
+#define ET_CORE		4		/* Core file */
+#define	ET_NUM		5		/* Number of defined types */
+#define ET_LOOS		0xfe00		/* OS-specific range start */
+#define ET_HIOS		0xfeff		/* OS-specific range end */
+#define ET_LOPROC	0xff00		/* Processor-specific range start */
+#define ET_HIPROC	0xffff		/* Processor-specific range end */
+
+/* Legal values for e_machine (architecture).  */
+
+#define EM_NONE		 0		/* No machine */
+#define EM_M32		 1		/* AT&T WE 32100 */
+#define EM_SPARC	 2		/* SUN SPARC */
+#define EM_386		 3		/* Intel 80386 */
+#define EM_68K		 4		/* Motorola m68k family */
+#define EM_88K		 5		/* Motorola m88k family */
+#define EM_860		 7		/* Intel 80860 */
+#define EM_MIPS		 8		/* MIPS R3000 big-endian */
+#define EM_S370		 9		/* IBM System/370 */
+#define EM_MIPS_RS3_LE	10		/* MIPS R3000 little-endian */
+
+#define EM_PARISC	15		/* HPPA */
+#define EM_VPP500	17		/* Fujitsu VPP500 */
+#define EM_SPARC32PLUS	18		/* Sun's "v8plus" */
+#define EM_960		19		/* Intel 80960 */
+#define EM_PPC		20		/* PowerPC */
+#define EM_PPC64	21		/* PowerPC 64-bit */
+#define EM_S390		22		/* IBM S390 */
+
+#define EM_V800		36		/* NEC V800 series */
+#define EM_FR20		37		/* Fujitsu FR20 */
+#define EM_RH32		38		/* TRW RH-32 */
+#define EM_RCE		39		/* Motorola RCE */
+#define EM_ARM		40		/* ARM */
+#define EM_FAKE_ALPHA	41		/* Digital Alpha */
+#define EM_SH		42		/* Hitachi SH */
+#define EM_SPARCV9	43		/* SPARC v9 64-bit */
+#define EM_TRICORE	44		/* Siemens Tricore */
+#define EM_ARC		45		/* Argonaut RISC Core */
+#define EM_H8_300	46		/* Hitachi H8/300 */
+#define EM_H8_300H	47		/* Hitachi H8/300H */
+#define EM_H8S		48		/* Hitachi H8S */
+#define EM_H8_500	49		/* Hitachi H8/500 */
+#define EM_IA_64	50		/* Intel Merced */
+#define EM_MIPS_X	51		/* Stanford MIPS-X */
+#define EM_COLDFIRE	52		/* Motorola Coldfire */
+#define EM_68HC12	53		/* Motorola M68HC12 */
+#define EM_MMA		54		/* Fujitsu MMA Multimedia Accelerator*/
+#define EM_PCP		55		/* Siemens PCP */
+#define EM_NCPU		56		/* Sony nCPU embeeded RISC */
+#define EM_NDR1		57		/* Denso NDR1 microprocessor */
+#define EM_STARCORE	58		/* Motorola Start*Core processor */
+#define EM_ME16		59		/* Toyota ME16 processor */
+#define EM_ST100	60		/* STMicroelectronic ST100 processor */
+#define EM_TINYJ	61		/* Advanced Logic Corp. Tinyj emb.fam*/
+#define EM_X86_64	62		/* AMD x86-64 architecture */
+#define EM_PDSP		63		/* Sony DSP Processor */
+
+#define EM_FX66		66		/* Siemens FX66 microcontroller */
+#define EM_ST9PLUS	67		/* STMicroelectronics ST9+ 8/16 mc */
+#define EM_ST7		68		/* STmicroelectronics ST7 8 bit mc */
+#define EM_68HC16	69		/* Motorola MC68HC16 microcontroller */
+#define EM_68HC11	70		/* Motorola MC68HC11 microcontroller */
+#define EM_68HC08	71		/* Motorola MC68HC08 microcontroller */
+#define EM_68HC05	72		/* Motorola MC68HC05 microcontroller */
+#define EM_SVX		73		/* Silicon Graphics SVx */
+#define EM_ST19		74		/* STMicroelectronics ST19 8 bit mc */
+#define EM_VAX		75		/* Digital VAX */
+#define EM_CRIS		76		/* Axis Communications 32-bit embedded processor */
+#define EM_JAVELIN	77		/* Infineon Technologies 32-bit embedded processor */
+#define EM_FIREPATH	78		/* Element 14 64-bit DSP Processor */
+#define EM_ZSP		79		/* LSI Logic 16-bit DSP Processor */
+#define EM_MMIX		80		/* Donald Knuth's educational 64-bit processor */
+#define EM_HUANY	81		/* Harvard University machine-independent object files */
+#define EM_PRISM	82		/* SiTera Prism */
+#define EM_AVR		83		/* Atmel AVR 8-bit microcontroller */
+#define EM_FR30		84		/* Fujitsu FR30 */
+#define EM_D10V		85		/* Mitsubishi D10V */
+#define EM_D30V		86		/* Mitsubishi D30V */
+#define EM_V850		87		/* NEC v850 */
+#define EM_M32R		88		/* Mitsubishi M32R */
+#define EM_MN10300	89		/* Matsushita MN10300 */
+#define EM_MN10200	90		/* Matsushita MN10200 */
+#define EM_PJ		91		/* picoJava */
+#define EM_OPENRISC	92		/* OpenRISC 32-bit embedded processor */
+#define EM_ARC_A5	93		/* ARC Cores Tangent-A5 */
+#define EM_XTENSA	94		/* Tensilica Xtensa Architecture */
+#define EM_NUM		95
+
+/* If it is necessary to assign new unofficial EM_* values, please
+   pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
+   chances of collision with official or non-GNU unofficial values.  */
+
+#define EM_ALPHA	0x9026
+
+/* Legal values for e_version (version).  */
+
+#define EV_NONE		0		/* Invalid ELF version */
+#define EV_CURRENT	1		/* Current version */
+#define EV_NUM		2
+
+/* Section header.  */
+
+typedef struct
+{
+  Elf32_Word	sh_name;		/* Section name (string tbl index) */
+  Elf32_Word	sh_type;		/* Section type */
+  Elf32_Word	sh_flags;		/* Section flags */
+  Elf32_Addr	sh_addr;		/* Section virtual addr at execution */
+  Elf32_Off	sh_offset;		/* Section file offset */
+  Elf32_Word	sh_size;		/* Section size in bytes */
+  Elf32_Word	sh_link;		/* Link to another section */
+  Elf32_Word	sh_info;		/* Additional section information */
+  Elf32_Word	sh_addralign;		/* Section alignment */
+  Elf32_Word	sh_entsize;		/* Entry size if section holds table */
+} Elf32_Shdr;
+
+typedef struct
+{
+  Elf64_Word	sh_name;		/* Section name (string tbl index) */
+  Elf64_Word	sh_type;		/* Section type */
+  Elf64_Xword	sh_flags;		/* Section flags */
+  Elf64_Addr	sh_addr;		/* Section virtual addr at execution */
+  Elf64_Off	sh_offset;		/* Section file offset */
+  Elf64_Xword	sh_size;		/* Section size in bytes */
+  Elf64_Word	sh_link;		/* Link to another section */
+  Elf64_Word	sh_info;		/* Additional section information */
+  Elf64_Xword	sh_addralign;		/* Section alignment */
+  Elf64_Xword	sh_entsize;		/* Entry size if section holds table */
+} Elf64_Shdr;
+
+/* Special section indices.  */
+
+#define SHN_UNDEF	0		/* Undefined section */
+#define SHN_LORESERVE	0xff00		/* Start of reserved indices */
+#define SHN_LOPROC	0xff00		/* Start of processor-specific */
+#define SHN_BEFORE	0xff00		/* Order section before all others
+					   (Solaris).  */
+#define SHN_AFTER	0xff01		/* Order section after all others
+					   (Solaris).  */
+#define SHN_HIPROC	0xff1f		/* End of processor-specific */
+#define SHN_LOOS	0xff20		/* Start of OS-specific */
+#define SHN_HIOS	0xff3f		/* End of OS-specific */
+#define SHN_ABS		0xfff1		/* Associated symbol is absolute */
+#define SHN_COMMON	0xfff2		/* Associated symbol is common */
+#define SHN_XINDEX	0xffff		/* Index is in extra table.  */
+#define SHN_HIRESERVE	0xffff		/* End of reserved indices */
+
+/* Legal values for sh_type (section type).  */
+
+#define SHT_NULL	  0		/* Section header table entry unused */
+#define SHT_PROGBITS	  1		/* Program data */
+#define SHT_SYMTAB	  2		/* Symbol table */
+#define SHT_STRTAB	  3		/* String table */
+#define SHT_RELA	  4		/* Relocation entries with addends */
+#define SHT_HASH	  5		/* Symbol hash table */
+#define SHT_DYNAMIC	  6		/* Dynamic linking information */
+#define SHT_NOTE	  7		/* Notes */
+#define SHT_NOBITS	  8		/* Program space with no data (bss) */
+#define SHT_REL		  9		/* Relocation entries, no addends */
+#define SHT_SHLIB	  10		/* Reserved */
+#define SHT_DYNSYM	  11		/* Dynamic linker symbol table */
+#define SHT_INIT_ARRAY	  14		/* Array of constructors */
+#define SHT_FINI_ARRAY	  15		/* Array of destructors */
+#define SHT_PREINIT_ARRAY 16		/* Array of pre-constructors */
+#define SHT_GROUP	  17		/* Section group */
+#define SHT_SYMTAB_SHNDX  18		/* Extended section indeces */
+#define	SHT_NUM		  19		/* Number of defined types.  */
+#define SHT_LOOS	  0x60000000	/* Start OS-specific.  */
+#define SHT_GNU_HASH	  0x6ffffff6	/* GNU-style hash table.  */
+#define SHT_GNU_LIBLIST	  0x6ffffff7	/* Prelink library list */
+#define SHT_CHECKSUM	  0x6ffffff8	/* Checksum for DSO content.  */
+#define SHT_LOSUNW	  0x6ffffffa	/* Sun-specific low bound.  */
+#define SHT_SUNW_move	  0x6ffffffa
+#define SHT_SUNW_COMDAT   0x6ffffffb
+#define SHT_SUNW_syminfo  0x6ffffffc
+#define SHT_GNU_verdef	  0x6ffffffd	/* Version definition section.  */
+#define SHT_GNU_verneed	  0x6ffffffe	/* Version needs section.  */
+#define SHT_GNU_versym	  0x6fffffff	/* Version symbol table.  */
+#define SHT_HISUNW	  0x6fffffff	/* Sun-specific high bound.  */
+#define SHT_HIOS	  0x6fffffff	/* End OS-specific type */
+#define SHT_LOPROC	  0x70000000	/* Start of processor-specific */
+#define SHT_HIPROC	  0x7fffffff	/* End of processor-specific */
+#define SHT_LOUSER	  0x80000000	/* Start of application-specific */
+#define SHT_HIUSER	  0x8fffffff	/* End of application-specific */
+
+/* Legal values for sh_flags (section flags).  */
+
+#define SHF_WRITE	     (1 << 0)	/* Writable */
+#define SHF_ALLOC	     (1 << 1)	/* Occupies memory during execution */
+#define SHF_EXECINSTR	     (1 << 2)	/* Executable */
+#define SHF_MERGE	     (1 << 4)	/* Might be merged */
+#define SHF_STRINGS	     (1 << 5)	/* Contains nul-terminated strings */
+#define SHF_INFO_LINK	     (1 << 6)	/* `sh_info' contains SHT index */
+#define SHF_LINK_ORDER	     (1 << 7)	/* Preserve order after combining */
+#define SHF_OS_NONCONFORMING (1 << 8)	/* Non-standard OS specific handling
+					   required */
+#define SHF_GROUP	     (1 << 9)	/* Section is member of a group.  */
+#define SHF_TLS		     (1 << 10)	/* Section hold thread-local data.  */
+#define SHF_MASKOS	     0x0ff00000	/* OS-specific.  */
+#define SHF_MASKPROC	     0xf0000000	/* Processor-specific */
+#define SHF_ORDERED	     (1 << 30)	/* Special ordering requirement
+					   (Solaris).  */
+#define SHF_EXCLUDE	     (1 << 31)	/* Section is excluded unless
+					   referenced or allocated (Solaris).*/
+
+/* Section group handling.  */
+#define GRP_COMDAT	0x1		/* Mark group as COMDAT.  */
+
+/* Symbol table entry.  */
+
+typedef struct
+{
+  Elf32_Word	st_name;		/* Symbol name (string tbl index) */
+  Elf32_Addr	st_value;		/* Symbol value */
+  Elf32_Word	st_size;		/* Symbol size */
+  unsigned char	st_info;		/* Symbol type and binding */
+  unsigned char	st_other;		/* Symbol visibility */
+  Elf32_Section	st_shndx;		/* Section index */
+} Elf32_Sym;
+
+typedef struct
+{
+  Elf64_Word	st_name;		/* Symbol name (string tbl index) */
+  unsigned char	st_info;		/* Symbol type and binding */
+  unsigned char st_other;		/* Symbol visibility */
+  Elf64_Section	st_shndx;		/* Section index */
+  Elf64_Addr	st_value;		/* Symbol value */
+  Elf64_Xword	st_size;		/* Symbol size */
+} Elf64_Sym;
+
+/* The syminfo section if available contains additional information about
+   every dynamic symbol.  */
+
+typedef struct
+{
+  Elf32_Half si_boundto;		/* Direct bindings, symbol bound to */
+  Elf32_Half si_flags;			/* Per symbol flags */
+} Elf32_Syminfo;
+
+typedef struct
+{
+  Elf64_Half si_boundto;		/* Direct bindings, symbol bound to */
+  Elf64_Half si_flags;			/* Per symbol flags */
+} Elf64_Syminfo;
+
+/* Possible values for si_boundto.  */
+#define SYMINFO_BT_SELF		0xffff	/* Symbol bound to self */
+#define SYMINFO_BT_PARENT	0xfffe	/* Symbol bound to parent */
+#define SYMINFO_BT_LOWRESERVE	0xff00	/* Beginning of reserved entries */
+
+/* Possible bitmasks for si_flags.  */
+#define SYMINFO_FLG_DIRECT	0x0001	/* Direct bound symbol */
+#define SYMINFO_FLG_PASSTHRU	0x0002	/* Pass-thru symbol for translator */
+#define SYMINFO_FLG_COPY	0x0004	/* Symbol is a copy-reloc */
+#define SYMINFO_FLG_LAZYLOAD	0x0008	/* Symbol bound to object to be lazy
+					   loaded */
+/* Syminfo version values.  */
+#define SYMINFO_NONE		0
+#define SYMINFO_CURRENT		1
+#define SYMINFO_NUM		2
+
+
+/* How to extract and insert information held in the st_info field.  */
+
+#define ELF32_ST_BIND(val)		(((unsigned char) (val)) >> 4)
+#define ELF32_ST_TYPE(val)		((val) & 0xf)
+#define ELF32_ST_INFO(bind, type)	(((bind) << 4) + ((type) & 0xf))
+
+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
+#define ELF64_ST_BIND(val)		ELF32_ST_BIND (val)
+#define ELF64_ST_TYPE(val)		ELF32_ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type)	ELF32_ST_INFO ((bind), (type))
+
+/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
+
+#define STB_LOCAL	0		/* Local symbol */
+#define STB_GLOBAL	1		/* Global symbol */
+#define STB_WEAK	2		/* Weak symbol */
+#define	STB_NUM		3		/* Number of defined types.  */
+#define STB_LOOS	10		/* Start of OS-specific */
+#define STB_HIOS	12		/* End of OS-specific */
+#define STB_LOPROC	13		/* Start of processor-specific */
+#define STB_HIPROC	15		/* End of processor-specific */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
+
+#define STT_NOTYPE	0		/* Symbol type is unspecified */
+#define STT_OBJECT	1		/* Symbol is a data object */
+#define STT_FUNC	2		/* Symbol is a code object */
+#define STT_SECTION	3		/* Symbol associated with a section */
+#define STT_FILE	4		/* Symbol's name is file name */
+#define STT_COMMON	5		/* Symbol is a common data object */
+#define STT_TLS		6		/* Symbol is thread-local data object*/
+#define	STT_NUM		7		/* Number of defined types.  */
+#define STT_LOOS	10		/* Start of OS-specific */
+#define STT_HIOS	12		/* End of OS-specific */
+#define STT_LOPROC	13		/* Start of processor-specific */
+#define STT_HIPROC	15		/* End of processor-specific */
+
+
+/* Symbol table indices are found in the hash buckets and chain table
+   of a symbol hash table section.  This special index value indicates
+   the end of a chain, meaning no further symbols are found in that bucket.  */
+
+#define STN_UNDEF	0		/* End of a chain.  */
+
+
+/* How to extract and insert information held in the st_other field.  */
+
+#define ELF32_ST_VISIBILITY(o)	((o) & 0x03)
+
+/* For ELF64 the definitions are the same.  */
+#define ELF64_ST_VISIBILITY(o)	ELF32_ST_VISIBILITY (o)
+
+/* Symbol visibility specification encoded in the st_other field.  */
+#define STV_DEFAULT	0		/* Default symbol visibility rules */
+#define STV_INTERNAL	1		/* Processor specific hidden class */
+#define STV_HIDDEN	2		/* Sym unavailable in other modules */
+#define STV_PROTECTED	3		/* Not preemptible, not exported */
+
+
+/* Relocation table entry without addend (in section of type SHT_REL).  */
+
+typedef struct
+{
+  Elf32_Addr	r_offset;		/* Address */
+  Elf32_Word	r_info;			/* Relocation type and symbol index */
+} Elf32_Rel;
+
+/* I have seen two different definitions of the Elf64_Rel and
+   Elf64_Rela structures, so we'll leave them out until Novell (or
+   whoever) gets their act together.  */
+/* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
+
+typedef struct
+{
+  Elf64_Addr	r_offset;		/* Address */
+  Elf64_Xword	r_info;			/* Relocation type and symbol index */
+} Elf64_Rel;
+
+/* Relocation table entry with addend (in section of type SHT_RELA).  */
+
+typedef struct
+{
+  Elf32_Addr	r_offset;		/* Address */
+  Elf32_Word	r_info;			/* Relocation type and symbol index */
+  Elf32_Sword	r_addend;		/* Addend */
+} Elf32_Rela;
+
+typedef struct
+{
+  Elf64_Addr	r_offset;		/* Address */
+  Elf64_Xword	r_info;			/* Relocation type and symbol index */
+  Elf64_Sxword	r_addend;		/* Addend */
+} Elf64_Rela;
+
+/* How to extract and insert information held in the r_info field.  */
+
+#define ELF32_R_SYM(val)		((val) >> 8)
+#define ELF32_R_TYPE(val)		((val) & 0xff)
+#define ELF32_R_INFO(sym, type)		(((sym) << 8) + ((type) & 0xff))
+
+#define ELF64_R_SYM(i)			((i) >> 32)
+#define ELF64_R_TYPE(i)			((i) & 0xffffffff)
+#define ELF64_R_INFO(sym,type)		((((Elf64_Xword) (sym)) << 32) + (type))
+
+/* Program segment header.  */
+
+typedef struct
+{
+  Elf32_Word	p_type;			/* Segment type */
+  Elf32_Off	p_offset;		/* Segment file offset */
+  Elf32_Addr	p_vaddr;		/* Segment virtual address */
+  Elf32_Addr	p_paddr;		/* Segment physical address */
+  Elf32_Word	p_filesz;		/* Segment size in file */
+  Elf32_Word	p_memsz;		/* Segment size in memory */
+  Elf32_Word	p_flags;		/* Segment flags */
+  Elf32_Word	p_align;		/* Segment alignment */
+} Elf32_Phdr;
+
+typedef struct
+{
+  Elf64_Word	p_type;			/* Segment type */
+  Elf64_Word	p_flags;		/* Segment flags */
+  Elf64_Off	p_offset;		/* Segment file offset */
+  Elf64_Addr	p_vaddr;		/* Segment virtual address */
+  Elf64_Addr	p_paddr;		/* Segment physical address */
+  Elf64_Xword	p_filesz;		/* Segment size in file */
+  Elf64_Xword	p_memsz;		/* Segment size in memory */
+  Elf64_Xword	p_align;		/* Segment alignment */
+} Elf64_Phdr;
+
+/* Legal values for p_type (segment type).  */
+
+#define	PT_NULL		0		/* Program header table entry unused */
+#define PT_LOAD		1		/* Loadable program segment */
+#define PT_DYNAMIC	2		/* Dynamic linking information */
+#define PT_INTERP	3		/* Program interpreter */
+#define PT_NOTE		4		/* Auxiliary information */
+#define PT_SHLIB	5		/* Reserved */
+#define PT_PHDR		6		/* Entry for header table itself */
+#define PT_TLS		7		/* Thread-local storage segment */
+#define	PT_NUM		8		/* Number of defined types */
+#define PT_LOOS		0x60000000	/* Start of OS-specific */
+#define PT_GNU_EH_FRAME	0x6474e550	/* GCC .eh_frame_hdr segment */
+#define PT_GNU_STACK	0x6474e551	/* Indicates stack executability */
+#define PT_GNU_RELRO	0x6474e552	/* Read-only after relocation */
+#define PT_LOSUNW	0x6ffffffa
+#define PT_SUNWBSS	0x6ffffffa	/* Sun Specific segment */
+#define PT_SUNWSTACK	0x6ffffffb	/* Stack segment */
+#define PT_HISUNW	0x6fffffff
+#define PT_HIOS		0x6fffffff	/* End of OS-specific */
+#define PT_LOPROC	0x70000000	/* Start of processor-specific */
+#define PT_HIPROC	0x7fffffff	/* End of processor-specific */
+
+/* Legal values for p_flags (segment flags).  */
+
+#define PF_X		(1 << 0)	/* Segment is executable */
+#define PF_W		(1 << 1)	/* Segment is writable */
+#define PF_R		(1 << 2)	/* Segment is readable */
+#define PF_MASKOS	0x0ff00000	/* OS-specific */
+#define PF_MASKPROC	0xf0000000	/* Processor-specific */
+
+/* Legal values for note segment descriptor types for core files. */
+
+#define NT_PRSTATUS	1		/* Contains copy of prstatus struct */
+#define NT_FPREGSET	2		/* Contains copy of fpregset struct */
+#define NT_PRPSINFO	3		/* Contains copy of prpsinfo struct */
+#define NT_PRXREG	4		/* Contains copy of prxregset struct */
+#define NT_TASKSTRUCT	4		/* Contains copy of task structure */
+#define NT_PLATFORM	5		/* String from sysinfo(SI_PLATFORM) */
+#define NT_AUXV		6		/* Contains copy of auxv array */
+#define NT_GWINDOWS	7		/* Contains copy of gwindows struct */
+#define NT_ASRS		8		/* Contains copy of asrset struct */
+#define NT_PSTATUS	10		/* Contains copy of pstatus struct */
+#define NT_PSINFO	13		/* Contains copy of psinfo struct */
+#define NT_PRCRED	14		/* Contains copy of prcred struct */
+#define NT_UTSNAME	15		/* Contains copy of utsname struct */
+#define NT_LWPSTATUS	16		/* Contains copy of lwpstatus struct */
+#define NT_LWPSINFO	17		/* Contains copy of lwpinfo struct */
+#define NT_PRFPXREG	20		/* Contains copy of fprxregset struct*/
+
+/* Legal values for the note segment descriptor types for object files.  */
+
+#define NT_VERSION	1		/* Contains a version string.  */
+
+
+/* Dynamic section entry.  */
+
+typedef struct
+{
+  Elf32_Sword	d_tag;			/* Dynamic entry type */
+  union
+    {
+      Elf32_Word d_val;			/* Integer value */
+      Elf32_Addr d_ptr;			/* Address value */
+    } d_un;
+} Elf32_Dyn;
+
+typedef struct
+{
+  Elf64_Sxword	d_tag;			/* Dynamic entry type */
+  union
+    {
+      Elf64_Xword d_val;		/* Integer value */
+      Elf64_Addr d_ptr;			/* Address value */
+    } d_un;
+} Elf64_Dyn;
+
+/* Legal values for d_tag (dynamic entry type).  */
+
+#define DT_NULL		0		/* Marks end of dynamic section */
+#define DT_NEEDED	1		/* Name of needed library */
+#define DT_PLTRELSZ	2		/* Size in bytes of PLT relocs */
+#define DT_PLTGOT	3		/* Processor defined value */
+#define DT_HASH		4		/* Address of symbol hash table */
+#define DT_STRTAB	5		/* Address of string table */
+#define DT_SYMTAB	6		/* Address of symbol table */
+#define DT_RELA		7		/* Address of Rela relocs */
+#define DT_RELASZ	8		/* Total size of Rela relocs */
+#define DT_RELAENT	9		/* Size of one Rela reloc */
+#define DT_STRSZ	10		/* Size of string table */
+#define DT_SYMENT	11		/* Size of one symbol table entry */
+#define DT_INIT		12		/* Address of init function */
+#define DT_FINI		13		/* Address of termination function */
+#define DT_SONAME	14		/* Name of shared object */
+#define DT_RPATH	15		/* Library search path (deprecated) */
+#define DT_SYMBOLIC	16		/* Start symbol search here */
+#define DT_REL		17		/* Address of Rel relocs */
+#define DT_RELSZ	18		/* Total size of Rel relocs */
+#define DT_RELENT	19		/* Size of one Rel reloc */
+#define DT_PLTREL	20		/* Type of reloc in PLT */
+#define DT_DEBUG	21		/* For debugging; unspecified */
+#define DT_TEXTREL	22		/* Reloc might modify .text */
+#define DT_JMPREL	23		/* Address of PLT relocs */
+#define	DT_BIND_NOW	24		/* Process relocations of object */
+#define	DT_INIT_ARRAY	25		/* Array with addresses of init fct */
+#define	DT_FINI_ARRAY	26		/* Array with addresses of fini fct */
+#define	DT_INIT_ARRAYSZ	27		/* Size in bytes of DT_INIT_ARRAY */
+#define	DT_FINI_ARRAYSZ	28		/* Size in bytes of DT_FINI_ARRAY */
+#define DT_RUNPATH	29		/* Library search path */
+#define DT_FLAGS	30		/* Flags for the object being loaded */
+#define DT_ENCODING	32		/* Start of encoded range */
+#define DT_PREINIT_ARRAY 32		/* Array with addresses of preinit fct*/
+#define DT_PREINIT_ARRAYSZ 33		/* size in bytes of DT_PREINIT_ARRAY */
+#define	DT_NUM		34		/* Number used */
+#define DT_LOOS		0x6000000d	/* Start of OS-specific */
+#define DT_HIOS		0x6ffff000	/* End of OS-specific */
+#define DT_LOPROC	0x70000000	/* Start of processor-specific */
+#define DT_HIPROC	0x7fffffff	/* End of processor-specific */
+#define	DT_PROCNUM	DT_MIPS_NUM	/* Most used by any processor */
+
+/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
+   Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's
+   approach.  */
+#define DT_VALRNGLO	0x6ffffd00
+#define DT_GNU_PRELINKED 0x6ffffdf5	/* Prelinking timestamp */
+#define DT_GNU_CONFLICTSZ 0x6ffffdf6	/* Size of conflict section */
+#define DT_GNU_LIBLISTSZ 0x6ffffdf7	/* Size of library list */
+#define DT_CHECKSUM	0x6ffffdf8
+#define DT_PLTPADSZ	0x6ffffdf9
+#define DT_MOVEENT	0x6ffffdfa
+#define DT_MOVESZ	0x6ffffdfb
+#define DT_FEATURE_1	0x6ffffdfc	/* Feature selection (DTF_*).  */
+#define DT_POSFLAG_1	0x6ffffdfd	/* Flags for DT_* entries, effecting
+					   the following DT_* entry.  */
+#define DT_SYMINSZ	0x6ffffdfe	/* Size of syminfo table (in bytes) */
+#define DT_SYMINENT	0x6ffffdff	/* Entry size of syminfo */
+#define DT_VALRNGHI	0x6ffffdff
+#define DT_VALTAGIDX(tag)	(DT_VALRNGHI - (tag))	/* Reverse order! */
+#define DT_VALNUM 12
+
+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
+   Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
+
+   If any adjustment is made to the ELF object after it has been
+   built these entries will need to be adjusted.  */
+#define DT_ADDRRNGLO	0x6ffffe00
+#define DT_GNU_HASH	0x6ffffef5	/* GNU-style hash table.  */
+#define DT_TLSDESC_PLT	0x6ffffef6
+#define DT_TLSDESC_GOT	0x6ffffef7
+#define DT_GNU_CONFLICT	0x6ffffef8	/* Start of conflict section */
+#define DT_GNU_LIBLIST	0x6ffffef9	/* Library list */
+#define DT_CONFIG	0x6ffffefa	/* Configuration information.  */
+#define DT_DEPAUDIT	0x6ffffefb	/* Dependency auditing.  */
+#define DT_AUDIT	0x6ffffefc	/* Object auditing.  */
+#define	DT_PLTPAD	0x6ffffefd	/* PLT padding.  */
+#define	DT_MOVETAB	0x6ffffefe	/* Move table.  */
+#define DT_SYMINFO	0x6ffffeff	/* Syminfo table.  */
+#define DT_ADDRRNGHI	0x6ffffeff
+#define DT_ADDRTAGIDX(tag)	(DT_ADDRRNGHI - (tag))	/* Reverse order! */
+#define DT_ADDRNUM 11
+
+/* The versioning entry types.  The next are defined as part of the
+   GNU extension.  */
+#define DT_VERSYM	0x6ffffff0
+
+#define DT_RELACOUNT	0x6ffffff9
+#define DT_RELCOUNT	0x6ffffffa
+
+/* These were chosen by Sun.  */
+#define DT_FLAGS_1	0x6ffffffb	/* State flags, see DF_1_* below.  */
+#define	DT_VERDEF	0x6ffffffc	/* Address of version definition
+					   table */
+#define	DT_VERDEFNUM	0x6ffffffd	/* Number of version definitions */
+#define	DT_VERNEED	0x6ffffffe	/* Address of table with needed
+					   versions */
+#define	DT_VERNEEDNUM	0x6fffffff	/* Number of needed versions */
+#define DT_VERSIONTAGIDX(tag)	(DT_VERNEEDNUM - (tag))	/* Reverse order! */
+#define DT_VERSIONTAGNUM 16
+
+/* Sun added these machine-independent extensions in the "processor-specific"
+   range.  Be compatible.  */
+#define DT_AUXILIARY    0x7ffffffd      /* Shared object to load before self */
+#define DT_FILTER       0x7fffffff      /* Shared object to get values from */
+#define DT_EXTRATAGIDX(tag)	((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
+#define DT_EXTRANUM	3
+
+/* Values of `d_un.d_val' in the DT_FLAGS entry.  */
+#define DF_ORIGIN	0x00000001	/* Object may use DF_ORIGIN */
+#define DF_SYMBOLIC	0x00000002	/* Symbol resolutions starts here */
+#define DF_TEXTREL	0x00000004	/* Object contains text relocations */
+#define DF_BIND_NOW	0x00000008	/* No lazy binding for this object */
+#define DF_STATIC_TLS	0x00000010	/* Module uses the static TLS model */
+
+/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
+   entry in the dynamic section.  */
+#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
+#define DF_1_GLOBAL	0x00000002	/* Set RTLD_GLOBAL for this object.  */
+#define DF_1_GROUP	0x00000004	/* Set RTLD_GROUP for this object.  */
+#define DF_1_NODELETE	0x00000008	/* Set RTLD_NODELETE for this object.*/
+#define DF_1_LOADFLTR	0x00000010	/* Trigger filtee loading at runtime.*/
+#define DF_1_INITFIRST	0x00000020	/* Set RTLD_INITFIRST for this object*/
+#define DF_1_NOOPEN	0x00000040	/* Set RTLD_NOOPEN for this object.  */
+#define DF_1_ORIGIN	0x00000080	/* $ORIGIN must be handled.  */
+#define DF_1_DIRECT	0x00000100	/* Direct binding enabled.  */
+#define DF_1_TRANS	0x00000200
+#define DF_1_INTERPOSE	0x00000400	/* Object is used to interpose.  */
+#define DF_1_NODEFLIB	0x00000800	/* Ignore default lib search path.  */
+#define DF_1_NODUMP	0x00001000	/* Object can't be dldump'ed.  */
+#define DF_1_CONFALT	0x00002000	/* Configuration alternative created.*/
+#define DF_1_ENDFILTEE	0x00004000	/* Filtee terminates filters search. */
+#define	DF_1_DISPRELDNE	0x00008000	/* Disp reloc applied at build time. */
+#define	DF_1_DISPRELPND	0x00010000	/* Disp reloc applied at run-time.  */
+
+/* Flags for the feature selection in DT_FEATURE_1.  */
+#define DTF_1_PARINIT	0x00000001
+#define DTF_1_CONFEXP	0x00000002
+
+/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry.  */
+#define DF_P1_LAZYLOAD	0x00000001	/* Lazyload following object.  */
+#define DF_P1_GROUPPERM	0x00000002	/* Symbols from next object are not
+					   generally available.  */
+
+/* Version definition sections.  */
+
+typedef struct
+{
+  Elf32_Half	vd_version;		/* Version revision */
+  Elf32_Half	vd_flags;		/* Version information */
+  Elf32_Half	vd_ndx;			/* Version Index */
+  Elf32_Half	vd_cnt;			/* Number of associated aux entries */
+  Elf32_Word	vd_hash;		/* Version name hash value */
+  Elf32_Word	vd_aux;			/* Offset in bytes to verdaux array */
+  Elf32_Word	vd_next;		/* Offset in bytes to next verdef
+					   entry */
+} Elf32_Verdef;
+
+typedef struct
+{
+  Elf64_Half	vd_version;		/* Version revision */
+  Elf64_Half	vd_flags;		/* Version information */
+  Elf64_Half	vd_ndx;			/* Version Index */
+  Elf64_Half	vd_cnt;			/* Number of associated aux entries */
+  Elf64_Word	vd_hash;		/* Version name hash value */
+  Elf64_Word	vd_aux;			/* Offset in bytes to verdaux array */
+  Elf64_Word	vd_next;		/* Offset in bytes to next verdef
+					   entry */
+} Elf64_Verdef;
+
+
+/* Legal values for vd_version (version revision).  */
+#define VER_DEF_NONE	0		/* No version */
+#define VER_DEF_CURRENT	1		/* Current version */
+#define VER_DEF_NUM	2		/* Given version number */
+
+/* Legal values for vd_flags (version information flags).  */
+#define VER_FLG_BASE	0x1		/* Version definition of file itself */
+#define VER_FLG_WEAK	0x2		/* Weak version identifier */
+
+/* Versym symbol index values.  */
+#define	VER_NDX_LOCAL		0	/* Symbol is local.  */
+#define	VER_NDX_GLOBAL		1	/* Symbol is global.  */
+#define	VER_NDX_LORESERVE	0xff00	/* Beginning of reserved entries.  */
+#define	VER_NDX_ELIMINATE	0xff01	/* Symbol is to be eliminated.  */
+
+/* Auxialiary version information.  */
+
+typedef struct
+{
+  Elf32_Word	vda_name;		/* Version or dependency names */
+  Elf32_Word	vda_next;		/* Offset in bytes to next verdaux
+					   entry */
+} Elf32_Verdaux;
+
+typedef struct
+{
+  Elf64_Word	vda_name;		/* Version or dependency names */
+  Elf64_Word	vda_next;		/* Offset in bytes to next verdaux
+					   entry */
+} Elf64_Verdaux;
+
+
+/* Version dependency section.  */
+
+typedef struct
+{
+  Elf32_Half	vn_version;		/* Version of structure */
+  Elf32_Half	vn_cnt;			/* Number of associated aux entries */
+  Elf32_Word	vn_file;		/* Offset of filename for this
+					   dependency */
+  Elf32_Word	vn_aux;			/* Offset in bytes to vernaux array */
+  Elf32_Word	vn_next;		/* Offset in bytes to next verneed
+					   entry */
+} Elf32_Verneed;
+
+typedef struct
+{
+  Elf64_Half	vn_version;		/* Version of structure */
+  Elf64_Half	vn_cnt;			/* Number of associated aux entries */
+  Elf64_Word	vn_file;		/* Offset of filename for this
+					   dependency */
+  Elf64_Word	vn_aux;			/* Offset in bytes to vernaux array */
+  Elf64_Word	vn_next;		/* Offset in bytes to next verneed
+					   entry */
+} Elf64_Verneed;
+
+
+/* Legal values for vn_version (version revision).  */
+#define VER_NEED_NONE	 0		/* No version */
+#define VER_NEED_CURRENT 1		/* Current version */
+#define VER_NEED_NUM	 2		/* Given version number */
+
+/* Auxiliary needed version information.  */
+
+typedef struct
+{
+  Elf32_Word	vna_hash;		/* Hash value of dependency name */
+  Elf32_Half	vna_flags;		/* Dependency specific information */
+  Elf32_Half	vna_other;		/* Unused */
+  Elf32_Word	vna_name;		/* Dependency name string offset */
+  Elf32_Word	vna_next;		/* Offset in bytes to next vernaux
+					   entry */
+} Elf32_Vernaux;
+
+typedef struct
+{
+  Elf64_Word	vna_hash;		/* Hash value of dependency name */
+  Elf64_Half	vna_flags;		/* Dependency specific information */
+  Elf64_Half	vna_other;		/* Unused */
+  Elf64_Word	vna_name;		/* Dependency name string offset */
+  Elf64_Word	vna_next;		/* Offset in bytes to next vernaux
+					   entry */
+} Elf64_Vernaux;
+
+
+/* Legal values for vna_flags.  */
+#define VER_FLG_WEAK	0x2		/* Weak version identifier */
+
+
+/* Auxiliary vector.  */
+
+/* This vector is normally only used by the program interpreter.  The
+   usual definition in an ABI supplement uses the name auxv_t.  The
+   vector is not usually defined in a standard <elf.h> file, but it
+   can't hurt.  We rename it to avoid conflicts.  The sizes of these
+   types are an arrangement between the exec server and the program
+   interpreter, so we don't fully specify them here.  */
+
+typedef struct
+{
+  uint32_t a_type;		/* Entry type */
+  union
+    {
+      uint32_t a_val;		/* Integer value */
+      /* We use to have pointer elements added here.  We cannot do that,
+	 though, since it does not work when using 32-bit definitions
+	 on 64-bit platforms and vice versa.  */
+    } a_un;
+} Elf32_auxv_t;
+
+typedef struct
+{
+  uint64_t a_type;		/* Entry type */
+  union
+    {
+      uint64_t a_val;		/* Integer value */
+      /* We use to have pointer elements added here.  We cannot do that,
+	 though, since it does not work when using 32-bit definitions
+	 on 64-bit platforms and vice versa.  */
+    } a_un;
+} Elf64_auxv_t;
+
+/* Legal values for a_type (entry type).  */
+
+#define AT_NULL		0		/* End of vector */
+#define AT_IGNORE	1		/* Entry should be ignored */
+#define AT_EXECFD	2		/* File descriptor of program */
+#define AT_PHDR		3		/* Program headers for program */
+#define AT_PHENT	4		/* Size of program header entry */
+#define AT_PHNUM	5		/* Number of program headers */
+#define AT_PAGESZ	6		/* System page size */
+#define AT_BASE		7		/* Base address of interpreter */
+#define AT_FLAGS	8		/* Flags */
+#define AT_ENTRY	9		/* Entry point of program */
+#define AT_NOTELF	10		/* Program is not ELF */
+#define AT_UID		11		/* Real uid */
+#define AT_EUID		12		/* Effective uid */
+#define AT_GID		13		/* Real gid */
+#define AT_EGID		14		/* Effective gid */
+#define AT_CLKTCK	17		/* Frequency of times() */
+
+/* Some more special a_type values describing the hardware.  */
+#define AT_PLATFORM	15		/* String identifying platform.  */
+#define AT_HWCAP	16		/* Machine dependent hints about
+					   processor capabilities.  */
+
+/* This entry gives some information about the FPU initialization
+   performed by the kernel.  */
+#define AT_FPUCW	18		/* Used FPU control word.  */
+
+/* Cache block sizes.  */
+#define AT_DCACHEBSIZE	19		/* Data cache block size.  */
+#define AT_ICACHEBSIZE	20		/* Instruction cache block size.  */
+#define AT_UCACHEBSIZE	21		/* Unified cache block size.  */
+
+/* A special ignored value for PPC, used by the kernel to control the
+   interpretation of the AUXV. Must be > 16.  */
+#define AT_IGNOREPPC	22		/* Entry should be ignored.  */
+
+#define	AT_SECURE	23		/* Boolean, was exec setuid-like?  */
+
+/* Pointer to the global system page used for system calls and other
+   nice things.  */
+#define AT_SYSINFO	32
+#define AT_SYSINFO_EHDR	33
+
+/* Shapes of the caches.  Bits 0-3 contains associativity; bits 4-7 contains
+   log2 of line size; mask those to get cache size.  */
+#define AT_L1I_CACHESHAPE	34
+#define AT_L1D_CACHESHAPE	35
+#define AT_L2_CACHESHAPE	36
+#define AT_L3_CACHESHAPE	37
+
+/* Note section contents.  Each entry in the note section begins with
+   a header of a fixed form.  */
+
+typedef struct
+{
+  Elf32_Word n_namesz;			/* Length of the note's name.  */
+  Elf32_Word n_descsz;			/* Length of the note's descriptor.  */
+  Elf32_Word n_type;			/* Type of the note.  */
+} Elf32_Nhdr;
+
+typedef struct
+{
+  Elf64_Word n_namesz;			/* Length of the note's name.  */
+  Elf64_Word n_descsz;			/* Length of the note's descriptor.  */
+  Elf64_Word n_type;			/* Type of the note.  */
+} Elf64_Nhdr;
+
+/* Known names of notes.  */
+
+/* Solaris entries in the note section have this name.  */
+#define ELF_NOTE_SOLARIS	"SUNW Solaris"
+
+/* Note entries for GNU systems have this name.  */
+#define ELF_NOTE_GNU		"GNU"
+
+
+/* Defined types of notes for Solaris.  */
+
+/* Value of descriptor (one word) is desired pagesize for the binary.  */
+#define ELF_NOTE_PAGESIZE_HINT	1
+
+
+/* Defined note types for GNU systems.  */
+
+/* ABI information.  The descriptor consists of words:
+   word 0: OS descriptor
+   word 1: major version of the ABI
+   word 2: minor version of the ABI
+   word 3: subminor version of the ABI
+*/
+#define ELF_NOTE_ABI		1
+
+/* Known OSes.  These value can appear in word 0 of an ELF_NOTE_ABI
+   note section entry.  */
+#define ELF_NOTE_OS_LINUX	0
+#define ELF_NOTE_OS_GNU		1
+#define ELF_NOTE_OS_SOLARIS2	2
+#define ELF_NOTE_OS_FREEBSD	3
+
+
+/* Move records.  */
+typedef struct
+{
+  Elf32_Xword m_value;		/* Symbol value.  */
+  Elf32_Word m_info;		/* Size and index.  */
+  Elf32_Word m_poffset;		/* Symbol offset.  */
+  Elf32_Half m_repeat;		/* Repeat count.  */
+  Elf32_Half m_stride;		/* Stride info.  */
+} Elf32_Move;
+
+typedef struct
+{
+  Elf64_Xword m_value;		/* Symbol value.  */
+  Elf64_Xword m_info;		/* Size and index.  */
+  Elf64_Xword m_poffset;	/* Symbol offset.  */
+  Elf64_Half m_repeat;		/* Repeat count.  */
+  Elf64_Half m_stride;		/* Stride info.  */
+} Elf64_Move;
+
+/* Macro to construct move records.  */
+#define ELF32_M_SYM(info)	((info) >> 8)
+#define ELF32_M_SIZE(info)	((unsigned char) (info))
+#define ELF32_M_INFO(sym, size)	(((sym) << 8) + (unsigned char) (size))
+
+#define ELF64_M_SYM(info)	ELF32_M_SYM (info)
+#define ELF64_M_SIZE(info)	ELF32_M_SIZE (info)
+#define ELF64_M_INFO(sym, size)	ELF32_M_INFO (sym, size)
+
+
+/* Motorola 68k specific definitions.  */
+
+/* Values for Elf32_Ehdr.e_flags.  */
+#define EF_CPU32	0x00810000
+
+/* m68k relocs.  */
+
+#define R_68K_NONE	0		/* No reloc */
+#define R_68K_32	1		/* Direct 32 bit  */
+#define R_68K_16	2		/* Direct 16 bit  */
+#define R_68K_8		3		/* Direct 8 bit  */
+#define R_68K_PC32	4		/* PC relative 32 bit */
+#define R_68K_PC16	5		/* PC relative 16 bit */
+#define R_68K_PC8	6		/* PC relative 8 bit */
+#define R_68K_GOT32	7		/* 32 bit PC relative GOT entry */
+#define R_68K_GOT16	8		/* 16 bit PC relative GOT entry */
+#define R_68K_GOT8	9		/* 8 bit PC relative GOT entry */
+#define R_68K_GOT32O	10		/* 32 bit GOT offset */
+#define R_68K_GOT16O	11		/* 16 bit GOT offset */
+#define R_68K_GOT8O	12		/* 8 bit GOT offset */
+#define R_68K_PLT32	13		/* 32 bit PC relative PLT address */
+#define R_68K_PLT16	14		/* 16 bit PC relative PLT address */
+#define R_68K_PLT8	15		/* 8 bit PC relative PLT address */
+#define R_68K_PLT32O	16		/* 32 bit PLT offset */
+#define R_68K_PLT16O	17		/* 16 bit PLT offset */
+#define R_68K_PLT8O	18		/* 8 bit PLT offset */
+#define R_68K_COPY	19		/* Copy symbol at runtime */
+#define R_68K_GLOB_DAT	20		/* Create GOT entry */
+#define R_68K_JMP_SLOT	21		/* Create PLT entry */
+#define R_68K_RELATIVE	22		/* Adjust by program base */
+/* Keep this the last entry.  */
+#define R_68K_NUM	23
+
+/* Intel 80386 specific definitions.  */
+
+/* i386 relocs.  */
+
+#define R_386_NONE	   0		/* No reloc */
+#define R_386_32	   1		/* Direct 32 bit  */
+#define R_386_PC32	   2		/* PC relative 32 bit */
+#define R_386_GOT32	   3		/* 32 bit GOT entry */
+#define R_386_PLT32	   4		/* 32 bit PLT address */
+#define R_386_COPY	   5		/* Copy symbol at runtime */
+#define R_386_GLOB_DAT	   6		/* Create GOT entry */
+#define R_386_JMP_SLOT	   7		/* Create PLT entry */
+#define R_386_RELATIVE	   8		/* Adjust by program base */
+#define R_386_GOTOFF	   9		/* 32 bit offset to GOT */
+#define R_386_GOTPC	   10		/* 32 bit PC relative offset to GOT */
+#define R_386_32PLT	   11
+#define R_386_TLS_TPOFF	   14		/* Offset in static TLS block */
+#define R_386_TLS_IE	   15		/* Address of GOT entry for static TLS
+					   block offset */
+#define R_386_TLS_GOTIE	   16		/* GOT entry for static TLS block
+					   offset */
+#define R_386_TLS_LE	   17		/* Offset relative to static TLS
+					   block */
+#define R_386_TLS_GD	   18		/* Direct 32 bit for GNU version of
+					   general dynamic thread local data */
+#define R_386_TLS_LDM	   19		/* Direct 32 bit for GNU version of
+					   local dynamic thread local data
+					   in LE code */
+#define R_386_16	   20
+#define R_386_PC16	   21
+#define R_386_8		   22
+#define R_386_PC8	   23
+#define R_386_TLS_GD_32	   24		/* Direct 32 bit for general dynamic
+					   thread local data */
+#define R_386_TLS_GD_PUSH  25		/* Tag for pushl in GD TLS code */
+#define R_386_TLS_GD_CALL  26		/* Relocation for call to
+					   __tls_get_addr() */
+#define R_386_TLS_GD_POP   27		/* Tag for popl in GD TLS code */
+#define R_386_TLS_LDM_32   28		/* Direct 32 bit for local dynamic
+					   thread local data in LE code */
+#define R_386_TLS_LDM_PUSH 29		/* Tag for pushl in LDM TLS code */
+#define R_386_TLS_LDM_CALL 30		/* Relocation for call to
+					   __tls_get_addr() in LDM code */
+#define R_386_TLS_LDM_POP  31		/* Tag for popl in LDM TLS code */
+#define R_386_TLS_LDO_32   32		/* Offset relative to TLS block */
+#define R_386_TLS_IE_32	   33		/* GOT entry for negated static TLS
+					   block offset */
+#define R_386_TLS_LE_32	   34		/* Negated offset relative to static
+					   TLS block */
+#define R_386_TLS_DTPMOD32 35		/* ID of module containing symbol */
+#define R_386_TLS_DTPOFF32 36		/* Offset in TLS block */
+#define R_386_TLS_TPOFF32  37		/* Negated offset in static TLS block */
+/* Keep this the last entry.  */
+#define R_386_NUM	   38
+
+/* SUN SPARC specific definitions.  */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
+
+#define STT_SPARC_REGISTER	13	/* Global register reserved to app. */
+
+/* Values for Elf64_Ehdr.e_flags.  */
+
+#define EF_SPARCV9_MM		3
+#define EF_SPARCV9_TSO		0
+#define EF_SPARCV9_PSO		1
+#define EF_SPARCV9_RMO		2
+#define EF_SPARC_LEDATA		0x800000 /* little endian data */
+#define EF_SPARC_EXT_MASK	0xFFFF00
+#define EF_SPARC_32PLUS		0x000100 /* generic V8+ features */
+#define EF_SPARC_SUN_US1	0x000200 /* Sun UltraSPARC1 extensions */
+#define EF_SPARC_HAL_R1		0x000400 /* HAL R1 extensions */
+#define EF_SPARC_SUN_US3	0x000800 /* Sun UltraSPARCIII extensions */
+
+/* SPARC relocs.  */
+
+#define R_SPARC_NONE		0	/* No reloc */
+#define R_SPARC_8		1	/* Direct 8 bit */
+#define R_SPARC_16		2	/* Direct 16 bit */
+#define R_SPARC_32		3	/* Direct 32 bit */
+#define R_SPARC_DISP8		4	/* PC relative 8 bit */
+#define R_SPARC_DISP16		5	/* PC relative 16 bit */
+#define R_SPARC_DISP32		6	/* PC relative 32 bit */
+#define R_SPARC_WDISP30		7	/* PC relative 30 bit shifted */
+#define R_SPARC_WDISP22		8	/* PC relative 22 bit shifted */
+#define R_SPARC_HI22		9	/* High 22 bit */
+#define R_SPARC_22		10	/* Direct 22 bit */
+#define R_SPARC_13		11	/* Direct 13 bit */
+#define R_SPARC_LO10		12	/* Truncated 10 bit */
+#define R_SPARC_GOT10		13	/* Truncated 10 bit GOT entry */
+#define R_SPARC_GOT13		14	/* 13 bit GOT entry */
+#define R_SPARC_GOT22		15	/* 22 bit GOT entry shifted */
+#define R_SPARC_PC10		16	/* PC relative 10 bit truncated */
+#define R_SPARC_PC22		17	/* PC relative 22 bit shifted */
+#define R_SPARC_WPLT30		18	/* 30 bit PC relative PLT address */
+#define R_SPARC_COPY		19	/* Copy symbol at runtime */
+#define R_SPARC_GLOB_DAT	20	/* Create GOT entry */
+#define R_SPARC_JMP_SLOT	21	/* Create PLT entry */
+#define R_SPARC_RELATIVE	22	/* Adjust by program base */
+#define R_SPARC_UA32		23	/* Direct 32 bit unaligned */
+
+/* Additional Sparc64 relocs.  */
+
+#define R_SPARC_PLT32		24	/* Direct 32 bit ref to PLT entry */
+#define R_SPARC_HIPLT22		25	/* High 22 bit PLT entry */
+#define R_SPARC_LOPLT10		26	/* Truncated 10 bit PLT entry */
+#define R_SPARC_PCPLT32		27	/* PC rel 32 bit ref to PLT entry */
+#define R_SPARC_PCPLT22		28	/* PC rel high 22 bit PLT entry */
+#define R_SPARC_PCPLT10		29	/* PC rel trunc 10 bit PLT entry */
+#define R_SPARC_10		30	/* Direct 10 bit */
+#define R_SPARC_11		31	/* Direct 11 bit */
+#define R_SPARC_64		32	/* Direct 64 bit */
+#define R_SPARC_OLO10		33	/* 10bit with secondary 13bit addend */
+#define R_SPARC_HH22		34	/* Top 22 bits of direct 64 bit */
+#define R_SPARC_HM10		35	/* High middle 10 bits of ... */
+#define R_SPARC_LM22		36	/* Low middle 22 bits of ... */
+#define R_SPARC_PC_HH22		37	/* Top 22 bits of pc rel 64 bit */
+#define R_SPARC_PC_HM10		38	/* High middle 10 bit of ... */
+#define R_SPARC_PC_LM22		39	/* Low miggle 22 bits of ... */
+#define R_SPARC_WDISP16		40	/* PC relative 16 bit shifted */
+#define R_SPARC_WDISP19		41	/* PC relative 19 bit shifted */
+#define R_SPARC_7		43	/* Direct 7 bit */
+#define R_SPARC_5		44	/* Direct 5 bit */
+#define R_SPARC_6		45	/* Direct 6 bit */
+#define R_SPARC_DISP64		46	/* PC relative 64 bit */
+#define R_SPARC_PLT64		47	/* Direct 64 bit ref to PLT entry */
+#define R_SPARC_HIX22		48	/* High 22 bit complemented */
+#define R_SPARC_LOX10		49	/* Truncated 11 bit complemented */
+#define R_SPARC_H44		50	/* Direct high 12 of 44 bit */
+#define R_SPARC_M44		51	/* Direct mid 22 of 44 bit */
+#define R_SPARC_L44		52	/* Direct low 10 of 44 bit */
+#define R_SPARC_REGISTER	53	/* Global register usage */
+#define R_SPARC_UA64		54	/* Direct 64 bit unaligned */
+#define R_SPARC_UA16		55	/* Direct 16 bit unaligned */
+#define R_SPARC_TLS_GD_HI22	56
+#define R_SPARC_TLS_GD_LO10	57
+#define R_SPARC_TLS_GD_ADD	58
+#define R_SPARC_TLS_GD_CALL	59
+#define R_SPARC_TLS_LDM_HI22	60
+#define R_SPARC_TLS_LDM_LO10	61
+#define R_SPARC_TLS_LDM_ADD	62
+#define R_SPARC_TLS_LDM_CALL	63
+#define R_SPARC_TLS_LDO_HIX22	64
+#define R_SPARC_TLS_LDO_LOX10	65
+#define R_SPARC_TLS_LDO_ADD	66
+#define R_SPARC_TLS_IE_HI22	67
+#define R_SPARC_TLS_IE_LO10	68
+#define R_SPARC_TLS_IE_LD	69
+#define R_SPARC_TLS_IE_LDX	70
+#define R_SPARC_TLS_IE_ADD	71
+#define R_SPARC_TLS_LE_HIX22	72
+#define R_SPARC_TLS_LE_LOX10	73
+#define R_SPARC_TLS_DTPMOD32	74
+#define R_SPARC_TLS_DTPMOD64	75
+#define R_SPARC_TLS_DTPOFF32	76
+#define R_SPARC_TLS_DTPOFF64	77
+#define R_SPARC_TLS_TPOFF32	78
+#define R_SPARC_TLS_TPOFF64	79
+/* Keep this the last entry.  */
+#define R_SPARC_NUM		80
+
+/* For Sparc64, legal values for d_tag of Elf64_Dyn.  */
+
+#define DT_SPARC_REGISTER 0x70000001
+#define DT_SPARC_NUM	2
+
+/* Bits present in AT_HWCAP on SPARC.  */
+
+#define HWCAP_SPARC_FLUSH	1	/* The CPU supports flush insn.  */
+#define HWCAP_SPARC_STBAR	2
+#define HWCAP_SPARC_SWAP	4
+#define HWCAP_SPARC_MULDIV	8
+#define HWCAP_SPARC_V9		16	/* The CPU is v9, so v8plus is ok.  */
+#define HWCAP_SPARC_ULTRA3	32
+#define HWCAP_SPARC_BLKINIT	64	/* Sun4v with block-init/load-twin.  */
+
+/* MIPS R3000 specific definitions.  */
+
+/* Legal values for e_flags field of Elf32_Ehdr.  */
+
+#define EF_MIPS_NOREORDER   1		/* A .noreorder directive was used */
+#define EF_MIPS_PIC	    2		/* Contains PIC code */
+#define EF_MIPS_CPIC	    4		/* Uses PIC calling sequence */
+#define EF_MIPS_XGOT	    8
+#define EF_MIPS_64BIT_WHIRL 16
+#define EF_MIPS_ABI2	    32
+#define EF_MIPS_ABI_ON32    64
+#define EF_MIPS_ARCH	    0xf0000000	/* MIPS architecture level */
+
+/* Legal values for MIPS architecture level.  */
+
+#define EF_MIPS_ARCH_1	    0x00000000	/* -mips1 code.  */
+#define EF_MIPS_ARCH_2	    0x10000000	/* -mips2 code.  */
+#define EF_MIPS_ARCH_3	    0x20000000	/* -mips3 code.  */
+#define EF_MIPS_ARCH_4	    0x30000000	/* -mips4 code.  */
+#define EF_MIPS_ARCH_5	    0x40000000	/* -mips5 code.  */
+#define EF_MIPS_ARCH_32	    0x60000000	/* MIPS32 code.  */
+#define EF_MIPS_ARCH_64	    0x70000000	/* MIPS64 code.  */
+
+/* The following are non-official names and should not be used.  */
+
+#define E_MIPS_ARCH_1	  0x00000000	/* -mips1 code.  */
+#define E_MIPS_ARCH_2	  0x10000000	/* -mips2 code.  */
+#define E_MIPS_ARCH_3	  0x20000000	/* -mips3 code.  */
+#define E_MIPS_ARCH_4	  0x30000000	/* -mips4 code.  */
+#define E_MIPS_ARCH_5	  0x40000000	/* -mips5 code.  */
+#define E_MIPS_ARCH_32	  0x60000000	/* MIPS32 code.  */
+#define E_MIPS_ARCH_64	  0x70000000	/* MIPS64 code.  */
+
+/* Special section indices.  */
+
+#define SHN_MIPS_ACOMMON    0xff00	/* Allocated common symbols */
+#define SHN_MIPS_TEXT	    0xff01	/* Allocated test symbols.  */
+#define SHN_MIPS_DATA	    0xff02	/* Allocated data symbols.  */
+#define SHN_MIPS_SCOMMON    0xff03	/* Small common symbols */
+#define SHN_MIPS_SUNDEFINED 0xff04	/* Small undefined symbols */
+
+/* Legal values for sh_type field of Elf32_Shdr.  */
+
+#define SHT_MIPS_LIBLIST       0x70000000 /* Shared objects used in link */
+#define SHT_MIPS_MSYM	       0x70000001
+#define SHT_MIPS_CONFLICT      0x70000002 /* Conflicting symbols */
+#define SHT_MIPS_GPTAB	       0x70000003 /* Global data area sizes */
+#define SHT_MIPS_UCODE	       0x70000004 /* Reserved for SGI/MIPS compilers */
+#define SHT_MIPS_DEBUG	       0x70000005 /* MIPS ECOFF debugging information*/
+#define SHT_MIPS_REGINFO       0x70000006 /* Register usage information */
+#define SHT_MIPS_PACKAGE       0x70000007
+#define SHT_MIPS_PACKSYM       0x70000008
+#define SHT_MIPS_RELD	       0x70000009
+#define SHT_MIPS_IFACE         0x7000000b
+#define SHT_MIPS_CONTENT       0x7000000c
+#define SHT_MIPS_OPTIONS       0x7000000d /* Miscellaneous options.  */
+#define SHT_MIPS_SHDR	       0x70000010
+#define SHT_MIPS_FDESC	       0x70000011
+#define SHT_MIPS_EXTSYM	       0x70000012
+#define SHT_MIPS_DENSE	       0x70000013
+#define SHT_MIPS_PDESC	       0x70000014
+#define SHT_MIPS_LOCSYM	       0x70000015
+#define SHT_MIPS_AUXSYM	       0x70000016
+#define SHT_MIPS_OPTSYM	       0x70000017
+#define SHT_MIPS_LOCSTR	       0x70000018
+#define SHT_MIPS_LINE	       0x70000019
+#define SHT_MIPS_RFDESC	       0x7000001a
+#define SHT_MIPS_DELTASYM      0x7000001b
+#define SHT_MIPS_DELTAINST     0x7000001c
+#define SHT_MIPS_DELTACLASS    0x7000001d
+#define SHT_MIPS_DWARF         0x7000001e /* DWARF debugging information.  */
+#define SHT_MIPS_DELTADECL     0x7000001f
+#define SHT_MIPS_SYMBOL_LIB    0x70000020
+#define SHT_MIPS_EVENTS	       0x70000021 /* Event section.  */
+#define SHT_MIPS_TRANSLATE     0x70000022
+#define SHT_MIPS_PIXIE	       0x70000023
+#define SHT_MIPS_XLATE	       0x70000024
+#define SHT_MIPS_XLATE_DEBUG   0x70000025
+#define SHT_MIPS_WHIRL	       0x70000026
+#define SHT_MIPS_EH_REGION     0x70000027
+#define SHT_MIPS_XLATE_OLD     0x70000028
+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
+
+/* Legal values for sh_flags field of Elf32_Shdr.  */
+
+#define SHF_MIPS_GPREL	 0x10000000	/* Must be part of global data area */
+#define SHF_MIPS_MERGE	 0x20000000
+#define SHF_MIPS_ADDR	 0x40000000
+#define SHF_MIPS_STRINGS 0x80000000
+#define SHF_MIPS_NOSTRIP 0x08000000
+#define SHF_MIPS_LOCAL	 0x04000000
+#define SHF_MIPS_NAMES	 0x02000000
+#define SHF_MIPS_NODUPE	 0x01000000
+
+
+/* Symbol tables.  */
+
+/* MIPS specific values for `st_other'.  */
+#define STO_MIPS_DEFAULT		0x0
+#define STO_MIPS_INTERNAL		0x1
+#define STO_MIPS_HIDDEN			0x2
+#define STO_MIPS_PROTECTED		0x3
+#define STO_MIPS_SC_ALIGN_UNUSED	0xff
+
+/* MIPS specific values for `st_info'.  */
+#define STB_MIPS_SPLIT_COMMON		13
+
+/* Entries found in sections of type SHT_MIPS_GPTAB.  */
+
+typedef union
+{
+  struct
+    {
+      Elf32_Word gt_current_g_value;	/* -G value used for compilation */
+      Elf32_Word gt_unused;		/* Not used */
+    } gt_header;			/* First entry in section */
+  struct
+    {
+      Elf32_Word gt_g_value;		/* If this value were used for -G */
+      Elf32_Word gt_bytes;		/* This many bytes would be used */
+    } gt_entry;				/* Subsequent entries in section */
+} Elf32_gptab;
+
+/* Entry found in sections of type SHT_MIPS_REGINFO.  */
+
+typedef struct
+{
+  Elf32_Word	ri_gprmask;		/* General registers used */
+  Elf32_Word	ri_cprmask[4];		/* Coprocessor registers used */
+  Elf32_Sword	ri_gp_value;		/* $gp register value */
+} Elf32_RegInfo;
+
+/* Entries found in sections of type SHT_MIPS_OPTIONS.  */
+
+typedef struct
+{
+  unsigned char kind;		/* Determines interpretation of the
+				   variable part of descriptor.  */
+  unsigned char size;		/* Size of descriptor, including header.  */
+  Elf32_Section section;	/* Section header index of section affected,
+				   0 for global options.  */
+  Elf32_Word info;		/* Kind-specific information.  */
+} Elf_Options;
+
+/* Values for `kind' field in Elf_Options.  */
+
+#define ODK_NULL	0	/* Undefined.  */
+#define ODK_REGINFO	1	/* Register usage information.  */
+#define ODK_EXCEPTIONS	2	/* Exception processing options.  */
+#define ODK_PAD		3	/* Section padding options.  */
+#define ODK_HWPATCH	4	/* Hardware workarounds performed */
+#define ODK_FILL	5	/* record the fill value used by the linker. */
+#define ODK_TAGS	6	/* reserve space for desktop tools to write. */
+#define ODK_HWAND	7	/* HW workarounds.  'AND' bits when merging. */
+#define ODK_HWOR	8	/* HW workarounds.  'OR' bits when merging.  */
+
+/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries.  */
+
+#define OEX_FPU_MIN	0x1f	/* FPE's which MUST be enabled.  */
+#define OEX_FPU_MAX	0x1f00	/* FPE's which MAY be enabled.  */
+#define OEX_PAGE0	0x10000	/* page zero must be mapped.  */
+#define OEX_SMM		0x20000	/* Force sequential memory mode?  */
+#define OEX_FPDBUG	0x40000	/* Force floating point debug mode?  */
+#define OEX_PRECISEFP	OEX_FPDBUG
+#define OEX_DISMISS	0x80000	/* Dismiss invalid address faults?  */
+
+#define OEX_FPU_INVAL	0x10
+#define OEX_FPU_DIV0	0x08
+#define OEX_FPU_OFLO	0x04
+#define OEX_FPU_UFLO	0x02
+#define OEX_FPU_INEX	0x01
+
+/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry.  */
+
+#define OHW_R4KEOP	0x1	/* R4000 end-of-page patch.  */
+#define OHW_R8KPFETCH	0x2	/* may need R8000 prefetch patch.  */
+#define OHW_R5KEOP	0x4	/* R5000 end-of-page patch.  */
+#define OHW_R5KCVTL	0x8	/* R5000 cvt.[ds].l bug.  clean=1.  */
+
+#define OPAD_PREFIX	0x1
+#define OPAD_POSTFIX	0x2
+#define OPAD_SYMBOL	0x4
+
+/* Entry found in `.options' section.  */
+
+typedef struct
+{
+  Elf32_Word hwp_flags1;	/* Extra flags.  */
+  Elf32_Word hwp_flags2;	/* Extra flags.  */
+} Elf_Options_Hw;
+
+/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries.  */
+
+#define OHWA0_R4KEOP_CHECKED	0x00000001
+#define OHWA1_R4KEOP_CLEAN	0x00000002
+
+/* MIPS relocs.  */
+
+#define R_MIPS_NONE		0	/* No reloc */
+#define R_MIPS_16		1	/* Direct 16 bit */
+#define R_MIPS_32		2	/* Direct 32 bit */
+#define R_MIPS_REL32		3	/* PC relative 32 bit */
+#define R_MIPS_26		4	/* Direct 26 bit shifted */
+#define R_MIPS_HI16		5	/* High 16 bit */
+#define R_MIPS_LO16		6	/* Low 16 bit */
+#define R_MIPS_GPREL16		7	/* GP relative 16 bit */
+#define R_MIPS_LITERAL		8	/* 16 bit literal entry */
+#define R_MIPS_GOT16		9	/* 16 bit GOT entry */
+#define R_MIPS_PC16		10	/* PC relative 16 bit */
+#define R_MIPS_CALL16		11	/* 16 bit GOT entry for function */
+#define R_MIPS_GPREL32		12	/* GP relative 32 bit */
+
+#define R_MIPS_SHIFT5		16
+#define R_MIPS_SHIFT6		17
+#define R_MIPS_64		18
+#define R_MIPS_GOT_DISP		19
+#define R_MIPS_GOT_PAGE		20
+#define R_MIPS_GOT_OFST		21
+#define R_MIPS_GOT_HI16		22
+#define R_MIPS_GOT_LO16		23
+#define R_MIPS_SUB		24
+#define R_MIPS_INSERT_A		25
+#define R_MIPS_INSERT_B		26
+#define R_MIPS_DELETE		27
+#define R_MIPS_HIGHER		28
+#define R_MIPS_HIGHEST		29
+#define R_MIPS_CALL_HI16	30
+#define R_MIPS_CALL_LO16	31
+#define R_MIPS_SCN_DISP		32
+#define R_MIPS_REL16		33
+#define R_MIPS_ADD_IMMEDIATE	34
+#define R_MIPS_PJUMP		35
+#define R_MIPS_RELGOT		36
+#define R_MIPS_JALR		37
+#define R_MIPS_TLS_DTPMOD32	38	/* Module number 32 bit */
+#define R_MIPS_TLS_DTPREL32	39	/* Module-relative offset 32 bit */
+#define R_MIPS_TLS_DTPMOD64	40	/* Module number 64 bit */
+#define R_MIPS_TLS_DTPREL64	41	/* Module-relative offset 64 bit */
+#define R_MIPS_TLS_GD		42	/* 16 bit GOT offset for GD */
+#define R_MIPS_TLS_LDM		43	/* 16 bit GOT offset for LDM */
+#define R_MIPS_TLS_DTPREL_HI16	44	/* Module-relative offset, high 16 bits */
+#define R_MIPS_TLS_DTPREL_LO16	45	/* Module-relative offset, low 16 bits */
+#define R_MIPS_TLS_GOTTPREL	46	/* 16 bit GOT offset for IE */
+#define R_MIPS_TLS_TPREL32	47	/* TP-relative offset, 32 bit */
+#define R_MIPS_TLS_TPREL64	48	/* TP-relative offset, 64 bit */
+#define R_MIPS_TLS_TPREL_HI16	49	/* TP-relative offset, high 16 bits */
+#define R_MIPS_TLS_TPREL_LO16	50	/* TP-relative offset, low 16 bits */
+/* Keep this the last entry.  */
+#define R_MIPS_NUM		51
+
+/* Legal values for p_type field of Elf32_Phdr.  */
+
+#define PT_MIPS_REGINFO	0x70000000	/* Register usage information */
+#define PT_MIPS_RTPROC  0x70000001	/* Runtime procedure table. */
+#define PT_MIPS_OPTIONS 0x70000002
+
+/* Special program header types.  */
+
+#define PF_MIPS_LOCAL	0x10000000
+
+/* Legal values for d_tag field of Elf32_Dyn.  */
+
+#define DT_MIPS_RLD_VERSION  0x70000001	/* Runtime linker interface version */
+#define DT_MIPS_TIME_STAMP   0x70000002	/* Timestamp */
+#define DT_MIPS_ICHECKSUM    0x70000003	/* Checksum */
+#define DT_MIPS_IVERSION     0x70000004	/* Version string (string tbl index) */
+#define DT_MIPS_FLAGS	     0x70000005	/* Flags */
+#define DT_MIPS_BASE_ADDRESS 0x70000006	/* Base address */
+#define DT_MIPS_MSYM	     0x70000007
+#define DT_MIPS_CONFLICT     0x70000008	/* Address of CONFLICT section */
+#define DT_MIPS_LIBLIST	     0x70000009	/* Address of LIBLIST section */
+#define DT_MIPS_LOCAL_GOTNO  0x7000000a	/* Number of local GOT entries */
+#define DT_MIPS_CONFLICTNO   0x7000000b	/* Number of CONFLICT entries */
+#define DT_MIPS_LIBLISTNO    0x70000010	/* Number of LIBLIST entries */
+#define DT_MIPS_SYMTABNO     0x70000011	/* Number of DYNSYM entries */
+#define DT_MIPS_UNREFEXTNO   0x70000012	/* First external DYNSYM */
+#define DT_MIPS_GOTSYM	     0x70000013	/* First GOT entry in DYNSYM */
+#define DT_MIPS_HIPAGENO     0x70000014	/* Number of GOT page table entries */
+#define DT_MIPS_RLD_MAP	     0x70000016	/* Address of run time loader map.  */
+#define DT_MIPS_DELTA_CLASS  0x70000017	/* Delta C++ class definition.  */
+#define DT_MIPS_DELTA_CLASS_NO    0x70000018 /* Number of entries in
+						DT_MIPS_DELTA_CLASS.  */
+#define DT_MIPS_DELTA_INSTANCE    0x70000019 /* Delta C++ class instances.  */
+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
+						DT_MIPS_DELTA_INSTANCE.  */
+#define DT_MIPS_DELTA_RELOC  0x7000001b /* Delta relocations.  */
+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
+					     DT_MIPS_DELTA_RELOC.  */
+#define DT_MIPS_DELTA_SYM    0x7000001d /* Delta symbols that Delta
+					   relocations refer to.  */
+#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
+					   DT_MIPS_DELTA_SYM.  */
+#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
+					     class declaration.  */
+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
+						DT_MIPS_DELTA_CLASSSYM.  */
+#define DT_MIPS_CXX_FLAGS    0x70000022 /* Flags indicating for C++ flavor.  */
+#define DT_MIPS_PIXIE_INIT   0x70000023
+#define DT_MIPS_SYMBOL_LIB   0x70000024
+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
+#define DT_MIPS_OPTIONS	     0x70000029 /* Address of .options.  */
+#define DT_MIPS_INTERFACE    0x7000002a /* Address of .interface.  */
+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
+#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
+						    function stored in GOT.  */
+#define DT_MIPS_PERF_SUFFIX  0x7000002e /* Default suffix of dso to be added
+					   by rld on dlopen() calls.  */
+#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
+#define DT_MIPS_GP_VALUE     0x70000030 /* GP value for aux GOTs.  */
+#define DT_MIPS_AUX_DYNAMIC  0x70000031 /* Address of aux .dynamic.  */
+#define DT_MIPS_NUM	     0x32
+
+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry.  */
+
+#define RHF_NONE		   0		/* No flags */
+#define RHF_QUICKSTART		   (1 << 0)	/* Use quickstart */
+#define RHF_NOTPOT		   (1 << 1)	/* Hash size not power of 2 */
+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)	/* Ignore LD_LIBRARY_PATH */
+#define RHF_NO_MOVE		   (1 << 3)
+#define RHF_SGI_ONLY		   (1 << 4)
+#define RHF_GUARANTEE_INIT	   (1 << 5)
+#define RHF_DELTA_C_PLUS_PLUS	   (1 << 6)
+#define RHF_GUARANTEE_START_INIT   (1 << 7)
+#define RHF_PIXIE		   (1 << 8)
+#define RHF_DEFAULT_DELAY_LOAD	   (1 << 9)
+#define RHF_REQUICKSTART	   (1 << 10)
+#define RHF_REQUICKSTARTED	   (1 << 11)
+#define RHF_CORD		   (1 << 12)
+#define RHF_NO_UNRES_UNDEF	   (1 << 13)
+#define RHF_RLD_ORDER_SAFE	   (1 << 14)
+
+/* Entries found in sections of type SHT_MIPS_LIBLIST.  */
+
+typedef struct
+{
+  Elf32_Word l_name;		/* Name (string table index) */
+  Elf32_Word l_time_stamp;	/* Timestamp */
+  Elf32_Word l_checksum;	/* Checksum */
+  Elf32_Word l_version;		/* Interface version */
+  Elf32_Word l_flags;		/* Flags */
+} Elf32_Lib;
+
+typedef struct
+{
+  Elf64_Word l_name;		/* Name (string table index) */
+  Elf64_Word l_time_stamp;	/* Timestamp */
+  Elf64_Word l_checksum;	/* Checksum */
+  Elf64_Word l_version;		/* Interface version */
+  Elf64_Word l_flags;		/* Flags */
+} Elf64_Lib;
+
+
+/* Legal values for l_flags.  */
+
+#define LL_NONE		  0
+#define LL_EXACT_MATCH	  (1 << 0)	/* Require exact match */
+#define LL_IGNORE_INT_VER (1 << 1)	/* Ignore interface version */
+#define LL_REQUIRE_MINOR  (1 << 2)
+#define LL_EXPORTS	  (1 << 3)
+#define LL_DELAY_LOAD	  (1 << 4)
+#define LL_DELTA	  (1 << 5)
+
+/* Entries found in sections of type SHT_MIPS_CONFLICT.  */
+
+typedef Elf32_Addr Elf32_Conflict;
+
+
+/* HPPA specific definitions.  */
+
+/* Legal values for e_flags field of Elf32_Ehdr.  */
+
+#define EF_PARISC_TRAPNIL	0x00010000 /* Trap nil pointer dereference.  */
+#define EF_PARISC_EXT		0x00020000 /* Program uses arch. extensions. */
+#define EF_PARISC_LSB		0x00040000 /* Program expects little endian. */
+#define EF_PARISC_WIDE		0x00080000 /* Program expects wide mode.  */
+#define EF_PARISC_NO_KABP	0x00100000 /* No kernel assisted branch
+					      prediction.  */
+#define EF_PARISC_LAZYSWAP	0x00400000 /* Allow lazy swapping.  */
+#define EF_PARISC_ARCH		0x0000ffff /* Architecture version.  */
+
+/* Defined values for `e_flags & EF_PARISC_ARCH' are:  */
+
+#define EFA_PARISC_1_0		    0x020b /* PA-RISC 1.0 big-endian.  */
+#define EFA_PARISC_1_1		    0x0210 /* PA-RISC 1.1 big-endian.  */
+#define EFA_PARISC_2_0		    0x0214 /* PA-RISC 2.0 big-endian.  */
+
+/* Additional section indeces.  */
+
+#define SHN_PARISC_ANSI_COMMON	0xff00	   /* Section for tenatively declared
+					      symbols in ANSI C.  */
+#define SHN_PARISC_HUGE_COMMON	0xff01	   /* Common blocks in huge model.  */
+
+/* Legal values for sh_type field of Elf32_Shdr.  */
+
+#define SHT_PARISC_EXT		0x70000000 /* Contains product specific ext. */
+#define SHT_PARISC_UNWIND	0x70000001 /* Unwind information.  */
+#define SHT_PARISC_DOC		0x70000002 /* Debug info for optimized code. */
+
+/* Legal values for sh_flags field of Elf32_Shdr.  */
+
+#define SHF_PARISC_SHORT	0x20000000 /* Section with short addressing. */
+#define SHF_PARISC_HUGE		0x40000000 /* Section far from gp.  */
+#define SHF_PARISC_SBP		0x80000000 /* Static branch prediction code. */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
+
+#define STT_PARISC_MILLICODE	13	/* Millicode function entry point.  */
+
+#define STT_HP_OPAQUE		(STT_LOOS + 0x1)
+#define STT_HP_STUB		(STT_LOOS + 0x2)
+
+/* HPPA relocs.  */
+
+#define R_PARISC_NONE		0	/* No reloc.  */
+#define R_PARISC_DIR32		1	/* Direct 32-bit reference.  */
+#define R_PARISC_DIR21L		2	/* Left 21 bits of eff. address.  */
+#define R_PARISC_DIR17R		3	/* Right 17 bits of eff. address.  */
+#define R_PARISC_DIR17F		4	/* 17 bits of eff. address.  */
+#define R_PARISC_DIR14R		6	/* Right 14 bits of eff. address.  */
+#define R_PARISC_PCREL32	9	/* 32-bit rel. address.  */
+#define R_PARISC_PCREL21L	10	/* Left 21 bits of rel. address.  */
+#define R_PARISC_PCREL17R	11	/* Right 17 bits of rel. address.  */
+#define R_PARISC_PCREL17F	12	/* 17 bits of rel. address.  */
+#define R_PARISC_PCREL14R	14	/* Right 14 bits of rel. address.  */
+#define R_PARISC_DPREL21L	18	/* Left 21 bits of rel. address.  */
+#define R_PARISC_DPREL14R	22	/* Right 14 bits of rel. address.  */
+#define R_PARISC_GPREL21L	26	/* GP-relative, left 21 bits.  */
+#define R_PARISC_GPREL14R	30	/* GP-relative, right 14 bits.  */
+#define R_PARISC_LTOFF21L	34	/* LT-relative, left 21 bits.  */
+#define R_PARISC_LTOFF14R	38	/* LT-relative, right 14 bits.  */
+#define R_PARISC_SECREL32	41	/* 32 bits section rel. address.  */
+#define R_PARISC_SEGBASE	48	/* No relocation, set segment base.  */
+#define R_PARISC_SEGREL32	49	/* 32 bits segment rel. address.  */
+#define R_PARISC_PLTOFF21L	50	/* PLT rel. address, left 21 bits.  */
+#define R_PARISC_PLTOFF14R	54	/* PLT rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF_FPTR32	57	/* 32 bits LT-rel. function pointer. */
+#define R_PARISC_LTOFF_FPTR21L	58	/* LT-rel. fct ptr, left 21 bits. */
+#define R_PARISC_LTOFF_FPTR14R	62	/* LT-rel. fct ptr, right 14 bits. */
+#define R_PARISC_FPTR64		64	/* 64 bits function address.  */
+#define R_PARISC_PLABEL32	65	/* 32 bits function address.  */
+#define R_PARISC_PCREL64	72	/* 64 bits PC-rel. address.  */
+#define R_PARISC_PCREL22F	74	/* 22 bits PC-rel. address.  */
+#define R_PARISC_PCREL14WR	75	/* PC-rel. address, right 14 bits.  */
+#define R_PARISC_PCREL14DR	76	/* PC rel. address, right 14 bits.  */
+#define R_PARISC_PCREL16F	77	/* 16 bits PC-rel. address.  */
+#define R_PARISC_PCREL16WF	78	/* 16 bits PC-rel. address.  */
+#define R_PARISC_PCREL16DF	79	/* 16 bits PC-rel. address.  */
+#define R_PARISC_DIR64		80	/* 64 bits of eff. address.  */
+#define R_PARISC_DIR14WR	83	/* 14 bits of eff. address.  */
+#define R_PARISC_DIR14DR	84	/* 14 bits of eff. address.  */
+#define R_PARISC_DIR16F		85	/* 16 bits of eff. address.  */
+#define R_PARISC_DIR16WF	86	/* 16 bits of eff. address.  */
+#define R_PARISC_DIR16DF	87	/* 16 bits of eff. address.  */
+#define R_PARISC_GPREL64	88	/* 64 bits of GP-rel. address.  */
+#define R_PARISC_GPREL14WR	91	/* GP-rel. address, right 14 bits.  */
+#define R_PARISC_GPREL14DR	92	/* GP-rel. address, right 14 bits.  */
+#define R_PARISC_GPREL16F	93	/* 16 bits GP-rel. address.  */
+#define R_PARISC_GPREL16WF	94	/* 16 bits GP-rel. address.  */
+#define R_PARISC_GPREL16DF	95	/* 16 bits GP-rel. address.  */
+#define R_PARISC_LTOFF64	96	/* 64 bits LT-rel. address.  */
+#define R_PARISC_LTOFF14WR	99	/* LT-rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF14DR	100	/* LT-rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF16F	101	/* 16 bits LT-rel. address.  */
+#define R_PARISC_LTOFF16WF	102	/* 16 bits LT-rel. address.  */
+#define R_PARISC_LTOFF16DF	103	/* 16 bits LT-rel. address.  */
+#define R_PARISC_SECREL64	104	/* 64 bits section rel. address.  */
+#define R_PARISC_SEGREL64	112	/* 64 bits segment rel. address.  */
+#define R_PARISC_PLTOFF14WR	115	/* PLT-rel. address, right 14 bits.  */
+#define R_PARISC_PLTOFF14DR	116	/* PLT-rel. address, right 14 bits.  */
+#define R_PARISC_PLTOFF16F	117	/* 16 bits LT-rel. address.  */
+#define R_PARISC_PLTOFF16WF	118	/* 16 bits PLT-rel. address.  */
+#define R_PARISC_PLTOFF16DF	119	/* 16 bits PLT-rel. address.  */
+#define R_PARISC_LTOFF_FPTR64	120	/* 64 bits LT-rel. function ptr.  */
+#define R_PARISC_LTOFF_FPTR14WR	123	/* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR14DR	124	/* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR16F	125	/* 16 bits LT-rel. function ptr.  */
+#define R_PARISC_LTOFF_FPTR16WF	126	/* 16 bits LT-rel. function ptr.  */
+#define R_PARISC_LTOFF_FPTR16DF	127	/* 16 bits LT-rel. function ptr.  */
+#define R_PARISC_LORESERVE	128
+#define R_PARISC_COPY		128	/* Copy relocation.  */
+#define R_PARISC_IPLT		129	/* Dynamic reloc, imported PLT */
+#define R_PARISC_EPLT		130	/* Dynamic reloc, exported PLT */
+#define R_PARISC_TPREL32	153	/* 32 bits TP-rel. address.  */
+#define R_PARISC_TPREL21L	154	/* TP-rel. address, left 21 bits.  */
+#define R_PARISC_TPREL14R	158	/* TP-rel. address, right 14 bits.  */
+#define R_PARISC_LTOFF_TP21L	162	/* LT-TP-rel. address, left 21 bits. */
+#define R_PARISC_LTOFF_TP14R	166	/* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14F	167	/* 14 bits LT-TP-rel. address.  */
+#define R_PARISC_TPREL64	216	/* 64 bits TP-rel. address.  */
+#define R_PARISC_TPREL14WR	219	/* TP-rel. address, right 14 bits.  */
+#define R_PARISC_TPREL14DR	220	/* TP-rel. address, right 14 bits.  */
+#define R_PARISC_TPREL16F	221	/* 16 bits TP-rel. address.  */
+#define R_PARISC_TPREL16WF	222	/* 16 bits TP-rel. address.  */
+#define R_PARISC_TPREL16DF	223	/* 16 bits TP-rel. address.  */
+#define R_PARISC_LTOFF_TP64	224	/* 64 bits LT-TP-rel. address.  */
+#define R_PARISC_LTOFF_TP14WR	227	/* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14DR	228	/* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP16F	229	/* 16 bits LT-TP-rel. address.  */
+#define R_PARISC_LTOFF_TP16WF	230	/* 16 bits LT-TP-rel. address.  */
+#define R_PARISC_LTOFF_TP16DF	231	/* 16 bits LT-TP-rel. address.  */
+#define R_PARISC_HIRESERVE	255
+
+/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr.  */
+
+#define PT_HP_TLS		(PT_LOOS + 0x0)
+#define PT_HP_CORE_NONE		(PT_LOOS + 0x1)
+#define PT_HP_CORE_VERSION	(PT_LOOS + 0x2)
+#define PT_HP_CORE_KERNEL	(PT_LOOS + 0x3)
+#define PT_HP_CORE_COMM		(PT_LOOS + 0x4)
+#define PT_HP_CORE_PROC		(PT_LOOS + 0x5)
+#define PT_HP_CORE_LOADABLE	(PT_LOOS + 0x6)
+#define PT_HP_CORE_STACK	(PT_LOOS + 0x7)
+#define PT_HP_CORE_SHM		(PT_LOOS + 0x8)
+#define PT_HP_CORE_MMF		(PT_LOOS + 0x9)
+#define PT_HP_PARALLEL		(PT_LOOS + 0x10)
+#define PT_HP_FASTBIND		(PT_LOOS + 0x11)
+#define PT_HP_OPT_ANNOT		(PT_LOOS + 0x12)
+#define PT_HP_HSL_ANNOT		(PT_LOOS + 0x13)
+#define PT_HP_STACK		(PT_LOOS + 0x14)
+
+#define PT_PARISC_ARCHEXT	0x70000000
+#define PT_PARISC_UNWIND	0x70000001
+
+/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr.  */
+
+#define PF_PARISC_SBP		0x08000000
+
+#define PF_HP_PAGE_SIZE		0x00100000
+#define PF_HP_FAR_SHARED	0x00200000
+#define PF_HP_NEAR_SHARED	0x00400000
+#define PF_HP_CODE		0x01000000
+#define PF_HP_MODIFY		0x02000000
+#define PF_HP_LAZYSWAP		0x04000000
+#define PF_HP_SBP		0x08000000
+
+
+/* Alpha specific definitions.  */
+
+/* Legal values for e_flags field of Elf64_Ehdr.  */
+
+#define EF_ALPHA_32BIT		1	/* All addresses must be < 2GB.  */
+#define EF_ALPHA_CANRELAX	2	/* Relocations for relaxing exist.  */
+
+/* Legal values for sh_type field of Elf64_Shdr.  */
+
+/* These two are primerily concerned with ECOFF debugging info.  */
+#define SHT_ALPHA_DEBUG		0x70000001
+#define SHT_ALPHA_REGINFO	0x70000002
+
+/* Legal values for sh_flags field of Elf64_Shdr.  */
+
+#define SHF_ALPHA_GPREL		0x10000000
+
+/* Legal values for st_other field of Elf64_Sym.  */
+#define STO_ALPHA_NOPV		0x80	/* No PV required.  */
+#define STO_ALPHA_STD_GPLOAD	0x88	/* PV only used for initial ldgp.  */
+
+/* Alpha relocs.  */
+
+#define R_ALPHA_NONE		0	/* No reloc */
+#define R_ALPHA_REFLONG		1	/* Direct 32 bit */
+#define R_ALPHA_REFQUAD		2	/* Direct 64 bit */
+#define R_ALPHA_GPREL32		3	/* GP relative 32 bit */
+#define R_ALPHA_LITERAL		4	/* GP relative 16 bit w/optimization */
+#define R_ALPHA_LITUSE		5	/* Optimization hint for LITERAL */
+#define R_ALPHA_GPDISP		6	/* Add displacement to GP */
+#define R_ALPHA_BRADDR		7	/* PC+4 relative 23 bit shifted */
+#define R_ALPHA_HINT		8	/* PC+4 relative 16 bit shifted */
+#define R_ALPHA_SREL16		9	/* PC relative 16 bit */
+#define R_ALPHA_SREL32		10	/* PC relative 32 bit */
+#define R_ALPHA_SREL64		11	/* PC relative 64 bit */
+#define R_ALPHA_GPRELHIGH	17	/* GP relative 32 bit, high 16 bits */
+#define R_ALPHA_GPRELLOW	18	/* GP relative 32 bit, low 16 bits */
+#define R_ALPHA_GPREL16		19	/* GP relative 16 bit */
+#define R_ALPHA_COPY		24	/* Copy symbol at runtime */
+#define R_ALPHA_GLOB_DAT	25	/* Create GOT entry */
+#define R_ALPHA_JMP_SLOT	26	/* Create PLT entry */
+#define R_ALPHA_RELATIVE	27	/* Adjust by program base */
+#define R_ALPHA_TLS_GD_HI	28
+#define R_ALPHA_TLSGD		29
+#define R_ALPHA_TLS_LDM		30
+#define R_ALPHA_DTPMOD64	31
+#define R_ALPHA_GOTDTPREL	32
+#define R_ALPHA_DTPREL64	33
+#define R_ALPHA_DTPRELHI	34
+#define R_ALPHA_DTPRELLO	35
+#define R_ALPHA_DTPREL16	36
+#define R_ALPHA_GOTTPREL	37
+#define R_ALPHA_TPREL64		38
+#define R_ALPHA_TPRELHI		39
+#define R_ALPHA_TPRELLO		40
+#define R_ALPHA_TPREL16		41
+/* Keep this the last entry.  */
+#define R_ALPHA_NUM		46
+
+/* Magic values of the LITUSE relocation addend.  */
+#define LITUSE_ALPHA_ADDR	0
+#define LITUSE_ALPHA_BASE	1
+#define LITUSE_ALPHA_BYTOFF	2
+#define LITUSE_ALPHA_JSR	3
+#define LITUSE_ALPHA_TLS_GD	4
+#define LITUSE_ALPHA_TLS_LDM	5
+
+/* Legal values for d_tag of Elf64_Dyn.  */
+#define DT_ALPHA_PLTRO		(DT_LOPROC + 0)
+#define DT_ALPHA_NUM		1
+
+/* PowerPC specific declarations */
+
+/* Values for Elf32/64_Ehdr.e_flags.  */
+#define EF_PPC_EMB		0x80000000	/* PowerPC embedded flag */
+
+/* Cygnus local bits below */
+#define EF_PPC_RELOCATABLE	0x00010000	/* PowerPC -mrelocatable flag*/
+#define EF_PPC_RELOCATABLE_LIB	0x00008000	/* PowerPC -mrelocatable-lib
+						   flag */
+
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE		0
+#define R_PPC_ADDR32		1	/* 32bit absolute address */
+#define R_PPC_ADDR24		2	/* 26bit address, 2 bits ignored.  */
+#define R_PPC_ADDR16		3	/* 16bit absolute address */
+#define R_PPC_ADDR16_LO		4	/* lower 16bit of absolute address */
+#define R_PPC_ADDR16_HI		5	/* high 16bit of absolute address */
+#define R_PPC_ADDR16_HA		6	/* adjusted high 16bit */
+#define R_PPC_ADDR14		7	/* 16bit address, 2 bits ignored */
+#define R_PPC_ADDR14_BRTAKEN	8
+#define R_PPC_ADDR14_BRNTAKEN	9
+#define R_PPC_REL24		10	/* PC relative 26 bit */
+#define R_PPC_REL14		11	/* PC relative 16 bit */
+#define R_PPC_REL14_BRTAKEN	12
+#define R_PPC_REL14_BRNTAKEN	13
+#define R_PPC_GOT16		14
+#define R_PPC_GOT16_LO		15
+#define R_PPC_GOT16_HI		16
+#define R_PPC_GOT16_HA		17
+#define R_PPC_PLTREL24		18
+#define R_PPC_COPY		19
+#define R_PPC_GLOB_DAT		20
+#define R_PPC_JMP_SLOT		21
+#define R_PPC_RELATIVE		22
+#define R_PPC_LOCAL24PC		23
+#define R_PPC_UADDR32		24
+#define R_PPC_UADDR16		25
+#define R_PPC_REL32		26
+#define R_PPC_PLT32		27
+#define R_PPC_PLTREL32		28
+#define R_PPC_PLT16_LO		29
+#define R_PPC_PLT16_HI		30
+#define R_PPC_PLT16_HA		31
+#define R_PPC_SDAREL16		32
+#define R_PPC_SECTOFF		33
+#define R_PPC_SECTOFF_LO	34
+#define R_PPC_SECTOFF_HI	35
+#define R_PPC_SECTOFF_HA	36
+
+/* PowerPC relocations defined for the TLS access ABI.  */
+#define R_PPC_TLS		67 /* none	(sym+add)@tls */
+#define R_PPC_DTPMOD32		68 /* word32	(sym+add)@dtpmod */
+#define R_PPC_TPREL16		69 /* half16*	(sym+add)@tprel */
+#define R_PPC_TPREL16_LO	70 /* half16	(sym+add)@tprel@l */
+#define R_PPC_TPREL16_HI	71 /* half16	(sym+add)@tprel@h */
+#define R_PPC_TPREL16_HA	72 /* half16	(sym+add)@tprel@ha */
+#define R_PPC_TPREL32		73 /* word32	(sym+add)@tprel */
+#define R_PPC_DTPREL16		74 /* half16*	(sym+add)@dtprel */
+#define R_PPC_DTPREL16_LO	75 /* half16	(sym+add)@dtprel@l */
+#define R_PPC_DTPREL16_HI	76 /* half16	(sym+add)@dtprel@h */
+#define R_PPC_DTPREL16_HA	77 /* half16	(sym+add)@dtprel@ha */
+#define R_PPC_DTPREL32		78 /* word32	(sym+add)@dtprel */
+#define R_PPC_GOT_TLSGD16	79 /* half16*	(sym+add)@got@tlsgd */
+#define R_PPC_GOT_TLSGD16_LO	80 /* half16	(sym+add)@got@tlsgd@l */
+#define R_PPC_GOT_TLSGD16_HI	81 /* half16	(sym+add)@got@tlsgd@h */
+#define R_PPC_GOT_TLSGD16_HA	82 /* half16	(sym+add)@got@tlsgd@ha */
+#define R_PPC_GOT_TLSLD16	83 /* half16*	(sym+add)@got@tlsld */
+#define R_PPC_GOT_TLSLD16_LO	84 /* half16	(sym+add)@got@tlsld@l */
+#define R_PPC_GOT_TLSLD16_HI	85 /* half16	(sym+add)@got@tlsld@h */
+#define R_PPC_GOT_TLSLD16_HA	86 /* half16	(sym+add)@got@tlsld@ha */
+#define R_PPC_GOT_TPREL16	87 /* half16*	(sym+add)@got@tprel */
+#define R_PPC_GOT_TPREL16_LO	88 /* half16	(sym+add)@got@tprel@l */
+#define R_PPC_GOT_TPREL16_HI	89 /* half16	(sym+add)@got@tprel@h */
+#define R_PPC_GOT_TPREL16_HA	90 /* half16	(sym+add)@got@tprel@ha */
+#define R_PPC_GOT_DTPREL16	91 /* half16*	(sym+add)@got@dtprel */
+#define R_PPC_GOT_DTPREL16_LO	92 /* half16*	(sym+add)@got@dtprel@l */
+#define R_PPC_GOT_DTPREL16_HI	93 /* half16*	(sym+add)@got@dtprel@h */
+#define R_PPC_GOT_DTPREL16_HA	94 /* half16*	(sym+add)@got@dtprel@ha */
+
+/* Keep this the last entry.  */
+#define R_PPC_NUM		95
+
+/* The remaining relocs are from the Embedded ELF ABI, and are not
+   in the SVR4 ELF ABI.  */
+#define R_PPC_EMB_NADDR32	101
+#define R_PPC_EMB_NADDR16	102
+#define R_PPC_EMB_NADDR16_LO	103
+#define R_PPC_EMB_NADDR16_HI	104
+#define R_PPC_EMB_NADDR16_HA	105
+#define R_PPC_EMB_SDAI16	106
+#define R_PPC_EMB_SDA2I16	107
+#define R_PPC_EMB_SDA2REL	108
+#define R_PPC_EMB_SDA21		109	/* 16 bit offset in SDA */
+#define R_PPC_EMB_MRKREF	110
+#define R_PPC_EMB_RELSEC16	111
+#define R_PPC_EMB_RELST_LO	112
+#define R_PPC_EMB_RELST_HI	113
+#define R_PPC_EMB_RELST_HA	114
+#define R_PPC_EMB_BIT_FLD	115
+#define R_PPC_EMB_RELSDA	116	/* 16 bit relative offset in SDA */
+
+/* Diab tool relocations.  */
+#define R_PPC_DIAB_SDA21_LO	180	/* like EMB_SDA21, but lower 16 bit */
+#define R_PPC_DIAB_SDA21_HI	181	/* like EMB_SDA21, but high 16 bit */
+#define R_PPC_DIAB_SDA21_HA	182	/* like EMB_SDA21, adjusted high 16 */
+#define R_PPC_DIAB_RELSDA_LO	183	/* like EMB_RELSDA, but lower 16 bit */
+#define R_PPC_DIAB_RELSDA_HI	184	/* like EMB_RELSDA, but high 16 bit */
+#define R_PPC_DIAB_RELSDA_HA	185	/* like EMB_RELSDA, adjusted high 16 */
+
+/* GNU relocs used in PIC code sequences.  */
+#define R_PPC_REL16		249	/* word32   (sym-.) */
+#define R_PPC_REL16_LO		250	/* half16   (sym-.)@l */
+#define R_PPC_REL16_HI		251	/* half16   (sym-.)@h */
+#define R_PPC_REL16_HA		252	/* half16   (sym-.)@ha */
+
+/* This is a phony reloc to handle any old fashioned TOC16 references
+   that may still be in object files.  */
+#define R_PPC_TOC16		255
+
+/* PowerPC specific values for the Dyn d_tag field.  */
+#define DT_PPC_GOT		(DT_LOPROC + 0)
+#define DT_PPC_NUM		1
+
+/* PowerPC64 relocations defined by the ABIs */
+#define R_PPC64_NONE		R_PPC_NONE
+#define R_PPC64_ADDR32		R_PPC_ADDR32 /* 32bit absolute address */
+#define R_PPC64_ADDR24		R_PPC_ADDR24 /* 26bit address, word aligned */
+#define R_PPC64_ADDR16		R_PPC_ADDR16 /* 16bit absolute address */
+#define R_PPC64_ADDR16_LO	R_PPC_ADDR16_LO	/* lower 16bits of address */
+#define R_PPC64_ADDR16_HI	R_PPC_ADDR16_HI	/* high 16bits of address. */
+#define R_PPC64_ADDR16_HA	R_PPC_ADDR16_HA /* adjusted high 16bits.  */
+#define R_PPC64_ADDR14		R_PPC_ADDR14 /* 16bit address, word aligned */
+#define R_PPC64_ADDR14_BRTAKEN	R_PPC_ADDR14_BRTAKEN
+#define R_PPC64_ADDR14_BRNTAKEN	R_PPC_ADDR14_BRNTAKEN
+#define R_PPC64_REL24		R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
+#define R_PPC64_REL14		R_PPC_REL14 /* PC relative 16 bit */
+#define R_PPC64_REL14_BRTAKEN	R_PPC_REL14_BRTAKEN
+#define R_PPC64_REL14_BRNTAKEN	R_PPC_REL14_BRNTAKEN
+#define R_PPC64_GOT16		R_PPC_GOT16
+#define R_PPC64_GOT16_LO	R_PPC_GOT16_LO
+#define R_PPC64_GOT16_HI	R_PPC_GOT16_HI
+#define R_PPC64_GOT16_HA	R_PPC_GOT16_HA
+
+#define R_PPC64_COPY		R_PPC_COPY
+#define R_PPC64_GLOB_DAT	R_PPC_GLOB_DAT
+#define R_PPC64_JMP_SLOT	R_PPC_JMP_SLOT
+#define R_PPC64_RELATIVE	R_PPC_RELATIVE
+
+#define R_PPC64_UADDR32		R_PPC_UADDR32
+#define R_PPC64_UADDR16		R_PPC_UADDR16
+#define R_PPC64_REL32		R_PPC_REL32
+#define R_PPC64_PLT32		R_PPC_PLT32
+#define R_PPC64_PLTREL32	R_PPC_PLTREL32
+#define R_PPC64_PLT16_LO	R_PPC_PLT16_LO
+#define R_PPC64_PLT16_HI	R_PPC_PLT16_HI
+#define R_PPC64_PLT16_HA	R_PPC_PLT16_HA
+
+#define R_PPC64_SECTOFF		R_PPC_SECTOFF
+#define R_PPC64_SECTOFF_LO	R_PPC_SECTOFF_LO
+#define R_PPC64_SECTOFF_HI	R_PPC_SECTOFF_HI
+#define R_PPC64_SECTOFF_HA	R_PPC_SECTOFF_HA
+#define R_PPC64_ADDR30		37 /* word30 (S + A - P) >> 2 */
+#define R_PPC64_ADDR64		38 /* doubleword64 S + A */
+#define R_PPC64_ADDR16_HIGHER	39 /* half16 #higher(S + A) */
+#define R_PPC64_ADDR16_HIGHERA	40 /* half16 #highera(S + A) */
+#define R_PPC64_ADDR16_HIGHEST	41 /* half16 #highest(S + A) */
+#define R_PPC64_ADDR16_HIGHESTA	42 /* half16 #highesta(S + A) */
+#define R_PPC64_UADDR64		43 /* doubleword64 S + A */
+#define R_PPC64_REL64		44 /* doubleword64 S + A - P */
+#define R_PPC64_PLT64		45 /* doubleword64 L + A */
+#define R_PPC64_PLTREL64	46 /* doubleword64 L + A - P */
+#define R_PPC64_TOC16		47 /* half16* S + A - .TOC */
+#define R_PPC64_TOC16_LO	48 /* half16 #lo(S + A - .TOC.) */
+#define R_PPC64_TOC16_HI	49 /* half16 #hi(S + A - .TOC.) */
+#define R_PPC64_TOC16_HA	50 /* half16 #ha(S + A - .TOC.) */
+#define R_PPC64_TOC		51 /* doubleword64 .TOC */
+#define R_PPC64_PLTGOT16	52 /* half16* M + A */
+#define R_PPC64_PLTGOT16_LO	53 /* half16 #lo(M + A) */
+#define R_PPC64_PLTGOT16_HI	54 /* half16 #hi(M + A) */
+#define R_PPC64_PLTGOT16_HA	55 /* half16 #ha(M + A) */
+
+#define R_PPC64_ADDR16_DS	56 /* half16ds* (S + A) >> 2 */
+#define R_PPC64_ADDR16_LO_DS	57 /* half16ds  #lo(S + A) >> 2 */
+#define R_PPC64_GOT16_DS	58 /* half16ds* (G + A) >> 2 */
+#define R_PPC64_GOT16_LO_DS	59 /* half16ds  #lo(G + A) >> 2 */
+#define R_PPC64_PLT16_LO_DS	60 /* half16ds  #lo(L + A) >> 2 */
+#define R_PPC64_SECTOFF_DS	61 /* half16ds* (R + A) >> 2 */
+#define R_PPC64_SECTOFF_LO_DS	62 /* half16ds  #lo(R + A) >> 2 */
+#define R_PPC64_TOC16_DS	63 /* half16ds* (S + A - .TOC.) >> 2 */
+#define R_PPC64_TOC16_LO_DS	64 /* half16ds  #lo(S + A - .TOC.) >> 2 */
+#define R_PPC64_PLTGOT16_DS	65 /* half16ds* (M + A) >> 2 */
+#define R_PPC64_PLTGOT16_LO_DS	66 /* half16ds  #lo(M + A) >> 2 */
+
+/* PowerPC64 relocations defined for the TLS access ABI.  */
+#define R_PPC64_TLS		67 /* none	(sym+add)@tls */
+#define R_PPC64_DTPMOD64	68 /* doubleword64 (sym+add)@dtpmod */
+#define R_PPC64_TPREL16		69 /* half16*	(sym+add)@tprel */
+#define R_PPC64_TPREL16_LO	70 /* half16	(sym+add)@tprel@l */
+#define R_PPC64_TPREL16_HI	71 /* half16	(sym+add)@tprel@h */
+#define R_PPC64_TPREL16_HA	72 /* half16	(sym+add)@tprel@ha */
+#define R_PPC64_TPREL64		73 /* doubleword64 (sym+add)@tprel */
+#define R_PPC64_DTPREL16	74 /* half16*	(sym+add)@dtprel */
+#define R_PPC64_DTPREL16_LO	75 /* half16	(sym+add)@dtprel@l */
+#define R_PPC64_DTPREL16_HI	76 /* half16	(sym+add)@dtprel@h */
+#define R_PPC64_DTPREL16_HA	77 /* half16	(sym+add)@dtprel@ha */
+#define R_PPC64_DTPREL64	78 /* doubleword64 (sym+add)@dtprel */
+#define R_PPC64_GOT_TLSGD16	79 /* half16*	(sym+add)@got@tlsgd */
+#define R_PPC64_GOT_TLSGD16_LO	80 /* half16	(sym+add)@got@tlsgd@l */
+#define R_PPC64_GOT_TLSGD16_HI	81 /* half16	(sym+add)@got@tlsgd@h */
+#define R_PPC64_GOT_TLSGD16_HA	82 /* half16	(sym+add)@got@tlsgd@ha */
+#define R_PPC64_GOT_TLSLD16	83 /* half16*	(sym+add)@got@tlsld */
+#define R_PPC64_GOT_TLSLD16_LO	84 /* half16	(sym+add)@got@tlsld@l */
+#define R_PPC64_GOT_TLSLD16_HI	85 /* half16	(sym+add)@got@tlsld@h */
+#define R_PPC64_GOT_TLSLD16_HA	86 /* half16	(sym+add)@got@tlsld@ha */
+#define R_PPC64_GOT_TPREL16_DS	87 /* half16ds*	(sym+add)@got@tprel */
+#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
+#define R_PPC64_GOT_TPREL16_HI	89 /* half16	(sym+add)@got@tprel@h */
+#define R_PPC64_GOT_TPREL16_HA	90 /* half16	(sym+add)@got@tprel@ha */
+#define R_PPC64_GOT_DTPREL16_DS	91 /* half16ds*	(sym+add)@got@dtprel */
+#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
+#define R_PPC64_GOT_DTPREL16_HI	93 /* half16	(sym+add)@got@dtprel@h */
+#define R_PPC64_GOT_DTPREL16_HA	94 /* half16	(sym+add)@got@dtprel@ha */
+#define R_PPC64_TPREL16_DS	95 /* half16ds*	(sym+add)@tprel */
+#define R_PPC64_TPREL16_LO_DS	96 /* half16ds	(sym+add)@tprel@l */
+#define R_PPC64_TPREL16_HIGHER	97 /* half16	(sym+add)@tprel@higher */
+#define R_PPC64_TPREL16_HIGHERA	98 /* half16	(sym+add)@tprel@highera */
+#define R_PPC64_TPREL16_HIGHEST	99 /* half16	(sym+add)@tprel@highest */
+#define R_PPC64_TPREL16_HIGHESTA 100 /* half16	(sym+add)@tprel@highesta */
+#define R_PPC64_DTPREL16_DS	101 /* half16ds* (sym+add)@dtprel */
+#define R_PPC64_DTPREL16_LO_DS	102 /* half16ds	(sym+add)@dtprel@l */
+#define R_PPC64_DTPREL16_HIGHER	103 /* half16	(sym+add)@dtprel@higher */
+#define R_PPC64_DTPREL16_HIGHERA 104 /* half16	(sym+add)@dtprel@highera */
+#define R_PPC64_DTPREL16_HIGHEST 105 /* half16	(sym+add)@dtprel@highest */
+#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16	(sym+add)@dtprel@highesta */
+
+/* Keep this the last entry.  */
+#define R_PPC64_NUM		107
+
+/* PowerPC64 specific values for the Dyn d_tag field.  */
+#define DT_PPC64_GLINK  (DT_LOPROC + 0)
+#define DT_PPC64_OPD	(DT_LOPROC + 1)
+#define DT_PPC64_OPDSZ	(DT_LOPROC + 2)
+#define DT_PPC64_NUM    3
+
+
+/* ARM specific declarations */
+
+/* Processor specific flags for the ELF header e_flags field.  */
+#define EF_ARM_RELEXEC     0x01
+#define EF_ARM_HASENTRY    0x02
+#define EF_ARM_INTERWORK   0x04
+#define EF_ARM_APCS_26     0x08
+#define EF_ARM_APCS_FLOAT  0x10
+#define EF_ARM_PIC         0x20
+#define EF_ARM_ALIGN8      0x40		/* 8-bit structure alignment is in use */
+#define EF_ARM_NEW_ABI     0x80
+#define EF_ARM_OLD_ABI     0x100
+
+/* Other constants defined in the ARM ELF spec. version B-01.  */
+/* NB. These conflict with values defined above.  */
+#define EF_ARM_SYMSARESORTED	0x04
+#define EF_ARM_DYNSYMSUSESEGIDX 0x08
+#define EF_ARM_MAPSYMSFIRST	0x10
+#define EF_ARM_EABIMASK		0XFF000000
+
+#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
+#define EF_ARM_EABI_UNKNOWN  0x00000000
+#define EF_ARM_EABI_VER1     0x01000000
+#define EF_ARM_EABI_VER2     0x02000000
+
+/* Additional symbol types for Thumb */
+#define STT_ARM_TFUNC      0xd
+
+/* ARM-specific values for sh_flags */
+#define SHF_ARM_ENTRYSECT  0x10000000   /* Section contains an entry point */
+#define SHF_ARM_COMDEF     0x80000000   /* Section may be multiply defined
+					   in the input to a link step */
+
+/* ARM-specific program header flags */
+#define PF_ARM_SB          0x10000000   /* Segment contains the location
+					   addressed by the static base */
+
+/* Processor specific values for the Phdr p_type field.  */
+#define PT_ARM_EXIDX	0x70000001	/* .ARM.exidx segment */
+
+/* ARM relocs.  */
+
+#define R_ARM_NONE		0	/* No reloc */
+#define R_ARM_PC24		1	/* PC relative 26 bit branch */
+#define R_ARM_ABS32		2	/* Direct 32 bit  */
+#define R_ARM_REL32		3	/* PC relative 32 bit */
+#define R_ARM_PC13		4
+#define R_ARM_ABS16		5	/* Direct 16 bit */
+#define R_ARM_ABS12		6	/* Direct 12 bit */
+#define R_ARM_THM_ABS5		7
+#define R_ARM_ABS8		8	/* Direct 8 bit */
+#define R_ARM_SBREL32		9
+#define R_ARM_THM_PC22		10
+#define R_ARM_THM_PC8		11
+#define R_ARM_AMP_VCALL9	12
+#define R_ARM_SWI24		13
+#define R_ARM_THM_SWI8		14
+#define R_ARM_XPC25		15
+#define R_ARM_THM_XPC22		16
+#define R_ARM_TLS_DTPMOD32	17	/* ID of module containing symbol */
+#define R_ARM_TLS_DTPOFF32	18	/* Offset in TLS block */
+#define R_ARM_TLS_TPOFF32	19	/* Offset in static TLS block */
+#define R_ARM_COPY		20	/* Copy symbol at runtime */
+#define R_ARM_GLOB_DAT		21	/* Create GOT entry */
+#define R_ARM_JUMP_SLOT		22	/* Create PLT entry */
+#define R_ARM_RELATIVE		23	/* Adjust by program base */
+#define R_ARM_GOTOFF		24	/* 32 bit offset to GOT */
+#define R_ARM_GOTPC		25	/* 32 bit PC relative offset to GOT */
+#define R_ARM_GOT32		26	/* 32 bit GOT entry */
+#define R_ARM_PLT32		27	/* 32 bit PLT address */
+#define R_ARM_ALU_PCREL_7_0	32
+#define R_ARM_ALU_PCREL_15_8	33
+#define R_ARM_ALU_PCREL_23_15	34
+#define R_ARM_LDR_SBREL_11_0	35
+#define R_ARM_ALU_SBREL_19_12	36
+#define R_ARM_ALU_SBREL_27_20	37
+#define R_ARM_GNU_VTENTRY	100
+#define R_ARM_GNU_VTINHERIT	101
+#define R_ARM_THM_PC11		102	/* thumb unconditional branch */
+#define R_ARM_THM_PC9		103	/* thumb conditional branch */
+#define R_ARM_TLS_GD32		104	/* PC-rel 32 bit for global dynamic
+					   thread local data */
+#define R_ARM_TLS_LDM32		105	/* PC-rel 32 bit for local dynamic
+					   thread local data */
+#define R_ARM_TLS_LDO32		106	/* 32 bit offset relative to TLS
+					   block */
+#define R_ARM_TLS_IE32		107	/* PC-rel 32 bit for GOT entry of
+					   static TLS block offset */
+#define R_ARM_TLS_LE32		108	/* 32 bit offset relative to static
+					   TLS block */
+#define R_ARM_RXPC25		249
+#define R_ARM_RSBREL32		250
+#define R_ARM_THM_RPC22		251
+#define R_ARM_RREL32		252
+#define R_ARM_RABS22		253
+#define R_ARM_RPC24		254
+#define R_ARM_RBASE		255
+/* Keep this the last entry.  */
+#define R_ARM_NUM		256
+
+/* IA-64 specific declarations.  */
+
+/* Processor specific flags for the Ehdr e_flags field.  */
+#define EF_IA_64_MASKOS		0x0000000f	/* os-specific flags */
+#define EF_IA_64_ABI64		0x00000010	/* 64-bit ABI */
+#define EF_IA_64_ARCH		0xff000000	/* arch. version mask */
+
+/* Processor specific values for the Phdr p_type field.  */
+#define PT_IA_64_ARCHEXT	(PT_LOPROC + 0)	/* arch extension bits */
+#define PT_IA_64_UNWIND		(PT_LOPROC + 1)	/* ia64 unwind bits */
+#define PT_IA_64_HP_OPT_ANOT	(PT_LOOS + 0x12)
+#define PT_IA_64_HP_HSL_ANOT	(PT_LOOS + 0x13)
+#define PT_IA_64_HP_STACK	(PT_LOOS + 0x14)
+
+/* Processor specific flags for the Phdr p_flags field.  */
+#define PF_IA_64_NORECOV	0x80000000	/* spec insns w/o recovery */
+
+/* Processor specific values for the Shdr sh_type field.  */
+#define SHT_IA_64_EXT		(SHT_LOPROC + 0) /* extension bits */
+#define SHT_IA_64_UNWIND	(SHT_LOPROC + 1) /* unwind bits */
+
+/* Processor specific flags for the Shdr sh_flags field.  */
+#define SHF_IA_64_SHORT		0x10000000	/* section near gp */
+#define SHF_IA_64_NORECOV	0x20000000	/* spec insns w/o recovery */
+
+/* Processor specific values for the Dyn d_tag field.  */
+#define DT_IA_64_PLT_RESERVE	(DT_LOPROC + 0)
+#define DT_IA_64_NUM		1
+
+/* IA-64 relocations.  */
+#define R_IA64_NONE		0x00	/* none */
+#define R_IA64_IMM14		0x21	/* symbol + addend, add imm14 */
+#define R_IA64_IMM22		0x22	/* symbol + addend, add imm22 */
+#define R_IA64_IMM64		0x23	/* symbol + addend, mov imm64 */
+#define R_IA64_DIR32MSB		0x24	/* symbol + addend, data4 MSB */
+#define R_IA64_DIR32LSB		0x25	/* symbol + addend, data4 LSB */
+#define R_IA64_DIR64MSB		0x26	/* symbol + addend, data8 MSB */
+#define R_IA64_DIR64LSB		0x27	/* symbol + addend, data8 LSB */
+#define R_IA64_GPREL22		0x2a	/* @gprel(sym + add), add imm22 */
+#define R_IA64_GPREL64I		0x2b	/* @gprel(sym + add), mov imm64 */
+#define R_IA64_GPREL32MSB	0x2c	/* @gprel(sym + add), data4 MSB */
+#define R_IA64_GPREL32LSB	0x2d	/* @gprel(sym + add), data4 LSB */
+#define R_IA64_GPREL64MSB	0x2e	/* @gprel(sym + add), data8 MSB */
+#define R_IA64_GPREL64LSB	0x2f	/* @gprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF22		0x32	/* @ltoff(sym + add), add imm22 */
+#define R_IA64_LTOFF64I		0x33	/* @ltoff(sym + add), mov imm64 */
+#define R_IA64_PLTOFF22		0x3a	/* @pltoff(sym + add), add imm22 */
+#define R_IA64_PLTOFF64I	0x3b	/* @pltoff(sym + add), mov imm64 */
+#define R_IA64_PLTOFF64MSB	0x3e	/* @pltoff(sym + add), data8 MSB */
+#define R_IA64_PLTOFF64LSB	0x3f	/* @pltoff(sym + add), data8 LSB */
+#define R_IA64_FPTR64I		0x43	/* @fptr(sym + add), mov imm64 */
+#define R_IA64_FPTR32MSB	0x44	/* @fptr(sym + add), data4 MSB */
+#define R_IA64_FPTR32LSB	0x45	/* @fptr(sym + add), data4 LSB */
+#define R_IA64_FPTR64MSB	0x46	/* @fptr(sym + add), data8 MSB */
+#define R_IA64_FPTR64LSB	0x47	/* @fptr(sym + add), data8 LSB */
+#define R_IA64_PCREL60B		0x48	/* @pcrel(sym + add), brl */
+#define R_IA64_PCREL21B		0x49	/* @pcrel(sym + add), ptb, call */
+#define R_IA64_PCREL21M		0x4a	/* @pcrel(sym + add), chk.s */
+#define R_IA64_PCREL21F		0x4b	/* @pcrel(sym + add), fchkf */
+#define R_IA64_PCREL32MSB	0x4c	/* @pcrel(sym + add), data4 MSB */
+#define R_IA64_PCREL32LSB	0x4d	/* @pcrel(sym + add), data4 LSB */
+#define R_IA64_PCREL64MSB	0x4e	/* @pcrel(sym + add), data8 MSB */
+#define R_IA64_PCREL64LSB	0x4f	/* @pcrel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_FPTR22	0x52	/* @ltoff(@fptr(s+a)), imm22 */
+#define R_IA64_LTOFF_FPTR64I	0x53	/* @ltoff(@fptr(s+a)), imm64 */
+#define R_IA64_LTOFF_FPTR32MSB	0x54	/* @ltoff(@fptr(s+a)), data4 MSB */
+#define R_IA64_LTOFF_FPTR32LSB	0x55	/* @ltoff(@fptr(s+a)), data4 LSB */
+#define R_IA64_LTOFF_FPTR64MSB	0x56	/* @ltoff(@fptr(s+a)), data8 MSB */
+#define R_IA64_LTOFF_FPTR64LSB	0x57	/* @ltoff(@fptr(s+a)), data8 LSB */
+#define R_IA64_SEGREL32MSB	0x5c	/* @segrel(sym + add), data4 MSB */
+#define R_IA64_SEGREL32LSB	0x5d	/* @segrel(sym + add), data4 LSB */
+#define R_IA64_SEGREL64MSB	0x5e	/* @segrel(sym + add), data8 MSB */
+#define R_IA64_SEGREL64LSB	0x5f	/* @segrel(sym + add), data8 LSB */
+#define R_IA64_SECREL32MSB	0x64	/* @secrel(sym + add), data4 MSB */
+#define R_IA64_SECREL32LSB	0x65	/* @secrel(sym + add), data4 LSB */
+#define R_IA64_SECREL64MSB	0x66	/* @secrel(sym + add), data8 MSB */
+#define R_IA64_SECREL64LSB	0x67	/* @secrel(sym + add), data8 LSB */
+#define R_IA64_REL32MSB		0x6c	/* data 4 + REL */
+#define R_IA64_REL32LSB		0x6d	/* data 4 + REL */
+#define R_IA64_REL64MSB		0x6e	/* data 8 + REL */
+#define R_IA64_REL64LSB		0x6f	/* data 8 + REL */
+#define R_IA64_LTV32MSB		0x74	/* symbol + addend, data4 MSB */
+#define R_IA64_LTV32LSB		0x75	/* symbol + addend, data4 LSB */
+#define R_IA64_LTV64MSB		0x76	/* symbol + addend, data8 MSB */
+#define R_IA64_LTV64LSB		0x77	/* symbol + addend, data8 LSB */
+#define R_IA64_PCREL21BI	0x79	/* @pcrel(sym + add), 21bit inst */
+#define R_IA64_PCREL22		0x7a	/* @pcrel(sym + add), 22bit inst */
+#define R_IA64_PCREL64I		0x7b	/* @pcrel(sym + add), 64bit inst */
+#define R_IA64_IPLTMSB		0x80	/* dynamic reloc, imported PLT, MSB */
+#define R_IA64_IPLTLSB		0x81	/* dynamic reloc, imported PLT, LSB */
+#define R_IA64_COPY		0x84	/* copy relocation */
+#define R_IA64_SUB		0x85	/* Addend and symbol difference */
+#define R_IA64_LTOFF22X		0x86	/* LTOFF22, relaxable.  */
+#define R_IA64_LDXMOV		0x87	/* Use of LTOFF22X.  */
+#define R_IA64_TPREL14		0x91	/* @tprel(sym + add), imm14 */
+#define R_IA64_TPREL22		0x92	/* @tprel(sym + add), imm22 */
+#define R_IA64_TPREL64I		0x93	/* @tprel(sym + add), imm64 */
+#define R_IA64_TPREL64MSB	0x96	/* @tprel(sym + add), data8 MSB */
+#define R_IA64_TPREL64LSB	0x97	/* @tprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_TPREL22	0x9a	/* @ltoff(@tprel(s+a)), imm2 */
+#define R_IA64_DTPMOD64MSB	0xa6	/* @dtpmod(sym + add), data8 MSB */
+#define R_IA64_DTPMOD64LSB	0xa7	/* @dtpmod(sym + add), data8 LSB */
+#define R_IA64_LTOFF_DTPMOD22	0xaa	/* @ltoff(@dtpmod(sym + add)), imm22 */
+#define R_IA64_DTPREL14		0xb1	/* @dtprel(sym + add), imm14 */
+#define R_IA64_DTPREL22		0xb2	/* @dtprel(sym + add), imm22 */
+#define R_IA64_DTPREL64I	0xb3	/* @dtprel(sym + add), imm64 */
+#define R_IA64_DTPREL32MSB	0xb4	/* @dtprel(sym + add), data4 MSB */
+#define R_IA64_DTPREL32LSB	0xb5	/* @dtprel(sym + add), data4 LSB */
+#define R_IA64_DTPREL64MSB	0xb6	/* @dtprel(sym + add), data8 MSB */
+#define R_IA64_DTPREL64LSB	0xb7	/* @dtprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_DTPREL22	0xba	/* @ltoff(@dtprel(s+a)), imm22 */
+
+/* SH specific declarations */
+
+/* SH relocs.  */
+#define	R_SH_NONE		0
+#define	R_SH_DIR32		1
+#define	R_SH_REL32		2
+#define	R_SH_DIR8WPN		3
+#define	R_SH_IND12W		4
+#define	R_SH_DIR8WPL		5
+#define	R_SH_DIR8WPZ		6
+#define	R_SH_DIR8BP		7
+#define	R_SH_DIR8W		8
+#define	R_SH_DIR8L		9
+#define	R_SH_SWITCH16		25
+#define	R_SH_SWITCH32		26
+#define	R_SH_USES		27
+#define	R_SH_COUNT		28
+#define	R_SH_ALIGN		29
+#define	R_SH_CODE		30
+#define	R_SH_DATA		31
+#define	R_SH_LABEL		32
+#define	R_SH_SWITCH8		33
+#define	R_SH_GNU_VTINHERIT	34
+#define	R_SH_GNU_VTENTRY	35
+#define	R_SH_TLS_GD_32		144
+#define	R_SH_TLS_LD_32		145
+#define	R_SH_TLS_LDO_32		146
+#define	R_SH_TLS_IE_32		147
+#define	R_SH_TLS_LE_32		148
+#define	R_SH_TLS_DTPMOD32	149
+#define	R_SH_TLS_DTPOFF32	150
+#define	R_SH_TLS_TPOFF32	151
+#define	R_SH_GOT32		160
+#define	R_SH_PLT32		161
+#define	R_SH_COPY		162
+#define	R_SH_GLOB_DAT		163
+#define	R_SH_JMP_SLOT		164
+#define	R_SH_RELATIVE		165
+#define	R_SH_GOTOFF		166
+#define	R_SH_GOTPC		167
+/* Keep this the last entry.  */
+#define	R_SH_NUM		256
+
+/* Additional s390 relocs */
+
+#define R_390_NONE		0	/* No reloc.  */
+#define R_390_8			1	/* Direct 8 bit.  */
+#define R_390_12		2	/* Direct 12 bit.  */
+#define R_390_16		3	/* Direct 16 bit.  */
+#define R_390_32		4	/* Direct 32 bit.  */
+#define R_390_PC32		5	/* PC relative 32 bit.	*/
+#define R_390_GOT12		6	/* 12 bit GOT offset.  */
+#define R_390_GOT32		7	/* 32 bit GOT offset.  */
+#define R_390_PLT32		8	/* 32 bit PC relative PLT address.  */
+#define R_390_COPY		9	/* Copy symbol at runtime.  */
+#define R_390_GLOB_DAT		10	/* Create GOT entry.  */
+#define R_390_JMP_SLOT		11	/* Create PLT entry.  */
+#define R_390_RELATIVE		12	/* Adjust by program base.  */
+#define R_390_GOTOFF32		13	/* 32 bit offset to GOT.	 */
+#define R_390_GOTPC		14	/* 32 bit PC relative offset to GOT.  */
+#define R_390_GOT16		15	/* 16 bit GOT offset.  */
+#define R_390_PC16		16	/* PC relative 16 bit.	*/
+#define R_390_PC16DBL		17	/* PC relative 16 bit shifted by 1.  */
+#define R_390_PLT16DBL		18	/* 16 bit PC rel. PLT shifted by 1.  */
+#define R_390_PC32DBL		19	/* PC relative 32 bit shifted by 1.  */
+#define R_390_PLT32DBL		20	/* 32 bit PC rel. PLT shifted by 1.  */
+#define R_390_GOTPCDBL		21	/* 32 bit PC rel. GOT shifted by 1.  */
+#define R_390_64		22	/* Direct 64 bit.  */
+#define R_390_PC64		23	/* PC relative 64 bit.	*/
+#define R_390_GOT64		24	/* 64 bit GOT offset.  */
+#define R_390_PLT64		25	/* 64 bit PC relative PLT address.  */
+#define R_390_GOTENT		26	/* 32 bit PC rel. to GOT entry >> 1. */
+#define R_390_GOTOFF16		27	/* 16 bit offset to GOT. */
+#define R_390_GOTOFF64		28	/* 64 bit offset to GOT. */
+#define R_390_GOTPLT12		29	/* 12 bit offset to jump slot.	*/
+#define R_390_GOTPLT16		30	/* 16 bit offset to jump slot.	*/
+#define R_390_GOTPLT32		31	/* 32 bit offset to jump slot.	*/
+#define R_390_GOTPLT64		32	/* 64 bit offset to jump slot.	*/
+#define R_390_GOTPLTENT		33	/* 32 bit rel. offset to jump slot.  */
+#define R_390_PLTOFF16		34	/* 16 bit offset from GOT to PLT. */
+#define R_390_PLTOFF32		35	/* 32 bit offset from GOT to PLT. */
+#define R_390_PLTOFF64		36	/* 16 bit offset from GOT to PLT. */
+#define R_390_TLS_LOAD		37	/* Tag for load insn in TLS code.  */
+#define R_390_TLS_GDCALL	38	/* Tag for function call in general
+					   dynamic TLS code. */
+#define R_390_TLS_LDCALL	39	/* Tag for function call in local
+					   dynamic TLS code. */
+#define R_390_TLS_GD32		40	/* Direct 32 bit for general dynamic
+					   thread local data.  */
+#define R_390_TLS_GD64		41	/* Direct 64 bit for general dynamic
+					  thread local data.  */
+#define R_390_TLS_GOTIE12	42	/* 12 bit GOT offset for static TLS
+					   block offset.  */
+#define R_390_TLS_GOTIE32	43	/* 32 bit GOT offset for static TLS
+					   block offset.  */
+#define R_390_TLS_GOTIE64	44	/* 64 bit GOT offset for static TLS
+					   block offset. */
+#define R_390_TLS_LDM32		45	/* Direct 32 bit for local dynamic
+					   thread local data in LE code.  */
+#define R_390_TLS_LDM64		46	/* Direct 64 bit for local dynamic
+					   thread local data in LE code.  */
+#define R_390_TLS_IE32		47	/* 32 bit address of GOT entry for
+					   negated static TLS block offset.  */
+#define R_390_TLS_IE64		48	/* 64 bit address of GOT entry for
+					   negated static TLS block offset.  */
+#define R_390_TLS_IEENT		49	/* 32 bit rel. offset to GOT entry for
+					   negated static TLS block offset.  */
+#define R_390_TLS_LE32		50	/* 32 bit negated offset relative to
+					   static TLS block.  */
+#define R_390_TLS_LE64		51	/* 64 bit negated offset relative to
+					   static TLS block.  */
+#define R_390_TLS_LDO32		52	/* 32 bit offset relative to TLS
+					   block.  */
+#define R_390_TLS_LDO64		53	/* 64 bit offset relative to TLS
+					   block.  */
+#define R_390_TLS_DTPMOD	54	/* ID of module containing symbol.  */
+#define R_390_TLS_DTPOFF	55	/* Offset in TLS block.	 */
+#define R_390_TLS_TPOFF		56	/* Negated offset in static TLS
+					   block.  */
+#define R_390_20		57	/* Direct 20 bit.  */
+#define R_390_GOT20		58	/* 20 bit GOT offset.  */
+#define R_390_GOTPLT20		59	/* 20 bit offset to jump slot.  */
+#define R_390_TLS_GOTIE20	60	/* 20 bit GOT offset for static TLS
+					   block offset.  */
+/* Keep this the last entry.  */
+#define R_390_NUM		61
+
+
+/* CRIS relocations.  */
+#define R_CRIS_NONE		0
+#define R_CRIS_8		1
+#define R_CRIS_16		2
+#define R_CRIS_32		3
+#define R_CRIS_8_PCREL		4
+#define R_CRIS_16_PCREL		5
+#define R_CRIS_32_PCREL		6
+#define R_CRIS_GNU_VTINHERIT	7
+#define R_CRIS_GNU_VTENTRY	8
+#define R_CRIS_COPY		9
+#define R_CRIS_GLOB_DAT		10
+#define R_CRIS_JUMP_SLOT	11
+#define R_CRIS_RELATIVE		12
+#define R_CRIS_16_GOT		13
+#define R_CRIS_32_GOT		14
+#define R_CRIS_16_GOTPLT	15
+#define R_CRIS_32_GOTPLT	16
+#define R_CRIS_32_GOTREL	17
+#define R_CRIS_32_PLT_GOTREL	18
+#define R_CRIS_32_PLT_PCREL	19
+
+#define R_CRIS_NUM		20
+
+
+/* AMD x86-64 relocations.  */
+#define R_X86_64_NONE		0	/* No reloc */
+#define R_X86_64_64		1	/* Direct 64 bit  */
+#define R_X86_64_PC32		2	/* PC relative 32 bit signed */
+#define R_X86_64_GOT32		3	/* 32 bit GOT entry */
+#define R_X86_64_PLT32		4	/* 32 bit PLT address */
+#define R_X86_64_COPY		5	/* Copy symbol at runtime */
+#define R_X86_64_GLOB_DAT	6	/* Create GOT entry */
+#define R_X86_64_JUMP_SLOT	7	/* Create PLT entry */
+#define R_X86_64_RELATIVE	8	/* Adjust by program base */
+#define R_X86_64_GOTPCREL	9	/* 32 bit signed PC relative
+					   offset to GOT */
+#define R_X86_64_32		10	/* Direct 32 bit zero extended */
+#define R_X86_64_32S		11	/* Direct 32 bit sign extended */
+#define R_X86_64_16		12	/* Direct 16 bit zero extended */
+#define R_X86_64_PC16		13	/* 16 bit sign extended pc relative */
+#define R_X86_64_8		14	/* Direct 8 bit sign extended  */
+#define R_X86_64_PC8		15	/* 8 bit sign extended pc relative */
+#define R_X86_64_DTPMOD64	16	/* ID of module containing symbol */
+#define R_X86_64_DTPOFF64	17	/* Offset in module's TLS block */
+#define R_X86_64_TPOFF64	18	/* Offset in initial TLS block */
+#define R_X86_64_TLSGD		19	/* 32 bit signed PC relative offset
+					   to two GOT entries for GD symbol */
+#define R_X86_64_TLSLD		20	/* 32 bit signed PC relative offset
+					   to two GOT entries for LD symbol */
+#define R_X86_64_DTPOFF32	21	/* Offset in TLS block */
+#define R_X86_64_GOTTPOFF	22	/* 32 bit signed PC relative offset
+					   to GOT entry for IE symbol */
+#define R_X86_64_TPOFF32	23	/* Offset in initial TLS block */
+
+#define R_X86_64_NUM		24
+
+
+/* AM33 relocations.  */
+#define R_MN10300_NONE		0	/* No reloc.  */
+#define R_MN10300_32		1	/* Direct 32 bit.  */
+#define R_MN10300_16		2	/* Direct 16 bit.  */
+#define R_MN10300_8		3	/* Direct 8 bit.  */
+#define R_MN10300_PCREL32	4	/* PC-relative 32-bit.  */
+#define R_MN10300_PCREL16	5	/* PC-relative 16-bit signed.  */
+#define R_MN10300_PCREL8	6	/* PC-relative 8-bit signed.  */
+#define R_MN10300_GNU_VTINHERIT	7	/* Ancient C++ vtable garbage... */
+#define R_MN10300_GNU_VTENTRY	8	/* ... collection annotation.  */
+#define R_MN10300_24		9	/* Direct 24 bit.  */
+#define R_MN10300_GOTPC32	10	/* 32-bit PCrel offset to GOT.  */
+#define R_MN10300_GOTPC16	11	/* 16-bit PCrel offset to GOT.  */
+#define R_MN10300_GOTOFF32	12	/* 32-bit offset from GOT.  */
+#define R_MN10300_GOTOFF24	13	/* 24-bit offset from GOT.  */
+#define R_MN10300_GOTOFF16	14	/* 16-bit offset from GOT.  */
+#define R_MN10300_PLT32		15	/* 32-bit PCrel to PLT entry.  */
+#define R_MN10300_PLT16		16	/* 16-bit PCrel to PLT entry.  */
+#define R_MN10300_GOT32		17	/* 32-bit offset to GOT entry.  */
+#define R_MN10300_GOT24		18	/* 24-bit offset to GOT entry.  */
+#define R_MN10300_GOT16		19	/* 16-bit offset to GOT entry.  */
+#define R_MN10300_COPY		20	/* Copy symbol at runtime.  */
+#define R_MN10300_GLOB_DAT	21	/* Create GOT entry.  */
+#define R_MN10300_JMP_SLOT	22	/* Create PLT entry.  */
+#define R_MN10300_RELATIVE	23	/* Adjust by program base.  */
+
+#define R_MN10300_NUM		24
+
+
+/* M32R relocs.  */
+#define R_M32R_NONE		0	/* No reloc. */
+#define R_M32R_16		1	/* Direct 16 bit. */
+#define R_M32R_32		2	/* Direct 32 bit. */
+#define R_M32R_24		3	/* Direct 24 bit. */
+#define R_M32R_10_PCREL		4	/* PC relative 10 bit shifted. */
+#define R_M32R_18_PCREL		5	/* PC relative 18 bit shifted. */
+#define R_M32R_26_PCREL		6	/* PC relative 26 bit shifted. */
+#define R_M32R_HI16_ULO		7	/* High 16 bit with unsigned low. */
+#define R_M32R_HI16_SLO		8	/* High 16 bit with signed low. */
+#define R_M32R_LO16		9	/* Low 16 bit. */
+#define R_M32R_SDA16		10	/* 16 bit offset in SDA. */
+#define R_M32R_GNU_VTINHERIT	11
+#define R_M32R_GNU_VTENTRY	12
+/* M32R relocs use SHT_RELA.  */
+#define R_M32R_16_RELA		33	/* Direct 16 bit. */
+#define R_M32R_32_RELA		34	/* Direct 32 bit. */
+#define R_M32R_24_RELA		35	/* Direct 24 bit. */
+#define R_M32R_10_PCREL_RELA	36	/* PC relative 10 bit shifted. */
+#define R_M32R_18_PCREL_RELA	37	/* PC relative 18 bit shifted. */
+#define R_M32R_26_PCREL_RELA	38	/* PC relative 26 bit shifted. */
+#define R_M32R_HI16_ULO_RELA	39	/* High 16 bit with unsigned low */
+#define R_M32R_HI16_SLO_RELA	40	/* High 16 bit with signed low */
+#define R_M32R_LO16_RELA	41	/* Low 16 bit */
+#define R_M32R_SDA16_RELA	42	/* 16 bit offset in SDA */
+#define R_M32R_RELA_GNU_VTINHERIT	43
+#define R_M32R_RELA_GNU_VTENTRY	44
+#define R_M32R_REL32		45	/* PC relative 32 bit.  */
+
+#define R_M32R_GOT24		48	/* 24 bit GOT entry */
+#define R_M32R_26_PLTREL	49	/* 26 bit PC relative to PLT shifted */
+#define R_M32R_COPY		50	/* Copy symbol at runtime */
+#define R_M32R_GLOB_DAT		51	/* Create GOT entry */
+#define R_M32R_JMP_SLOT		52	/* Create PLT entry */
+#define R_M32R_RELATIVE		53	/* Adjust by program base */
+#define R_M32R_GOTOFF		54	/* 24 bit offset to GOT */
+#define R_M32R_GOTPC24		55	/* 24 bit PC relative offset to GOT */
+#define R_M32R_GOT16_HI_ULO	56	/* High 16 bit GOT entry with unsigned
+					   low */
+#define R_M32R_GOT16_HI_SLO	57	/* High 16 bit GOT entry with signed
+					   low */
+#define R_M32R_GOT16_LO		58	/* Low 16 bit GOT entry */
+#define R_M32R_GOTPC_HI_ULO	59	/* High 16 bit PC relative offset to
+					   GOT with unsigned low */
+#define R_M32R_GOTPC_HI_SLO	60	/* High 16 bit PC relative offset to
+					   GOT with signed low */
+#define R_M32R_GOTPC_LO		61	/* Low 16 bit PC relative offset to
+					   GOT */
+#define R_M32R_GOTOFF_HI_ULO	62	/* High 16 bit offset to GOT
+					   with unsigned low */
+#define R_M32R_GOTOFF_HI_SLO	63	/* High 16 bit offset to GOT
+					   with signed low */
+#define R_M32R_GOTOFF_LO	64	/* Low 16 bit offset to GOT */
+#define R_M32R_NUM		256	/* Keep this the last entry. */
+
+__END_DECLS
+
+#endif	/* elf.h */
--- ./hotspot/src/share/vm/utilities/elfFile.hpp	2011-05-26 17:33:59.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/elfFile.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -27,7 +27,13 @@
 
 #ifndef _WINDOWS
 
+#ifdef __APPLE__
+#include "elf.hpp"
+#elif defined(__OpenBSD__)
+#include <sys/exec_elf.h>
+#else
 #include <elf.h>
+#endif
 #include <stdio.h>
 
 #ifdef _LP64
@@ -41,7 +47,9 @@
 typedef Elf64_Shdr      Elf_Shdr;
 typedef Elf64_Sym       Elf_Sym;
 
+#if !defined(_ALLBSD_SOURCE) || defined(__APPLE__)
 #define ELF_ST_TYPE ELF64_ST_TYPE
+#endif
 
 #else
 
@@ -55,8 +63,10 @@
 typedef Elf32_Shdr      Elf_Shdr;
 typedef Elf32_Sym       Elf_Sym;
 
+#if !defined(_ALLBSD_SOURCE) || defined(__APPLE__)
 #define ELF_ST_TYPE ELF32_ST_TYPE
 #endif
+#endif
 
 #include "globalDefinitions.hpp"
 #include "memory/allocation.hpp"
--- ./hotspot/src/share/vm/utilities/events.cpp	2011-05-26 17:34:00.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/events.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -38,6 +38,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 #ifndef PRODUCT
--- ./hotspot/src/share/vm/utilities/exceptions.cpp	2011-05-26 17:34:00.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/exceptions.cpp	2011-05-07 21:53:42.000000000 -0700
@@ -42,6 +42,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 // Implementation of ThreadShadow
--- ./hotspot/src/share/vm/utilities/globalDefinitions.hpp	2011-05-26 17:34:01.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/globalDefinitions.hpp	2011-04-23 12:09:39.000000000 -0700
@@ -25,6 +25,8 @@
 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
 
+#define __STDC_FORMAT_MACROS
+
 #ifdef TARGET_COMPILER_gcc
 # include "utilities/globalDefinitions_gcc.hpp"
 #endif
@@ -37,6 +39,8 @@
 
 #include "utilities/macros.hpp"
 
+#include <inttypes.h>
+
 // This file holds all globally used constants & types, class (forward)
 // declarations and a few frequently used utility functions.
 
@@ -1188,20 +1192,20 @@
 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
 
 // Format 32-bit quantities.
-#define INT32_FORMAT  "%d"
-#define UINT32_FORMAT "%u"
+#define INT32_FORMAT  "%" PRId32
+#define UINT32_FORMAT "%" PRIu32
 #define INT32_FORMAT_W(width)   "%" #width "d"
 #define UINT32_FORMAT_W(width)  "%" #width "u"
 
-#define PTR32_FORMAT  "0x%08x"
+#define PTR32_FORMAT  "0x%08" PRIx32
 
 // Format 64-bit quantities.
-#define INT64_FORMAT  "%" FORMAT64_MODIFIER "d"
-#define UINT64_FORMAT "%" FORMAT64_MODIFIER "u"
-#define PTR64_FORMAT  "0x%016" FORMAT64_MODIFIER "x"
+#define INT64_FORMAT  "%" PRId64
+#define UINT64_FORMAT "%" PRIu64
+#define PTR64_FORMAT  "0x%016" PRIx64
 
-#define INT64_FORMAT_W(width)  "%" #width FORMAT64_MODIFIER "d"
-#define UINT64_FORMAT_W(width) "%" #width FORMAT64_MODIFIER "u"
+#define INT64_FORMAT_W(width)  "%" #width PRId64
+#define UINT64_FORMAT_W(width) "%" #width PRIu64
 
 // Format macros that allow the field width to be specified.  The width must be
 // a string literal (e.g., "8") or a macro that evaluates to one.
@@ -1226,19 +1230,17 @@
 // using "%x".
 #ifdef  _LP64
 #define PTR_FORMAT    PTR64_FORMAT
-#define UINTX_FORMAT  UINT64_FORMAT
-#define INTX_FORMAT   INT64_FORMAT
 #define SIZE_FORMAT   UINT64_FORMAT
 #define SSIZE_FORMAT  INT64_FORMAT
 #else   // !_LP64
 #define PTR_FORMAT    PTR32_FORMAT
-#define UINTX_FORMAT  UINT32_FORMAT
-#define INTX_FORMAT   INT32_FORMAT
 #define SIZE_FORMAT   UINT32_FORMAT
 #define SSIZE_FORMAT  INT32_FORMAT
 #endif  // _LP64
+#define UINTX_FORMAT  "%" PRIuPTR
+#define INTX_FORMAT   "%" PRIdPTR
 
-#define INTPTR_FORMAT PTR_FORMAT
+#define INTPTR_FORMAT "%" PRIdPTR
 
 // Enable zap-a-lot if in debug version.
 
--- ./hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp	2011-05-26 17:34:01.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp	2011-04-23 12:13:39.000000000 -0700
@@ -76,15 +76,28 @@
 # include <sys/procfs.h>
 # endif
 
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif // __STDC_LIMIT_MACROS
 #include <inttypes.h>
 #include <signal.h>
+#ifndef __OpenBSD__
 #include <ucontext.h>
+#endif
+#ifdef __APPLE__
+  #include <AvailabilityMacros.h>
+  #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
+    // Mac OS X 10.4 defines EFL_AC and EFL_ID,
+    // which conflict with hotspot variable names.
+    //
+    // This has been fixed in Mac OS X 10.5.
+    #undef EFL_AC
+    #undef EFL_ID
+  #endif
+#endif
 #include <sys/time.h>
-#endif // LINUX
+#endif // LINUX || _ALLBSD_SOURCE
 
 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
@@ -120,7 +133,7 @@
 // pointer is stored as integer value.  On some platforms, sizeof(intptr_t) >
 // sizeof(void*), so here we want something which is integer type, but has the
 // same size as a pointer.
-#ifdef LINUX
+#ifdef __GNUC__
   #ifdef _LP64
     #define NULL_WORD  0L
   #else
@@ -132,7 +145,7 @@
   #define NULL_WORD  NULL
 #endif
 
-#ifndef LINUX
+#if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
 // Compiler-specific primitive types
 typedef unsigned short     uint16_t;
 #ifndef _UINT32_T
@@ -152,7 +165,7 @@
 // prior definition of intptr_t, and add "&& !defined(XXX)" above.
 #endif // _SYS_INT_TYPES_H
 
-#endif // !LINUX
+#endif // !LINUX && !_ALLBSD_SOURCE
 
 // Additional Java basic types
 
@@ -244,7 +257,9 @@
 inline int g_isnan(float  f) { return isnand(f); }
 #endif
 inline int g_isnan(double f) { return isnand(f); }
-#elif LINUX
+#elif defined(__APPLE__)
+inline int g_isnan(double f) { return isnan(f); }
+#elif defined(LINUX) || defined(_ALLBSD_SOURCE)
 inline int g_isnan(float  f) { return isnanf(f); }
 inline int g_isnan(double f) { return isnan(f); }
 #else
--- ./hotspot/src/share/vm/utilities/growableArray.cpp	2011-05-26 17:34:01.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/growableArray.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -34,6 +34,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef ASSERT
 void GenericGrowableArray::set_nesting() {
   if (on_stack()) {
--- ./hotspot/src/share/vm/utilities/histogram.hpp	2011-05-26 17:34:02.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/histogram.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // This class provides a framework for collecting various statistics.
 // The current implementation is oriented towards counting invocations
--- ./hotspot/src/share/vm/utilities/macros.hpp	2011-05-26 17:34:03.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/macros.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -161,6 +161,14 @@
 #define NOT_WINDOWS(code) code
 #endif
 
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#define BSD_ONLY(code) code
+#define NOT_BSD(code)
+#else
+#define BSD_ONLY(code)
+#define NOT_BSD(code) code
+#endif
+
 #ifdef _WIN64
 #define WIN64_ONLY(code) code
 #define NOT_WIN64(code)
--- ./hotspot/src/share/vm/utilities/ostream.cpp	2011-05-26 17:34:04.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/ostream.cpp	2011-04-22 22:28:37.000000000 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 extern "C" void jio_print(const char* s); // Declarationtion of jvm method
 
@@ -909,7 +912,7 @@
 
 #ifndef PRODUCT
 
-#if defined(SOLARIS) || defined(LINUX)
+#if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
--- ./hotspot/src/share/vm/utilities/preserveException.hpp	2011-05-26 17:34:04.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/preserveException.hpp	2011-04-22 22:28:37.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // This file provides more support for exception handling; see also exceptions.hpp
 class PreserveExceptionMark {
--- ./hotspot/src/share/vm/utilities/taskqueue.cpp	2011-05-26 17:34:05.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/taskqueue.cpp	2011-04-22 22:28:38.000000000 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifdef TRACESPINNING
 uint ParallelTaskTerminator::_total_yields = 0;
--- ./hotspot/src/share/vm/utilities/taskqueue.hpp	2011-05-26 17:34:05.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/taskqueue.hpp	2011-04-22 22:28:38.000000000 -0700
@@ -53,6 +53,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
 
 // Simple TaskQueue stats that are collected by default in debug builds.
 
--- ./hotspot/src/share/vm/utilities/vmError.cpp	2011-05-26 17:34:07.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/vmError.cpp	2011-04-22 22:28:38.000000000 -0700
@@ -45,13 +45,18 @@
   "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
   "JAVA_COMPILER", "PATH", "USERNAME",
 
-  // Env variables that are defined on Solaris/Linux
+  // Env variables that are defined on Solaris/Linux/BSD
   "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
   "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
 
   // defined on Linux
   "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM",
 
+  // defined on Darwin
+  "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
+  "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
+  "DYLD_INSERT_LIBRARIES",
+
   // defined on Windows
   "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",
 
@@ -958,7 +963,7 @@
     const char* ptr = OnError;
     while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
       out.print_raw   ("#   Executing ");
-#if defined(LINUX)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
       out.print_raw   ("/bin/sh -c ");
 #elif defined(SOLARIS)
       out.print_raw   ("/usr/bin/sh -c ");
--- ./hotspot/src/share/vm/utilities/workgroup.hpp	2011-05-26 17:34:08.000000000 -0700
+++ ./hotspot/src/share/vm/utilities/workgroup.hpp	2011-04-22 22:28:38.000000000 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Task class hierarchy:
 //   AbstractGangTask
--- ./hotspot/test/Makefile	2011-05-26 17:34:08.000000000 -0700
+++ ./hotspot/test/Makefile	2011-04-22 22:28:38.000000000 -0700
@@ -44,6 +44,22 @@
     ARCH = i586
   endif
 endif
+ifeq ($(OSNAME), Darwin)
+  PLATFORM = bsd
+  SLASH_JAVA = /java
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH = i586
+  endif
+endif
+ifeq ($(findstring BSD,$(OSNAME)), BSD)
+  PLATFORM = bsd
+  SLASH_JAVA = /java
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH = i586
+  endif
+endif
 ifeq ($(OSNAME), Windows_NT)
   PLATFORM = windows
   SLASH_JAVA = J:
@@ -143,7 +159,7 @@
 endif
 
 # Expect JPRT to set TESTDIRS to the jtreg test dirs
-JTREG_TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof
+JTREG_TESTDIRS = compiler
 ifdef TESTDIRS
   JTREG_TESTDIRS = $(TESTDIRS)
 endif
--- ./hotspot/test/jprt.config	2011-05-26 17:34:32.000000000 -0700
+++ ./hotspot/test/jprt.config	2011-04-22 22:28:38.000000000 -0700
@@ -75,8 +75,8 @@
 
 # Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
 osname=`uname -s`
-if [ "${osname}" = SunOS ] ; then
-   
+case "${osname}" in
+  SunOS )
     # SOLARIS: Sparc or X86
     osarch=`uname -p`
     if [ "${osarch}" = sparc ] ; then
@@ -100,9 +100,9 @@
 
     # File creation mask
     umask 002
+    ;;
 
-elif [ "${osname}" = Linux ] ; then
-   
+  Linux | Darwin )
     # Add basic paths
     path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
@@ -111,9 +111,31 @@
     fileMustExist "${make}" make
 
     umask 002
+    ;;
+
+  FreeBSD | OpenBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
+
+    # Find GNU make
+    make=/usr/local/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
 
-else
+  NetBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
+    # Find GNU make
+    make=/usr/pkg/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
+
+  * )
     # Windows: Differs on CYGWIN vs. MKS.
    
     # We need to determine if we are running a CYGWIN shell or an MKS shell
@@ -154,8 +176,8 @@
     if [ "${unix_toolset}" = CYGWIN ] ; then
 	path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
     fi
-
-fi
+    ;;
+esac
 
 # Export PATH setting
 PATH="${path4sdk}"
--- ./hotspot/test/runtime/6929067/Test6929067.sh	2011-05-26 17:34:35.000000000 -0700
+++ ./hotspot/test/runtime/6929067/Test6929067.sh	2011-04-22 22:28:38.000000000 -0700
@@ -29,7 +29,7 @@
     PS=":"
     FS="/"
     ;;
-  SunOS | Windows_* )
+  SunOS | Windows_* | *BSD)
     NULL=NUL
     PS=";"
     FS="\\"
--- ./jaxp/.hgtags	2011-05-26 17:46:21.000000000 -0700
+++ ./jaxp/.hgtags	2011-05-27 00:00:49.000000000 -0700
@@ -118,3 +118,4 @@
 e1b5ef243445bf836d095fd44866e1771ef99374 jdk7-b141
 7d067af4b25e4b7e6b28bef48527d67f8650e6c5 jdk7-b142
 16b847e9bbd747f9d27785b2fc20d4d720cca893 jdk7-b143
+39bf6dcaab2336326b21743cef7042d0a2de9ba0 jdk7-b144
--- ./jaxp/.jcheck/conf	2011-05-26 17:46:21.000000000 -0700
+++ ./jaxp/.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./jaxws/.hgtags	2011-05-26 17:53:54.000000000 -0700
+++ ./jaxws/.hgtags	2011-05-27 00:00:52.000000000 -0700
@@ -118,3 +118,4 @@
 66826b0aec5a1834da3821c35cf85ac154e9b04d jdk7-b141
 0ef3ef823c39eee3d670e58027c3219cb66f0283 jdk7-b142
 569d1e7ea980d172046c4aba79d96b5c3afabbba jdk7-b143
+6bd683f2d527c9afd47beac1cbf614506929598d jdk7-b144
--- ./jaxws/.jcheck/conf	2011-05-26 17:53:54.000000000 -0700
+++ ./jaxws/.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./jdk/.hgtags	2011-05-26 18:33:40.000000000 -0700
+++ ./jdk/.hgtags	2011-05-27 00:01:00.000000000 -0700
@@ -118,3 +118,4 @@
 63eeefe118da18c75ba3d36266768cd1ccaaca6b jdk7-b141
 312612e89ece62633f4809706dec00bcd5fe7c2d jdk7-b142
 efbf75c24b0f31847c9c403f6dc07dc80551908d jdk7-b143
+23bdcede4e3945894574892e80b848bd9f15b5f3 jdk7-b144
--- ./jdk/.jcheck/conf	2011-05-26 18:33:40.000000000 -0700
+++ ./jdk/.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./jdk/make/com/sun/java/pack/Makefile	2011-05-26 18:33:44.000000000 -0700
+++ ./jdk/make/com/sun/java/pack/Makefile	2011-05-07 21:54:09.000000000 -0700
@@ -57,6 +57,7 @@
 vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)
 
 ifeq ($(STANDALONE),true)
+ ifneq ($(SYSTEM_ZLIB),true)
   ZIPOBJDIR = $(OUTPUTDIR)/tmp/sun/java.util.zip/zip/$(OBJDIRNAME)
 
   ZIPOBJS =  $(ZIPOBJDIR)/zcrc32.$(OBJECT_SUFFIX) \
@@ -73,6 +74,10 @@
   ZINCLUDE=-I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
   OTHER_CXXFLAGS += $(ZINCLUDE)
   LDDFLAGS += $(ZIPOBJS)
+ else
+  LDDFLAGS += -lz
+  OTHER_CXXFLAGS += -DSYSTEM_ZLIB
+ endif
 else
   OTHER_CXXFLAGS += -DNO_ZLIB -DUNPACK_JNI
   OTHER_LDLIBS += $(JVMLIB)
@@ -94,7 +99,11 @@
   RES = $(OBJDIR)/$(PGRM).res
 else
   LDOUTPUT = -o #Have a space 
+ifeq ($(PLATFORM), bsd)
+  LDDFLAGS += -pthread
+else
   LDDFLAGS += -lc
+endif
   OTHER_LDLIBS  += $(LIBCXX)
 # setup the list of libraries to link in...
 ifeq ($(PLATFORM), linux)
--- ./jdk/make/com/sun/nio/Makefile	2011-05-26 18:33:46.000000000 -0700
+++ ./jdk/make/com/sun/nio/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -30,7 +30,16 @@
 BUILDDIR = ../../..
 include $(BUILDDIR)/common/Defs.gmk
 
+ifneq ($(PLATFORM), bsd)
 SUBDIRS = sctp
+else
+ifeq ($(OS_VENDOR), FreeBSD)
+# FreeBSD 5.x and lower are unsupported, 6.x has no sctp support.
+ifneq ($(call MajorVersion,$(shell uname -r)), 6)
+SUBDIRS = sctp
+endif
+endif
+endif
 include $(BUILDDIR)/common/Subdirs.gmk
 
 all build clean clobber::
--- ./jdk/make/com/sun/nio/sctp/Makefile	2011-05-26 18:33:47.000000000 -0700
+++ ./jdk/make/com/sun/nio/sctp/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -59,15 +59,11 @@
   -I$(PLATFORM_SRC)/native/java/net \
   -I$(CLASSHDRDIR)/../../../../java/java.nio/nio/CClassHeaders
 
+OTHER_LDLIBS += $(LIBSOCKET) -L$(LIBDIR)/$(LIBARCH) -lnet -lnio
 ifeq ($(PLATFORM), linux)
 COMPILER_WARNINGS_FATAL=true
-#OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread -ldl
-OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -lnio -lnet -lpthread -ldl
+OTHER_LDLIBS += -lpthread $(LIBDL)
 endif
-ifeq ($(PLATFORM), solaris)
-#LIBSCTP = -lsctp
-OTHER_LDLIBS += $(LIBSOCKET) -L$(LIBDIR)/$(LIBARCH) -lnet -lnio
-endif # PLATFORM
 
 else # windows
 include $(BUILDDIR)/common/Classes.gmk
--- ./jdk/make/com/sun/security/auth/module/Makefile	2011-05-26 18:33:49.000000000 -0700
+++ ./jdk/make/com/sun/security/auth/module/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -67,7 +67,7 @@
   include FILES_c_solaris.gmk
 endif # solaris
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
   LIBRARY = jaas_unix
   include FILES_export_unix.gmk
   include FILES_c_unix.gmk
--- ./jdk/make/com/sun/tools/attach/Exportedfiles.gmk	2011-05-26 18:33:51.000000000 -0700
+++ ./jdk/make/com/sun/tools/attach/Exportedfiles.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -43,5 +43,7 @@
 	sun/tools/attach/LinuxVirtualMachine.java
 endif
 
-
-
+ifeq ($(PLATFORM), bsd)
+FILES_export = \
+	sun/tools/attach/BsdVirtualMachine.java
+endif
--- ./jdk/make/com/sun/tools/attach/FILES_c.gmk	2011-05-26 18:33:51.000000000 -0700
+++ ./jdk/make/com/sun/tools/attach/FILES_c.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -39,4 +39,7 @@
 	LinuxVirtualMachine.c
 endif
 
-
+ifeq ($(PLATFORM),bsd)
+FILES_c = \
+	BsdVirtualMachine.c
+endif
--- ./jdk/make/com/sun/tools/attach/FILES_java.gmk	2011-05-26 18:33:51.000000000 -0700
+++ ./jdk/make/com/sun/tools/attach/FILES_java.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -43,6 +43,11 @@
 	sun/tools/attach/LinuxAttachProvider.java
 endif
 
+ifeq ($(PLATFORM), bsd)
+FILES_java += \
+	sun/tools/attach/BsdAttachProvider.java
+endif
+
 #
 # Files that need to be copied
 #
--- ./jdk/make/com/sun/tools/attach/Makefile	2011-05-26 18:33:51.000000000 -0700
+++ ./jdk/make/com/sun/tools/attach/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -36,6 +36,9 @@
 ifeq ($(PLATFORM), linux)
 FILES_m = mapfile-linux
 endif
+ifeq ($(PLATFORM), bsd)
+FILES_m = mapfile-bsd
+endif
 include $(BUILDDIR)/common/Mapfile-vers.gmk
 
 #
--- ./jdk/make/com/sun/tools/attach/mapfile-bsd	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/make/com/sun/tools/attach/mapfile-bsd	2011-04-22 23:08:15.000000000 -0700
@@ -30,14 +30,12 @@
 	    Java_sun_tools_attach_BsdVirtualMachine_checkPermissions;
 	    Java_sun_tools_attach_BsdVirtualMachine_close;
 	    Java_sun_tools_attach_BsdVirtualMachine_connect;
-	    Java_sun_tools_attach_BsdVirtualMachine_getBsdThreadsManager;
-	    Java_sun_tools_attach_BsdVirtualMachine_isBsdThreads;
 	    Java_sun_tools_attach_BsdVirtualMachine_open;
 	    Java_sun_tools_attach_BsdVirtualMachine_sendQuitTo;
-            Java_sun_tools_attach_BsdVirtualMachine_sendQuitToChildrenOf;
 	    Java_sun_tools_attach_BsdVirtualMachine_socket;
 	    Java_sun_tools_attach_BsdVirtualMachine_read;
 	    Java_sun_tools_attach_BsdVirtualMachine_write;
+	    Java_sun_tools_attach_BsdVirtualMachine_createAttachFile;
 	local:
 		*;
 };
--- ./jdk/make/common/Defs-bsd.gmk	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/make/common/Defs-bsd.gmk	2011-05-07 22:01:55.000000000 -0700
@@ -25,7 +25,7 @@
 
 #
 # Makefile to specify compiler flags for programs and libraries
-# targeted to Bsd.  Should not contain any rules.
+# targeted to BSD.  Should not contain any rules.
 #
 # WARNING: This file is shared with other workspaces. 
 #          So when it includes other files, it must use JDK_TOPDIR.
@@ -61,7 +61,7 @@
 endif
 
 # platform specific include files
-PLATFORM_INCLUDE_NAME = $(PLATFORM)
+PLATFORM_INCLUDE_NAME = $(OS_NAME)
 PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
 
 # suffix used for make dependencies files.
@@ -100,9 +100,11 @@
 #    We need this frame pointer to make it easy to walk the stacks.
 #    This should be the default on X86, but ia64 and amd64 may not have this
 #    as the default.
-CFLAGS_REQUIRED_amd64   += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
-CFLAGS_REQUIRED_i586    += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
-CFLAGS_REQUIRED_ia64    += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
+CFLAGS_REQUIRED_amd64   += -m64 -fno-omit-frame-pointer -D_LITTLE_ENDIAN
+LDFLAGS_COMMON_amd64    += -m64
+CFLAGS_REQUIRED_i586    += -m32 -fno-omit-frame-pointer -D_LITTLE_ENDIAN
+LDFLAGS_COMMON_i586     += -m32
+CFLAGS_REQUIRED_ia64    += -m64 -fno-omit-frame-pointer -D_LITTLE_ENDIAN
 CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
 LDFLAGS_COMMON_sparcv9  += -m64 -mcpu=v9
 CFLAGS_REQUIRED_sparc   += -m32 -mcpu=v9
@@ -119,9 +121,13 @@
   CFLAGS_REQUIRED       =  $(CFLAGS_REQUIRED_$(ARCH))
   LDFLAGS_COMMON        += $(LDFLAGS_COMMON_$(ARCH))
 endif
+ifeq ($(OS_VENDOR),Apple)
+  # 16-byte stack re-alignment on 32-bit Darwin
+  CFLAGS_REQUIRED_i586 += -mstackrealign
+endif
 
 # If this is a --hash-style=gnu system, use --hash-style=both
-#   The gnu .hash section won't work on some Bsd systems like SuSE 10.
+#   The gnu .hash section won't work on some Linux systems like SuSE 10.
 _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
 ifneq ($(_HAS_HASH_STYLE_GNU),)
   LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
@@ -156,7 +162,7 @@
  CFLAGS_COMMON += -pipe
 endif
 
-# Bsd 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
+# BSD 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
 DEBUG_FLAG = -g
 ifeq ($(FASTDEBUG), true)
   ifeq ($(ARCH_DATA_MODEL), 64)
@@ -193,8 +199,7 @@
 else
   CPP_ARCH_FLAGS += -D_$(ARCH)_
 endif
-
-CPPFLAGS_COMMON = $(CPP_ARCH_FLAGS) -DBSD $(VERSION_DEFINES) \
+CPPFLAGS_COMMON = $(CPP_ARCH_FLAGS) -D_ALLBSD_SOURCE $(VERSION_DEFINES) \
 		  -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT
 
 ifeq ($(ARCH_DATA_MODEL), 64)
@@ -207,44 +212,37 @@
   CPPFLAGS_DBG    += -DLOGGING 
 endif
 
-ifdef LIBRARY
-  # Libraries need to locate other libraries at runtime, and you can tell
-  #   a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
-  #   buried inside the .so. The $ORIGIN says to look relative to where
-  #   the library itself is and it can be followed with relative paths from
-  #   that. By default we always look in $ORIGIN, optionally we add relative
-  #   paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
-  #   On Bsd we add a flag -z origin, not sure if this is necessary, but 
-  #   doesn't seem to hurt.
-  #   The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
-  #   Try: 'readelf -d lib*.so' to see these settings in a library.
-  #
-  Z_ORIGIN_FLAG/sparc = -Xlinker -z -Xlinker origin
-  Z_ORIGIN_FLAG/i586  = -Xlinker -z -Xlinker origin
-  Z_ORIGIN_FLAG/amd64 = -Xlinker -z -Xlinker origin 
-  Z_ORIGIN_FLAG/ia64  = -Xlinker -z -Xlinker origin
-  Z_ORIGIN_FLAG/arm   = 
-  Z_ORIGIN_FLAG/ppc   =
-  Z_ORIGIN_FLAG/zero  = -Xlinker -z -Xlinker origin
-
-  LDFLAG_Z_ORIGIN = $(Z_ORIGIN_FLAG/$(ARCH_FAMILY))
-
-  LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN
-  LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN/%)
-
+# Libraries need to locate other libraries at runtime, and you can tell
+#   a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
+#   buried inside the .{so,dylib}. The {$ORIGIN,@loader_path/} says to look
+#   relative to where the library itself is and it can be followed
+#   with relative paths from that. By default we always look in
+#   {$ORIGIN,@loader_path/}, optionally we add relative paths if the Makefile
+#   sets LD_RUNPATH_EXTRAS to those relative paths.
+#   Except on MacOS X we add a flag -z origin, not sure if this is necessary,
+#   but doesn't seem to hurt.
+#   The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
+#   See 'man {dyld,rtld}' for more information.
+#   Try: 'readelf -d lib*.so' to see these settings in a library.
+#
+ifeq ($(OS_VENDOR), Apple)
+  LDFLAGS_COMMON += -Xlinker -rpath -Xlinker @loader_path/.
+  LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-Xlinker -rpath -Xlinker @loader_path/%)
+  LDFLAGS_COMMON += -Xlinker -install_name -Xlinker @rpath/$(@F)
+else
+  LDFLAGS_COMMON += -Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$ORIGIN
+  LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$ORIGIN/%)
 endif
 
-EXTRA_LIBS += -lc
-
-LDFLAGS_DEFS_OPTION  = -Xlinker -z -Xlinker defs
-LDFLAGS_COMMON  += $(LDFLAGS_DEFS_OPTION)
-
 #
 # -L paths for finding and -ljava
 #
-LDFLAGS_OPT     = -Xlinker -O1
 LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
+
+ifneq ($(OS_VENDOR), Apple)
+LDFLAGS_OPT     = -Xlinker -O1
 LDFLAGS_COMMON += -Wl,-soname=$(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
+endif
 
 #
 # -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
@@ -265,9 +263,9 @@
 ifeq ($(VARIANT), OPT)
   ifneq ($(NO_STRIP), true)
     ifneq ($(DEBUG_BINARIES), true)
-      # Debug 'strip -g' leaves local function Elf symbols (better stack
+      # Debug 'strip -S' leaves local function Elf symbols (better stack
       # traces)
-      POST_STRIP_PROCESS = $(STRIP) -g
+      POST_STRIP_PROCESS = $(STRIP) -S
     endif
   endif
 endif
@@ -286,6 +284,11 @@
 LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
 endif
 
+# Darwin does not support linker map files.
+ifeq ($(OS_VENDOR), Apple)
+LDNOMAP=true
+endif
+
 #
 # Path and option to link against the VM, if you have to.  Note that
 # there are libraries that link against only -ljava, but they do get
@@ -293,7 +296,11 @@
 # the library itself should not.
 #
 VM_NAME         = server
+ifeq ($(OS_VENDOR),Apple)
 JVMLIB          = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
+else
+JVMLIB          = -Xlinker -rpath -Xlinker $(LIBDIR)/$(LIBARCH)/$(VM_NAME) -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
+endif
 JAVALIB         = -ljava $(JVMLIB)
 
 #
@@ -312,7 +319,9 @@
 override HAVE_FILIOH             = false
 override HAVE_GETHRTIME          = false
 override HAVE_GETHRVTIME         = false
+ifeq ($(OS_VENDOR),Apple)
 override HAVE_SIGIGNORE          = true
+endif
 override LEX_LIBRARY             = -lfl
 ifeq ($(STATIC_CXX),true)
 override LIBCXX                  = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
@@ -323,13 +332,11 @@
 override LIBSOCKET               =
 override LIBNSL                  =
 override LIBTHREAD               =
+override LIBDL                   =
 override MOOT_PRIORITIES         = true
 override NO_INTERRUPTIBLE_IO     = true
-ifeq ($(ARCH), amd64)
-override OPENWIN_LIB             = $(OPENWIN_HOME)/lib64
-else
+override OPENWIN_HOME            = $(X11_PATH)
 override OPENWIN_LIB             = $(OPENWIN_HOME)/lib
-endif
 override OTHER_M4FLAGS           = -D__GLIBC__ -DGNU_ASSEMBLER
 override SUN_CMM_SUBDIR          =
 override THREADS_FLAG            = native
@@ -350,6 +357,14 @@
 # DPS (Displayable PostScript) is available on Solaris machines
 HAVE_DPS = no
 
+ifeq ($(OS_VENDOR), FreeBSD)
+  SYSTEM_ZLIB = true
+endif
+
+ifeq ($(OS_VENDOR), OpenBSD)
+  SYSTEM_ZLIB = true
+endif
+
 #
 # Japanese manpages
 #
@@ -361,7 +376,7 @@
 SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
 
 # The JDI - Serviceability Agent binding is not currently supported
-# on Bsd-ia64.
+# on ia64.
 ifeq ($(ARCH), ia64)
   INCLUDE_SA = false
 else
--- ./jdk/make/common/Defs-linux.gmk	2011-05-26 18:33:52.000000000 -0700
+++ ./jdk/make/common/Defs-linux.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -323,8 +323,10 @@
 override LIBSOCKET               =
 override LIBNSL                  =
 override LIBTHREAD               =
+override LIBDL                   = -ldl
 override MOOT_PRIORITIES         = true
 override NO_INTERRUPTIBLE_IO     = true
+override OPENWIN_HOME            = $(X11_PATH)
 ifeq ($(ARCH), amd64)
 override OPENWIN_LIB             = $(OPENWIN_HOME)/lib64
 else
--- ./jdk/make/common/Defs-solaris.gmk	2011-05-26 18:33:52.000000000 -0700
+++ ./jdk/make/common/Defs-solaris.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -648,6 +648,9 @@
 # Network Services library
 LIBNSL = -lnsl
 
+# Dynamic Loading library
+LIBDL = -ldl
+
 # GLOBAL_KPIC: If set means all libraries are PIC, position independent code
 #    EXCEPT for select compiles
 #    If a .o file is compiled non-PIC then it should be forced
--- ./jdk/make/common/Defs.gmk	2011-05-26 18:33:52.000000000 -0700
+++ ./jdk/make/common/Defs.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -109,6 +109,49 @@
   endif
 endif
 
+ifneq ($(PLATFORM), windows)
+  ifdef ALT_X11_PATH
+    X11_PATH = $(ALT_X11_PATH)
+  else
+    ifneq ($(OS_VENDOR), NetBSD)
+      X11_PATH = /usr/X11R6
+    else
+      X11_PATH = /usr/X11R7
+    endif
+  endif
+
+  ifdef ALT_PACKAGE_PATH
+    PACKAGE_PATH = $(ALT_PACKAGE_PATH)
+  else
+    ifeq ($(PLATFORM), linux)
+      PACKAGE_PATH = /usr
+    else
+      ifeq ($(OS_VENDOR), Apple)
+        PACKAGE_PATH = /opt/local
+      else
+	ifeq ($(OS_NAME), netbsd)
+	  PACKAGE_PATH = /usr/pkg
+	else
+          PACKAGE_PATH = /usr/local
+	endif
+      endif
+    endif
+  endif
+
+  # ALSA
+  ifdef ALT_ALSA_LIB_PATH
+    ALSA_LIB_PATH = $(ALT_ALSA_LIB_PATH)
+  else
+    ALSA_LIB_PATH = $(PACKAGE_PATH)/lib
+  endif
+
+  ifdef ALT_ALSA_HEADERS_PATH
+    ALSA_HEADERS_PATH = $(ALT_ALSA_HEADERS_PATH)
+  else
+    ALSA_HEADERS_PATH = $(PACKAGE_PATH)/include
+  endif
+endif
+
 #
 # Get platform definitions
 #
@@ -179,6 +222,7 @@
 
   ifdef ALT_FREETYPE_LIB_PATH
     FREETYPE_LIB_PATH = $(ALT_FREETYPE_LIB_PATH)
+    USING_SYSTEM_FT_LIB=true
   else
     ifeq ($(DEVTOOLS_FT_DIR_EXISTS), true)
       FREETYPE_LIB_PATH = $(DEVTOOLS_FT_DIR)/lib
@@ -243,6 +287,10 @@
     LDLIBS_COMMON = -ldl
   endif
 
+  ifeq ($(PLATFORM), bsd)
+    LDLIBS_COMMON = -pthread
+  endif
+
 endif # PROGRAM
 
 LDLIBS_COMMON += $(EXTRA_LIBS)
--- ./jdk/make/common/Program.gmk	2011-05-26 18:33:53.000000000 -0700
+++ ./jdk/make/common/Program.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -73,11 +73,27 @@
 # Create a dependency on libjli (Java Launcher Infrastructure)
 #
 # On UNIX, this is a relative dependency using $ORIGIN. Unfortunately, to
-# do this reliably on Linux takes a different syntax than Solaris.
+# do this reliably on Linux takes a different syntax than Solaris. BSD's
+# don't support $ORIGIN so build an archive instead.
 #
 # On Windows, this is done by using the same directory as the executable
 # itself, as with all the Windows libraries.
 #
+ifeq ($(PLATFORM), bsd)
+  ifeq ($(OS_VENDOR), Apple)
+    LDFLAGS += -Wl,-all_load
+    LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
+  else
+    LDFLAGS += -Wl,--whole-archive
+    LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
+    LDFLAGS += -Wl,--no-whole-archive
+# Work-around an dlsym(RTLD_DEFAULT) bug in at least FreeBSD & OpenBSD
+    LDFLAGS += -Wl,--export-dynamic
+  endif
+  ifeq ($(SYSTEM_ZLIB),true)
+      OTHER_LDLIBS += -lz
+  endif
+endif
 ifneq (,$(findstring $(PLATFORM), linux solaris))	# UNIX systems
     LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli
     OTHER_LDLIBS += -ljli
@@ -183,6 +199,10 @@
   THREADLIBS = $(LIBTHREAD)
 endif # USE_PTHREADS
 
+ifeq ($(PLATFORM), bsd)
+THREADLIBS = -pthread
+endif
+
 #
 # This rule only applies on unix.  It supports quantify and its ilk.
 #
@@ -239,15 +259,19 @@
 
 
 ifneq ($(PLATFORM), windows)
+ifneq ($(PLATFORM), bsd)
 HAVE_GETHRTIME=true
 endif
+endif
 
 ifeq ($(HAVE_GETHRTIME),true)
 OTHER_CPPFLAGS += -DHAVE_GETHRTIME
 endif
 
 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin
+ifneq ($(SYSTEM_ZLIB),true)
 OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
+endif
 
 OTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"'
 VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"'
--- ./jdk/make/common/Release.gmk	2011-05-26 18:33:53.000000000 -0700
+++ ./jdk/make/common/Release.gmk	2011-05-12 20:55:05.000000000 -0700
@@ -128,7 +128,6 @@
 JDK_MAN_PAGES =            \
 	$(JRE_MAN_PAGES)   \
 	appletviewer.1     \
-        apt.1              \
 	extcheck.1         \
 	idlj.1             \
 	jar.1              \
@@ -167,6 +166,12 @@
   JA_DIRNAME=ja_JP.UTF-8
 endif # linux
 
+ifeq ($(PLATFORM), bsd)
+  MANBASEDIRS=$(JDK_TOPDIR)/src/bsd/doc $(IMPORTDOCDIR)
+  MAN1SUBDIR = man
+  JA_DIRNAME=ja_JP.UTF-8
+endif
+
 define copy-man-pages
 $(MKDIR) -p $1/man/man1
 for manbase in $(MANBASEDIRS:%=%/$(MAN1SUBDIR)) ; do \
@@ -300,6 +305,12 @@
   SOURCE_DIRS += $(CLOSED_SRC)/share/classes
 endif
 
+ifeq ($(OS_VENDOR), OpenBSD)
+  FILES_FROM_ARG=-I
+else
+  FILES_FROM_ARG=-T
+endif
+
 
 #
 # Specific files and directories that will be filtered out from above areas.
@@ -990,7 +1001,7 @@
 	@# generated by the more efficient solaris/windows method of copying files.
 	@# So for Linux, make use of the -T option (like Solaris' -I option) of
 	@# obtaining the list of files from a file. MKS tar has no such option.
-  ifeq ($(PLATFORM), linux)
+  ifneq (,$(findstring $(PLATFORM), linux bsd))
 	for d in $(SOURCE_DIRS); do \
 	  $(RM) $(ABS_TEMPDIR)/src-files.list; \
 	  ($(CD) $$d &&  \
@@ -1003,7 +1014,7 @@
 	    done ; \
 	  ) ; \
 	  if [ -f  $(ABS_TEMPDIR)/src-files.list ] ; then \
-	    ($(CD) $$d && $(TAR) cf - -T $(ABS_TEMPDIR)/src-files.list ) \
+	    ($(CD) $$d && $(TAR) cf - $(FILES_FROM_ARG) $(ABS_TEMPDIR)/src-files.list ) \
 	       | ($(CD) $(JDK_IMAGE_DIR)/src && $(TAR) xf -); \
 	  fi; \
 	done
--- ./jdk/make/common/shared/Compiler-gcc.gmk	2011-05-26 18:33:54.000000000 -0700
+++ ./jdk/make/common/shared/Compiler-gcc.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -72,6 +72,24 @@
 
 endif
 
+ifeq ($(PLATFORM), bsd)
+
+  # Settings specific to BSD
+  CC             = $(COMPILER_PATH)gcc
+  CPP            = $(COMPILER_PATH)gcc -E
+  CXX            = $(COMPILER_PATH)g++
+  REQUIRED_CC_VER = 3.2
+
+  # Option used to create a shared library
+  # Option used to create a shared library
+  ifeq ($(OS_VENDOR), Apple)
+    SHARED_LIBRARY_FLAG = -dynamiclib 
+  else
+    SHARED_LIBRARY_FLAG = -shared
+  endif
+  SUN_COMP_VER := $(shell $(CC) --verbose 2>&1 )
+endif
+
 ifeq ($(PLATFORM), solaris)
 
   # Settings specific to Solaris
--- ./jdk/make/common/shared/Defs-bsd.gmk	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/make/common/shared/Defs-bsd.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -54,7 +54,7 @@
 endef
 
 # Location on system where jdk installs might be
-USRJDKINSTANCES_PATH =/opt/java
+USRJDKINSTANCES_PATH = $(PACKAGE_PATH)
 
 # UNIXCOMMAND_PATH: path to where the most common Unix commands are.
 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
@@ -107,7 +107,7 @@
 ifneq ($(ALT_OPENWIN_HOME),)
   OPENWIN_HOME :=$(call PrefixPath,$(ALT_OPENWIN_HOME))
 else
-  OPENWIN_HOME  =/usr/X11R6/
+  OPENWIN_HOME  =$(X11_PATH)
 endif
 
 # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
@@ -115,7 +115,7 @@
 ifneq "$(origin ALT_DEVTOOLS_PATH)" "undefined"
   DEVTOOLS_PATH :=$(call PrefixPath,$(ALT_DEVTOOLS_PATH))
 else
-  DEVTOOLS_PATH =/usr/bin/
+  DEVTOOLS_PATH =$(PACKAGE_PATH)/bin/
 endif
 
 # _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
@@ -129,16 +129,12 @@
 BUILD_HEADLESS = true
 LIBM=-lm
 
-# GCC29_COMPILER_PATH: is the path to where the gcc 2.9 compiler is installed
-#  NOTE: Must end with / so that it could be empty, allowing PATH usage.
-ifdef ALT_GCC29_COMPILER_PATH
-  GCC29_COMPILER_PATH :=$(call PrefixPath,$(ALT_GCC29_COMPILER_PATH))
+ifeq ($(OS_VENDOR), Apple)
+  _CUPS_HEADERS_PATH=/usr/include
 else
-  GCC29_COMPILER_PATH = $(JDK_DEVTOOLS_DIR)/$(PLATFORM)/gcc29/usr/
+  _CUPS_HEADERS_PATH=$(PACKAGE_PATH)/include
 endif
 
-_CUPS_HEADERS_PATH=/usr/include
-
 # Import JDK images allow for partial builds, components not built are
 #    imported (or copied from) these import areas when needed.
 
@@ -196,6 +192,20 @@
 # Macro to check it's input file for banned dependencies and verify the
 #   binary built properly. Relies on process exit code.
 ifndef CROSS_COMPILE_ARCH
+ifeq ($(OS_VENDOR), Apple)
+define binary_file_verification # binary_file
+( \
+  $(ECHO) "Checking for mapfile use in: $1" && \
+  if [ "`$(NM) -g $1 | $(EGREP) 'SUNWprivate'`" = "" ] ; then \
+    $(ECHO) "WARNING: File was not built with a mapfile: $1"; \
+  fi && \
+  $(ECHO) "Library loads for: $1" && \
+  $(OTOOL) -L $1 && \
+  $(ECHO) "RUNPATH for: $1" && \
+  ( $(OTOOL) -l $1 | $(EGREP) 'path ' ) \
+) || true
+endef
+else
 define binary_file_verification # binary_file
 ( \
   $(ECHO) "Checking for mapfile use in: $1" && \
@@ -208,6 +218,7 @@
   ( $(READELF) -d $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
 )
 endef
+endif # OS_VENDOR == Apple
 else
 define binary_file_verification 
 ( \
--- ./jdk/make/common/shared/Defs-utils.gmk	2011-05-26 18:33:55.000000000 -0700
+++ ./jdk/make/common/shared/Defs-utils.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -67,6 +67,13 @@
   UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
 endif
 
+ifeq ($(PLATFORM),bsd)
+  UTILS_COMMAND_PATH=$(UNIXCOMMAND_PATH)
+  UTILS_USR_BIN_PATH=$(USRBIN_PATH)
+  UTILS_CCS_BIN_PATH=$(USRBIN_PATH)
+  UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
+endif
+
 # Utilities
 ifdef CROSS_COMPILE_ARCH
   AR             = $(COMPILER_PATH)ar
@@ -126,6 +133,8 @@
 MSGFMT         = $(UTILS_USR_BIN_PATH)msgfmt
 MV             = $(UTILS_COMMAND_PATH)mv
 NAWK           = $(UTILS_USR_BIN_PATH)nawk
+NM             = $(UTILS_CCS_BIN_PATH)nm
+OTOOL          = $(UTILS_USR_BIN_PATH)otool
 PKGMK          = $(UTILS_COMMAND_PATH)pkgmk
 PRINTF         = $(UTILS_USR_BIN_PATH)printf
 PWD            = $(UTILS_COMMAND_PATH)pwd
@@ -220,3 +229,39 @@
   ECHO           = /usr/bin/echo
 endif
 
+# BSD specific
+ifeq ($(PLATFORM),bsd)
+  BASENAME     = $(UTILS_USR_BIN_PATH)basename
+  EGREP        = $(UTILS_USR_BIN_PATH)egrep
+  EXPR         = $(UTILS_COMMAND_PATH)expr
+  FMT          = $(UTILS_USR_BIN_PATH)fmt
+  GREP         = $(UTILS_USR_BIN_PATH)grep
+  GUNZIP       = $(UTILS_USR_BIN_PATH)gunzip
+  ID           = $(UTILS_USR_BIN_PATH)id
+  MSGFMT       = $(UTILS_DEVTOOL_PATH)msgfmt
+  SED          = $(UTILS_USR_BIN_PATH)sed
+  SORT         = $(UTILS_USR_BIN_PATH)sort
+  TEST         = $(UTILS_COMMAND_PATH)test
+  TOUCH        = $(UTILS_USR_BIN_PATH)touch
+  TRUE         = $(UTILS_USR_BIN_PATH)true
+  UNAME        = $(UTILS_USR_BIN_PATH)uname
+  # BSD OS_VENDOR specific
+  ifeq ($(OS_VENDOR), Apple)
+    NAWK       = $(UTILS_USR_BIN_PATH)awk
+    UNZIPSFX   = $(UTILS_USR_BIN_PATH)unzipsfx
+    ZIPEXE     = $(UTILS_USR_BIN_PATH)zip
+  else
+    UNZIP      = $(UTILS_DEVTOOL_PATH)unzip
+  endif
+  ifeq ($(OS_VENDOR), OpenBSD)
+    NAWK       = $(UTILS_USR_BIN_PATH)awk
+  else
+    CPIO       = $(UTILS_USR_BIN_PATH)cpio
+    TAR        = $(UTILS_USR_BIN_PATH)tar
+  endif
+  ifeq ($(OS_VENDOR), NetBSD)
+    NAWK       = $(UTILS_USR_BIN_PATH)awk
+    ZIPEXE     = $(UTILS_DEVTOOL_PATH)zip
+    UNZIP      = $(UTILS_DEVTOOL_PATH)unzip
+  endif
+endif
--- ./jdk/make/common/shared/Defs-versions.gmk	2011-05-26 18:33:55.000000000 -0700
+++ ./jdk/make/common/shared/Defs-versions.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -44,6 +44,11 @@
   override CC_VERSION = gcc
 endif
 
+# BSD uses GNU compilers by default
+ifeq ($(PLATFORM), bsd)
+  override CC_VERSION = gcc
+endif
+
 ##########################################################################
 #
 # List of JDK official minimum, expected, or required versions:
--- ./jdk/make/common/shared/Platform.gmk	2011-05-26 18:33:55.000000000 -0700
+++ ./jdk/make/common/shared/Platform.gmk	2011-05-07 21:54:09.000000000 -0700
@@ -86,7 +86,7 @@
 SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files .hgignore .hgtags
 # When changing SCM_DIRs also change SCM_DIRS_rexp and SCM_DIRS_prune:
 SCM_DIRS_rexp = ".hg|.svn|CVS|RCS|SCCS|Codemgr_wsdata|deleted_files|.hgignore|.hgtags"
-SCM_DIRS_prune = \( -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files -o -name .hgignore -o -name .hgtags \) -prune
+SCM_DIRS_prune = \( -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files -o -name .hgignore -o -name .hgtags -o -name \*.orig \) -prune
 
 # Don't define this unless it's not defined
 ifndef VARIANT
@@ -224,6 +224,101 @@
   MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
 endif
 
+ifeq ($(SYSTEM_UNAME), FreeBSD)
+  PLATFORM = bsd
+  OS_NAME = freebsd
+  OS_VENDOR = FreeBSD
+  REQUIRED_OS_VERSION = 6.0
+endif
+
+ifeq ($(SYSTEM_UNAME), Darwin)
+  PLATFORM = bsd
+  OS_NAME = darwin
+  OS_VENDOR = Apple
+  REQUIRED_OS_VERSION = 8.0
+endif
+
+ifeq ($(SYSTEM_UNAME), NetBSD)
+  PLATFORM = bsd
+  OS_NAME = netbsd
+  OS_VENDOR = NetBSD
+  REQUIRED_OS_VERSION = 3.0
+endif
+
+ifeq ($(SYSTEM_UNAME), OpenBSD)
+  PLATFORM = bsd
+  OS_NAME = openbsd
+  OS_VENDOR = OpenBSD
+  REQUIRED_OS_VERSION = 4.2
+endif
+
+# Platform settings specific to BSD
+ifeq ($(PLATFORM), bsd)
+  OS_VERSION := $(shell uname -r)
+  # Arch and OS name/version
+  mach := $(shell uname -m)
+  archExpr = case "$(mach)" in \
+                i[3-9]86) \
+                    echo i586 \
+                    ;; \
+                sparc64) \
+                    echo sparcv9 \
+                    ;; \
+                sparc*) \
+                    echo sparc \
+                    ;; \
+                x86_64) \
+                    echo amd64 \
+                    ;; \
+                "Power Macintosh") \
+                    echo ppc \
+                    ;; \
+                *) \
+                    echo $(mach) \
+                    ;; \
+      esac
+  ARCH        := $(shell $(archExpr) )
+  ARCH_FAMILY := $(ARCH)
+
+  # Darwin builds may be 32-bit or 64-bit data model.
+  ifeq ($(SYSTEM_UNAME), Darwin)
+    ifeq ($(ARCH), i586)
+      ifeq ($(ARCH_DATA_MODEL), 64)
+        ARCH=amd64
+      endif
+    endif
+  endif
+
+  # i586, sparc, and ppc are 32 bit, amd64 and sparc64 are 64
+  ifneq (,$(findstring $(ARCH), i586 sparc ppc))
+    ARCH_DATA_MODEL=32
+  else
+    ARCH_DATA_MODEL=64
+  endif
+
+  # Need to maintain the jre/lib/i386 location for 32-bit Intel
+  ifeq ($(ARCH), i586)
+    LIBARCH = i386
+  else
+    LIBARCH = $(ARCH)
+  endif
+
+  # Value of Java os.arch property
+  ARCHPROP  = $(LIBARCH)
+
+  # Suffix for file bundles used in previous release
+  BUNDLE_FILE_SUFFIX=.tar.gz
+  # Minimum disk space needed as determined by running 'du -sk' on 
+  #    a fully built workspace.
+  REQUIRED_FREE_SPACE=1500000
+  # How much RAM does this machine have:
+  ifeq ($(OS_VENDOR), OpenBSD)
+    MB_OF_MEMORY=$(shell sysctl -n hw.physmem | awk '{print int($$NF / 1048576); }' )
+  else
+    MB_OF_MEMORY=$(shell (sysctl -n hw.physmem64 2> /dev/null || sysctl -n hw.physmem) | awk '{print int($$NF / 1048576); }' )
+  endif
+endif
+
 # Windows with and without CYGWIN will be slightly different
 ifeq ($(SYSTEM_UNAME), Windows_NT)
   PLATFORM = windows
@@ -425,6 +520,14 @@
   ARCH_VM_SUBDIR=jre/lib/$(LIBARCH)
 endif
 
+# Darwin-specific Overrides
+ifeq ($(SYSTEM_UNAME),Darwin)
+  # The suffix applied to runtime libraries
+  LIBRARY_SUFFIX = dylib
+  # The suffix applied to link libraries
+  LIB_SUFFIX = dylib
+endif
+
 # Machines with 512Mb or less of real memory are considered low memory
 #    build machines and adjustments will be made to prevent excessing
 #    system swapping during the build.
@@ -452,6 +555,18 @@
   export MIN_VM_MEMORY
 endif
 
+# for OpenBSD/i386 limit to 736 max
+ifeq ($(OS_VENDOR), OpenBSD)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    MAX_VM_MEMORY := $(shell \
+      if [ $(MAX_VM_MEMORY) -gt 736 ] ; then \
+        echo "736"; \
+      else \
+        echo "$(MAX_VM_MEMORY)" ; \
+      fi)
+  endif
+endif
+
 # If blanks in the username, use the first 4 words and pack them together
 _USER1:=$(subst ', ,$(_USER))
 _USER2:=$(subst ", ,$(_USER1))
--- ./jdk/make/common/shared/Sanity.gmk	2011-05-26 18:33:55.000000000 -0700
+++ ./jdk/make/common/shared/Sanity.gmk	2011-05-07 23:39:41.000000000 -0700
@@ -140,6 +140,9 @@
     $(EGREP) "\#define" | $(NAWK) '{print $$3}')
 endif
 
+ifeq ($(PLATFORM), bsd)
+endif
+
 # Get the version numbers of what we are using
 _MAKE_VER  :=$(shell $(MAKE) --version 2>&1 | $(HEAD) -n 1)
 _ZIP_VER   :=$(shell $(ZIPEXE) -help 2>&1 | $(HEAD) -n 4 | $(EGREP) '^Zip')
@@ -839,8 +842,10 @@
 
 ######################################################
 # Check for existence of DEVTOOLS_PATH
+# All needed tools come with base system on Apple
 ######################################################
 sane-devtools_path:
+ifneq ($(OS_VENDOR), Apple)
 	@if [ "$(DEVTOOLS_PATH)" != "" -a ! -r "$(DEVTOOLS_PATH)" ]; then \
 	  $(ECHO) "ERROR: You do not have a valid DEVTOOLS_PATH setting. \n" \
 	    "      Please check your access to \n" \
@@ -848,6 +853,7 @@
 	    "      and/or check your value of ALT_DEVTOOLS_PATH. \n" \
 	    "" >> $(ERROR_FILE) ; \
 	fi
+endif
 
 ######################################################
 # Check for existence of MS_RUNTIME_LIBRARIES
--- ./jdk/make/java/Makefile	2011-05-26 18:33:56.000000000 -0700
+++ ./jdk/make/java/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -53,7 +53,7 @@
   endif
 endif # PLATFORM
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
   SUBDIRS += jexec
 endif # PLATFORM
 
--- ./jdk/make/java/instrument/Makefile	2011-05-26 18:33:57.000000000 -0700
+++ ./jdk/make/java/instrument/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -102,9 +102,29 @@
   # equivalent of strcasecmp is stricmp on Windows
   CPPFLAGS_COMMON += -Dstrcasecmp=stricmp
 else
+ifeq ($(PLATFORM), bsd)
+  ifeq ($(OS_VENDOR), Apple)
+    LDFLAGS += -Wl,-all_load
+    LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
+    OTHER_LDLIBS += -liconv
+  else
+    LDFLAGS += -Wl,--whole-archive
+    LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
+    LDFLAGS += -Wl,--no-whole-archive
+    ifneq ($(OS_NAME), netbsd)
+# Use CPPFLAGS instead of OTHER_INCLUDES to force this last
+      CPPFLAGS += -I$(PACKAGE_PATH)/include
+      OTHER_LDLIBS += -L$(PACKAGE_PATH)/lib -liconv
+    endif
+  endif
+
+  ifeq ($(SYSTEM_ZLIB), true)
+    OTHER_LDLIBS += -lz
+  endif
+else
   LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli
   OTHER_LDLIBS += -ljli
-  OTHER_LDLIBS += -ldl 
+  OTHER_LDLIBS += $(LIBDL)
   ifeq ($(PLATFORM), solaris)
     LDFLAGS += -R \$$ORIGIN/jli
   endif
@@ -114,6 +134,7 @@
     LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/jli
   endif
 endif
+endif
 
 #
 # Library to compile.
--- ./jdk/make/java/java/Makefile	2011-05-26 18:33:58.000000000 -0700
+++ ./jdk/make/java/java/Makefile	2011-05-12 20:55:05.000000000 -0700
@@ -165,8 +165,10 @@
 # Is the altzone extern documented in ctime(3C) available?
 #
 ifneq ($(PLATFORM), windows)
+ifneq ($(PLATFORM), bsd)
 HAVE_ALTZONE=true
 endif
+endif
 
 ifeq ($(HAVE_ALTZONE),true)
 OTHER_CPPFLAGS += -DHAVE_ALTZONE
@@ -205,7 +207,7 @@
 		       -libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \
 		       shell32.lib delayimp.lib /DELAYLOAD:shell32.dll
 else
-OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
+OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) $(LIBDL) \
 		-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
 endif
 
--- ./jdk/make/java/java/genlocales.gmk	2011-05-26 18:33:58.000000000 -0700
+++ ./jdk/make/java/java/genlocales.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -76,10 +76,14 @@
 $(LocaleDataMetaInfo_Dest):$(LocaleDataMetaInfo_Src) $(LOCALEGEN_SH)
 	@$(RM) $@.tmp.euro $@.tmp.noneuro;
 	@$(prep-target) 
-	@$(ECHO) $(subst .properties,'\n',$(Euro_Resources_properties)) > $@.tmp.euro;
-	@$(ECHO) $(subst .java,'\n',$(Euro_Resources_java)) >> $@.tmp.euro;	
-	@$(ECHO) $(subst .properties,'\n',$(NonEuro_Resources_properties)) > $@.tmp.noneuro;
-	@$(ECHO) $(subst .java,'\n',$(NonEuro_Resources_java)) >> $@.tmp.noneuro;
+	@$(ECHO) $(Euro_Resources_properties) | $(SED) -e s@.properties@'\
+'@g > $@.tmp.euro;
+	@$(ECHO) $(Euro_Resources_java) | $(SED) -e s@.java@'\
+'@g >> $@.tmp.euro;
+	@$(ECHO) $(NonEuro_Resources_properties) | $(SED) -e s@.properties@'\
+'@g > $@.tmp.noneuro;
+	@$(ECHO) $(NonEuro_Resources_java) | $(SED) -e s@.java@'\
+'@g >> $@.tmp.noneuro;
 	NAWK="$(NAWK)" SED="$(SED)" SORT="$(SORT)" \
 	     $(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.euro \
 		$@.tmp.noneuro $< $@
--- ./jdk/make/java/java/localegen.sh	2011-05-26 18:33:58.000000000 -0700
+++ ./jdk/make/java/java/localegen.sh	2011-04-22 23:08:15.000000000 -0700
@@ -55,9 +55,9 @@
 for FILE in $RESOURCE_NAMES 
 do
     getlocalelist $FILE $EURO_FILES_LIST
-    sed_script=$sed_script"-e \"s/#"$FILE"_EuroLocales#/$localelist/g\" "
+    sed_script=$sed_script"-e \"s@#"$FILE"_EuroLocales#@$localelist@g\" "
     getlocalelist $FILE $NONEURO_FILES_LIST
-    sed_script=$sed_script"-e \"s/#"$FILE"_NonEuroLocales#/$localelist/g\" "
+    sed_script=$sed_script"-e \"s@#"$FILE"_NonEuroLocales#@$localelist@g\" "
 done
 
 sed_script=$sed_script"$INPUT_FILE > $OUTPUT_FILE"
--- ./jdk/make/java/java_hprof_demo/Makefile	2011-05-26 18:33:59.000000000 -0700
+++ ./jdk/make/java/java_hprof_demo/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -83,7 +83,7 @@
 ifeq ($(PLATFORM), windows)
   OTHER_LDLIBS += wsock32.lib winmm.lib
 else
-  OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) -ldl
+  OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) $(LIBDL)
 endif
 
 #
--- ./jdk/make/java/jli/Makefile	2011-05-26 18:33:59.000000000 -0700
+++ ./jdk/make/java/jli/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -44,7 +44,9 @@
 
 include $(BUILDDIR)/common/Defs.gmk
 
+ifneq ($(SYSTEM_ZLIB),true)
 ZIP_SRC = $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+endif
 LAUNCHER_SHARE_SRC = $(SHARE_SRC)/bin
 LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)/bin
 
@@ -69,13 +71,17 @@
 	parse_manifest.c \
 	version_comp.c \
 	wildcard.c \
-	jli_util.c \
+	jli_util.c
+
+ifneq ($(SYSTEM_ZLIB),true)
+FILES_c += \
 	inflate.c \
 	inftrees.c \
 	inffast.c \
 	zadler32.c \
 	zcrc32.c \
 	zutil.c
+endif
 
 ifneq ($(PLATFORM), windows)
   FILES_c += ergo.c 
@@ -96,7 +102,7 @@
   LIBARCH_DEFINES += -DLIBARCH64NAME='"$(LIBARCH64)"'
 endif
 
-OTHER_CPPFLAGS += $(LIBARCH_DEFINES)
+OTHER_CPPFLAGS += $(LIBARCH_DEFINES) -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
 
 
 ifneq ($(PLATFORM), windows)	# UNIX systems
@@ -105,7 +111,7 @@
 	# Note: its important to keep this order meaning -lc is the
 	# last library otherwise it could cause compatibility issues
 	# by pulling in SUNW_private symbols from libc
-	LDLIBS = -ldl -lc
+	LDLIBS = $(LIBDL) -lc
 ifeq ($(USE_PTHREADS),true)
 	LDLIBS += -lpthread
 endif # USE_PTHREADS 
@@ -129,7 +135,11 @@
 
 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)
 OTHER_INCLUDES += -I$(LAUNCHER_PLATFORM_SRC)
-OTHER_INCLUDES += -I$(ZIP_SRC)
+ifneq ($(SYSTEM_ZLIB),true)
+  OTHER_INCLUDES += -I$(ZIP_SRC)
+else
+  LDLIBS += -lz
+endif
 
 #
 # Library to compile.
@@ -161,7 +171,28 @@
 
 endif	# PLATFORM
 
+ifeq ($(PLATFORM), bsd)
+
+STATIC_LIBRARY_DIR = $(OBJDIR)/static
+STATIC_LIBRARY_NAME = lib$(LIBRARY).a
+STATIC_LIBRARY = $(STATIC_LIBRARY_DIR)/$(STATIC_LIBRARY_NAME)
+
+$(STATIC_LIBRARY_DIR): $(OBJDIR)
+	@$(MKDIR) $(STATIC_LIBRARY_DIR)
+
+$(STATIC_LIBRARY): $(STATIC_LIBRARY_DIR)
+	@$(prep-target)
+	$(AR) -r $@ $(FILES_o)
+
+library:: $(STATIC_LIBRARY)
+
+endif  # PLATFORM
+
 #
 # Add to ambient vpath so we pick up the library files
 #
-vpath %.c $(LAUNCHER_SHARE_SRC) $(ZIP_SRC) $(LAUNCHER_PLATFORM_SRC)
+vpath %.c $(LAUNCHER_SHARE_SRC) $(LAUNCHER_PLATFORM_SRC)
+ifneq ($(SYSTEM_ZLIB),true)
+  vpath %.c $(ZIP_SRC)
+endif
+
--- ./jdk/make/java/net/FILES_c.gmk	2011-05-26 18:34:02.000000000 -0700
+++ ./jdk/make/java/net/FILES_c.gmk	2011-04-22 23:08:15.000000000 -0700
@@ -43,6 +43,10 @@
     FILES_c += linux_close.c
 endif
 
+ifeq ($(OS_VENDOR), FreeBSD)
+    FILES_c += $(CTARGDIR)bsd_close.c
+endif
+
 ifeq ($(PLATFORM), windows)
     FILES_c += TwoStacksPlainSocketImpl.c
     FILES_c += DualStackPlainSocketImpl.c
--- ./jdk/make/java/net/Makefile	2011-05-26 18:34:02.000000000 -0700
+++ ./jdk/make/java/net/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -91,16 +91,23 @@
 
 include $(BUILDDIR)/common/Library.gmk
 
+ifeq ($(PLATFORM), bsd)
+ifdef DONT_ENABLE_IPV6
+  OTHER_CFLAGS += -DDONT_ENABLE_IPV6
+endif
+  OTHER_LDLIBS = $(JVMLIB) -pthread
+else
 ifeq ($(PLATFORM), windows)
   OTHER_LDLIBS = ws2_32.lib $(JVMLIB) \
                  secur32.lib iphlpapi.lib delayimp.lib \
                  /DELAYLOAD:secur32.dll /DELAYLOAD:iphlpapi.dll
 else
-  OTHER_LDLIBS = $(LIBSOCKET) $(LIBNSL) -ldl $(JVMLIB)
+  OTHER_LDLIBS = $(LIBSOCKET) $(LIBNSL) $(LIBDL) $(JVMLIB)
 endif
 ifeq ($(PLATFORM), linux)
   OTHER_LDLIBS += -lpthread
 endif
+endif # PLATFORM == bsd
 
 CLASSES.export += java.lang.Integer java.io.FileDescriptor java.net.InetAddressImplFactory java.net.Inet4AddressImpl java.net.Inet6AddressImpl
 
--- ./jdk/make/java/nio/Makefile	2011-05-26 18:34:02.000000000 -0700
+++ ./jdk/make/java/nio/Makefile	2011-04-22 23:08:15.000000000 -0700
@@ -260,6 +260,69 @@
 	sun/nio/fs/UnixConstants.java
 endif # PLATFORM = linux
 
+ifeq ($(PLATFORM), bsd)
+FILES_java += \
+        sun/nio/ch/AbstractPollSelectorImpl.java \
+	sun/nio/ch/InheritedChannel.java \
+        sun/nio/ch/PollSelectorProvider.java \
+        sun/nio/ch/PollSelectorImpl.java \
+	sun/nio/ch/Port.java \
+	sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \
+	sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+	sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+	\
+	sun/nio/fs/GnomeFileTypeDetector.java \
+	sun/nio/fs/BsdFileStore.java \
+	sun/nio/fs/BsdFileSystem.java \
+	sun/nio/fs/BsdFileSystemProvider.java \
+	sun/nio/fs/BsdNativeDispatcher.java \
+	sun/nio/fs/PollingWatchService.java \
+	sun/nio/fs/UnixChannelFactory.java \
+	sun/nio/fs/UnixCopyFile.java \
+	sun/nio/fs/UnixDirectoryStream.java \
+	sun/nio/fs/UnixException.java \
+	sun/nio/fs/UnixFileAttributeViews.java \
+	sun/nio/fs/UnixFileAttributes.java \
+	sun/nio/fs/UnixFileKey.java \
+	sun/nio/fs/UnixFileModeAttribute.java \
+	sun/nio/fs/UnixFileStore.java \
+	sun/nio/fs/UnixFileStoreAttributes.java \
+	sun/nio/fs/UnixFileSystem.java \
+	sun/nio/fs/UnixFileSystemProvider.java \
+	sun/nio/fs/UnixMountEntry.java \
+	sun/nio/fs/UnixNativeDispatcher.java \
+	sun/nio/fs/UnixPath.java \
+	sun/nio/fs/UnixSecureDirectoryStream.java \
+	sun/nio/fs/UnixUriUtils.java \
+	sun/nio/fs/UnixUserPrincipals.java
+
+FILES_c += \
+	InheritedChannel.c \
+	NativeThread.c \
+        PollArrayWrapper.c \
+	UnixAsynchronousServerSocketChannelImpl.c \
+	UnixAsynchronousSocketChannelImpl.c \
+	\
+	GnomeFileTypeDetector.c \
+	BsdNativeDispatcher.c \
+	UnixCopyFile.c \
+	UnixNativeDispatcher.c
+
+FILES_export += \
+	sun/nio/ch/InheritedChannel.java \
+	sun/nio/ch/NativeThread.java \
+	sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+	sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+	\
+	sun/nio/fs/GnomeFileTypeDetector.java \
+	sun/nio/fs/BsdNativeDispatcher.java \
+	sun/nio/fs/UnixCopyFile.java \
+	sun/nio/fs/UnixNativeDispatcher.java
+	
+FILES_gen += \
+	sun/nio/fs/UnixConstants.java
+endif # PLATFORM = bsd
+
 #
 # Find platform-specific C source files
 #
@@ -292,10 +355,13 @@
      $(OBJDIR)/../../../java.lang/java/$(OBJDIRNAME)/FileDescriptor_md.obj
 endif
 ifeq ($(PLATFORM), linux)
-OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread -ldl
+OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread $(LIBDL)
+endif
+ifeq ($(PLATFORM), bsd)
+OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -pthread
 endif
 ifeq ($(PLATFORM), solaris)
-OTHER_LDLIBS += $(JVMLIB) $(LIBSOCKET) -lposix4 -ldl -lsendfile \
+OTHER_LDLIBS += $(JVMLIB) $(LIBSOCKET) -lposix4 $(LIBDL) -lsendfile \
 		-L$(LIBDIR)/$(LIBARCH) -ljava -lnet
 endif # PLATFORM
 
@@ -316,6 +382,9 @@
 ifeq ($(PLATFORM), linux)
 FILES_m = mapfile-linux
 endif
+ifeq ($(PLATFORM), bsd)
+FILES_m = mapfile-bsd
+endif
 include $(BUILDDIR)/common/Mapfile-vers.gmk
 include $(BUILDDIR)/common/Library.gmk
 
--- ./jdk/make/java/nio/mapfile-bsd	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/make/java/nio/mapfile-bsd	2011-05-12 20:59:33.000000000 -0700
@@ -36,24 +36,6 @@
                 Java_sun_nio_ch_DatagramDispatcher_readv0;
                 Java_sun_nio_ch_DatagramDispatcher_write0;
                 Java_sun_nio_ch_DatagramDispatcher_writev0;
-                Java_sun_nio_ch_EPollArrayWrapper_epollCreate;
-                Java_sun_nio_ch_EPollArrayWrapper_epollCtl;
-                Java_sun_nio_ch_EPollArrayWrapper_epollWait;
-		Java_sun_nio_ch_EPollArrayWrapper_fdLimit;
-		Java_sun_nio_ch_EPollArrayWrapper_init;
-		Java_sun_nio_ch_EPollArrayWrapper_interrupt;
-		Java_sun_nio_ch_EPollArrayWrapper_offsetofData;
-		Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent;
-		Java_sun_nio_ch_EPoll_eventSize;
-		Java_sun_nio_ch_EPoll_eventsOffset;
-		Java_sun_nio_ch_EPoll_dataOffset;
-		Java_sun_nio_ch_EPoll_epollCreate;
-		Java_sun_nio_ch_EPoll_epollCtl;
-		Java_sun_nio_ch_EPoll_epollWait;
-		Java_sun_nio_ch_EPollPort_close0;
-		Java_sun_nio_ch_EPollPort_drain1;
-		Java_sun_nio_ch_EPollPort_interrupt;
-		Java_sun_nio_ch_EPollPort_socketpair;
                 Java_sun_nio_ch_FileChannelImpl_close0;
                 Java_sun_nio_ch_FileChannelImpl_initIDs;
                 Java_sun_nio_ch_FileChannelImpl_map0;
@@ -124,25 +106,14 @@
 		Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
 		Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
 		Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
+		Java_sun_nio_fs_BsdNativeDispatcher_initIDs;
+		Java_sun_nio_fs_BsdNativeDispatcher_getfsstat;
+		Java_sun_nio_fs_BsdNativeDispatcher_fsstatEntry;
+		Java_sun_nio_fs_BsdNativeDispatcher_endfsstat;
 		Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
 		Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
 		Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
 		Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
-		Java_sun_nio_fs_BsdWatchService_eventSize;
-		Java_sun_nio_fs_BsdWatchService_eventOffsets;
-		Java_sun_nio_fs_BsdWatchService_inotifyInit;
-		Java_sun_nio_fs_BsdWatchService_inotifyAddWatch;
-		Java_sun_nio_fs_BsdWatchService_inotifyRmWatch;
-		Java_sun_nio_fs_BsdWatchService_configureBlocking;
-		Java_sun_nio_fs_BsdWatchService_socketpair;
-		Java_sun_nio_fs_BsdWatchService_poll;
-		Java_sun_nio_fs_BsdNativeDispatcher_init;
-		Java_sun_nio_fs_BsdNativeDispatcher_fgetxattr0;
-		Java_sun_nio_fs_BsdNativeDispatcher_flistxattr;
-		Java_sun_nio_fs_BsdNativeDispatcher_fsetxattr0;
-		Java_sun_nio_fs_BsdNativeDispatcher_fremovexattr0;
-		Java_sun_nio_fs_BsdNativeDispatcher_setmntent0;
-		Java_sun_nio_fs_BsdNativeDispatcher_endmntent;
 		Java_sun_nio_fs_UnixNativeDispatcher_init;
 		Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
 		Java_sun_nio_fs_UnixNativeDispatcher_strerror;
--- ./jdk/make/java/npt/Makefile	2011-05-26 18:34:03.000000000 -0700
+++ ./jdk/make/java/npt/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -67,6 +67,18 @@
   OTHER_LCF += -export:nptInitialize -export:nptTerminate
 endif
 
+# Add location of iconv headers
+ifeq ($(PLATFORM), bsd)
+  ifeq ($(OS_VENDOR), Apple)
+    OTHER_LDLIBS += -liconv
+  else
+    ifneq ($(OS_NAME), netbsd)
+      CPPFLAGS += -I$(PACKAGE_PATH)/include
+      OTHER_LDLIBS += -L$(PACKAGE_PATH)/lib -liconv
+    endif
+  endif
+endif
+
 #
 # Add to ambient vpath so we pick up the library files
 #
--- ./jdk/make/java/redist/fonts/Makefile	2011-05-26 18:34:04.000000000 -0700
+++ ./jdk/make/java/redist/fonts/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -42,7 +42,7 @@
 	$(LIBDIR)/fonts/LucidaSansRegular.ttf       	\
 	$(LIBDIR)/fonts/LucidaSansDemiBold.ttf       	\
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
 
 # The oblique versions of the font are derived from the base versions
 # and since 2D can do this derivation on the fly at run time there is no
@@ -82,7 +82,7 @@
 $(FONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.fonts.dir
 	$(install-file)
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
 
 # The oblique fonts are only needed/wanted on Linux.
 
@@ -96,7 +96,7 @@
 $(OBLFONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.oblique-fonts.dir
 	$(install-file)
 
-endif # linux
+endif # linux || bsd
 
 all build : $(INTERNAL_IMPORT_LIST)
 
--- ./jdk/make/java/security/Makefile	2011-05-26 18:34:04.000000000 -0700
+++ ./jdk/make/java/security/Makefile	2011-05-12 20:58:11.000000000 -0700
@@ -47,7 +47,14 @@
 # Register Microsoft CryptoAPI provider only on Windows platform.
 ifeq ($(PLATFORM), windows)
   PROPS_SRC   = $(TOPDIR)/src/share/lib/security/java.security-windows
-endif
+else # windows
+
+ifeq ($(PLATFORM), bsd)
+  ifeq ($(OS_VENDOR), OpenBSD)
+    PROPS_SRC   = $(TOPDIR)/src/share/lib/security/java.security-openbsd
+  endif
+endif # bsd
+endif # windows
 endif # PLATFORM
 
 
--- ./jdk/make/java/zip/FILES_c.gmk	2011-05-26 18:34:06.000000000 -0700
+++ ./jdk/make/java/zip/FILES_c.gmk	2011-04-22 23:08:16.000000000 -0700
@@ -29,7 +29,10 @@
 	Deflater.c \
 	Inflater.c \
 	ZipFile.c \
-	zip_util.c \
+	zip_util.c
+
+ifneq ($(SYSTEM_ZLIB),true)
+FILES_c += \
 	compress.c \
 	deflate.c \
 	gzio.c \
@@ -41,4 +44,5 @@
 	uncompr.c \
 	zadler32.c \
 	zcrc32.c \
-	zutil.c 
+	zutil.c
+endif
--- ./jdk/make/java/zip/Makefile	2011-05-26 18:34:06.000000000 -0700
+++ ./jdk/make/java/zip/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -74,16 +74,24 @@
 CPPFLAGS += -UDEBUG 
 endif
 
-CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
 CPPFLAGS += -I$(SHARE_SRC)/native/java/io
 CPPFLAGS += -I$(PLATFORM_SRC)/native/java/io
 
+ifneq ($(SYSTEM_ZLIB),true)
+CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+
 #
 # Add to ambient vpath so we pick up the library files
 #
 vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/zlib-$(ZLIB_VERSION)
+endif
 
 #
 # Link to JVM library for JVM_Zip* functions
 #
+ifeq ($(SYSTEM_ZLIB),true)
+OTHER_LDLIBS = -lz
+else
 OTHER_LDLIBS = $(JVMLIB)
+endif
+
--- ./jdk/make/javax/sound/FILES_c.gmk	2011-05-26 18:34:09.000000000 -0700
+++ ./jdk/make/javax/sound/FILES_c.gmk	2011-04-22 23:08:16.000000000 -0700
@@ -34,6 +34,8 @@
 
 FILES_linux = 
 
+FILES_bsd =
+
 FILES_windows = \
 	PLATFORM_API_WinOS_MidiIn.c \
 	PLATFORM_API_WinOS_MidiOut.c \
--- ./jdk/make/javax/sound/Makefile	2011-05-26 18:34:10.000000000 -0700
+++ ./jdk/make/javax/sound/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -105,6 +105,22 @@
   #MXSPP_ADD = $(PLATFORM)-$(ARCH)/
 endif # PLATFORM linux
 
+# XXXBSD: ???
+ifeq ($(PLATFORM), bsd)
+ifeq ($(OS_VENDOR), FreeBSD)
+  # ALSA handles directaudio, ports, and MIDI
+  SUBDIRS += jsoundalsa
+  EXTRA_SOUND_JNI_LIBS += jsoundalsa
+else
+    # build with empty MIDI i/o
+    INCLUDE_MIDI = TRUE
+    # build with empty ports
+    INCLUDE_PORTS = TRUE
+    # build with empty direct audio
+    INCLUDE_DAUDIO = TRUE
+endif
+endif # PLATFORM bsd
+
 ifeq ($(PLATFORM), solaris)
   # build with ports and direct audio
   CPPFLAGS += -DUSE_PORTS=TRUE 	\
--- ./jdk/make/javax/sound/SoundDefs.gmk	2011-05-26 18:34:10.000000000 -0700
+++ ./jdk/make/javax/sound/SoundDefs.gmk	2011-04-22 23:08:16.000000000 -0700
@@ -40,6 +40,10 @@
   CPPFLAGS += -DX_PLATFORM=X_LINUX
 endif # PLATFORM linux
 
+ifeq ($(PLATFORM), bsd)
+  CPPFLAGS += -DX_PLATFORM=X_BSD
+endif # PLATFORM bsd
+
 ifeq ($(PLATFORM), solaris)
   CPPFLAGS += -DX_PLATFORM=X_SOLARIS
 
--- ./jdk/make/javax/sound/jsoundalsa/Makefile	2011-05-26 18:34:10.000000000 -0700
+++ ./jdk/make/javax/sound/jsoundalsa/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -51,6 +51,7 @@
 	$(PORTFILES_c)
 
 # platform dependent files
+ifeq ($(PLATFORM), linux)
 FILES_c += \
 	PLATFORM_API_LinuxOS_ALSA_CommonUtils.c   \
 	PLATFORM_API_LinuxOS_ALSA_PCM.c     \
@@ -60,19 +61,37 @@
 	PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
 	PLATFORM_API_LinuxOS_ALSA_Ports.c
 
+MIDI_CPPFLAGS= \
+	-DUSE_PLATFORM_MIDI_OUT=TRUE \
+	-DUSE_PLATFORM_MIDI_IN=TRUE
+endif
+
+ifeq ($(PLATFORM), bsd)
+FILES_c += \
+	PLATFORM_API_BsdOS_ALSA_CommonUtils.c   \
+	PLATFORM_API_BsdOS_ALSA_PCM.c     \
+	PLATFORM_API_BsdOS_ALSA_PCMUtils.c   \
+	PLATFORM_API_BsdOS_ALSA_MidiIn.c  \
+	PLATFORM_API_BsdOS_ALSA_MidiOut.c \
+	PLATFORM_API_BsdOS_ALSA_MidiUtils.c \
+	PLATFORM_API_BsdOS_ALSA_Ports.c
+
+MIDI_CPPFLAGS=
+endif
+
 FILES_export = \
 	$(DAUDIOFILES_export) \
 	$(MIDIFILES_export) \
 	$(PORTFILES_export)
 
-LDFLAGS += -lasound
+LDFLAGS += -L$(ALSA_LIB_PATH) -lasound
 
 CPPFLAGS += \
 	-DUSE_DAUDIO=TRUE \
 	-DUSE_PORTS=TRUE  \
-	-DUSE_PLATFORM_MIDI_OUT=TRUE \
-	-DUSE_PLATFORM_MIDI_IN=TRUE \
-	-I$(SHARE_SRC)/native/com/sun/media/sound
+	$(MIDI_CPPFLAGS) \
+	-I$(SHARE_SRC)/native/com/sun/media/sound \
+	-I$(ALSA_HEADERS_PATH)
 
 #
 # Add to the ambient VPATH.
--- ./jdk/make/jpda/back/Makefile	2011-05-26 18:34:11.000000000 -0700
+++ ./jdk/make/jpda/back/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -49,7 +49,7 @@
                  -I$(GENNATIVESRCDIR)/jdwp
 
 ifneq ($(PLATFORM), windows)
-  OTHER_LDLIBS += -ldl
+  OTHER_LDLIBS += $(LIBDL)
 endif # PLATFORM
 
 #
--- ./jdk/make/jpda/transport/socket/Makefile	2011-05-26 18:34:12.000000000 -0700
+++ ./jdk/make/jpda/transport/socket/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -40,6 +40,11 @@
   OTHER_LDLIBS += $(LIBNSL) $(LIBSOCKET) -lpthread
 endif
 
+ifeq ($(PLATFORM), bsd)
+  LIBSOCKET =
+  OTHER_LDLIBS += -pthread
+endif
+
 ifeq ($(PLATFORM), solaris)
   OTHER_LDLIBS += $(LIBNSL) $(LIBSOCKET)
 endif
--- ./jdk/make/mkdemo/jvmti/hprof/Makefile	2011-05-26 18:34:19.000000000 -0700
+++ ./jdk/make/mkdemo/jvmti/hprof/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -37,12 +37,11 @@
 
 ifeq ($(PLATFORM), windows)
   EXTRA_LIBS += wsock32.lib winmm.lib
-endif
-ifeq ($(PLATFORM), solaris)
-  OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) -ldl
-endif
+else
+  OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) $(LIBDL)
 ifeq ($(PLATFORM), linux)
-  OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) -ldl -lpthread
+  OTHER_LDLIBS += -lpthread
+endif
 endif
 
 #
--- ./jdk/make/sun/awt/Makefile	2011-05-26 18:34:33.000000000 -0700
+++ ./jdk/make/sun/awt/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -93,7 +93,7 @@
 ifeq  ($(PLATFORM), solaris)
 FILES_c = $(FILES_2D_c)
 FILES_c += awt_LoadLibrary.c
-OTHER_LDLIBS = $(JVMLIB) $(LIBM) -ldl
+OTHER_LDLIBS = $(JVMLIB) $(LIBM) $(LIBDL)
 ifeq ($(CC_VER), 5.8)
   ifndef REMOVE_ALL_WORKAROUNDS
     ifeq ($(ARCH_FAMILY), i586)
@@ -120,7 +120,14 @@
 FILES_c = $(FILES_2D_c)
 FILES_c += awt_LoadLibrary.c
 OTHER_CFLAGS += -DMLIB_NO_LIBSUNMATH
-OTHER_LDLIBS = $(JVMLIB) $(LIBM) -ldl
+OTHER_LDLIBS = $(JVMLIB) $(LIBM) $(LIBDL)
+endif
+
+ifeq  ($(PLATFORM), bsd)
+FILES_c = $(FILES_2D_c)
+FILES_c += awt_LoadLibrary.c
+OTHER_CFLAGS += -DMLIB_NO_LIBSUNMATH
+OTHER_LDLIBS = $(JVMLIB) $(LIBM)
 endif
 
 FILES_c += initIDs.c
@@ -240,7 +247,7 @@
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ WINDOWS
 endif # PLATFORM
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
 # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv LINUX
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/../java2d/opengl
 vpath %.c   $(PLATFORM_SRC)/native/$(PKGDIR)/../java2d/opengl
@@ -390,6 +397,19 @@
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SOLARIS
 endif # PLATFORM
 
+ifeq ($(PLATFORM), bsd)
+# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv BSD
+
+FONTCONFIGS_SRC = $(PLATFORM_SRC)/classes/sun/awt/fontconfigs
+_FONTCONFIGS   = \
+       fontconfig.properties
+
+FONTCONFIGS_SRC_PREFIX = $(PLATFORM).
+
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ BSD
+endif # PLATFORM
+
+
 FONTCONFIGS     = $(_FONTCONFIGS:%=$(LIBDIR)/%.src)
 BINARYFONTCONFIGS = $(_FONTCONFIGS:%.properties=$(LIBDIR)/%.bfc)
 
@@ -482,6 +502,9 @@
             -I$(OPENWIN_HOME)/include/X11/extensions \
             -I$(PLATFORM_SRC)/native/$(PKGDIR)/font 
 endif
+ifeq ($(PLATFORM), bsd)
+CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/font 
+endif
 CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
             -I$(SHARE_SRC)/native/$(PKGDIR)/../font \
             -I$(PLATFORM_SRC)/native/$(PKGDIR)/../font \
@@ -503,7 +526,13 @@
             -I$(PLATFORM_SRC)/native/$(PKGDIR) \
 	    $(EVENT_MODEL)
 
-ifeq ($(PLATFORM), linux)
+# include these last so we don't pick up unintentional includes
+ifeq ($(PLATFORM), bsd)
+CPPFLAGS += -I$(OPENWIN_HOME)/include \
+            -I$(OPENWIN_HOME)/include/X11/extensions
+endif
+
+ifneq (,$(findstring $(PLATFORM), linux bsd))
 LDFLAGS += -L$(OPENWIN_LIB)
 endif
 
--- ./jdk/make/sun/awt/mawt.gmk	2011-05-26 18:34:34.000000000 -0700
+++ ./jdk/make/sun/awt/mawt.gmk	2011-04-22 23:08:16.000000000 -0700
@@ -169,7 +169,7 @@
 OTHER_LDLIBS = -lXt -lXext $(LIBXTST) $(LIBXMU) -lX11 -lXi
 endif
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
 OTHER_CFLAGS += -DMLIB_NO_LIBSUNMATH
 # XXX what is this define below? Isn't it motif-related?
 OTHER_CFLAGS += -DXMSTRINGDEFINES=1
@@ -180,7 +180,7 @@
 # !HEADLESS
 
 OTHER_LDLIBS += $(JVMLIB) $(LIBCXX) \
-                -lawt $(LIBM) -ldl
+                -lawt $(LIBM) $(LIBDL)
 
 #
 # Sun CC with -Xa misdefines __STDC__ to 0 (zero).
@@ -198,6 +198,9 @@
 ifndef HEADLESS
 CPPFLAGS += -I$(OPENWIN_HOME)/include 
 LDFLAGS  += -L$(OPENWIN_LIB)
+ifeq ($(OS_NAME), netbsd)
+LDFLAGS  += -Wl,-R$(OPENWIN_LIB)
+endif
 
 endif # !HEADLESS
 
@@ -223,16 +226,33 @@
         -I$(PLATFORM_SRC)/native/$(PKGDIR) \
         $(EVENT_MODEL)
 
+CPPFLAGS += -I$(CUPS_HEADERS_PATH)
+
+ifndef HEADLESS
+CPPFLAGS += -I$(MOTIF_DIR)/include \
+            -I$(OPENWIN_HOME)/include 
+LDFLAGS  += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
+
+endif # !HEADLESS
+
 ifeq ($(PLATFORM), linux)
   # Checking for the X11/extensions headers at the additional location
   CPPFLAGS += -I$(firstword $(wildcard $(OPENWIN_HOME)/include/X11/extensions) \
                         $(wildcard /usr/include/X11/extensions))
 endif
 
+ifeq ($(PLATFORM), bsd)
+  CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
+              -I$(OPENWIN_HOME)/include 
+endif
+
 ifeq ($(PLATFORM), solaris)
   CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions
 endif
 
+ifneq ($(PLATFORM), windows)
+  CPPFLAGS += -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
+endif
 
 LDFLAGS += -L$(LIBDIR)/$(LIBARCH)/$(TSOBJDIR) \
 	   $(AWT_RUNPATH)
--- ./jdk/make/sun/font/Makefile	2011-05-26 18:34:36.000000000 -0700
+++ ./jdk/make/sun/font/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -172,6 +172,15 @@
 # Libraries to link, and other C flags.
 #
 
+ifeq ($(PLATFORM), bsd)
+OTHER_INCLUDES += -I$(X11_PATH)/include
+OTHER_LDLIBS  += -lawt $(LIBM) $(LIBCXX)
+ ifeq ($(OS_VENDOR),Apple)
+   # XXXDARWIN Match BSD/Linux behavior -- the mawt.dylib symbols will
+   # be available at runtime.
+   OTHER_LDLIBS += -flat_namespace -undefined suppress
+ endif
+else
 ifeq ($(PLATFORM), solaris)
   # Note that on Solaris, fontmanager is built against the headless library.
   LDFLAGS      += -L$(LIBDIR)/$(LIBARCH)/headless
@@ -182,6 +191,7 @@
     OTHER_LDLIBS  += -Wl,-Bstatic -lgcc_eh -Wl,-Bdynamic
   endif                           
 endif
+endif
 
 endif # PLATFORM
 
--- ./jdk/make/sun/image/generic/Makefile	2011-05-26 18:34:38.000000000 -0700
+++ ./jdk/make/sun/image/generic/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -70,6 +70,6 @@
 OTHER_CFLAGS += -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES
 
 ifneq ($(PLATFORM), windows)
-	OTHER_LDLIBS = $(LIBM) -ldl
+	OTHER_LDLIBS = $(LIBM) $(LIBDL)
 endif
 
--- ./jdk/make/sun/image/vis/Makefile	2011-05-26 18:34:39.000000000 -0700
+++ ./jdk/make/sun/image/vis/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -68,5 +68,5 @@
 CFLAGS += $(CFLAGS_$(ARCH)) $(INLINE) -I$(PLATFORM_SRC)/native/sun/awt/medialib -I$(SHARE_SRC)/native/sun/awt/medialib
 
 OTHER_CFLAGS += -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES
-OTHER_LDLIBS = $(LIBM) -ldl
+OTHER_LDLIBS = $(LIBM) $(LIBDL)
 
--- ./jdk/make/sun/jawt/Makefile	2011-05-26 18:34:43.000000000 -0700
+++ ./jdk/make/sun/jawt/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -92,8 +92,7 @@
 #
 # Other extra flags needed for compiling.
 #
-CPPFLAGS += -I$(OPENWIN_HOME)/include \
-	    -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
+CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
             -I$(SHARE_SRC)/native/$(PKGDIR)/image \
 	    -I$(SHARE_SRC)/native/$(PKGDIR)/image/cvutils \
 	    -I$(SHARE_SRC)/native/$(PKGDIR)/alphacomposite \
@@ -107,6 +106,7 @@
 	    -I$(SHARE_SRC)/native/$(PKGDIR)/../dc/doe \
 	    -I$(SHARE_SRC)/native/$(PKGDIR)/../dc/path \
             -I$(PLATFORM_SRC)/native/$(PKGDIR)/../jdga \
+	    -I$(OPENWIN_HOME)/include \
 	    $(EVENT_MODEL)
 #
 # Libraries to link in.
@@ -119,7 +119,7 @@
   endif
 endif # PLATFORM
 
-ifeq ($(PLATFORM), linux)
+ifneq (,$(findstring $(PLATFORM), linux bsd))
   ifndef BUILD_HEADLESS_ONLY
     OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
   else
@@ -130,7 +130,6 @@
 
 endif # PLATFORM
 
-
 #
 # Lets not remove any class files.
 #
--- ./jdk/make/sun/jdga/Makefile	2011-05-26 18:34:44.000000000 -0700
+++ ./jdk/make/sun/jdga/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -55,7 +55,7 @@
 vpath %.c   $(PLATFORM_SRC)/native/$(PKGDIR)
 
 ifneq ($(PLATFORM), windows)
-  LDLIBS =  -ldga -lX11 -ldl -lc
+  LDLIBS =  -ldga -lX11 $(LIBDL) -lc
 
   CPPFLAGS += \
 	-I$(SHARE_SRC)/javavm/export \
--- ./jdk/make/sun/rmi/rmi/Makefile	2011-05-26 18:34:49.000000000 -0700
+++ ./jdk/make/sun/rmi/rmi/Makefile	2011-05-20 20:16:38.000000000 -0700
@@ -97,6 +97,9 @@
     BUILD_TARGETS += bin
   endif
 endif
+ifeq ($(PLATFORM), bsd)
+  BUILD_TARGETS += bin
+endif
 
 build: $(BUILD_TARGETS)
 
--- ./jdk/make/sun/security/ec/Makefile	2011-05-26 18:34:50.000000000 -0700
+++ ./jdk/make/sun/security/ec/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -192,7 +192,7 @@
   ifeq ($(PLATFORM), windows)
     OTHER_LDLIBS += $(JVMLIB)
   else
-    OTHER_LDLIBS = -ldl $(JVMLIB) $(LIBCXX)
+    OTHER_LDLIBS = $(LIBDL) $(JVMLIB) $(LIBCXX)
   endif
 
   include $(BUILDDIR)/common/Mapfile-vers.gmk
--- ./jdk/make/sun/security/jgss/wrapper/Makefile	2011-05-26 18:34:51.000000000 -0700
+++ ./jdk/make/sun/security/jgss/wrapper/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -71,6 +71,6 @@
 #
 # Libraries to link
 #
-ifneq ($(PLATFORM), windows)
-  OTHER_LDLIBS = -ldl $(JVMLIB)
+ifeq ($(PLATFORM), windows)
+OTHER_LDLIBS = $(LIBDL) $(JVMLIB)
 endif
--- ./jdk/make/sun/security/krb5/Makefile	2011-05-26 18:34:51.000000000 -0700
+++ ./jdk/make/sun/security/krb5/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -75,7 +75,7 @@
 ifeq ($(PLATFORM), windows)
   OTHER_LDLIBS = $(JVMLIB)
 else
-  OTHER_LDLIBS = -ldl $(JVMLIB)
+  OTHER_LDLIBS = $(LIBDL) $(JVMLIB)
 endif
 
 build:
--- ./jdk/make/sun/security/pkcs11/Makefile	2011-05-26 18:34:52.000000000 -0700
+++ ./jdk/make/sun/security/pkcs11/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -156,10 +156,10 @@
 #
 # Libraries to link
 #
-ifeq ($(PLATFORM), windows)
+ifneq ($(PLATFORM), windows)
   OTHER_LDLIBS = $(JVMLIB)
 else
-  OTHER_LDLIBS = -ldl $(JVMLIB)
+  OTHER_LDLIBS = $(LIBDL) $(JVMLIB)
 endif
 
 # Other config files
--- ./jdk/make/sun/security/smartcardio/Makefile	2011-05-26 18:34:52.000000000 -0700
+++ ./jdk/make/sun/security/smartcardio/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -75,6 +75,6 @@
 ifeq ($(PLATFORM), windows)
   OTHER_LDLIBS = $(JVMLIB) winscard.lib
 else
-  OTHER_LDLIBS = -ldl $(JVMLIB)
+  OTHER_LDLIBS = $(LIBDL) $(JVMLIB)
   OTHER_CFLAGS = -D__sun_jdk
 endif
--- ./jdk/make/sun/splashscreen/FILES_c.gmk	2011-05-26 18:34:53.000000000 -0700
+++ ./jdk/make/sun/splashscreen/FILES_c.gmk	2011-04-22 23:08:16.000000000 -0700
@@ -49,18 +49,6 @@
 	dgif_lib.c \
 	gif_err.c \
 	gifalloc.c \
-	compress.c \
-	deflate.c \
-	gzio.c \
-	infback.c \
-	inffast.c \
-	inflate.c \
-	inftrees.c \
-	trees.c \
-	uncompr.c \
-	zadler32.c \
-	zcrc32.c \
-	zutil.c \
 	jcomapi.c \
 	jdapimin.c \
 	jdapistd.c \
@@ -106,3 +94,18 @@
 	jfdctfst.c \
 	jfdctint.c
 
+ifneq ($(SYSTEM_ZLIB),true)
+  FILES_c += \
+	compress.c \
+	deflate.c \
+	gzio.c \
+	infback.c \
+	inffast.c \
+	inflate.c \
+	inftrees.c \
+	trees.c \
+	uncompr.c \
+	zadler32.c \
+	zcrc32.c \
+	zutil.c
+endif
--- ./jdk/make/sun/splashscreen/Makefile	2011-05-26 18:34:53.000000000 -0700
+++ ./jdk/make/sun/splashscreen/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -63,8 +63,24 @@
 
 ifneq ($(PLATFORM), windows)
   CFLAGS += -DWITH_X11
-  CPPFLAGS += -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
-  OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread
+  ifeq ($(PLATFORM), bsd)
+    ifeq ($(OS_VENDOR), Apple)
+      OTHER_LDLIBS += -liconv
+    else
+      ifneq ($(OS_NAME), netbsd)
+        CPPFLAGS += -I$(PACKAGE_PATH)/include
+        OTHER_LDLIBS += -L$(PACKAGE_PATH)/lib -liconv
+      else
+        OTHER_LDLIBS += -Wl,-R$(OPENWIN_LIB)
+      endif
+    endif
+    CPPFLAGS += -I$(OPENWIN_HOME)/include \
+                -I$(OPENWIN_HOME)/include/X11/extensions
+    OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -pthread
+  else
+    CPPFLAGS += -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions
+    OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11 -lXext $(LIBM) -lpthread
+  endif
 else # PLATFORM
   CFLAGS += -DWITH_WIN32
   OTHER_LDLIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib /DELAYLOAD:user32.dll
@@ -77,13 +93,20 @@
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/splashscreen
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/giflib
-vpath %.c   $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+ifneq ($(SYSTEM_ZLIB),true)
+  vpath %.c   $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+endif
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/libpng
 vpath %.c   $(SHARE_SRC)/native/$(PKGDIR)/image/jpeg
 vpath %.c   $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen
 
 CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
-CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg
+ifneq ($(SYSTEM_ZLIB),true)
+  CPPFLAGS += -I$(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
+else
+  OTHER_LDLIBS += -lz
+endif
 
 # Shun the less than portable MMX assembly code in pnggccrd.c,
 # and use alternative implementations in C.
--- ./jdk/make/sun/tracing/dtrace/Makefile	2011-05-26 18:34:54.000000000 -0700
+++ ./jdk/make/sun/tracing/dtrace/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -55,7 +55,7 @@
 FILES_export = $(FILES_java)
 
 ifeq ($(PLATFORM), linux)
-OTHER_LDLIBS += -ldl
+OTHER_LDLIBS += $(LIBDL)
 endif
 
 #
--- ./jdk/make/sun/xawt/Makefile	2011-05-26 18:34:55.000000000 -0700
+++ ./jdk/make/sun/xawt/Makefile	2011-04-22 23:08:16.000000000 -0700
@@ -47,6 +47,9 @@
 AUTO_JAVA_PRUNE = WrapperGenerator.java
 
 LDFLAGS += -L$(OPENWIN_LIB)
+ifeq ($(OS_NAME), netbsd)
+LDFLAGS += -Wl,-R$(OPENWIN_LIB)
+endif
 
 # For Xrender extension.
 ifeq ($(PLATFORM), solaris)
@@ -58,6 +61,11 @@
 dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
 endif
 
+ifeq ($(PLATFORM), bsd)
+LDFLAGS += -pthread
+dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
+endif
+
 # Since this library will be living in a subdirectory below the other libraries
 #   we need to add an extra runpath so that libraries in the upper directory
 #   are found at runtime.
@@ -92,7 +100,7 @@
 vpath %.c   $(PLATFORM_SRC)/native/sun/java2d/opengl
 vpath %.c   $(PLATFORM_SRC)/native/sun/java2d/x11
 
-OTHER_LDLIBS = $(LIBM) -lawt -lXext -lX11 -lXrender -ldl \
+OTHER_LDLIBS = $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) \
                    $(LDFLAGS_COMMON) $(AWT_RUNPATH) $(OTHER_LDFLAGS) -lXtst -lXi
 
 ifeq  ($(PLATFORM), solaris)
@@ -100,8 +108,6 @@
 dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
 endif
 
-CPPFLAGS += -I$(CUPS_HEADERS_PATH)
-
 CPPFLAGS += -DXAWT -DXAWT_HACK \
         -I$(TEMPDIR)/../../sun.awt/awt/CClassHeaders \
         -I$(PLATFORM_SRC)/native/sun/awt \
@@ -128,12 +134,14 @@
         -I$(SHARE_SRC)/native/sun/awt \
         -I$(PLATFORM_SRC)/native/sun/awt
 
+CPPFLAGS += -I$(CUPS_HEADERS_PATH)
+
 ifeq ($(PLATFORM), linux)
   ifndef CROSS_COMPILE_ARCH
     # Allows for builds on Debian GNU Linux, X11 is in a different place 
     # This should really be handled at a higher-level so we don't have to
     # work-around this when cross-compiling
-    CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
+    CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
                 -I/usr/include/X11/extensions \
                 -I$(OPENWIN_HOME)/include 
   else
@@ -163,6 +171,14 @@
  endif
 endif
 
+ifeq ($(PLATFORM), bsd)
+  CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions -I$(OPENWIN_HOME)/include
+endif
+
+ifneq ($(PLATFORM), windows)
+  CPPFLAGS += -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
+endif
+
 ifeq ($(MILESTONE), internal)
   CPPFLAGS += -DINTERNAL_BUILD
 endif
--- ./jdk/make/tools/freetypecheck/Makefile	2011-05-26 18:35:35.000000000 -0700
+++ ./jdk/make/tools/freetypecheck/Makefile	2011-04-22 23:08:17.000000000 -0700
@@ -49,8 +49,15 @@
   # Add runtime lib search path to ensure test will be runnable
   ifeq ($(PLATFORM), solaris)
     FT_LD_OPTIONS += -R $(FREETYPE_LIB_PATH) -lfreetype
-  else #linux
+  else 
+    ifeq ($(PLATFORM), bsd)
+      ifeq ($(OS_NAME), netbsd)
+        FT_LD_OPTIONS += -Wl,-R$(FREETYPE_LIB_PATH)
+      endif
+      FT_LD_OPTIONS += -lfreetype -lz
+    else # linux
       FT_LD_OPTIONS += -Wl,-rpath -Wl,$(FREETYPE_LIB_PATH) -lfreetype
+    endif
   endif
 endif
 FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH)
--- ./jdk/make/tools/reorder/Makefile	2011-05-26 18:35:37.000000000 -0700
+++ ./jdk/make/tools/reorder/Makefile	2011-04-22 23:08:17.000000000 -0700
@@ -185,11 +185,11 @@
 
 # This library 'libmcount.so' also used by hotspot reordering.
 $(OBJDIR)/libmcount.so : $(MCOUNT_OBJ)
-	$(CC) -G -mt -zdefs -o $@ $^ -ldl -lelf $(EXTRA_LIBS)
+	$(CC) -G -mt -zdefs -o $@ $^ $(LIBDL) -lelf $(EXTRA_LIBS)
 
 # This library 'libmcount.so' also used by hotspot reordering.
 $(OBJDIR)/remove_mcount : remove_mcount.c
-	$(CC) -g -o $@ $^ -ldl -lelf $(EXTRA_LIBS)
+	$(CC) -g -o $@ $^ $(LIBDL) -lelf $(EXTRA_LIBS)
 
 
 # Reorder libraries.
--- ./jdk/src/bsd/doc/man/ja/jvisualvm.1	2011-05-29 11:28:24.000000000 -0700
+++ ./jdk/src/bsd/doc/man/ja/jvisualvm.1	1969-12-31 16:00:00.000000000 -0800
@@ -1,126 +0,0 @@
-." Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code 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 General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH jvisualvm 1 "07 May 2011"
-
-.LP
-.SH "̾��"
-\f2jvisualvm\fP \- Java ���ۥޥ���δƻ롢�ȥ�֥륷�塼�ƥ��󥰡�����ӥץ��ե�����󥰥ġ���
-.LP
-.RS 3
-.TP 2
-o
-���� 
-.TP 2
-o
-�ѥ�᡼�� 
-.TP 2
-o
-���� 
-.TP 2
-o
-���ץ���� 
-.TP 2
-o
-������ˡ 
-.TP 2
-o
-��Ϣ���� 
-.RE
-
-.LP
-.SH "����"
-.LP
-.nf
-\f3
-.fl
-        \fP\f3jvisualvm\fP [ \f2options\fP ]
-.fl
-.fi
-
-.LP
-.SH "�ѥ�᡼��"
-.LP
-.LP
-���ץ�������Ѥ����硢���ޥ��̾��ľ��˵��Ҥ��Ƥ������������ץ����λ������˷�ޤ�Ϥ���ޤ�������Υ��ץ�����Ŭ�Ѥ����ѥ�᡼���ˤĤ��Ƥϡ����Τ��ȤΡ֥��ץ����פ򻲾Ȥ��Ƥ���������
-.LP
-.SH " ����"
-.LP
-.LP
-Java VisualVM �ϡ����ꤵ�줿 Java ���ۥޥ��� (JVM(*)) �� Java �ƥ��Υ����١����Υ��ץꥱ������� (Java ���ץꥱ�������) ���¹Ԥ���Ƥ���Ȥ��ˡ����� Java ���ץꥱ�������˴ؤ���ܺ٤ʾ�����󶡤���ľ��Ū�ʥ���ե�����桼�������󥿥ե������Ǥ���Java VisualVM �Ȥ���̾���ϡ�Java VisualVM �� JVM ���եȥ������˴ؤ�������ֻ��Ū�ˡ��󶡤���Ȥ������¤�ͳ�褷�Ƥ��ޤ���
-.LP
-.LP
-Java VisualVM �ϡ������Ĥ��δƻ롢�ȥ�֥륷�塼�ƥ��󥰡�����ӥץ��ե�����󥰥桼�ƥ���ƥ����� 1 �ĤΥġ�������礷�ޤ������Ȥ��С�������ɥ�����ġ��� \f2jmap\fP�� \f2jinfo\fP�� \f2jstat\fP ������� \f2jstack\fP ���󶡤���Ƥ��뵡ǽ�ΤۤȤ�ɤ���Java VisualVM ���Ȥ߹��ޤ�Ƥ��ޤ���JConsole �ġ���ˤ�ä��󶡤��������ε�ǽ�ʤɡ��ۤ��ε�ǽ�ϥ��ץ����Υץ饰����Ȥ����ɲäǤ��ޤ���
-.LP
-.SH "���ץ����"
-.LP
-.LP
-���Υ��ץ����ϡ�Java VisualVM ��ư�����Ȥ��˼¹Բ�ǽ�ˤʤ�ޤ���
-.LP
-.RS 3
-.TP 3
-\-J<jvm_option>\  
-���� \f2<jvm_option>\fP �� JVM ���եȥ��������Ϥ��ޤ��� 
-.RE
-
-.LP
-.SH "������ˡ"
-.LP
-.LP
-Java VisualVM �ϡ�Java ���ץꥱ�������γ�ȯ�Ԥ����ץꥱ�������Υȥ�֥륷�塼�ƥ��󥰤�Ԥʤä��ꡢ���ץꥱ�������Υѥե����ޥ󥹤�ƻ뤪��Ӳ��������ꤹ��Τ���Ω���ޤ���Java VisualVM ����Ѥ���ȡ���ȯ�Ԥϥҡ��ץ���פ���������Ӳ��ϡ����꡼�꡼�������ꡢ���١������쥯�����μ¹Ԥ���Ӵƻ롢����ӥ��꡼�� CPU �δʰץץ��ե�����󥰤μ¹Ԥ���ǽ�ˤʤ�ޤ���Java VisualVM �ε�ǽ���ĥ����ץ饰����⤤���Ĥ�����ޤ������Ȥ��С�JConsole �ġ���ΤۤȤ�ɤε�ǽ�ϡ�MBeans ���֤���� JConsole Plug\-in Wrapper �ץ饰�����𤷤ƻ��ѤǤ��ޤ���ɸ��� Java VisualVM �ץ饰����Υ��������������򤹤�ˤϡ�Java VisualVM ��˥塼�Ρ֥ġ����>�֥ץ饰����פ����򤷤ޤ���
-.LP
-.LP
-Java VisualVM ��ư����ˤϡ����Υ��ޥ�ɤ�¹Ԥ��ޤ���
-.LP
-.nf
-\f3
-.fl
-%  jvisualvm \fP\f4<options>\fP\f3
-.fl
-\fP
-.fi
-
-.LP
-.SH "��Ϣ����"
-.LP
-.LP
-Java VisualVM �ξܺ٤ϡ����Υڡ����򻲾Ȥ��Ƥ���������
-.LP
-.RS 3
-.TP 2
-o
-.na
-\f2Java VisualVM ��ȯ�ԤΥ�����\fP @
-.fi
-http://visualvm.java.net 
-.TP 2
-o
-.na
-\f2Java SE �ץ�åȥե�����Ǥ� Java VisualVM �Υɥ������\fP @
-.fi
-http://java.sun.com/javase/6/docs/technotes/guides/visualvm/index.html 
-.RE
-
-.LP
-.LP
-\f2(* ��Java ���ۥޥ���פȡ�JVM�פȤ����Ѹ�ϡ�Java �ץ�åȥե�����β��ۥޥ�����̣���Ƥ��ޤ���)\fP
-.LP
- 
--- ./jdk/src/bsd/doc/man/ja/kinit.1	1969-12-31 16:00:00.000000000 -0800
+++ ./jdk/src/bsd/doc/man/ja/kinit.1	2011-04-22 23:08:18.000000000 -0700
@@ -0,0 +1,159 @@
+'\" t
+.\"
+.\" Copyright 2002-2004 Sun Microsystems, Inc.  All Rights Reserved.
+.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+.\"
+.\" This code is free software; you can redistribute it and/or modify it
+.\" under the terms of the GNU General Public License version 2 only, as
+.\" published by the Free Software Foundation.
+.\"
+.\" This code 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 General Public License
+.\" version 2 for more details (a copy is included in the LICENSE file that
+.\" accompanied this code).
+.\"
+.\" You should have received a copy of the GNU General Public License version
+.\" 2 along with this work; if not, write to the Free Software Foundation,
+.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+.\"
+.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+.\" or visit www.oracle.com if you need additional information or have any
+.\" questions.
+.\"
+.\"
+.\" 
+.TH kinit 1 "2004 ǯ 6 �� 22 ��"
+.SH "̾��"
+kinit \- kinit �� Kerberos �����åȵ��ĥ����åȤ��������ӥ���å���
+����Ȥ��˻��Ѥ��ޤ������Υġ���Ϥۤ��ΰ���Ū�� Kerberos ���� 
+(SEAM �� MIT �Υ�ե���󥹼����ʤ�) �� kinit �ġ���ȵ�ǽŪ�˻��Ƥ��ޤ���
+.LP
+kinit ����Ѥ��뤿��ˤϡ�kinit ��¹Ԥ������� Key Distribution Center 
+(KDC) ����Ѥ��ƥץ�󥷥ѥ�Ȥ�����Ͽ����ɬ�פ�����ޤ���
+.SH "����"
+.B kinit
+[
+.IR commands " ]" 
+<principal name>
+.SH "��ǽ����"
+�ǥե���ȤǤϡ�UNIX �ץ�åȥե�����ξ�硢/tmp/krb5cc_<uid> �Ȥ���
+̾���Υ���å���ե����뤬��������ޤ���<uid> �ϡ������ƥ�˥�������
+�����桼���Υ桼�������ֹ�Ǥ�������¾�Υץ�åȥե�����ξ�硢
+<USER_HOME>/krb5cc_<USER_NAME> �Ȥ���̾���Υ���å���ե�����
+����������ޤ���
+.LP
+<USER_HOME> �� 
+.BR java.lang.System 
+�ץ��ѥƥ��� 
+.BR user.home
+�����������ޤ���<USER_NAME> �� 
+.BR java.lang.System 
+�ץ��ѥƥ��� 
+.BR user.name
+�����������ޤ���<USER_HOME> �� null �Ǥ����硢
+����å���ե�����ϥץ�������¹Ԥ������ߤΥǥ��쥯�ȥ�˳�Ǽ����
+�ޤ���<USER_NAME> �ϥ��ڥ졼�ƥ��󥰥����ƥ�Υ�������桼��̾
+�Ǥ������Υ桼��̾�ϥ桼���Υץ�󥷥ѥ�̾�Ȥϰۤʤ��礬����ޤ���
+���Ȥ��� Solaris �Ǥϡ�<USER_NAME> �� duke �Ǥ��ꡢ<USER_HOME> 
+�� /home/duke �Ǥ����硢�桼���Υץ�󥷥ѥ�̾�� /home/duke/krb5cc_duke 
+�ˤʤ�ޤ���
+.LP
+�ǥե���ȤǤϡ���������̾�� Kerberos �����ե����뤫���������ޤ���
+��������̾�� Kerberos �����ե�����˻��ꤵ��Ƥ��ʤ���硢��������̾�� <USER_HOME>/krb5.keytab �ˤʤ�ޤ���
+.LP
+���ޥ�ɹԤ� password ���ץ����ǥѥ���ɤ���ꤷ�ʤ���硢
+kinit �ϥѥ���ɤ����Ϥ���ޤ���
+.LP
+.B ��:
+���ޥ�ɹԤ� password ���ץ����ϥƥ��Ȥ���Ū�������󶡤���ޤ���
+�ѥ���ɤ򥹥���ץ���˻��ꤷ���ꡢ���ޥ�ɹԤ˻��ꤷ���ꤷ�ʤ���
+�����������������뤳�Ȥˤ�äơ��ѥ���ɤ�ϳ����ǽ��������ޤ���
+.LP
+�ܺ٤ˤĤ��Ƥϡ�kinit ��Ϣ�Υޥ˥奢��ڡ����򻲾Ȥ��Ƥ���������
+.SH "���ޥ��"
+.B kinit \-fp
+[
+\-c <cache_name> ]
+[
+\-k ]
+[
+\-t <keytab_filename> ]
+[
+<principal> ]
+[
+<password> ]
+[
+\-help ]
+.TP
+.BI \-f
+ž����ǽ�ʥ����åȤ�ȯ�Ԥ��ޤ���
+.TP
+.BI \-p
+�ץ�������ǽ�ʥ����åȤ�ȯ�Ԥ��ޤ���
+.TP
+.BI \-c 
+<cache_name>
+����å���̾ (���Ȥ��С�FILE:/temp/mykrb5cc)��
+.TP
+.BI \-k
+�������֤���Ѥ��ޤ���
+.TP
+.BI \-t 
+<keytab_filename>
+��������̾ (���Ȥ��С�/home/duke/krb5.keytab)��
+.TP
+.BI <principal>
+�ץ�󥷥ѥ�̾ (���Ȥ��С�duke@java.sun.com)��
+.TP
+.BI <password>
+�ץ�󥷥ѥ�� Kerberos �ѥ���� (���ޥ�ɹԤ䥹����ץȤ˥ѥ����
+����ꤷ�ʤ��Ǥ�������)��
+.TP
+.BI \-help
+�إ�פ�ɽ�����ޤ���
+.SH "������"
+ǧ�ڤ�ͭ���ʻ�ʤ򸽺ߤΥ��饤����ȥۥ��Ȥ����׵ᤷ�ơ�
+�ǥե���ȥ����ӥ��Τ���˻�ʤΥ���å����ǥե���Ȥξ�� 
+(/home/duke/krb5cc_duke) �˳�Ǽ���ޤ���
+.LP
+.ft 3
+.nf
+kinit duke@JAVA.SUN.COM
+.fi
+.ft 1
+.LP
+�ۤʤ�ץ�󥷥ѥ�Τ���˥ץ�������ǽ�ʻ�ʤ��׵ᤷ�ơ������λ�ʤ�
+���ꤷ���ե����륭��å���˳�Ǽ���ޤ���
+.LP
+.ft 3
+.nf
+kinit \-p \-c FILE:/home/duke/credentials/krb5cc_cafebeef cafebeef@JAVA.SUN.COM
+.fi
+.ft 1
+.LP
+�ۤʤ�ץ�󥷥ѥ�Τ���˥ץ�������ǽ��ž����ǽ�ʻ�ʤ��׵ᤷ�ơ�
+�����λ�ʤ���ꤷ���ե����륭��å���˳�Ǽ���ޤ���
+.LP
+.ft 3
+.nf
+kinit \-f \-p \-c
+FILE:/home/duke/credentials/krb5cc_cafebeef cafebeef@JAVA.SUN.COM
+.fi
+.ft 1
+.LP
+kinit �Υإ�ץ�˥塼��ɽ�����ޤ���
+.LP
+.ft 3
+.nf
+kinit \-help
+.fi
+.ft 1
+.LP
+.SH "�������ƥ��˴ؤ���ٹ�"
+���ޥ�ɹԤ� 
+.BR password
+���ץ����ϥƥ��Ȥ���Ū�������󶡤���ޤ����ѥ���ɤ򥳥ޥ�ɹԤ˻��ꤷ�ʤ��Ǥ���������
+����ϥ������ƥ��ۡ���ˤʤ�ޤ������Ȥ��С�UNIX �� 
+.BR ps
+���ޥ�ɤμ¹���ˡ�����Ԥϥѥ���ɤ򸡽Ф��뤳�Ȥ��Ǥ��Ƥ��ޤ��ޤ���
--- ./jdk/src/bsd/doc/man/ja/klist.1	1969-12-31 16:00:00.000000000 -0800
+++ ./jdk/src/bsd/doc/man/ja/klist.1	2011-04-22 23:08:18.000000000 -0700
@@ -0,0 +1,110 @@
+'\" t
+.\"
+.\" Copyright 2002-2004 Sun Microsystems, Inc.  All Rights Reserved.
+.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+.\"
+.\" This code is free software; you can redistribute it and/or modify it
+.\" under the terms of the GNU General Public License version 2 only, as
+.\" published by the Free Software Foundation.
+.\"
+.\" This code 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 General Public License
+.\" version 2 for more details (a copy is included in the LICENSE file that
+.\" accompanied this code).
+.\"
+.\" You should have received a copy of the GNU General Public License version
+.\" 2 along with this work; if not, write to the Free Software Foundation,
+.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+.\"
+.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+.\" or visit www.oracle.com if you need additional information or have any
+.\" questions.
+.\"
+.\" 
+.TH klist 1 "2004 ǯ 6 �� 22 ��"
+.SH "̾��"
+klist \- Kerberos ����ǥ󥷥�륭��å���ȥ���������Υ���ȥ��ɽ�����ޤ���
+.LP
+.BR klist 
+����Ѥ���ȡ��桼���ϥ�������ˤ��륯��ǥ󥷥�륭��å����
+�����ơ��֥���Υ���ȥ��ɽ���Ǥ��ޤ���
+.SH "����"
+.B klist
+[
+.IR commands " ]" 
+.SH "��ǽ����"
+.BR klist
+�ϥ�������ˤ��륯��ǥ󥷥�륭��å���ȥ����ơ��֥���Υ���ȥ��ɽ�����ޤ���
+�桼����
+.BR kinit 
+����Ѥ��ƥ���ǥ󥷥�륭��å�����ѹ������ꡢ
+.BR ktab
+����Ѥ��ƥ������֤��ѹ������塢�ѹ����ǧ����ͣ�����ˡ�ϡ�
+.BR klist
+����Ѥ��ƥ���ǥ󥷥�륭��å���ޤ��ϥ������֤����Ƥ�ɽ�����뤳�ȤǤ���
+.BR klist
+�� Kerberos �ǡ����١������ѹ����ޤ���
+
+.SH "���ޥ��"
+.B klist 
+[
+\-c [\-fe]]
+[
+\-k [\-tK]]
+[
+<name>]
+[
+\-help ]
+.TP
+.BI \-c
+ɽ������������ǥ󥷥�륭��å���Υ���ȥ����ꤷ�ޤ���
+.TP
+.BI \-k
+ɽ���������������֤Υ���ȥ����ꤷ�ޤ���
+.TP
+.BI <cache_name>
+����ǥ󥷥�륭��å���̾�ޤ��ϥ�������̾����ꤷ�ޤ���̾������ꤷ�ʤ���硢
+����ǥ󥷥�륭��å���̾�ޤ��ϥ������֤Υǥե�����ͤ����Ѥ���ޤ���
+����å���ȥ������֤Υǥե�����ͤˤĤ��Ƥϡ�
+.BR kinit
+�Υޥ˥奢��ڡ����򻲾Ȥ��Ƥ���������
+.LP
+\-c ���ץ�������ꤷ����硢����ǥ󥷥�륭��å����ѤΥ��ץ����ϼ��ΤȤ���Ǥ���
+.TP
+.BI \-f
+����ǥ󥷥��ե饰��ɽ�����ޤ���
+.TP
+.BI \-e
+�Ź沽�����פ�ɽ�����ޤ���
+.LP
+\-k ���ץ�������ꤷ����硢���������ѤΥ��ץ����ϼ��ΤȤ���Ǥ���
+.TP
+.BI \-t
+�������֥���ȥ�Υ����ॹ����פ�ɽ�����ޤ���
+.TP
+.BI \-K
+�������֥���ȥ�� DES ������ɽ�����ޤ���
+.LP
+.TP
+.BI \-help
+�إ�פ�ɽ�����ޤ���
+.SH "������"
+���ꤷ�������ơ��֥�Υ���ȥ�ȡ����Υ����ॹ����פ� DES ����
+��ɽ�����ޤ���
+.LP
+.ft 3
+.nf
+klist \-k \-t \-K FILE:/temp/mykrb5cc
+.fi
+.ft 1
+.LP
+���ꤷ������ǥ󥷥�륭��å���Υ���ȥ�ȡ����Υ���ǥ󥷥��ե饰�ȥ��ɥ쥹�ꥹ�Ȥ�
+ɽ�����ޤ���
+.LP
+.ft 3
+.nf
+klist \-c \-f FILE:/temp/mykrb5cc
+.fi
+.ft 1
+.LP
--- ./jdk/src/bsd/doc/man/ja/ktab.1	1969-12-31 16:00:00.000000000 -0800
+++ ./jdk/src/bsd/doc/man/ja/ktab.1	2011-04-22 23:08:18.000000000 -0700
@@ -0,0 +1,125 @@
+'\" t
+.\"
+.\" Copyright 2002-2004 Sun Microsystems, Inc.  All Rights Reserved.
+.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+.\"
+.\" This code is free software; you can redistribute it and/or modify it
+.\" under the terms of the GNU General Public License version 2 only, as
+.\" published by the Free Software Foundation.
+.\"
+.\" This code 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 General Public License
+.\" version 2 for more details (a copy is included in the LICENSE file that
+.\" accompanied this code).
+.\"
+.\" You should have received a copy of the GNU General Public License version
+.\" 2 along with this work; if not, write to the Free Software Foundation,
+.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+.\"
+.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+.\" or visit www.oracle.com if you need additional information or have any
+.\" questions.
+.\"
+.\" 
+.TH ktab 1 "2004 ǯ 6 �� 22 ��"
+.SH "̾��"
+ktab \- Kerberos �����ơ��֥�ޥ͡�����
+.LP
+.BR ktab
+����Ѥ���ȡ��桼���ϥ�������ˤ��륭���ơ��֥�˳�Ǽ���줿
+�ץ�󥷥ѥ�̾�ȥ����ӥ�����������Ǥ��ޤ�������������Υץ�󥷥ѥ�
+�ȥ����ڥ��ϡ��ۥ��Ⱦ��ư��Ƥ��륵���ӥ��ˡ�����鼫�Ȥ� 
+Key Distribution Center (KDC) ��ǧ�ڤ����ޤ��������Ф� Kerberos ��
+���ѤǤ���褦�����ꤹ��ˤϡ��������˥桼���ϥ����Ф�ư��Ƥ���
+�ۥ��Ⱦ�ǥ������֤����ꤹ��ɬ�פ�����ޤ���ktab ����Ѥ��ƥ�������
+���ѹ����Ƥ⡢Kerberos �ǡ����١����ˤϱƶ����ʤ����Ȥ����դ��Ƥ�����
+��������������Υ������ѹ�������硢Kerberos �ǡ����١�������б�����
+�ս���ѹ�����ɬ�פ�����ޤ���
+.SH "����"
+.B ktab
+[
+.IR commands " ]" 
+.SH "��ǽ����"
+.BR ktab
+�ϡ������ơ��֥���Υץ�󥷥ѥ�̾�ȥ����ڥ���������ޤ���
+.BR ktab
+����Ѥ���ȡ��桼���ϥ����ơ��֥���Υץ�󥷥ѥ�̾�ȥ����ڥ���
+����ɽ�����ɲá��������ޤ��Ϻ���Ǥ��ޤ������������Ϥ��٤ơ�
+Kerberos �ǡ����١����ˤϱƶ����ޤ���
+.LP
+.ft 3
+.B ��������
+.LP
+�������֤Ȥϡ��ۥ��Ȥ����ļ�ʬ���ȤΥ����ꥹ�ȤΥ��ԡ��Ǥ��ꡢ�桼��
+�Υѥ���ɤȻ��Ƥ��ޤ�����ʬ���Ȥ� Key Distribution Center (KDC) 
+��ǧ�ڤ�����ɬ�פ����륢�ץꥱ������󥵡��Фϡ����켫�ȤΥץ�󥷥ѥ�
+�ȥ�����ޤ७�����֤���äƤ���ɬ�פ�����ޤ����桼������ʬ��
+�ѥ���ɤ��ݸ�뤳�Ȥ����ڤǤ���Τ�Ʊ�ͤˡ��ۥ��Ȥϼ�ʬ�Υ�������
+���ݸ�뤳�Ȥ����ڤǤ����������֥ե�����Ͼ�˥�������ǥ�������
+��Ǽ���ơ�root �ʳ��Υ桼�����ɤ�ʤ��褦�����ꤷ�Ƥ���ɬ�פ�����ޤ���
+�������֥ե�����ϰŹ沽�����˥ͥåȥ�����������ʤ��Ǥ���������
+.SH "���ޥ��"
+����ˡ: ���ޥ�ɹԥ��ץ����Ǥ���ʸ���Ⱦ�ʸ���϶��̤��ޤ���
+.LP
+.B ktab
+\-help
+.LP
+.B ktab
+\-l [\-k <keytab_name>]
+.LP
+.B ktab
+[\-a <principal_name> <password>] [\-k <keytab_name>]
+.LP
+.B ktab
+[\-d <principal_name>] [\-k <keytab_name>]
+.LP
+.TP
+.BI \-l
+��������̾�ȥ���ȥ�����ɽ�����ޤ���
+.TP
+.BI \-a
+<principal_name> <password>
+����ȥ�򥭡����֤��ɲä��ޤ���Kerberos �ǡ����١������ѹ����ޤ��� 
+(���ޥ�ɹԤ䥹����ץȤ˥ѥ���ɤ���ꤷ�ʤ��Ǥ�������)��
+.TP
+.BI \-d 
+<principal_name>
+�������֤��饨��ȥ�������ޤ���Kerberos �ǡ����١������ѹ����ޤ���
+.TP
+.BI \-k
+<keytab_name>
+��������̾�ȡ���Ƭ�� FILE: �ǻϤޤ�ѥ�����ꤷ�ޤ���
+.TP
+.BI \-help
+�إ�פ�ɽ�����ޤ���
+.SH "������"
+�ǥե���ȤΥ����ơ��֥���Υ���ȥ�򤹤٤�ɽ�����ޤ���
+.LP
+.ft 3
+.nf
+ktab \-l
+.fi
+.ft 1
+.LP
+�������ץ�󥷥ѥ�򥭡��ơ��֥���ɲä��ޤ����ѥ���ɤ����Ϥ������ޤ���
+.LP
+.ft 3
+.nf
+ktab \-a duke@java.sun.com
+.fi
+.ft 1
+.LP
+�����ơ��֥뤫��ץ�󥷥ѥ�������ޤ���
+.LP
+.ft 3
+.nf
+ktab \-d duke@java.sun.com
+.fi
+.ft 1
+.LP
+.SH "�������ƥ��˴ؤ���ٹ�"
+�ѥ���ɤ򥳥ޥ�ɹԤ˻��ꤷ�ʤ��Ǥ�������������ϥ������ƥ��ۡ���
+�ˤʤ�ޤ������Ȥ��С�UNIX ��
+.BI ps
+���ޥ�ɤμ¹���ˡ�����Ԥϥѥ���ɤ򸡽Ф��뤳�Ȥ��Ǥ��Ƥ��ޤ��ޤ���
--- ./jdk/src/bsd/doc/man/jvisualvm.1	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/bsd/doc/man/jvisualvm.1	1969-12-31 16:00:00.000000000 -0800
@@ -1,104 +0,0 @@
-." Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code 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 General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH jvisualvm 1 "10 May 2011"
-
-.LP
-.SH "Name"
-\f2jvisualvm\fP \- Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool
-.LP
-.SH "SYNOPSIS"
-.LP
-.nf
-\f3
-.fl
-        \fP\f3jvisualvm\fP [ \f2options\fP ]
-.fl
-.fi
-
-.LP
-.SH "PARAMETERS"
-.LP
-.LP
-Options, if used, should follow immediately after the command name. Options may be in any order. For a discussion of parameters that apply to a specific option, see OPTIONS below.
-.LP
-.SH "DESCRIPTION"
-.LP
-.LP
-Java VisualVM is an intuitive graphical user interface that provides detailed information about Java technology\-based applications (Java applications) while they are running on a given Java Virtual Machine (JVM(*)). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software \f2visually\fP.
-.LP
-.LP
-Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools \f2jmap\fP, \f2jinfo\fP, \f2jstat\fP and \f2jstack\fP have been integrated into Java VisualVM. Other functionalities, such as some of those offered by the JConsole tool, can be added as optional plug\-ins.
-.LP
-.SH "OPTIONS"
-.LP
-.LP
-The following option is possible when you launch Java VisualVM.
-.LP
-.RS 3
-.TP 3
-\-J<jvm_option>\  
-Pass this \f2<jvm_option>\fP to the JVM software. 
-.RE
-
-.LP
-.SH "USAGE"
-.LP
-.LP
-Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM can allow developers to generate and analyse heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. Plug\-ins also exist that expand the functionality of Java VisualVM. For example, most of the functionality of the JConsole tool is available via the MBeans Tab and JConsole Plug\-in Wrapper plug\-ins. You can choose from a catalog of standard Java VisualVM plug\-ins by selecting 'Tools' | 'Plugins' in the Java VisualVM menus.
-.LP
-.LP
-Start Java VisualVM with the following command:
-.LP
-.nf
-\f3
-.fl
-%  jvisualvm \fP\f4<options>\fP\f3
-.fl
-\fP
-.fi
-
-.LP
-.SH "SEE ALSO"
-.LP
-.LP
-For more details about Java VisualVM see the following pages.
-.LP
-.RS 3
-.TP 2
-o
-.na
-\f2Java VisualVM developers' site\fP @
-.fi
-http://visualvm.java.net 
-.TP 2
-o
-.na
-\f2Java VisualVM in Java SE platform documentation\fP @
-.fi
-http://download.oracle.com/javase/7/docs/technotes/guides/visualvm/index.html 
-.RE
-
-.LP
-.LP
-\f2(* The terms "Java Virtual Machine" and "JVM" mean a Virtual Machine for the Java platform.)\fP
-.LP
- 
--- ./jdk/src/share/back/commonRef.c	2011-05-26 18:36:27.000000000 -0700
+++ ./jdk/src/share/back/commonRef.c	2011-04-22 23:08:18.000000000 -0700
@@ -23,6 +23,10 @@
  * questions.
  */
 
+#if defined(_ALLBSD_SOURCE)
+#include <stdint.h>			/* for uintptr_t */
+#endif
+
 #include "util.h"
 #include "commonRef.h"
 
--- ./jdk/src/share/bin/java.c	2011-05-26 18:36:33.000000000 -0700
+++ ./jdk/src/share/bin/java.c	2011-04-22 23:08:18.000000000 -0700
@@ -70,6 +70,10 @@
 static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
 static char     *showSettings = NULL;      /* print but continue */
 
+#ifdef __APPLE__
+static jboolean continueInSameThread = JNI_FALSE; /* start VM in current thread */
+#endif
+
 static const char *_program_name;
 static const char *_launcher_name;
 static jboolean _is_java_args = JNI_FALSE;
@@ -120,6 +124,10 @@
 static void DumpState();
 static jboolean RemovableOption(char *option);
 
+#ifdef __APPLE__
+static int ContinueInSameThread(InvocationFunctions* ifn, int argc, char **argv, int mode, char *what, int ret);
+#endif
+
 /* Maximum supported entries from jvm.cfg. */
 #define INIT_MAX_KNOWN_VMS      10
 
@@ -315,7 +323,15 @@
     /* Show the splash screen if needed */
     ShowSplashScreen();
 
+#ifdef __APPLE__
+    if (continueInSameThread == JNI_TRUE) {
+        return ContinueInSameThread(&ifn, argc, argv, mode, what, ret);
+    } else {
+        return ContinueInNewThread(&ifn, argc, argv, mode, what, ret);
+    }
+#else
     return ContinueInNewThread(&ifn, argc, argv, mode, what, ret);
+#endif
 
 }
 /*
@@ -1006,6 +1022,12 @@
         } else if (JLI_StrCmp(arg, "-X") == 0) {
             printXUsage = JNI_TRUE;
             return JNI_TRUE;
+#ifdef __APPLE__
+        } else if (JLI_StrCmp(arg, "-XstartOnFirstThread") == 0) {
+            continueInSameThread = JNI_TRUE;
+        } else if (JLI_StrCCmp(arg, "-Xdock:") == 0) {
+           // XXXDARWIN: Apple VM supports configuration of Dock icon and name via -Xdock:
+#endif            
 /*
  * The following case checks for -XshowSettings OR -XshowSetting:SUBOPT.
  * In the latter case, any SUBOPT value not recognized will default to "all"
@@ -1897,6 +1919,44 @@
     }
 }
 
+#ifdef __APPLE__
+static int
+ContinueInSameThread(InvocationFunctions* ifn, int argc, char **argv,
+		     int mode, char *what, int ret)
+{
+        
+    /*
+     * If user doesn't specify stack size, check if VM has a preference.
+     * Note that HotSpot no longer supports JNI_VERSION_1_1 but it will
+     * return its default stack size through the init args structure.
+     */
+    if (threadStackSize == 0) {
+        struct JDK1_1InitArgs args1_1;
+        memset((void*)&args1_1, 0, sizeof(args1_1));
+        args1_1.version = JNI_VERSION_1_1;
+        ifn->GetDefaultJavaVMInitArgs(&args1_1);  /* ignore return value */
+        if (args1_1.javaStackSize > 0) {
+            threadStackSize = args1_1.javaStackSize;
+        }
+    }
+    
+    { /* Create create JVM and invoke main method */
+        JavaMainArgs args;
+        int rslt;
+        
+        args.argc = argc;
+        args.argv = argv;
+        args.mode = mode;
+        args.what = what;
+        args.ifn = *ifn;
+        
+        rslt = JavaMain((void*)&args);
+        
+        return (ret != 0) ? ret : rslt;
+    }
+}
+#endif
+
 static void
 DumpState()
 {
--- ./jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	2011-05-26 18:37:04.000000000 -0700
+++ ./jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	2011-04-22 23:08:19.000000000 -0700
@@ -477,6 +477,10 @@
                 String[] dirs = new String[] {
                     userHome + sep + ".themes",
                     System.getProperty("swing.metacitythemedir"),
+		    "/usr/X11R6/share/themes",
+		    "/usr/X11R6/share/gnome/themes",
+		    "/usr/local/share/themes",
+		    "/usr/local/share/gnome/themes",
                     "/usr/share/themes",
                     "/usr/gnome/share/themes",  // Debian/Redhat/Solaris
                     "/opt/gnome2/share/themes"  // SuSE
--- ./jdk/src/share/classes/com/sun/jmx/snmp/SnmpPduTrap.java	2011-05-26 18:37:55.000000000 -0700
+++ ./jdk/src/share/classes/com/sun/jmx/snmp/SnmpPduTrap.java	2011-04-22 23:08:19.000000000 -0700
@@ -78,6 +78,9 @@
      */
     public long            timeStamp ;
 
+    // TODO: IcedTea: I am a stub.
+    static public int trapAuthenticationFailure = 0;
+
 
 
     /**
--- ./jdk/src/share/classes/com/sun/media/sound/services/bsd-i586/javax.sound.sampled.spi.MixerProvider	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/share/classes/com/sun/media/sound/services/bsd-i586/javax.sound.sampled.spi.MixerProvider	1969-12-31 16:00:00.000000000 -0800
@@ -1,6 +0,0 @@
-# service provider file for Bsd: with DirectAudioDeviceProvider
-# last mixer is default mixer
-com.sun.media.sound.PortMixerProvider
-com.sun.media.sound.SimpleInputDeviceProvider
-com.sun.media.sound.DirectAudioDeviceProvider
-com.sun.media.sound.HeadspaceMixerProvider
--- ./jdk/src/share/classes/com/sun/servicetag/BsdSystemEnvironment.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/share/classes/com/sun/servicetag/BsdSystemEnvironment.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.servicetag;
-
-// This class is a copy of the com.sun.scn.servicetags.BsdSystemEnvironment
-// class from the Sun Connection source.
-//
-// The Service Tags team maintains the latest version of the implementation
-// for system environment data collection.  JDK will include a copy of
-// the most recent released version for a JDK release. We rename
-// the package to com.sun.servicetag so that the Sun Connection
-// product always uses the latest version from the com.sun.scn.servicetags
-// package. JDK and users of the com.sun.servicetag API
-// (e.g. NetBeans and SunStudio) will use the version in JDK.
-//
-// So we keep this class in src/share/classes instead of src/<os>/classes.
-
-import java.io.*;
-
-/**
- * Bsd implementation of the SystemEnvironment class.
- */
-class BsdSystemEnvironment extends SystemEnvironment {
-    BsdSystemEnvironment() {
-        setHostId(getBsdHostId());
-        setSystemModel(getCommandOutput("/bin/uname", "-i"));
-        setSystemManufacturer(getBsdSystemManufacturer());
-        setCpuManufacturer(getBsdCpuManufacturer());
-        setSerialNumber(getBsdSN());
-    }
-    private String dmiInfo = null;
-
-    private static final int SN  = 1;
-    private static final int SYS = 2;
-    private static final int CPU = 3;
-
-    private String getBsdHostId() {
-        String output = getCommandOutput("/usr/bin/hostid");
-        // trim off the leading 0x
-        if (output.startsWith("0x")) {
-            output = output.substring(2);
-        }
-        return output;
-    }
-
-    /**
-     * Tries to obtain and return the cpu manufacturer.
-     * @return The cpu manufacturer (an empty string if not found or an error occurred)
-     */
-    private String getBsdCpuManufacturer() {
-        String tmp = getBsdPSNInfo(CPU);
-        if (tmp.length() > 0) {
-            return tmp;
-        }
-
-        String contents = getFileContent("/proc/cpuinfo");
-        for (String line : contents.split("\n")) {
-            if (line.contains("vendor_id")) {
-                String[] ss = line.split(":", 2);
-                if (ss.length > 1) {
-                    return ss[1].trim();
-                }
-            }
-        }
-
-        // returns an empty string if it can't be found or an error happened
-        return getBsdDMIInfo("dmi type 4", "manufacturer");
-    }
-
-
-    /**
-     * Tries to obtain and return the system manufacturer.
-     * @return The system manufacturer (an empty string if not found or an error occurred)
-     */
-    private String getBsdSystemManufacturer() {
-        String tmp = getBsdPSNInfo(SYS);
-        if (tmp.length() > 0) {
-            return tmp;
-        }
-
-        // returns an empty string if it can't be found or an error happened
-        return getBsdDMIInfo("dmi type 1", "manufacturer");
-    }
-
-    /**
-     * Tries to obtain and return the serial number of the system.
-     * @return The serial number (an empty string if not found or an error occurred)
-     */
-    private String getBsdSN() {
-        String tmp = getBsdPSNInfo(SN);
-        if (tmp.length() > 0) {
-            return tmp;
-        }
-
-        // returns an empty string if it can't be found or an error happened
-        return getBsdDMIInfo("dmi type 1", "serial number");
-    }
-
-    private String getBsdPSNInfo(int target) {
-        // try to read from the psn file if it exists
-        String contents = getFileContent("/var/run/psn");
-        String[] ss = contents.split("\n");
-        if (target <= ss.length) {
-            return ss[target-1];
-        }
-
-        // default case is to return ""
-        return "";
-    }
-
-    // reads from dmidecode with the given type and target
-    // returns an empty string if nothing was found or an error occurred
-    //
-    // Sample output segment:
-    // Handle 0x0001
-    //         DMI type 1, 25 bytes.
-    //         System Information
-    //                 Manufacturer: System manufacturer
-    //                 Product Name: System Product Name
-    //                 Version: System Version
-    //                 Serial Number: System Serial Number
-    //                 UUID: 3091D719-B25B-D911-959D-6D1B12C7686E
-    //                 Wake-up Type: Power Switch
-
-    private synchronized String getBsdDMIInfo(String dmiType, String target) {
-        // only try to get dmidecode information once, after that, we can
-        // reuse the output
-        if (dmiInfo == null) {
-            Thread dmidecodeThread = new Thread() {
-                public void run() {
-                    dmiInfo = getCommandOutput("/usr/sbin/dmidecode");
-                }
-            };
-            dmidecodeThread.start();
-
-            try {
-                dmidecodeThread.join(2000);
-                if (dmidecodeThread.isAlive()) {
-                    dmidecodeThread.interrupt();
-                    dmiInfo = "";
-                }
-            } catch (InterruptedException ie) {
-                dmidecodeThread.interrupt();
-            }
-        }
-
-        if (dmiInfo.length() == 0) {
-            return "";
-        }
-        boolean dmiFlag = false;
-        for (String s : dmiInfo.split("\n")) {
-            String line = s.toLowerCase();
-            if (dmiFlag) {
-                if (line.contains(target)) {
-                    String key = target + ":";
-                    int indx = line.indexOf(key) + key.length();
-                    if (line.contains(key) && indx < line.length()) {
-                        return line.substring(indx).trim();
-                    }
-                    String[] ss = line.split(":");
-                    return ss[ss.length-1];
-                }
-            } else if (line.contains(dmiType)) {
-                dmiFlag = true;
-            }
-        }
-        return "";
-    }
-
-}
--- ./jdk/src/share/classes/java/awt/GraphicsEnvironment.java	2011-05-26 18:40:49.000000000 -0700
+++ ./jdk/src/share/classes/java/awt/GraphicsEnvironment.java	2011-04-22 23:08:22.000000000 -0700
@@ -172,7 +172,12 @@
                         } else {
                             String osName = System.getProperty("os.name");
                             headless = defaultHeadless =
-                                Boolean.valueOf(("Linux".equals(osName) || "SunOS".equals(osName)) &&
+                                Boolean.valueOf(("Linux".equals(osName) ||
+                                                "SunOS".equals(osName) ||
+                                                "FreeBSD".equals(osName) ||
+                                                "NetBSD".equals(osName) ||
+                                                "OpenBSD".equals(osName) ||
+                                                "Darwin".equals(osName)) &&
                                                 (System.getenv("DISPLAY") == null));
                         }
                     } else if (nm.equals("true")) {
--- ./jdk/src/share/classes/java/util/TimeZone.java	2011-05-26 18:43:50.000000000 -0700
+++ ./jdk/src/share/classes/java/util/TimeZone.java	2011-04-22 23:08:24.000000000 -0700
@@ -849,15 +849,13 @@
         }
         int gmtOffset =  (hours * 60 + num) * 60 * 1000;
 
+        zi = ZoneInfoFile.getCustomTimeZone(id, negative ? -gmtOffset : gmtOffset);
         if (gmtOffset == 0) {
-            zi = ZoneInfoFile.getZoneInfo(GMT_ID);
             if (negative) {
                 zi.setID("GMT-00:00");
             } else {
                 zi.setID("GMT+00:00");
             }
-        } else {
-            zi = ZoneInfoFile.getCustomTimeZone(id, negative ? -gmtOffset : gmtOffset);
         }
         return zi;
     }
--- ./jdk/src/share/classes/sun/awt/FontConfiguration.java	2011-05-26 18:48:46.000000000 -0700
+++ ./jdk/src/share/classes/sun/awt/FontConfiguration.java	2011-04-22 23:08:28.000000000 -0700
@@ -1131,7 +1131,7 @@
      */
     HashMap<String, Boolean> existsMap;
     public boolean needToSearchForFile(String fileName) {
-        if (!FontUtilities.isLinux) {
+        if (!FontUtilities.isLinux || FontUtilities.isBSD) {
             return false;
         } else if (existsMap == null) {
            existsMap = new HashMap<String, Boolean>();
--- ./jdk/src/share/classes/sun/awt/OSInfo.java	2011-05-26 18:48:48.000000000 -0700
+++ ./jdk/src/share/classes/sun/awt/OSInfo.java	2011-04-22 23:08:28.000000000 -0700
@@ -39,6 +39,7 @@
         WINDOWS,
         LINUX,
         SOLARIS,
+        BSD,
         UNKNOWN
     }
 
@@ -100,6 +101,14 @@
                 return SOLARIS;
             }
 
+            if (osName.contains("BSD")) {
+                return BSD;
+            }
+
+            if (osName.contains("Darwin")) {
+                return BSD;
+            }
+
             // determine another OS here
         }
 
--- ./jdk/src/share/classes/sun/font/FontUtilities.java	2011-05-26 18:49:03.000000000 -0700
+++ ./jdk/src/share/classes/sun/font/FontUtilities.java	2011-04-22 23:08:28.000000000 -0700
@@ -48,6 +48,8 @@
 
     public static boolean isLinux;
 
+    public static boolean isBSD;
+
     public static boolean isSolaris8;
 
     public static boolean isSolaris9;
@@ -76,6 +78,11 @@
 
                 isLinux = osName.startsWith("Linux");
 
+	        isBSD = (osName.startsWith("FreeBSD") ||
+	                 osName.startsWith("NetBSD") ||
+	                 osName.startsWith("OpenBSD") ||
+	                 osName.startsWith("Darwin"));
+
                 String t2kStr = System.getProperty("sun.java2d.font.scaler");
                 if (t2kStr != null) {
                     useT2K = "t2k".equals(t2kStr);
--- ./jdk/src/share/classes/sun/font/SunFontManager.java	2011-05-26 18:49:04.000000000 -0700
+++ ./jdk/src/share/classes/sun/font/SunFontManager.java	2011-04-22 23:08:28.000000000 -0700
@@ -413,7 +413,7 @@
                          * registerFonts method as on-screen these JRE fonts
                          * always go through the T2K rasteriser.
                          */
-                        if (FontUtilities.isLinux) {
+                        if (FontUtilities.isLinux || FontUtilities.isBSD) {
                             /* Linux font configuration uses these fonts */
                             registerFontDir(jreFontDirName);
                         }
--- ./jdk/src/share/classes/sun/io/ByteToCharEUC_JP_BSD.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/share/classes/sun/io/ByteToCharEUC_JP_BSD.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.io;
-
-/**
- * Class for converting bytes to characters for the EUC-JP encoding in
- * bsd. This converter supports the JIS0201 and the JIS0208 encoding and
- * omits support for the JIS212 encoding.
- *
- * @author Naveen Sanjeeva
- */
-
-public class ByteToCharEUC_JP_BSD extends  ByteToCharJIS0208 {
-    private byte savedSecond = 0;
-    ByteToCharJIS0201 bcJIS0201 = new ByteToCharJIS0201();
-
-    public ByteToCharEUC_JP_BSD() {
-        super();
-        start = 0xA1;
-        end = 0xFE;
-        savedSecond = 0;
-    }
-
-    public int flush(char[] output, int outStart, int outEnd)
-        throws MalformedInputException
-    {
-        if (savedSecond != 0) {
-            reset();
-            throw new MalformedInputException();
-        }
-        reset();
-        return 0;
-    }
-
-    /**
-     * Resets the converter.
-     * Call this method to reset the converter to its initial state
-     */
-    public void reset() {
-        super.reset();
-        savedSecond = 0;
-    }
-
-    public String getCharacterEncoding() {
-        return "EUC_JP_BSD";
-    }
-
-    protected char convSingleByte(int b) {
-        if (b < 0 || b > 0x7F)
-            return REPLACE_CHAR;
-        return bcJIS0201.getUnicode(b);
-    }
-
-    protected char getUnicode(int byte1, int byte2) {
-        if (byte1 == 0x8E) {
-            return bcJIS0201.getUnicode(byte2 - 256);
-        }
-        // Fix for bug 4121358 - similar fix for bug 4117820 put
-        // into ByteToCharDoubleByte.getUnicode()
-        if (((byte1 < 0) || (byte1 > index1.length))
-            || ((byte2 < start) || (byte2 > end)))
-            return REPLACE_CHAR;
-
-        int n = (index1[byte1 - 0x80] & 0xf) * (end - start + 1)
-                + (byte2 - start);
-        return index2[index1[byte1 - 0x80] >> 4].charAt(n);
-    }
-
-    /**
-     * Converts sequences of bytes to characters.
-     * Conversions that result in Exceptions can be restarted by calling
-     * convert again, with appropriately modified parameters.
-     * @return the characters written to output.
-     * @param input byte array containing text in Double/single Byte
-     * @param inStart offset in input array
-     * @param inEnd offset of last byte to be converted
-     * @param output character array to receive conversion result
-     * @param outStart starting offset
-     * @param outEnd offset of last byte to be written to
-     * @throw UnsupportedCharacterException for any bytes
-     * that cannot be converted to the external character set.
-     */
-    public int convert(byte[] input, int inOff, int inEnd,
-                       char[] output, int outOff, int outEnd)
-        throws UnknownCharacterException,
-               ConversionBufferFullException
-    {
-        char    outputChar = REPLACE_CHAR;
-        int     inputSize = 0;          // Size of input
-
-        // Record beginning offsets
-        charOff = outOff;
-        byteOff = inOff;
-
-        // Loop until we hit the end of the input
-        while (byteOff < inEnd) {
-            int byte1, byte2;
-
-            if (savedByte == 0) {
-                byte1 = input[byteOff];
-                inputSize = 1;
-            } else {
-                byte1 = savedByte;
-                savedByte = 0;
-                inputSize = 0;
-            }
-
-            outputChar = convSingleByte(byte1);
-
-            if (outputChar == REPLACE_CHAR) {   // Multibyte char
-                if ((byte1 & 0xff) != 0x8F) {   // JIS0208
-                    if (byteOff + inputSize >= inEnd) {
-                        // split in the middle of a character
-                        // save the first byte for next time around
-                        savedByte = (byte) byte1;
-                        byteOff += inputSize;
-                        break;
-                    }
-                    byte1 &= 0xff;
-                    byte2 = input[byteOff + inputSize] & 0xff;
-                    inputSize++;
-                    outputChar = getUnicode(byte1, byte2);
-                } else if ((byte1 & 0xff) == 0x8F) {   // JIS0212
-                    // Handling of 3-byte sequences for this converter involves
-                    // just ignoring the relevant bytes and returning a
-                    // suitable substitute char if one exists.
-                    if (byteOff + inputSize + 1 >= inEnd) {
-                        // split in the middle of a character
-                        // save the first 2 bytes for next time around
-                        savedByte = (byte) byte1;
-                        byteOff += inputSize;
-                        if (byteOff < inEnd) {
-                            savedSecond = input[byteOff];
-                            byteOff++;
-                        }
-                        break;
-                    }
-
-                    // Skip over the saved bytes if any
-                    if (savedSecond != 0) {
-                        savedSecond = 0;
-                    } else {
-                        inputSize++;
-                    }
-                    inputSize++;
-                }
-            }
-
-            if (outputChar == REPLACE_CHAR) {
-                if (subMode)
-                    outputChar = subChars[0];
-                else {
-                    badInputLength = inputSize;
-                    throw new UnknownCharacterException();
-                }
-            }
-
-            if (charOff >= outEnd)
-                throw new ConversionBufferFullException();
-
-            output[charOff++] = outputChar;
-            byteOff += inputSize;
-        }
-
-        return charOff - outOff;
-    }
-}
--- ./jdk/src/share/classes/sun/io/CharToByteEUC_JP_BSD.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/share/classes/sun/io/CharToByteEUC_JP_BSD.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.io;
-
-/**
- * Class for converting characters to bytes for the EUC-JP encoding in
- * bsd. This converter supports the JIS0201 and the JIS0208 encoding and
- * omits support for the JIS212 encoding.
- *
- * @author Naveen Sanjeeva
- */
-
-public class CharToByteEUC_JP_BSD extends CharToByteJIS0208 {
-    CharToByteJIS0201 cbJIS0201 = new CharToByteJIS0201();
-
-    public String getCharacterEncoding() {
-        return "EUC_JP_BSD";
-    }
-
-    protected int convSingleByte(char inputChar, byte[] outputByte) {
-        byte b;
-
-        if (inputChar == 0) {
-            outputByte[0] = (byte)0;
-            return 1;
-        }
-
-        if ((b = cbJIS0201.getNative(inputChar)) == 0)
-            return 0;
-
-        if (b > 0 && b < 128) {
-            outputByte[0] = b;
-            return 1;
-        }
-        outputByte[0] = (byte)0x8E;
-        outputByte[1] = b;
-        return 2;
-    }
-
-    protected int getNative(char ch) {
-        int offset = index1[((ch & 0xff00) >> 8 )] << 8;
-        int r = index2[offset >> 12].charAt((offset & 0xfff) + (ch & 0xff));
-        if (r != 0)
-            return r + 0x8080;
-        return r;
-    }
-
-    /**
-     * Converts characters to sequences of bytes.
-     * Conversions that result in Exceptions can be restarted by calling
-     * convert again, with appropriately modified parameters.
-     * @return the characters written to output.
-     * @param input char array containing text in Unicode
-     * @param inStart offset in input array
-     * @param inEnd offset of last byte to be converted
-     * @param output byte array to receive conversion result
-     * @param outStart starting offset
-     * @param outEnd offset of last byte to be written to
-     * @throw UnsupportedCharacterException for any character
-     * that cannot be converted to the external character set.
-     */
-    public int convert(char[] input, int inOff, int inEnd,
-                       byte[] output, int outOff, int outEnd)
-        throws MalformedInputException, UnknownCharacterException,
-               ConversionBufferFullException
-    {
-        char    inputChar;                 // Input character to be converted
-        byte[]  outputByte;                // Output byte written to output
-        int     inputSize = 0;             // Size of input
-        int     outputSize = 0;            // Size of output
-        byte[]  tmpbuf = new byte[4];
-
-        // Record beginning offsets
-        charOff = inOff;
-        byteOff = outOff;
-
-        if (highHalfZoneCode != 0) {
-            inputChar = highHalfZoneCode;
-            highHalfZoneCode = 0;
-            if (input[inOff] >= 0xdc00 && input[inOff] <= 0xdfff) {
-                // This is legal UTF16 sequence.
-                badInputLength = 1;
-                throw new UnknownCharacterException();
-            } else {
-                // This is illegal UTF16 sequence.
-                badInputLength = 0;
-                throw new MalformedInputException();
-            }
-        }
-
-        // Loop until we hit the end of the input
-        while(charOff < inEnd) {
-            inputSize = 1;
-            outputByte = tmpbuf;
-            inputChar = input[charOff]; // Get the input character
-
-            // Is this a high surrogate?
-            if(inputChar >= '\uD800' && inputChar <= '\uDBFF') {
-                // Is this the last character of the input?
-                if (charOff + 1 >= inEnd) {
-                    highHalfZoneCode = inputChar;
-                    break;
-                }
-
-                // Is there a low surrogate following?
-                inputChar = input[charOff + 1];
-                if (inputChar >= '\uDC00' && inputChar <= '\uDFFF') {
-                    // We have a valid surrogate pair.  Too bad we don't do
-                    // surrogates.  Is substitution enabled?
-                    if (subMode) {
-                        outputByte = subBytes;
-                        outputSize = subBytes.length;
-                        inputSize = 2;
-                    } else {
-                        badInputLength = 2;
-                        throw new UnknownCharacterException();
-                    }
-                } else {
-                    // We have a malformed surrogate pair
-                    badInputLength = 1;
-                    throw new MalformedInputException();
-                }
-            }
-            // Is this an unaccompanied low surrogate?
-            else if (inputChar >= '\uDC00' && inputChar <= '\uDFFF') {
-                badInputLength = 1;
-                throw new MalformedInputException();
-            } else {
-                outputSize = convSingleByte(inputChar, outputByte);
-                if (outputSize == 0) { // DoubleByte
-                    int ncode = getNative(inputChar);
-                    if (ncode != 0 && ((ncode & 0xFF0000) == 0)) {
-                            outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
-                            outputByte[1] = (byte) (ncode & 0xff);
-                            outputSize = 2;
-                    } else {
-                        if (subMode) {
-                            outputByte = subBytes;
-                            outputSize = subBytes.length;
-                        } else {
-                            badInputLength = 1;
-                            throw new UnknownCharacterException();
-                        }
-                    }
-                }
-            }
-
-            // If we don't have room for the output, throw an exception
-            if (byteOff + outputSize > outEnd)
-                throw new ConversionBufferFullException();
-
-            // Put the byte in the output buffer
-            for (int i = 0; i < outputSize; i++) {
-                output[byteOff++] = outputByte[i];
-            }
-            charOff += inputSize;
-        }
-        // Return the length written to the output buffer
-        return byteOff - outOff;
-    }
-
-
-    /**
-     * the maximum number of bytes needed to hold a converted char
-     * @returns the maximum number of bytes needed for a converted char
-     */
-    public int getMaxBytesPerChar() {
-        return 2;
-    }
-}
--- ./jdk/src/share/classes/sun/nio/cs/ext/EUC_JP_BSD.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/share/classes/sun/nio/cs/ext/EUC_JP_BSD.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,370 +0,0 @@
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-
-package sun.nio.cs.ext;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CoderResult;
-import sun.nio.cs.HistoricallyNamedCharset;
-import sun.nio.cs.Surrogate;
-
-public class EUC_JP_BSD
-    extends Charset
-    implements HistoricallyNamedCharset
-{
-    public EUC_JP_BSD() {
-        super("x-euc-jp-bsd", ExtendedCharsets.aliasesFor("x-euc-jp-bsd"));
-    }
-
-    public String historicalName() {
-        return "EUC_JP_BSD";
-    }
-
-    public boolean contains(Charset cs) {
-        return ((cs instanceof JIS_X_0201)
-               || (cs.name().equals("US-ASCII"))
-               || (cs instanceof EUC_JP_BSD));
-    }
-
-    public CharsetDecoder newDecoder() {
-        return new Decoder(this);
-    }
-
-    public CharsetEncoder newEncoder() {
-        return new Encoder(this);
-    }
-
-    private static class Decoder extends CharsetDecoder {
-        JIS_X_0201.Decoder decoderJ0201;
-        protected final char REPLACE_CHAR='\uFFFD';
-
-        private static final int start = 0xa1;
-        private static final int end = 0xfe;
-        private static final short[] jis0208Index1 =
-            JIS_X_0208_Decoder.getIndex1();
-        private static final String[] jis0208Index2 =
-            JIS_X_0208_Decoder.getIndex2();
-
-        private Decoder(Charset cs) {
-            super(cs, 1.0f, 1.0f);
-            decoderJ0201 = new JIS_X_0201.Decoder(cs);
-        }
-
-        protected char convSingleByte(int b) {
-            if (b < 0 || b > 0x7f)
-                return REPLACE_CHAR;
-            return decoderJ0201.decode(b);
-        }
-
-        protected char decodeDouble(int byte1, int byte2) {
-            if (byte1 == 0x8e) {
-                return decoderJ0201.decode(byte2 - 256);
-            }
-
-            if (((byte1 < 0) || (byte1 > jis0208Index1.length))
-                || ((byte2 < start) || (byte2 > end)))
-                return REPLACE_CHAR;
-
-            int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (end - start + 1)
-                    + (byte2 - start);
-            return jis0208Index2[jis0208Index1[byte1 - 0x80] >> 4].charAt(n);
-        }
-
-        private CoderResult decodeArrayLoop(ByteBuffer src,
-                                            CharBuffer dst)
-        {
-            byte[] sa = src.array();
-            int sp = src.arrayOffset() + src.position();
-            int sl = src.arrayOffset() + src.limit();
-            assert (sp <= sl);
-            sp = (sp <= sl ? sp : sl);
-
-            char[] da = dst.array();
-            int dp = dst.arrayOffset() + dst.position();
-            int dl = dst.arrayOffset() + dst.limit();
-            assert (dp <= dl);
-            dp = (dp <= dl ? dp : dl);
-
-            int b1 = 0, b2 = 0;
-            int inputSize = 0;
-            char outputChar = REPLACE_CHAR; // U+FFFD;
-
-            try {
-                while (sp < sl) {
-                    b1 = sa[sp] & 0xff;
-                    inputSize = 1;
-                    if ((b1 & 0x80) == 0) {
-                        outputChar = (char)b1;
-                    }
-                    else {      // Multibyte char
-                        if ((b1 & 0xff) == 0x8f) {   // JIS0212
-                            if (sp + 3 > sl)
-                               return CoderResult.UNDERFLOW;
-                            inputSize = 3;
-                            return CoderResult.unmappableForLength(inputSize); // substitute
-                        } else {
-                          // JIS0208
-                            if (sp + 2 > sl)
-                               return CoderResult.UNDERFLOW;
-                            b2 = sa[sp + 1] & 0xff;
-                            inputSize = 2;
-                            outputChar = decodeDouble(b1, b2);
-                        }
-                    }
-                    if (outputChar == REPLACE_CHAR) { // can't be decoded
-                        return CoderResult.unmappableForLength(inputSize);
-                    }
-                    if (dp + 1 > dl)
-                        return CoderResult.OVERFLOW;
-                    da[dp++] = outputChar;
-                    sp += inputSize;
-                }
-                return CoderResult.UNDERFLOW;
-            } finally {
-                src.position(sp - src.arrayOffset());
-                dst.position(dp - dst.arrayOffset());
-            }
-        }
-
-        private CoderResult decodeBufferLoop(ByteBuffer src,
-                                             CharBuffer dst)
-        {
-            int mark = src.position();
-            char outputChar = REPLACE_CHAR; // U+FFFD;
-
-            try {
-                while (src.hasRemaining()) {
-                    int b1 = src.get() & 0xff;
-                    int inputSize = 1;
-
-                    if ((b1 & 0x80) == 0) {
-                        outputChar = (char)b1;
-                    } else {    // Multibyte char
-
-                        if ((b1 & 0xff) == 0x8f) { // JIS0212 not supported
-                            if (src.remaining() < 2)
-                                return CoderResult.UNDERFLOW;
-                            return CoderResult.unmappableForLength(3);
-                        } else {
-                            // JIS0208
-                            if (src.remaining() < 1)
-                                return CoderResult.UNDERFLOW;
-                            int b2 = src.get() & 0xff;
-                            inputSize++;
-                            outputChar = decodeDouble(b1, b2);
-                        }
-                    }
-
-                    if (outputChar == REPLACE_CHAR)
-                        return CoderResult.unmappableForLength(inputSize);
-                    if (dst.remaining() < 1)
-                        return CoderResult.OVERFLOW;
-                    dst.put(outputChar);
-                    mark += inputSize;
-                }
-                return CoderResult.UNDERFLOW;
-            } finally {
-                src.position(mark);
-            }
-        }
-
-        protected CoderResult decodeLoop(ByteBuffer src,
-                                         CharBuffer dst)
-        {
-            if (src.hasArray() && dst.hasArray())
-                return decodeArrayLoop(src, dst);
-            else
-                return decodeBufferLoop(src, dst);
-        }
-    }
-
-
-    private static class Encoder extends CharsetEncoder {
-
-        JIS_X_0201.Encoder encoderJ0201;
-
-        private final Surrogate.Parser sgp = new Surrogate.Parser();
-        private static final short[] jis0208Index1 =
-            JIS_X_0208_Encoder.getIndex1();
-        private static final String[] jis0208Index2 =
-            JIS_X_0208_Encoder.getIndex2();
-
-        private Encoder(Charset cs) {
-            super(cs, 2.0f, 2.0f);
-            encoderJ0201 = new JIS_X_0201.Encoder(cs);
-        }
-
-        public boolean canEncode(char c) {
-            byte[]  encodedBytes = new byte[2];
-
-            if (encodeSingle(c, encodedBytes) == 0) { //doublebyte
-                if (encodeDouble(c) == 0)
-                    return false;
-            }
-            return true;
-        }
-
-        protected int encodeSingle(char inputChar, byte[] outputByte) {
-            byte b;
-
-            if (inputChar == 0) {
-                outputByte[0] = (byte)0;
-                return 1;
-            }
-
-            if ((b = encoderJ0201.encode(inputChar)) == 0)
-                return 0;
-
-            if (b > 0 && b < 128) {
-                outputByte[0] = b;
-                return 1;
-            }
-            outputByte[0] = (byte)0x8e;
-            outputByte[1] = b;
-            return 2;
-        }
-
-        protected int encodeDouble(char ch) {
-            int offset = jis0208Index1[((ch & 0xff00) >> 8 )] << 8;
-            int r = jis0208Index2[offset >> 12].charAt((offset & 0xfff) + (ch & 0xff));
-            if (r != 0)
-                return r + 0x8080;
-            return r;
-        }
-
-        private CoderResult encodeArrayLoop(CharBuffer src,
-                                            ByteBuffer dst)
-        {
-            char[] sa = src.array();
-            int sp = src.arrayOffset() + src.position();
-            int sl = src.arrayOffset() + src.limit();
-            assert (sp <= sl);
-            sp = (sp <= sl ? sp : sl);
-            byte[] da = dst.array();
-            int dp = dst.arrayOffset() + dst.position();
-            int dl = dst.arrayOffset() + dst.limit();
-            assert (dp <= dl);
-            dp = (dp <= dl ? dp : dl);
-
-            final byte[]  outputByte = new byte[2];
-
-            try {
-                while (sp < sl) {
-                    char c = sa[sp];
-
-                    if (Character.isSurrogate(c)) {
-                        if (sgp.parse(c, sa, sp, sl) < 0)
-                            return sgp.error();
-                        return sgp.unmappableResult();
-                    }
-
-                    int outputSize = encodeSingle(c, outputByte);
-                    if (outputSize == 0) { // DoubleByte
-                        int ncode = encodeDouble(c);
-                        if (ncode != 0 && ((ncode & 0xFF0000) == 0)) {
-                                outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
-                                outputByte[1] = (byte) (ncode & 0xff);
-                                outputSize = 2;
-                        } else {
-                                return CoderResult.unmappableForLength(1);
-                        }
-                    }
-
-                    if (dl - dp < outputSize)
-                        return CoderResult.OVERFLOW;
-                    // Put the byte in the output buffer
-                    for (int i = 0; i < outputSize; i++) {
-                        da[dp++] = outputByte[i];
-                    }
-                    sp++;
-                }
-                return CoderResult.UNDERFLOW;
-            } finally {
-                src.position(sp - src.arrayOffset());
-                dst.position(dp - dst.arrayOffset());
-            }
-        }
-
-        private CoderResult encodeBufferLoop(CharBuffer src,
-                                             ByteBuffer dst)
-        {
-            final byte[]  outputByte = new byte[4];
-            int mark = src.position();
-
-            try {
-                while (src.hasRemaining()) {
-                    char c = src.get();
-                    if (Character.isSurrogate(c)) {
-                        if (sgp.parse(c, src) < 0)
-                            return sgp.error();
-                        return sgp.unmappableResult();
-                    }
-
-                    int outputSize = encodeSingle(c, outputByte);
-                    if (outputSize == 0) { // DoubleByte
-                        int ncode = encodeDouble(c);
-                        if (ncode != 0 ) {
-                            if ((ncode & 0xFF0000) == 0) {
-                                outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
-                                outputByte[1] = (byte) (ncode & 0xff);
-                                outputSize = 2;
-                            }
-                        } else {
-                                return CoderResult.unmappableForLength(1);
-                        }
-                    }
-
-                    if (dst.remaining() < outputSize)
-                        return CoderResult.OVERFLOW;
-
-                    // Put the byte in the output buffer
-                    for (int i = 0; i < outputSize; i++) {
-                        dst.put(outputByte[i]);
-                    }
-                    mark++;
-                }
-                return CoderResult.UNDERFLOW;
-            } finally {
-                src.position(mark);
-            }
-        }
-
-        protected CoderResult encodeLoop(CharBuffer src,
-                                         ByteBuffer dst)
-        {
-            if (src.hasArray() && dst.hasArray())
-                return encodeArrayLoop(src, dst);
-            else
-                return encodeBufferLoop(src, dst);
-        }
-    }
-}
--- ./jdk/src/share/classes/sun/print/PSPrinterJob.java	2011-05-26 18:50:48.000000000 -0700
+++ ./jdk/src/share/classes/sun/print/PSPrinterJob.java	2011-04-22 23:08:30.000000000 -0700
@@ -1534,7 +1534,9 @@
             pFlags |= NOSHEET;
             ncomps+=1;
         }
-       if (System.getProperty("os.name").equals("Linux")) {
+
+       String osname = System.getProperty("os.name");
+       if (osname.equals("Linux") || osname.equals("FreeBSD") || osname.equals("NetBSD") || osname.equals("OpenBSD") || osname.equals("Darwin")) {
             execCmd = new String[ncomps];
             execCmd[n++] = "/usr/bin/lpr";
             if ((pFlags & PRINTER) != 0) {
--- ./jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java	2011-05-26 18:51:24.000000000 -0700
+++ ./jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java	2011-04-22 23:08:31.000000000 -0700
@@ -83,7 +83,9 @@
                             String osname = System.getProperty("os.name");
                             if (osname.startsWith("SunOS")) {
                                 gssLibs = new String[]{ "libgss.so" };
-                            } else if (osname.startsWith("Linux")) {
+                            } else if (osname.startsWith("Linux") ||
+				       osname.startsWith("Darwin") ||
+				       osname.endsWith("BSD")) {
                                 gssLibs = new String[]{
                                     "libgssapi.so",
                                     "libgssapi_krb5.so",
--- ./jdk/src/share/classes/sun/tools/attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider	2011-05-26 18:52:37.000000000 -0700
+++ ./jdk/src/share/classes/sun/tools/attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider	2011-04-22 23:08:32.000000000 -0700
@@ -30,3 +30,4 @@
 #[solaris]sun.tools.attach.SolarisAttachProvider
 #[windows]sun.tools.attach.WindowsAttachProvider
 #[linux]sun.tools.attach.LinuxAttachProvider
+#[bsd]sun.tools.attach.BsdAttachProvider
--- ./jdk/src/share/classes/sun/tools/jar/Main.java	2011-05-26 18:52:37.000000000 -0700
+++ ./jdk/src/share/classes/sun/tools/jar/Main.java	2011-04-22 23:08:32.000000000 -0700
@@ -51,6 +51,7 @@
     String zname = "";
     String[] files;
     String rootjar = null;
+    String cwd;
 
     // An entryName(path)->File map generated during "expand", it helps to
     // decide whether or not an existing entry in a jar file needs to be
@@ -867,6 +868,19 @@
      * Extracts specified entries from JAR file.
      */
     void extract(InputStream in, String files[]) throws IOException {
+        // Current working directory
+
+        cwd = System.getProperty("user.dir");
+        if (cwd == null) {
+            fatalError(getMsg("error.no.cwd"));
+        }
+        cwd = (new File(cwd)).getCanonicalPath();
+        if (!cwd.endsWith(File.separator)) {
+            cwd += File.separator;
+        }
+
+        // Extract the files
+
         ZipInputStream zis = new ZipInputStream(in);
         ZipEntry e;
         // Set of all directory entries specified in archive.  Disallows
@@ -897,6 +911,19 @@
      * Extracts specified entries from JAR file, via ZipFile.
      */
     void extract(String fname, String files[]) throws IOException {
+        // Current working directory
+
+        cwd = System.getProperty("user.dir");
+        if (cwd == null) {
+             fatalError(getMsg("error.no.cwd"));
+        }
+        cwd = (new File(cwd)).getCanonicalPath();
+        if (!cwd.endsWith(File.separator)) {
+            cwd += File.separator;
+        }
+
+        // Extract the files
+
         ZipFile zf = new ZipFile(fname);
         Set<ZipEntry> dirs = newDirSet();
         Enumeration<? extends ZipEntry> zes = zf.entries();
@@ -928,6 +955,10 @@
         ZipEntry rc = null;
         String name = e.getName();
         File f = new File(e.getName().replace('/', File.separatorChar));
+        if (!f.getCanonicalPath().startsWith(cwd)) {
+            output(formatMsg("out.ignore.entry", name));
+            return null;
+        }
         if (e.isDirectory()) {
             if (f.exists()) {
                 if (!f.isDirectory()) {
@@ -949,6 +980,10 @@
         } else {
             if (f.getParent() != null) {
                 File d = new File(f.getParent());
+                if (!d.getCanonicalPath().startsWith(cwd)) {
+                    output(formatMsg("out.ignore.entry", name));
+                    return null;
+                }
                 if (!d.exists() && !d.mkdirs() || !d.isDirectory()) {
                     throw new IOException(formatMsg(
                         "error.create.dir", d.getPath()));
--- ./jdk/src/share/classes/sun/tools/jar/resources/jar.properties	2011-05-26 18:52:38.000000000 -0700
+++ ./jdk/src/share/classes/sun/tools/jar/resources/jar.properties	2011-04-22 23:08:32.000000000 -0700
@@ -44,6 +44,8 @@
         {0} : could not create directory
 error.incorrect.length=\
         incorrect length while processing: {0}
+error.no.cwd=\
+	{0} : could not determine current working directory
 out.added.manifest=\
         added manifest
 out.update.manifest=\
--- ./jdk/src/share/demo/jvmti/compiledMethodLoad/sample.makefile.txt	2011-05-26 18:53:56.000000000 -0700
+++ ./jdk/src/share/demo/jvmti/compiledMethodLoad/sample.makefile.txt	2011-04-22 23:08:34.000000000 -0700
@@ -38,6 +38,7 @@
 #       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
 #       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
 #       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
+#       gnumake JDK=<java_home> OSNAME=bsd     [OPT=true]
 #
 ########################################################################
 
@@ -120,6 +121,29 @@
     LINK_SHARED=link -dll -out:$@
 endif
 
+# BSD GNU C Compiler
+ifeq ($(OSNAME), bsd)
+    # GNU Compiler options needed to build it
+    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
+    # Options that help find errors
+    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
+    ifeq ($(OPT), true)
+        CFLAGS=-O2 $(COMMON_FLAGS)
+    else
+        CFLAGS=-g $(COMMON_FLAGS)
+    endif
+    # Object files needed to create library
+    OBJECTS=$(SOURCES:%.c=%.o)
+    # Library name and options needed to build it
+    # XXX: Needs to be fixed for MacOS X
+    LIBRARY=lib$(LIBNAME).so
+    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
+    # Libraries we are dependent on
+    LIBRARIES=-lc
+    # Building a shared library
+    LINK_SHARED=$(LINK.c) -shared -o $@
+endif
+
 # Common -I options
 CFLAGS += -I.
 CFLAGS += -I../agent_util
--- ./jdk/src/share/lib/security/java.security-openbsd	1969-12-31 16:00:00.000000000 -0800
+++ ./jdk/src/share/lib/security/java.security-openbsd	2011-04-22 23:08:35.000000000 -0700
@@ -0,0 +1,269 @@
+#
+# This is the "master security properties file".
+#
+# In this file, various security properties are set for use by
+# java.security classes. This is where users can statically register
+# Cryptography Package Providers ("providers" for short). The term
+# "provider" refers to a package or set of packages that supply a
+# concrete implementation of a subset of the cryptography aspects of
+# the Java Security API. A provider may, for example, implement one or
+# more digital signature algorithms or message digest algorithms.
+#
+# Each provider must implement a subclass of the Provider class.
+# To register a provider in this master security properties file,
+# specify the Provider subclass name and priority in the format
+#
+#    security.provider.<n>=<className>
+#
+# This declares a provider, and specifies its preference
+# order n. The preference order is the order in which providers are
+# searched for requested algorithms (when no specific provider is
+# requested). The order is 1-based; 1 is the most preferred, followed
+# by 2, and so on.
+#
+# <className> must specify the subclass of the Provider class whose
+# constructor sets the values of various properties that are required
+# for the Java Security API to look up the algorithms or other
+# facilities implemented by the provider.
+#
+# There must be at least one provider specification in java.security.
+# There is a default provider that comes standard with the JDK. It
+# is called the "SUN" provider, and its Provider subclass
+# named Sun appears in the sun.security.provider package. Thus, the
+# "SUN" provider is registered via the following:
+#
+#    security.provider.1=sun.security.provider.Sun
+#
+# (The number 1 is used for the default provider.)
+#
+# Note: Providers can be dynamically registered instead by calls to
+# either the addProvider or insertProviderAt method in the Security
+# class.
+
+#
+# List of providers and their preference orders (see above):
+#
+security.provider.1=sun.security.provider.Sun
+security.provider.2=sun.security.rsa.SunRsaSign
+security.provider.3=sun.security.ec.SunEC
+security.provider.4=com.sun.net.ssl.internal.ssl.Provider
+security.provider.5=com.sun.crypto.provider.SunJCE
+security.provider.6=sun.security.jgss.SunProvider
+security.provider.7=com.sun.security.sasl.Provider
+security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI
+security.provider.9=sun.security.smartcardio.SunPCSC
+
+#
+# Select the source of seed data for SecureRandom. By default an
+# attempt is made to use the entropy gathering device specified by 
+# the securerandom.source property. If an exception occurs when
+# accessing the URL then the traditional system/thread activity 
+# algorithm is used. 
+#
+# On Solaris and Linux systems, if file:/dev/urandom is specified and it
+# exists, a special SecureRandom implementation is activated by default.
+# This "NativePRNG" reads random bytes directly from /dev/urandom.
+#
+# On Windows systems, the URLs file:/dev/random and file:/dev/urandom
+# enables use of the Microsoft CryptoAPI seed functionality.
+#
+# On OpenBSD use file:///dev/srandom for strong but blocking random
+# generator, file:/dev/random for hardware random generators,
+# file:///dev/arandom for non-blocking high-quality pseudo-random
+# data and file:///dev/urandom for non-blocking random data that
+# does not guarantee the data to be strong. See random(4) for more
+# info.
+#
+securerandom.source=file:///dev/arandom
+#
+# The entropy gathering device is described as a URL and can also
+# be specified with the system property "java.security.egd". For example,
+#   -Djava.security.egd=file:/dev/urandom
+# Specifying this system property will override the securerandom.source 
+# setting.
+
+#
+# Class to instantiate as the javax.security.auth.login.Configuration
+# provider.
+#
+login.configuration.provider=com.sun.security.auth.login.ConfigFile
+
+#
+# Default login configuration file
+#
+#login.config.url.1=file:${user.home}/.java.login.config
+
+#
+# Class to instantiate as the system Policy. This is the name of the class
+# that will be used as the Policy object.
+#
+policy.provider=sun.security.provider.PolicyFile
+
+# The default is to have a single system-wide policy file,
+# and a policy file in the user's home directory.
+policy.url.1=file:${java.home}/lib/security/java.policy
+policy.url.2=file:${user.home}/.java.policy
+
+# whether or not we expand properties in the policy file
+# if this is set to false, properties (${...}) will not be expanded in policy
+# files.
+policy.expandProperties=true
+
+# whether or not we allow an extra policy to be passed on the command line
+# with -Djava.security.policy=somefile. Comment out this line to disable
+# this feature.
+policy.allowSystemProperty=true
+
+# whether or not we look into the IdentityScope for trusted Identities
+# when encountering a 1.1 signed JAR file. If the identity is found
+# and is trusted, we grant it AllPermission.
+policy.ignoreIdentityScope=false
+
+#
+# Default keystore type.
+#
+keystore.type=jks
+
+#
+# Class to instantiate as the system scope:
+#
+system.scope=sun.security.provider.IdentityDatabase
+
+#
+# List of comma-separated packages that start with or equal this string
+# will cause a security exception to be thrown when
+# passed to checkPackageAccess unless the
+# corresponding RuntimePermission ("accessClassInPackage."+package) has
+# been granted.
+package.access=sun.,com.sun.imageio.
+
+#
+# List of comma-separated packages that start with or equal this string
+# will cause a security exception to be thrown when
+# passed to checkPackageDefinition unless the
+# corresponding RuntimePermission ("defineClassInPackage."+package) has
+# been granted.
+#
+# by default, no packages are restricted for definition, and none of
+# the class loaders supplied with the JDK call checkPackageDefinition.
+#
+#package.definition=
+
+#
+# Determines whether this properties file can be appended to
+# or overridden on the command line via -Djava.security.properties
+#
+security.overridePropertiesFile=true
+
+#
+# Determines the default key and trust manager factory algorithms for 
+# the javax.net.ssl package.
+#
+ssl.KeyManagerFactory.algorithm=SunX509
+ssl.TrustManagerFactory.algorithm=PKIX
+
+#
+# The Java-level namelookup cache policy for successful lookups:
+#
+# any negative value: caching forever
+# any positive value: the number of seconds to cache an address for
+# zero: do not cache
+#
+# default value is forever (FOREVER). For security reasons, this
+# caching is made forever when a security manager is set. When a security
+# manager is not set, the default behavior in this implementation
+# is to cache for 30 seconds.
+#
+# NOTE: setting this to anything other than the default value can have
+#       serious security implications. Do not set it unless 
+#       you are sure you are not exposed to DNS spoofing attack.
+#
+#networkaddress.cache.ttl=-1 
+
+# The Java-level namelookup cache policy for failed lookups:
+#
+# any negative value: cache forever
+# any positive value: the number of seconds to cache negative lookup results
+# zero: do not cache
+#
+# In some Microsoft Windows networking environments that employ
+# the WINS name service in addition to DNS, name service lookups
+# that fail may take a noticeably long time to return (approx. 5 seconds).
+# For this reason the default caching policy is to maintain these
+# results for 10 seconds. 
+#
+#
+networkaddress.cache.negative.ttl=10
+
+#
+# Properties to configure OCSP for certificate revocation checking
+#
+
+# Enable OCSP 
+#
+# By default, OCSP is not used for certificate revocation checking.
+# This property enables the use of OCSP when set to the value "true".
+#
+# NOTE: SocketPermission is required to connect to an OCSP responder.
+#
+# Example,
+#   ocsp.enable=true
+ 
+#
+# Location of the OCSP responder
+#
+# By default, the location of the OCSP responder is determined implicitly
+# from the certificate being validated. This property explicitly specifies
+# the location of the OCSP responder. The property is used when the
+# Authority Information Access extension (defined in RFC 3280) is absent
+# from the certificate or when it requires overriding.
+#
+# Example,
+#   ocsp.responderURL=http://ocsp.example.net:80
+ 
+#
+# Subject name of the OCSP responder's certificate
+#
+# By default, the certificate of the OCSP responder is that of the issuer
+# of the certificate being validated. This property identifies the certificate
+# of the OCSP responder when the default does not apply. Its value is a string 
+# distinguished name (defined in RFC 2253) which identifies a certificate in 
+# the set of certificates supplied during cert path validation. In cases where 
+# the subject name alone is not sufficient to uniquely identify the certificate
+# then both the "ocsp.responderCertIssuerName" and
+# "ocsp.responderCertSerialNumber" properties must be used instead. When this
+# property is set then those two properties are ignored.
+#
+# Example,
+#   ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp"
+
+#
+# Issuer name of the OCSP responder's certificate
+#
+# By default, the certificate of the OCSP responder is that of the issuer
+# of the certificate being validated. This property identifies the certificate
+# of the OCSP responder when the default does not apply. Its value is a string
+# distinguished name (defined in RFC 2253) which identifies a certificate in
+# the set of certificates supplied during cert path validation. When this 
+# property is set then the "ocsp.responderCertSerialNumber" property must also 
+# be set. When the "ocsp.responderCertSubjectName" property is set then this 
+# property is ignored.
+#
+# Example,
+#   ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp"
+ 
+#
+# Serial number of the OCSP responder's certificate
+#
+# By default, the certificate of the OCSP responder is that of the issuer
+# of the certificate being validated. This property identifies the certificate
+# of the OCSP responder when the default does not apply. Its value is a string
+# of hexadecimal digits (colon or space separators may be present) which
+# identifies a certificate in the set of certificates supplied during cert path
+# validation. When this property is set then the "ocsp.responderCertIssuerName"
+# property must also be set. When the "ocsp.responderCertSubjectName" property
+# is set then this property is ignored.
+#
+# Example,
+#   ocsp.responderCertSerialNumber=2A:FF:00
+ 
--- ./jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	2011-05-26 18:54:24.000000000 -0700
+++ ./jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	2011-04-22 23:08:35.000000000 -0700
@@ -32,6 +32,10 @@
 #include <unistd.h>
 #endif
 
+#ifndef NO_ZLIB
+#      include <zconf.h>
+#endif
+
 #ifndef FULL
 #define FULL 1 /* Adds <500 bytes to the zipped final product. */
 #endif
@@ -89,11 +93,13 @@
 // bytes and byte arrays
 
 typedef unsigned int uint;
+#ifdef NO_ZLIB
 #ifdef _LP64
 typedef unsigned int uLong; // Historical zlib, should be 32-bit.
 #else
 typedef unsigned long uLong;
 #endif
+#endif
 #ifdef _MSC_VER
 typedef LONGLONG        jlong;
 typedef DWORDLONG       julong;
--- ./jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp	2011-05-26 18:54:24.000000000 -0700
+++ ./jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp	2011-04-22 23:08:35.000000000 -0700
@@ -22,6 +22,9 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+#ifdef _ALLBSD_SOURCE
+#include <stdint.h>
+#endif
 #include <sys/types.h>
 
 #include <stdio.h>
@@ -35,7 +38,7 @@
 
 #if defined(unix) && !defined(PRODUCT)
 #include "pthread.h"
-#define THREAD_SELF ((int)pthread_self())
+#define THREAD_SELF ((intptr_t) pthread_self())
 #endif
 
 #include "defines.h"
@@ -58,9 +61,9 @@
 // Single-threaded, implementation, not reentrant.
 // Includes a weak error check against MT access.
 #ifndef THREAD_SELF
-#define THREAD_SELF (0)
+#define THREAD_SELF ((intptr_t) 0)
 #endif
-NOT_PRODUCT(static int uThread = -1;)
+NOT_PRODUCT(static intptr_t uThread = -1;)
 
 unpacker* unpacker::non_mt_current = null;
 unpacker* unpacker::current() {
@@ -69,7 +72,7 @@
 }
 static void set_current_unpacker(unpacker* u) {
   unpacker::non_mt_current = u;
-  assert(((uThread = (u == null) ? -1 : THREAD_SELF),
+  assert(((uThread = (u == null) ? ((intptr_t) -1) : THREAD_SELF),
           true));
 }
 
--- ./jdk/src/share/native/com/sun/media/sound/DirectAudioDevice.c	2011-05-26 18:54:25.000000000 -0700
+++ ./jdk/src/share/native/com/sun/media/sound/DirectAudioDevice.c	2011-04-22 23:08:35.000000000 -0700
@@ -33,7 +33,11 @@
 
 #include <jni.h>
 // for malloc
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 #include "SoundDefs.h"
 #include "DirectAudio.h"
 #include "Utilities.h"
--- ./jdk/src/share/native/com/sun/media/sound/Platform.c	2011-05-26 18:54:26.000000000 -0700
+++ ./jdk/src/share/native/com/sun/media/sound/Platform.c	2011-04-22 23:08:35.000000000 -0700
@@ -99,5 +99,24 @@
         return com_sun_media_sound_Platform_LIB_ALSA;
     }
 #endif
+#if (X_PLATFORM == X_BSD)
+    switch (feature) {
+    case com_sun_media_sound_Platform_FEATURE_MIDIIO:
+       return com_sun_media_sound_Platform_LIB_MAIN;
+#ifdef __FreeBSD__
+    case com_sun_media_sound_Platform_FEATURE_PORTS:
+       return com_sun_media_sound_Platform_LIB_ALSA;
+    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
+       return com_sun_media_sound_Platform_LIB_ALSA;
+#else
+    case com_sun_media_sound_Platform_FEATURE_PORTS:
+       return com_sun_media_sound_Platform_LIB_MAIN;
+    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
+       // XXXBSD: When native Direct Audio support is ported change
+       // this back to returning com_sun_media_sound_Platform_LIB_MAIN
+       return 0;
+#endif
+    }
+#endif
     return 0;
 }
--- ./jdk/src/share/native/com/sun/media/sound/SoundDefs.h	2011-05-26 18:54:26.000000000 -0700
+++ ./jdk/src/share/native/com/sun/media/sound/SoundDefs.h	2011-04-22 23:08:35.000000000 -0700
@@ -31,6 +31,7 @@
 #define X_WINDOWS       1
 #define X_SOLARIS       2
 #define X_LINUX         3
+#define X_BSD           4
 
 // types for X_ARCH
 #define X_I586          1
@@ -52,7 +53,7 @@
 
 
 // following is needed for _LP64
-#if ((X_PLATFORM == X_SOLARIS) || (X_PLATFORM == X_LINUX))
+#if ((X_PLATFORM == X_SOLARIS) || (X_PLATFORM == X_LINUX) || (X_PLATFORM == X_BSD))
 #include <sys/types.h>
 #endif
 
@@ -132,4 +133,9 @@
 #endif
 
 
+#if X_PLATFORM == X_BSD
+#define INLINE          inline
+#endif
+
+
 #endif  // __SOUNDDEFS_INCLUDED__
--- ./jdk/src/share/native/common/check_code.c	2011-05-26 18:54:27.000000000 -0700
+++ ./jdk/src/share/native/common/check_code.c	2011-04-22 23:08:35.000000000 -0700
@@ -1067,7 +1067,7 @@
  * Make sure that branches don't go into the middle of nowhere.
  */
 
-static jint ntohl(jint n)
+static jint _ck_ntohl(jint n)
 {
     unsigned char *p = (unsigned char *)&n;
     return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
@@ -1146,26 +1146,26 @@
             }
         }
         if (opcode == JVM_OPC_tableswitch) {
-            keys = ntohl(lpc[2]) -  ntohl(lpc[1]) + 1;
+            keys = _ck_ntohl(lpc[2]) -  _ck_ntohl(lpc[1]) + 1;
             delta = 1;
         } else {
-            keys = ntohl(lpc[1]); /* number of pairs */
+            keys = _ck_ntohl(lpc[1]); /* number of pairs */
             delta = 2;
             /* Make sure that the tableswitch items are sorted */
             for (k = keys - 1, lptr = &lpc[2]; --k >= 0; lptr += 2) {
-                int this_key = ntohl(lptr[0]);  /* NB: ntohl may be unsigned */
-                int next_key = ntohl(lptr[2]);
+                int this_key = _ck_ntohl(lptr[0]);  /* NB: ntohl may be unsigned */
+                int next_key = _ck_ntohl(lptr[2]);
                 if (this_key >= next_key) {
                     CCerror(context, "Unsorted lookup switch");
                 }
             }
         }
         saved_operand = NEW(int, keys + 2);
-        if (!isLegalTarget(context, offset + ntohl(lpc[0])))
+        if (!isLegalTarget(context, offset + _ck_ntohl(lpc[0])))
             CCerror(context, "Illegal default target in switch");
-        saved_operand[keys + 1] = code_data[offset + ntohl(lpc[0])];
+        saved_operand[keys + 1] = code_data[offset + _ck_ntohl(lpc[0])];
         for (k = keys, lptr = &lpc[3]; --k >= 0; lptr += delta) {
-            int target = offset + ntohl(lptr[0]);
+            int target = offset + _ck_ntohl(lptr[0]);
             if (!isLegalTarget(context, target))
                 CCerror(context, "Illegal branch in tableswitch");
             saved_operand[k + 1] = code_data[target];
@@ -1634,7 +1634,7 @@
             if (lpc + 2 >= (int *)end) {
                 return -1; /* do not read pass the end */
             }
-            index = ntohl(lpc[2]) - ntohl(lpc[1]);
+	    index = _ck_ntohl(lpc[2]) - _ck_ntohl(lpc[1]);
             if ((index < 0) || (index > 65535)) {
                 return -1;      /* illegal */
             } else {
@@ -1647,7 +1647,7 @@
             int npairs;
             if (lpc + 1 >= (int *)end)
                 return -1; /* do not read pass the end */
-            npairs = ntohl(lpc[1]);
+	    npairs = _ck_ntohl(lpc[1]);
             /* There can't be more than 64K labels because of the limit
              * on per-method byte code length.
              */
--- ./jdk/src/share/native/java/io/io_util.h	2011-05-26 18:54:29.000000000 -0700
+++ ./jdk/src/share/native/java/io/io_util.h	2011-04-22 23:08:35.000000000 -0700
@@ -29,7 +29,15 @@
 extern jfieldID IO_fd_fdID;
 extern jfieldID IO_handle_fdID;
 
-#if !defined(O_DSYNC) || !defined(O_SYNC)
+#ifdef _ALLBSD_SOURCE
+#include <fcntl.h>
+#ifndef O_SYNC
+#define O_SYNC  O_FSYNC
+#endif
+#ifndef O_DSYNC
+#define O_DSYNC O_FSYNC
+#endif
+#elif !defined(O_DSYNC) || !defined(O_SYNC)
 #define O_SYNC  (0x0800)
 #define O_DSYNC (0x2000)
 #endif
--- ./jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h	2011-05-26 18:54:31.000000000 -0700
+++ ./jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h	2011-04-22 23:08:35.000000000 -0700
@@ -24,6 +24,15 @@
  * questions.
  */
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#endif
+#ifdef _ALLBSD_SOURCE
+#include <machine/endian.h>
+#elif __linux__
+#define __USE_BSD 1
+#include <endian.h>
+#endif
 #include "jfdlibm.h"
 
 #ifdef __NEWVALID       /* special setup for Sun test regime */
@@ -34,7 +43,8 @@
 #endif
 #endif
 
-#ifdef _LITTLE_ENDIAN
+#if (defined(__solaris__) && defined(_LITTLE_ENDIAN)) || \
+    BYTE_ORDER == LITTLE_ENDIAN
 #define __HI(x) *(1+(int*)&x)
 #define __LO(x) *(int*)&x
 #define __HIp(x) *(1+(int*)x)
--- ./jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h	2011-05-26 18:54:31.000000000 -0700
+++ ./jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h	2011-04-22 23:08:35.000000000 -0700
@@ -61,7 +61,7 @@
 #define log1p   jlog1p
 #define expm1   jexpm1
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #define __ieee754_sqrt          __j__ieee754_sqrt
 #define __ieee754_acos          __j__ieee754_acos
 #define __ieee754_acosh         __j__ieee754_acosh
--- ./jdk/src/share/native/java/util/zip/Inflater.c	2011-05-26 18:54:39.000000000 -0700
+++ ./jdk/src/share/native/java/util/zip/Inflater.c	2011-04-22 23:08:35.000000000 -0700
@@ -65,6 +65,10 @@
         return jlong_zero;
     } else {
         char *msg;
+// BSDXXX needed for FreeBSD 5.4 and below with system zlib
+#if defined(__FreeBSD__) && __FreeBSD__ < 6
+	strm->adler = 1;
+#endif
         switch (inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS)) {
           case Z_OK:
             return ptr_to_jlong(strm);
@@ -192,6 +196,10 @@
     if (inflateReset(jlong_to_ptr(addr)) != Z_OK) {
         JNU_ThrowInternalError(env, 0);
     }
+// BSDXXX needed for FreeBSD 5.4 and below with system zlib
+#if defined(__FreeBSD__) && __FreeBSD__ < 6
+    ((z_stream *)jlong_to_ptr(strm))->adler = 1;
+#endif
 }
 
 JNIEXPORT void JNICALL
--- ./jdk/src/share/native/java/util/zip/zip_util.c	2011-05-26 18:54:39.000000000 -0700
+++ ./jdk/src/share/native/java/util/zip/zip_util.c	2011-04-22 23:08:35.000000000 -0700
@@ -46,6 +46,11 @@
 #include "zip_util.h"
 #include "zlib.h"
 
+#ifdef _ALLBSD_SOURCE
+#define off64_t	off_t
+#define mmap64 mmap
+#endif
+
 /* USE_MMAP means mmap the CEN & ENDHDR part of the zip file. */
 #ifdef USE_MMAP
 #include <sys/mman.h>
--- ./jdk/src/share/native/sun/awt/debug/debug_util.h	2011-05-26 18:54:42.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/debug/debug_util.h	2011-04-22 23:08:35.000000000 -0700
@@ -50,7 +50,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#if !defined(_ALLBSD_SOURCE)
 #include <malloc.h>
+#endif
 #include <limits.h>
 
 /* keep these after the other headers */
--- ./jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c	2011-05-26 18:54:42.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c	2011-04-22 23:08:35.000000000 -0700
@@ -24,7 +24,11 @@
  */
 
 #include "BufImgSurfaceData.h"
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include "malloc.h"
+#endif
 
 #include "sun_awt_image_BufImgSurfaceData.h"
 
--- ./jdk/src/share/native/sun/awt/image/DataBufferNative.c	2011-05-26 18:54:43.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/image/DataBufferNative.c	2011-04-22 23:08:35.000000000 -0700
@@ -23,7 +23,11 @@
  * questions.
  */
 
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include "malloc.h"
+#endif
 
 #include "SurfaceData.h"
 #include "sun_awt_image_DataBufferNative.h"
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv2x2_f.c	2011-05-26 18:54:54.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv2x2_f.c	2011-04-22 23:08:36.000000000 -0700
@@ -86,7 +86,7 @@
 #endif /* MLIB_USE_FTOI_CLAMPING */
 
 /***************************************************************/
-#if defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG)
+#if (BYTE_ORDER == LITTLE_ENDIAN) && !defined(_NO_LONGLONG)
 
 /* NB: Explicit cast to DTYPE is necessary to avoid warning from Microsoft VC compiler.
       And we need to explicitly define cast behavior if source exceeds destination range.
@@ -103,7 +103,7 @@
   dp[0    ] = (DTYPE) ((res0) & DTYPE_MASK);                      \
   dp[chan1] = (DTYPE) ((res1) & DTYPE_MASK)
 
-#endif /* defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG) */
+#endif /* (BYTE_ORDER == LITTLE_ENDIAN) && !defined(_NO_LONGLONG) */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -114,17 +114,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | ((mlib_s64)sp[0] & 0xffffffff)
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | ((mlib_s64)sp[chan1] & 0xffffffff)
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 #endif /* _NO_LONGLONG */
 
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c	2011-05-26 18:54:55.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16ext.c	2011-04-22 23:08:36.000000000 -0700
@@ -126,7 +126,7 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define STORE2(res0, res1)                                      \
   dp[0    ] = res1;                                             \
@@ -138,7 +138,7 @@
   dp[0    ] = res0;                                             \
   dp[chan1] = res1
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -149,17 +149,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c	2011-05-26 18:54:55.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_16nw.c	2011-04-22 23:08:36.000000000 -0700
@@ -94,7 +94,7 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define STORE2(res0, res1)                                      \
   dp[0    ] = res1;                                             \
@@ -106,7 +106,7 @@
   dp[0    ] = res0;                                             \
   dp[chan1] = res1
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -117,17 +117,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c	2011-05-26 18:54:55.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8ext.c	2011-04-22 23:08:36.000000000 -0700
@@ -126,7 +126,7 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define STORE2(res0, res1)                                      \
   dp[0    ] = res1;                                             \
@@ -138,7 +138,7 @@
   dp[0    ] = res0;                                             \
   dp[chan1] = res1
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -149,17 +149,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c	2011-05-26 18:54:55.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_8nw.c	2011-04-22 23:08:36.000000000 -0700
@@ -95,7 +95,7 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define STORE2(res0, res1)                                      \
   dp[0    ] = res1;                                             \
@@ -107,7 +107,7 @@
   dp[0    ] = res0;                                             \
   dp[chan1] = res1
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -118,17 +118,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c	2011-05-26 18:54:56.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16ext.c	2011-04-22 23:08:36.000000000 -0700
@@ -126,7 +126,7 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define STORE2(res0, res1)                                      \
   dp[0    ] = res1;                                             \
@@ -138,7 +138,7 @@
   dp[0    ] = res0;                                             \
   dp[chan1] = res1
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -149,17 +149,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c	2011-05-26 18:54:56.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageConv_u16nw.c	2011-04-22 23:08:36.000000000 -0700
@@ -94,7 +94,7 @@
 #define D2I(x) CLAMP_S32((x) SAT_OFF)
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define STORE2(res0, res1)                                      \
   dp[0    ] = res1;                                             \
@@ -106,7 +106,7 @@
   dp[0    ] = res0;                                             \
   dp[chan1] = res1
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 #ifdef _NO_LONGLONG
@@ -117,17 +117,17 @@
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | S64TOS32((mlib_s64)sp[0])
 
-#else /* _LITTLE_ENDIAN */
+#else
 
 #define LOAD_BUFF(buff)                                         \
   *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | S64TOS32((mlib_s64)sp[chan1])
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #endif /* _NO_LONGLONG */
 
 /***************************************************************/
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageCopy_Bit.c	2011-05-26 18:54:56.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageCopy_Bit.c	2011-04-22 23:08:36.000000000 -0700
@@ -95,7 +95,7 @@
     dst = dp[0];
     if (ld_offset + size < 32) {
       dmask = (mask0 << (32 - size)) >> ld_offset;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
       src = (src0 >> (ld_offset - ls_offset));
       dst = (dst << 24) | ((dst & 0xFF00) << 8) | ((dst >> 8) & 0xFF00) | (dst >> 24);
@@ -104,12 +104,12 @@
 #else
       src = (src0 >> (ld_offset - ls_offset));
       dp[0] = (dst & (~dmask)) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       return;
     }
 
     dmask = mask0 >> ld_offset;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
     src = (src0 >> (ld_offset - ls_offset));
     dst = (dst << 24) | ((dst & 0xFF00) << 8) | ((dst >> 8) & 0xFF00) | (dst >> 24);
@@ -118,7 +118,7 @@
 #else
     src = (src0 >> (ld_offset - ls_offset));
     dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     j = 32 - ld_offset;
     dp++;
     ls_offset += j;
@@ -131,7 +131,7 @@
 
     if (ld_offset + size < 32) {
       dmask = (mask0 << (32 - size)) >> ld_offset;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
       src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
       src = (src0 << shift) | (src1 >> (32 - shift));
@@ -141,12 +141,12 @@
 #else
       src = (src0 << shift) | (src1 >> (32 - shift));
       dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       return;
     }
 
     dmask = mask0 >> ld_offset;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
     src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
     src = (src0 << shift) | (src1 >> (32 - shift));
@@ -156,7 +156,7 @@
 #else
     src = (src0 << shift) | (src1 >> (32 - shift));
     dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     j = 32 - ld_offset;
     dp++;
     sp++;
@@ -164,19 +164,19 @@
   }
 
   if (j < size) src1 = sp[0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
   src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
   for (; j <= size - 32; j += 32) {
     src0 = src1;
     src1 = sp[1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
     src = (src0 << ls_offset) | (src1 >> (32 - ls_offset));
     dp[0] = (src << 24) | ((src & 0xFF00) << 8) | ((src >> 8) & 0xFF00) | (src >> 24);
 #else
     dp[0] = (src0 << ls_offset) | (src1 >> (32 - ls_offset));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     sp++;
     dp++;
   }
@@ -187,7 +187,7 @@
     if (ls_offset + j > 32) src1 = sp[1];
     dst = dp[0];
     dmask = mask0 << (32 - j);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
     src = (src0 << ls_offset) | (src1 >> (32 - ls_offset));
     dst = (dst << 24) | ((dst & 0xFF00) << 8) | ((dst >> 8) & 0xFF00) | (dst >> 24);
@@ -196,7 +196,7 @@
 #else
     src = (src0 << ls_offset) | (src1 >> (32 - ls_offset));
     dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
   }
 
 #else /* _LONGLONG */
@@ -315,7 +315,7 @@
     dst = dp[0];
     if (ld_offset >= size) {
       dmask = (lmask0 << (32 - size)) >> (ld_offset - size);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
       src = (src0 << (ls_offset - ld_offset));
       dst = (dst << 24) | ((dst & 0xFF00) << 8) | ((dst >> 8) & 0xFF00) | (dst >> 24);
@@ -324,12 +324,12 @@
 #else
       src = (src0 << (ls_offset - ld_offset));
       dp[0] = (dst & (~dmask)) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       return;
     }
 
     dmask = lmask0 << (32 - ld_offset);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
     src = (src0 << (ls_offset - ld_offset));
     dst = (dst << 24) | ((dst & 0xFF00) << 8) | ((dst >> 8) & 0xFF00) | (dst >> 24);
@@ -338,7 +338,7 @@
 #else
     src = (src0 << (ls_offset - ld_offset));
     dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     j = ld_offset;
     dp--;
     ls_offset -= j;
@@ -351,7 +351,7 @@
 
     if (ld_offset >= size) {
       dmask = (lmask0 << (32 - size)) >> (ld_offset - size);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
       src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
       src = (src0 >> shift) | (src1 << (32 - shift));
@@ -361,12 +361,12 @@
 #else
       src = (src0 >> shift) | (src1 << (32 - shift));
       dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       return;
     }
 
     dmask = lmask0 << (32 - ld_offset);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src0 = (src0 << 24) | ((src0 & 0xFF00) << 8) | ((src0 >> 8) & 0xFF00) | (src0 >> 24);
     src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
     src = (src0 >> shift) | (src1 << (32 - shift));
@@ -376,7 +376,7 @@
 #else
     src = (src0 >> shift) | (src1 << (32 - shift));
     dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     j = ld_offset;
     dp--;
     sp--;
@@ -384,22 +384,22 @@
   }
 
   if (j < size) src1 = sp[0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
   src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 #ifdef __SUNPRO_C
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
   for (; j <= size - 32; j += 32) {
     src0 = src1;
     src1 = sp[-1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
     src = (src0 >> (32 - ls_offset)) | (src1 << ls_offset);
     dp[0] = (src << 24) | ((src & 0xFF00) << 8) | ((src >> 8) & 0xFF00) | (src >> 24);
 #else
     dp[0] = (src0 >> (32 - ls_offset)) | (src1 << ls_offset);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     sp--;
     dp--;
   }
@@ -410,7 +410,7 @@
     if (ls_offset < j) src1 = sp[-1];
     dst = dp[0];
     dmask = lmask0 >> (32 - j);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     src1 = (src1 << 24) | ((src1 & 0xFF00) << 8) | ((src1 >> 8) & 0xFF00) | (src1 >> 24);
     src = (src0 >> (32 - ls_offset)) | (src1 << ls_offset);
     dst = (dst << 24) | ((dst & 0xFF00) << 8) | ((dst >> 8) & 0xFF00) | (dst >> 24);
@@ -419,7 +419,7 @@
 #else
     src = (src0 >> (32 - ls_offset)) | (src1 << ls_offset);
     dp[0] = (dst & ~dmask) | (src & dmask);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
   }
 
 #else  /* _LONGLONG */
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageLookUp_64.c	2011-05-26 18:54:56.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageLookUp_64.c	2011-04-22 23:08:36.000000000 -0700
@@ -168,7 +168,7 @@
 }
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define READ_U8_D64(table0, table1, table2, table3)             \
   t0 = *(mlib_d64*)((mlib_u8*)table0 + ((s0 << 3) & 0x7F8));    \
@@ -184,7 +184,7 @@
   t2 = *(mlib_d64*)((mlib_u8*)table2 + ((s0 >> 5)  & 0x7F8));   \
   t3 = *(mlib_d64*)((mlib_u8*)table3 + ((s0 << 3)  & 0x7F8))
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 void mlib_ImageLookUp_U8_D64(const mlib_u8  *src,
@@ -613,7 +613,7 @@
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
       for (i = 0; i < size - 7; i += 4, dp += 8, sa++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 5) & 0x7F8));
@@ -623,12 +623,12 @@
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 21) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[0] = t0;
         dp[1] = t1;
         dp[2] = t2;
         dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 21) & 0x7F8));
@@ -638,7 +638,7 @@
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 5) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         dp[4] = t0;
         dp[5] = t1;
@@ -646,7 +646,7 @@
         dp[7] = t3;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 5) & 0x7F8));
@@ -656,12 +656,12 @@
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 21) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[0] = t0;
       dp[1] = t1;
       dp[2] = t2;
       dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 21) & 0x7F8));
@@ -671,7 +671,7 @@
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 5) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[4] = t0;
       dp[5] = t1;
       dp[6] = t2;
@@ -719,7 +719,7 @@
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
       for (i = 0; i < size - 7; i += 4, dp += 12, sa++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
@@ -733,14 +733,14 @@
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
         t4 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
         t5 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[0] = t0;
         dp[1] = t1;
         dp[2] = t2;
         dp[3] = t3;
         dp[4] = t4;
         dp[5] = t5;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
@@ -754,7 +754,7 @@
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
         t4 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
         t5 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         dp[6] = t0;
         dp[7] = t1;
@@ -764,7 +764,7 @@
         dp[11] = t5;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
@@ -778,14 +778,14 @@
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
       t4 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
       t5 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[0] = t0;
       dp[1] = t1;
       dp[2] = t2;
       dp[3] = t3;
       dp[4] = t4;
       dp[5] = t5;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
@@ -799,7 +799,7 @@
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
       t4 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
       t5 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[6] = t0;
       dp[7] = t1;
       dp[8] = t2;
@@ -852,7 +852,7 @@
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
       for (i = 0; i < size - 7; i += 4, dp += 16, sa++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
@@ -862,12 +862,12 @@
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 21) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 21) & 0x7F8));
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 >> 21) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[0] = t0;
         dp[1] = t1;
         dp[2] = t2;
         dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 5) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 5) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 5) & 0x7F8));
@@ -877,12 +877,12 @@
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 >> 13) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[4] = t0;
         dp[5] = t1;
         dp[6] = t2;
         dp[7] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
@@ -892,12 +892,12 @@
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 5) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 5) & 0x7F8));
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 >> 5) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[8] = t0;
         dp[9] = t1;
         dp[10] = t2;
         dp[11] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 21) & 0x7F8));
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 21) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 21) & 0x7F8));
@@ -907,7 +907,7 @@
         t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
         t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
         t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 << 3) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         dp[12] = t0;
         dp[13] = t1;
@@ -915,7 +915,7 @@
         dp[15] = t3;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 << 3) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
@@ -925,12 +925,12 @@
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 21) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 21) & 0x7F8));
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 >> 21) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[0] = t0;
       dp[1] = t1;
       dp[2] = t2;
       dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 5) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 5) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 5) & 0x7F8));
@@ -940,12 +940,12 @@
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 >> 13) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[4] = t0;
       dp[5] = t1;
       dp[6] = t2;
       dp[7] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 13) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 13) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 13) & 0x7F8));
@@ -955,12 +955,12 @@
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 5) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 5) & 0x7F8));
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 >> 5) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[8] = t0;
       dp[9] = t1;
       dp[10] = t2;
       dp[11] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_d64 *) ((mlib_u8 *) tab0 + ((s0 >> 21) & 0x7F8));
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 >> 21) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 >> 21) & 0x7F8));
@@ -970,7 +970,7 @@
       t1 = *(mlib_d64 *) ((mlib_u8 *) tab1 + ((s0 << 3) & 0x7F8));
       t2 = *(mlib_d64 *) ((mlib_u8 *) tab2 + ((s0 << 3) & 0x7F8));
       t3 = *(mlib_d64 *) ((mlib_u8 *) tab3 + ((s0 << 3) & 0x7F8));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[12] = t0;
       dp[13] = t1;
       dp[14] = t2;
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageLookUp_Bit.c	2011-05-26 18:54:56.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageLookUp_Bit.c	2011-04-22 23:08:36.000000000 -0700
@@ -88,7 +88,7 @@
 } d64_2_f32;
 
 /***************************************************************/
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 static const mlib_u32 mlib_bit_mask[16] = {
   0x00000000u, 0xFF000000u, 0x00FF0000u, 0xFFFF0000u,
@@ -126,7 +126,7 @@
   0x00000000u, 0x00FFFFFFu, 0xFF000000u, 0xFFFFFFFFu
 };
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 mlib_status mlib_ImageLookUp_Bit_U8_1(const mlib_u8 *src,
@@ -228,13 +228,13 @@
 #endif /* __SUNPRO_C */
     for (; i <= (size - 16); i += 16) {
       s0 = *(mlib_u16*)sa;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       *da++ = dd_array[s0 & 0xFF];
       *da++ = dd_array[s0 >> 8];
 #else
       *da++ = dd_array[s0 >> 8];
       *da++ = dd_array[s0 & 0xFF];
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       sa += 2;
     }
 
@@ -258,20 +258,20 @@
         val1 = p_dd[2*val0+1];
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
 #else
       emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       ((mlib_u32*)da)[0] = (val1 & emask) | (((mlib_u32*)da)[0] &~ emask);
 
 #else /* _NO_LONGLONG */
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       mlib_u64 emask = (mlib_u64)((mlib_s64)(-1)) >> ((8 - (size - i)) * 8);
 #else
       mlib_u64 emask = (mlib_s64)(-1) << ((8 - (size - i)) * 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
       ((mlib_u64*)da)[0] = (((mlib_u64*)dd_array)[sa[0]] & emask) | (((mlib_u64*)da)[0] &~ emask);
 
@@ -323,13 +323,13 @@
 
   val0 = table[0][0];
   val1 = table[0][1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
   val0 = val0 | (table[1][0] << 8);
   val1 = val1 | (table[1][1] << 8);
 #else
   val0 = (val0 << 8) | table[1][0];
   val1 = (val1 << 8) | table[1][1];
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
   val0 |= (val0 << 16);
   val1 |= (val1 << 16);
 
@@ -394,11 +394,11 @@
         dd1 = dd2;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
 #else
       emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       ((mlib_u32*)da)[0] = (dd1 & emask) | (((mlib_u32*)da)[0] &~ emask);
 
 #else /* _NO_LONGLONG */
@@ -412,11 +412,11 @@
         dd = ((mlib_u64*)dd_array)[s0 & 0xf];
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       emask = (mlib_u64)((mlib_s64)(-1)) >> ((8 - (size - i)) * 8);
 #else
       emask = (mlib_s64)(-1) << ((8 - (size - i)) * 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       ((mlib_u64*)da)[0] = (dd & emask) | (((mlib_u64*)da)[0] &~ emask);
 
 #endif /* _NO_LONGLONG */
@@ -462,7 +462,7 @@
 
   buffs = buff + size;
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
   l0 = (table[0][0] << 24) | (table[2][0] << 16) | (table[1][0] << 8) | (table[0][0]);
   h0 = (table[0][1] << 24) | (table[2][1] << 16) | (table[1][1] << 8) | (table[0][1]);
   l1 = (l0 >> 8); l1 |= (l1 << 24);
@@ -476,7 +476,7 @@
   h1 = (h0 << 8); h1 |= (h1 >> 24);
   l2 = (l1 << 8); l2 |= (l2 >> 24);
   h2 = (h1 << 8); h2 |= (h2 >> 24);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
   /* calculate lookup table */
 #ifdef __SUNPRO_C
@@ -564,11 +564,11 @@
         dd = ((mlib_u32*)(d_array12 + (s0 & 0xF)))[1];
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       emask = (mlib_u32)((mlib_s32)(-1)) >> ((4 - (size - i)) * 8);
 #else
       emask = (mlib_s32)(-1) << ((4 - (size - i)) * 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       da[0] = (dd & emask) | (da[0] &~ emask);
     }
 
@@ -611,13 +611,13 @@
 
   buffs = buff + size;
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
   l = (table[3][0] << 24) | (table[2][0] << 16) | (table[1][0] << 8) | (table[0][0]);
   h = (table[3][1] << 24) | (table[2][1] << 16) | (table[1][1] << 8) | (table[0][1]);
 #else
   l = (table[0][0] << 24) | (table[1][0] << 16) | (table[2][0] << 8) | (table[3][0]);
   h = (table[0][1] << 24) | (table[1][1] << 16) | (table[2][1] << 8) | (table[3][1]);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
   ((mlib_u32*)lh)[0] = l;  ((mlib_u32*)lh)[1] = l;
   ((mlib_u32*)lh)[2] = l;  ((mlib_u32*)lh)[3] = h;
--- ./jdk/src/share/native/sun/awt/medialib/mlib_ImageUtils.c	2011-05-26 18:54:57.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_ImageUtils.c	2011-04-22 23:08:36.000000000 -0700
@@ -30,7 +30,7 @@
 typedef union {
   mlib_d64 db;
   struct {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     mlib_s32 int1, int0;
 #else
     mlib_s32 int0, int1;
--- ./jdk/src/share/native/sun/awt/medialib/mlib_c_ImageCopy.c	2011-05-26 18:54:58.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_c_ImageCopy.c	2011-04-22 23:08:36.000000000 -0700
@@ -275,11 +275,11 @@
       for (i = 0; j <= (b_size - 4); j += 4, i++) {
         src0 = src1;
         src1 = pws[i + 1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         pwd[i] = (src0 >> lshift) | (src1 << rshift);
 #else
         pwd[i] = (src0 << lshift) | (src1 >> rshift);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       }
 
       sa += i << 2;
@@ -381,11 +381,11 @@
         for (; j <= (src_width - 4); j += 4) {
           src0 = src1;
           src1 = ps[1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           *((mlib_s32 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
 #else
           *((mlib_s32 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           ps++;
         }
       }
@@ -414,11 +414,11 @@
         for (; j <= (src_width - 8); j += 8) {
           src0 = src1;
           src1 = ps[1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           *((mlib_s64 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
 #else
           *((mlib_s64 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           ps++;
         }
       }
@@ -484,11 +484,11 @@
         for (; j <= (src_width - 2); j += 2) {
           src0 = src1;
           src1 = ps[1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           *((mlib_s32 *) (pdst_row + j)) = (src0 >> 16) | (src1 << 16);
 #else
           *((mlib_s32 *) (pdst_row + j)) = (src0 << 16) | (src1 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           ps++;
         }
       }
@@ -516,11 +516,11 @@
         for (; j <= (src_width - 4); j += 4) {
           src0 = src1;
           src1 = ps[1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           *((mlib_s64 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
 #else
           *((mlib_s64 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           ps++;
         }
       }
@@ -585,11 +585,11 @@
         for (; j <= (src_width - 2); j += 2) {
           src0 = src1;
           src1 = ps[1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           *((mlib_s64 *) (pdst_row + j)) = (src0 >> 32) | (src1 << 32);
 #else
           *((mlib_s64 *) (pdst_row + j)) = (src0 << 32) | (src1 >> 32);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           ps++;
         }
       }
@@ -687,11 +687,11 @@
 #endif /* __SUNPRO_C */
       for (; n > SIZE; n -= SIZE) {
         s1 = *tmp++;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *(TYPE *) dp = (s0 >> shl) | (s1 << shr);
 #else
         *(TYPE *) dp = (s0 << shl) | (s1 >> shr);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = s1;
         dp += SIZE;
         sp += SIZE;
--- ./jdk/src/share/native/sun/awt/medialib/mlib_c_ImageLookUp_f.c	2011-05-26 18:54:58.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_c_ImageLookUp_f.c	2011-04-22 23:08:36.000000000 -0700
@@ -120,7 +120,7 @@
   }                                                               \
 }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 /***************************************************************/
 #define READ_U8_U8_ALIGN(table0, table1, table2, table3)        \
@@ -163,7 +163,7 @@
   t2 = *(mlib_u32*)((mlib_u8*)table2 + ((s0 >> 14)  & 0x3FC));  \
   t3 = *(mlib_u32*)((mlib_u8*)table3 + ((s0 >> 22)  & 0x3FC))
 
-#else /* _LITTLE_ENDIAN */
+#else /* BYTE_ORDER == ... */
 
 /***********/
 #define READ_U8_U8_ALIGN(table0, table1, table2, table3)        \
@@ -206,7 +206,7 @@
   t2 = *(mlib_u32*)((mlib_u8*)table2 + ((s0 >> 6)  & 0x3FC));   \
   t3 = *(mlib_u32*)((mlib_u8*)table3 + ((s0 << 2)  & 0x3FC))
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /***************************************************************/
 void mlib_c_ImageLookUp_U8_U8(const mlib_u8 *src,
@@ -297,11 +297,11 @@
         da[0] = t;
         da++;
         dp = (mlib_u8 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = tab[s2 >> 8];
 #else
         *dp++ = tab[s2 & 0xFF];
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         sp = (mlib_u8 *) sa;
         i += 5;
         for (; i < size; i++, dp++, sp++)
@@ -403,11 +403,11 @@
         da[0] = t;
         da++;
         dp = (mlib_u8 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = tab0[s2 >> 8];
 #else
         *dp++ = tab0[s2 & 0xFF];
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         sp = (mlib_u8 *) sa;
         i += 5;
 
@@ -544,11 +544,11 @@
         da[0] = t;
         da++;
         dp = (mlib_u8 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = tab1[s2 >> 8];
 #else
         *dp++ = tab1[s2 & 0xFF];
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         sp = (mlib_u8 *) sa;
         i += 5;
 
@@ -694,11 +694,11 @@
         da[0] = t;
         da++;
         dp = (mlib_u8 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = tab0[s2 >> 8];
 #else
         *dp++ = tab0[s2 & 0xFF];
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         sp = (mlib_u8 *) sa;
         i += 5;
 
@@ -1852,21 +1852,21 @@
     s0 = tab0[0];
     s1 = tab1[0];
     for (i = 1; i < 256; i++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       s2 = (s1 << 8) + s0;
 #else
       s2 = (s0 << 8) + s1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = tab0[i];
       s1 = tab1[i];
       tab[i - 1] = (mlib_u16) s2;
     }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     s2 = (s1 << 8) + s0;
 #else
     s2 = (s0 << 8) + s1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     tab[255] = (mlib_u16) s2;
 
     for (j = 0; j < ysize; j++, dst += dlb, src += slb) {
@@ -1897,11 +1897,11 @@
         for (i = 0; i < size - 3; i += 2, da++, sa += 2) {
           t0 = tab[s0];
           t1 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           t = (t1 << 16) + t0;
 #else
           t = (t0 << 16) + t1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           s0 = sa[0];
           s1 = sa[1];
           da[0] = t;
@@ -1909,11 +1909,11 @@
 
         t0 = tab[s0];
         t1 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t = (t1 << 16) + t0;
 #else
         t = (t0 << 16) + t1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = t;
         da++;
 
@@ -1927,13 +1927,13 @@
 
         if (off > 1) {
           t0 = tab[sa[0]];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           dp[1] = (t0 >> 8);
           dp[0] = t0;
 #else
           dp[0] = (t0 >> 8);
           dp[1] = t0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           sa++;
           size--;
           dp += 2;
@@ -1941,11 +1941,11 @@
 
         t0 = tab[sa[0]];
         sa++;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = t0;
 #else
         *dp++ = (t0 >> 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
         da = (mlib_s32 *) dp;
 
@@ -1959,11 +1959,11 @@
         for (i = 0; i < size - 4; i += 2, da++, sa += 2) {
           t1 = tab[s0];
           t2 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           t = (t0 >> 8) + (t1 << 8) + (t2 << 24);
 #else
           t = (t0 << 24) + (t1 << 8) + (t2 >> 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           t0 = t2;
           s0 = sa[0];
           s1 = sa[1];
@@ -1972,29 +1972,29 @@
 
         t1 = tab[s0];
         t2 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t = (t0 >> 8) + (t1 << 8) + (t2 << 24);
 #else
         t = (t0 << 24) + (t1 << 8) + (t2 >> 8);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = t;
         da++;
         dp = (mlib_u8 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         dp[0] = (t2 >> 8);
 #else
         dp[0] = t2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
         if ((size & 1) == 0) {
           t0 = tab[sa[0]];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           dp[2] = (t0 >> 8);
           dp[1] = t0;
 #else
           dp[1] = (t0 >> 8);
           dp[2] = t0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         }
       }
     }
@@ -2012,22 +2012,22 @@
     s1 = tab1[0];
     s2 = tab2[0];
     for (i = 1; i < 256; i++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       s3 = (s2 << 24) + (s1 << 16) + (s0 << 8);
 #else
       s3 = (s0 << 16) + (s1 << 8) + s2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = tab0[i];
       s1 = tab1[i];
       s2 = tab2[i];
       tab[i - 1] = s3;
     }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     s3 = (s2 << 24) + (s1 << 16) + (s0 << 8);
 #else
     s3 = (s0 << 16) + (s1 << 8) + s2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     tab[255] = s3;
 
     for (j = 0; j < ysize; j++, dst += dlb, src += slb) {
@@ -2064,24 +2064,24 @@
       for (i = 0; i < size - 7; i += 4, da += 3, sa += 4) {
         t0 = tab[s0];
         t1 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         da[0] = (t0 >> 8) + (t1 << 16);
         res2 = (t1 >> 16);
 #else
         da[0] = (t0 << 8) + (t1 >> 16);
         res2 = (t1 << 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         s1 = sa[1];
         t0 = tab[s0];
         t1 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res2 += (t0 << 8);
         res1 = (t0 >> 24) + t1;
 #else
         res2 += (t0 >> 8);
         res1 = (t0 << 24) + t1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[2];
         s1 = sa[3];
         da[1] = res2;
@@ -2090,24 +2090,24 @@
 
       t0 = tab[s0];
       t1 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       da[0] = (t0 >> 8) + (t1 << 16);
       res2 = (t1 >> 16);
 #else
       da[0] = (t0 << 8) + (t1 >> 16);
       res2 = (t1 << 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = sa[0];
       s1 = sa[1];
       t0 = tab[s0];
       t1 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       res2 += (t0 << 8);
       res1 = (t0 >> 24) + t1;
 #else
       res2 += (t0 >> 8);
       res1 = (t0 << 24) + t1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       da[1] = res2;
       da[2] = res1;
       da += 3;
@@ -2143,11 +2143,11 @@
     s2 = tab2[0];
     s3 = tab3[0];
     for (i = 1; i < 256; i++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       s4 = (s3 << 24) + (s2 << 16) + (s1 << 8) + s0;
 #else
       s4 = (s0 << 24) + (s1 << 16) + (s2 << 8) + s3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = tab0[i];
       s1 = tab1[i];
       s2 = tab2[i];
@@ -2155,11 +2155,11 @@
       tab[i - 1] = s4;
     }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     s4 = (s3 << 24) + (s2 << 16) + (s1 << 8) + s0;
 #else
     s4 = (s0 << 24) + (s1 << 16) + (s2 << 8) + s3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     tab[255] = s4;
 
     for (j = 0; j < ysize; j++, dst += dlb, src += slb) {
@@ -2225,13 +2225,13 @@
         for (i = 0; i < size - 4; i += 2, da += 2, sa += 2) {
           t1 = tab[s0];
           t2 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res1 = (t0 >> shift) + (t1 << shift1);
           res2 = (t1 >> shift) + (t2 << shift1);
 #else
           res1 = (t0 << shift) + (t1 >> shift1);
           res2 = (t1 << shift) + (t2 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           t0 = t2;
           s0 = sa[0];
           s1 = sa[1];
@@ -2241,28 +2241,28 @@
 
         t1 = tab[s0];
         t2 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (t0 >> shift) + (t1 << shift1);
         res2 = (t1 >> shift) + (t2 << shift1);
 #else
         res1 = (t0 << shift) + (t1 >> shift1);
         res2 = (t1 << shift) + (t2 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res1;
         da[1] = res2;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = (da[2] >> shift1);
         da[2] = (t2 >> shift) + (t0 << shift1);
 #else
         t0 = (da[2] << shift1);
         da[2] = (t2 << shift) + (t0 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da += 2;
         dp = (mlib_u8 *) da + (4 - off);
 
         if ((size & 1) == 0) {
           t0 = tab[sa[0]];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           dp[3] = (mlib_u8) (t0 >> 24);
           dp[2] = (mlib_u8) (t0 >> 16);
           dp[1] = (mlib_u8) (t0 >> 8);
@@ -2272,7 +2272,7 @@
           dp[1] = (mlib_u8) (t0 >> 16);
           dp[2] = (mlib_u8) (t0 >> 8);
           dp[3] = (mlib_u8) t0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         }
       }
     }
@@ -2348,13 +2348,13 @@
         t3 = tab0[s1];
         t4 = tab1[s1];
         t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         da[0] = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
         res2 = (t5 << 8) + t4;
 #else
         da[0] = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
         res2 = (t4 << 24) + (t5 << 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         s1 = sa[1];
         t0 = tab0[s0];
@@ -2363,13 +2363,13 @@
         t3 = tab0[s1];
         t4 = tab1[s1];
         t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res2 += ((t1 << 24) + (t0 << 16));
         res1 = (t5 << 24) + (t4 << 16) + (t3 << 8) + t2;
 #else
         res2 += ((t0 << 8) + t1);
         res1 = (t2 << 24) + (t3 << 16) + (t4 << 8) + t5;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[2];
         s1 = sa[3];
         da[1] = res2;
@@ -2382,13 +2382,13 @@
       t3 = tab0[s1];
       t4 = tab1[s1];
       t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       da[0] = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
       res2 = (t5 << 8) + t4;
 #else
       da[0] = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
       res2 = (t4 << 24) + (t5 << 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = sa[0];
       s1 = sa[1];
       t0 = tab0[s0];
@@ -2397,13 +2397,13 @@
       t3 = tab0[s1];
       t4 = tab1[s1];
       t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       res2 += ((t1 << 24) + (t0 << 16));
       res1 = (t5 << 24) + (t4 << 16) + (t3 << 8) + t2;
 #else
       res2 += ((t0 << 8) + t1);
       res1 = (t2 << 24) + (t3 << 16) + (t4 << 8) + t5;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       da[1] = res2;
       da[2] = res1;
       da += 3;
@@ -2455,11 +2455,11 @@
           t1 = tab1[s0];
           t2 = tab2[s0];
           t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
 #else
           res = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           s0 = sa[0];
           da[0] = res;
         }
@@ -2468,11 +2468,11 @@
         t1 = tab1[s0];
         t2 = tab2[s0];
         t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
 #else
         res = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res;
 
       }
@@ -2496,11 +2496,11 @@
         t2 = tab2[s0];
         t3 = tab3[s0];
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
 #else
         res1 = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
         s0 = sa[0];
         sa++;
@@ -2513,13 +2513,13 @@
           t1 = tab1[s0];
           t2 = tab2[s0];
           t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res2 = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
           res = (res1 >> shift) + (res2 << shift1);
 #else
           res2 = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
           res = (res1 << shift) + (res2 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           res1 = res2;
           s0 = sa[0];
           da[0] = res;
@@ -2529,21 +2529,21 @@
         t1 = tab1[s0];
         t2 = tab2[s0];
         t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res2 = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
         res = (res1 >> shift) + (res2 << shift1);
 #else
         res2 = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
         res = (res1 << shift) + (res2 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (da[1] >> shift1);
         da[1] = (res2 >> shift) + (res1 << shift1);
 #else
         res1 = (da[1] << shift1);
         da[1] = (res2 << shift) + (res1 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       }
     }
   }
@@ -2617,13 +2617,13 @@
         t3 = tab0[s1];
         t4 = tab1[s1];
         t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         da[0] = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
         res2 = (t5 << 8) + t4;
 #else
         da[0] = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
         res2 = (t4 << 24) + (t5 << 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         s1 = sa[1];
         t0 = tab0[s0];
@@ -2632,13 +2632,13 @@
         t3 = tab0[s1];
         t4 = tab1[s1];
         t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res2 += ((t1 << 24) + (t0 << 16));
         res1 = (t5 << 24) + (t4 << 16) + (t3 << 8) + t2;
 #else
         res2 += ((t0 << 8) + t1);
         res1 = (t2 << 24) + (t3 << 16) + (t4 << 8) + t5;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[2];
         s1 = sa[3];
         da[1] = res2;
@@ -2651,13 +2651,13 @@
       t3 = tab0[s1];
       t4 = tab1[s1];
       t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       da[0] = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
       res2 = (t5 << 8) + t4;
 #else
       da[0] = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
       res2 = (t4 << 24) + (t5 << 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = sa[0];
       s1 = sa[1];
       t0 = tab0[s0];
@@ -2666,13 +2666,13 @@
       t3 = tab0[s1];
       t4 = tab1[s1];
       t5 = tab2[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       res2 += ((t1 << 24) + (t0 << 16));
       res1 = (t5 << 24) + (t4 << 16) + (t3 << 8) + t2;
 #else
       res2 += ((t0 << 8) + t1);
       res1 = (t2 << 24) + (t3 << 16) + (t4 << 8) + t5;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       da[1] = res2;
       da[2] = res1;
       da += 3;
@@ -2724,11 +2724,11 @@
           t1 = tab1[s0];
           t2 = tab2[s0];
           t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
 #else
           res = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           s0 = sa[0];
           da[0] = res;
         }
@@ -2737,11 +2737,11 @@
         t1 = tab1[s0];
         t2 = tab2[s0];
         t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
 #else
         res = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res;
 
       }
@@ -2765,11 +2765,11 @@
         t2 = tab2[s0];
         t3 = tab3[s0];
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
 #else
         res1 = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
         s0 = sa[0];
         sa++;
@@ -2782,13 +2782,13 @@
           t1 = tab1[s0];
           t2 = tab2[s0];
           t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res2 = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
           res = (res1 >> shift) + (res2 << shift1);
 #else
           res2 = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
           res = (res1 << shift) + (res2 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           res1 = res2;
           s0 = sa[0];
           da[0] = res;
@@ -2798,21 +2798,21 @@
         t1 = tab1[s0];
         t2 = tab2[s0];
         t3 = tab3[s0];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res2 = (t3 << 24) + (t2 << 16) + (t1 << 8) + t0;
         res = (res1 >> shift) + (res2 << shift1);
 #else
         res2 = (t0 << 24) + (t1 << 16) + (t2 << 8) + t3;
         res = (res1 << shift) + (res2 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (da[1] >> shift1);
         da[1] = (res2 >> shift) + (res1 << shift1);
 #else
         res1 = (da[1] << shift1);
         da[1] = (res2 << shift) + (res1 >> shift1);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       }
     }
   }
@@ -2863,21 +2863,21 @@
     s0 = tab0[0];
     s1 = tab1[0];
     for (i = 1; i < 256; i++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       s2 = (s1 << 16) + s0;
 #else
       s2 = (s0 << 16) + s1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = tab0[i];
       s1 = tab1[i];
       tab[i - 1] = s2;
     }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     s2 = (s1 << 16) + s0;
 #else
     s2 = (s0 << 16) + s1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     tab[255] = s2;
 
     for (j = 0; j < ysize; j++, dst += dlb, src += slb) {
@@ -2919,11 +2919,11 @@
       else {
 
         t0 = tab[*sa++];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = (mlib_u16) (t0);
 #else
         *dp++ = (mlib_u16) (t0 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da = (mlib_u32 *) dp;
         s0 = sa[0];
         s1 = sa[1];
@@ -2935,13 +2935,13 @@
         for (i = 0; i < size - 4; i += 2, da += 2, sa += 2) {
           t1 = tab[s0];
           t2 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res1 = (t0 >> 16) + (t1 << 16);
           res2 = (t1 >> 16) + (t2 << 16);
 #else
           res1 = (t0 << 16) + (t1 >> 16);
           res2 = (t1 << 16) + (t2 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           t0 = t2;
           s0 = sa[0];
           s1 = sa[1];
@@ -2951,32 +2951,32 @@
 
         t1 = tab[s0];
         t2 = tab[s1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (t0 >> 16) + (t1 << 16);
         res2 = (t1 >> 16) + (t2 << 16);
 #else
         res1 = (t0 << 16) + (t1 >> 16);
         res2 = (t1 << 16) + (t2 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res1;
         da[1] = res2;
         da += 2;
         dp = (mlib_u16 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         dp[0] = (mlib_u16) (t2 >> 16);
 #else
         dp[0] = (mlib_u16) t2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
         if ((size & 1) == 0) {
           t0 = tab[sa[0]];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           dp[2] = (mlib_u16) (t0 >> 16);
           dp[1] = (mlib_u16) t0;
 #else
           dp[1] = (mlib_u16) (t0 >> 16);
           dp[2] = (mlib_u16) t0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         }
       }
     }
@@ -2994,13 +2994,13 @@
     s1 = tab1[0];
     s2 = tab2[0];
     for (i = 1; i < 256; i++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       s3 = (s0 << 16);
       s4 = (s2 << 16) + s1;
 #else
       s3 = s0;
       s4 = (s1 << 16) + s2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = tab0[i];
       s1 = tab1[i];
       s2 = tab2[i];
@@ -3008,13 +3008,13 @@
       tab[2 * i - 1] = s4;
     }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     s4 = (s2 << 16) + s1;
     tab[510] = s0 << 16;
 #else
     s4 = (s1 << 16) + s2;
     tab[510] = s0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     tab[511] = s4;
 
     for (j = 0; j < ysize; j++, dst += dlb, src += slb) {
@@ -3050,13 +3050,13 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab + s0 + 4);
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab + s1);
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab + s1 + 4);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (t0 >> 16) + (t1 << 16);
         res2 = (t1 >> 16) + t2;
 #else
         res1 = (t0 << 16) + (t1 >> 16);
         res2 = (t1 << 16) + t2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0] << 3;
         s1 = sa[1] << 3;
         da[0] = res1;
@@ -3068,13 +3068,13 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab + s0 + 4);
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab + s1);
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab + s1 + 4);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       res1 = (t0 >> 16) + (t1 << 16);
       res2 = (t1 >> 16) + t2;
 #else
       res1 = (t0 << 16) + (t1 >> 16);
       res2 = (t1 << 16) + t2;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       da[0] = res1;
       da[1] = res2;
       da[2] = t3;
@@ -3105,13 +3105,13 @@
     s2 = tab2[0];
     s3 = tab3[0];
     for (i = 1; i < 256; i++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       s4 = (s1 << 16) + s0;
       s5 = (s3 << 16) + s2;
 #else
       s4 = (s0 << 16) + s1;
       s5 = (s2 << 16) + s3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       s0 = tab0[i];
       s1 = tab1[i];
       s2 = tab2[i];
@@ -3120,13 +3120,13 @@
       tab[2 * i - 1] = s5;
     }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
     s4 = (s1 << 16) + s0;
     s5 = (s3 << 16) + s2;
 #else
     s4 = (s0 << 16) + s1;
     s5 = (s2 << 16) + s3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
     tab[510] = s4;
     tab[511] = s5;
 
@@ -3181,18 +3181,18 @@
 
         t4 = tab[2 * sa[0]];
         t5 = tab[2 * sa[0] + 1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *dp++ = (mlib_u16) (t4);
 #else
         *dp++ = (mlib_u16) (t4 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         sa++;
         da = (mlib_u32 *) dp;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         *da++ = (t4 >> 16) + (t5 << 16);
 #else
         *da++ = (t4 << 16) + (t5 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0] << 3;
         s1 = sa[1] << 3;
         sa += 2;
@@ -3205,7 +3205,7 @@
           t1 = *(mlib_u32 *) ((mlib_u8 *) tab + s0 + 4);
           t2 = *(mlib_u32 *) ((mlib_u8 *) tab + s1);
           t3 = *(mlib_u32 *) ((mlib_u8 *) tab + s1 + 4);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           res1 = (t5 >> 16) + (t0 << 16);
           res2 = (t0 >> 16) + (t1 << 16);
           res3 = (t1 >> 16) + (t2 << 16);
@@ -3215,7 +3215,7 @@
           res2 = (t0 << 16) + (t1 >> 16);
           res3 = (t1 << 16) + (t2 >> 16);
           res4 = (t2 << 16) + (t3 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           s0 = sa[0] << 3;
           s1 = sa[1] << 3;
           da[0] = res1;
@@ -3229,7 +3229,7 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab + s0 + 4);
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab + s1);
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab + s1 + 4);
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         res1 = (t5 >> 16) + (t0 << 16);
         res2 = (t0 >> 16) + (t1 << 16);
         res3 = (t1 >> 16) + (t2 << 16);
@@ -3239,36 +3239,36 @@
         res2 = (t0 << 16) + (t1 >> 16);
         res3 = (t1 << 16) + (t2 >> 16);
         res4 = (t2 << 16) + (t3 >> 16);
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         da[0] = res1;
         da[1] = res2;
         da[2] = res3;
         da[3] = res4;
         da += 4;
         dp = (mlib_u16 *) da;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         dp[0] = (mlib_u16) (t3 >> 16);
 #else
         dp[0] = (mlib_u16) t3;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
         if ((size & 1) == 0) {
           t0 = tab[2 * sa[0]];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           dp[2] = (mlib_u16) (t0 >> 16);
           dp[1] = (mlib_u16) t0;
 #else
           dp[1] = (mlib_u16) (t0 >> 16);
           dp[2] = (mlib_u16) t0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
           t0 = tab[2 * sa[0] + 1];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
           dp[4] = (mlib_u16) (t0 >> 16);
           dp[3] = (mlib_u16) t0;
 #else
           dp[3] = (mlib_u16) (t0 >> 16);
           dp[4] = (mlib_u16) t0;
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         }
       }
     }
@@ -3439,7 +3439,7 @@
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
       for (i = 0; i < size - 7; i += 4, dp += 8, sa++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 6) & 0x3FC));
@@ -3449,12 +3449,12 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 22) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[0] = t0;
         dp[1] = t1;
         dp[2] = t2;
         dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 22) & 0x3FC));
@@ -3464,7 +3464,7 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 6) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         dp[4] = t0;
         dp[5] = t1;
@@ -3472,7 +3472,7 @@
         dp[7] = t3;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 6) & 0x3FC));
@@ -3482,12 +3482,12 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 22) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[0] = t0;
       dp[1] = t1;
       dp[2] = t2;
       dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 22) & 0x3FC));
@@ -3497,7 +3497,7 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 6) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[4] = t0;
       dp[5] = t1;
       dp[6] = t2;
@@ -3545,7 +3545,7 @@
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
       for (i = 0; i < size - 7; i += 4, dp += 12, sa++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
@@ -3559,14 +3559,14 @@
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
         t4 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
         t5 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[0] = t0;
         dp[1] = t1;
         dp[2] = t2;
         dp[3] = t3;
         dp[4] = t4;
         dp[5] = t5;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
@@ -3580,7 +3580,7 @@
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
         t4 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
         t5 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         dp[6] = t0;
         dp[7] = t1;
@@ -3590,7 +3590,7 @@
         dp[11] = t5;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
@@ -3604,14 +3604,14 @@
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
       t4 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
       t5 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[0] = t0;
       dp[1] = t1;
       dp[2] = t2;
       dp[3] = t3;
       dp[4] = t4;
       dp[5] = t5;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
@@ -3625,7 +3625,7 @@
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
       t4 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
       t5 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[6] = t0;
       dp[7] = t1;
       dp[8] = t2;
@@ -3678,7 +3678,7 @@
 #pragma pipeloop(0)
 #endif /* __SUNPRO_C */
       for (i = 0; i < size - 7; i += 4, dp += 16, sa++) {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
@@ -3688,12 +3688,12 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 22) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 22) & 0x3FC));
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 >> 22) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[0] = t0;
         dp[1] = t1;
         dp[2] = t2;
         dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 6) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 6) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 6) & 0x3FC));
@@ -3703,12 +3703,12 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 >> 14) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[4] = t0;
         dp[5] = t1;
         dp[6] = t2;
         dp[7] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
@@ -3718,12 +3718,12 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 6) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 6) & 0x3FC));
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 >> 6) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         dp[8] = t0;
         dp[9] = t1;
         dp[10] = t2;
         dp[11] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 22) & 0x3FC));
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 22) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 22) & 0x3FC));
@@ -3733,7 +3733,7 @@
         t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
         t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
         t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 << 2) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
         s0 = sa[0];
         dp[12] = t0;
         dp[13] = t1;
@@ -3741,7 +3741,7 @@
         dp[15] = t3;
       }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 << 2) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
@@ -3751,12 +3751,12 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 22) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 22) & 0x3FC));
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 >> 22) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[0] = t0;
       dp[1] = t1;
       dp[2] = t2;
       dp[3] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 6) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 6) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 6) & 0x3FC));
@@ -3766,12 +3766,12 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 >> 14) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[4] = t0;
       dp[5] = t1;
       dp[6] = t2;
       dp[7] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 14) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 14) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 14) & 0x3FC));
@@ -3781,12 +3781,12 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 6) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 6) & 0x3FC));
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 >> 6) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[8] = t0;
       dp[9] = t1;
       dp[10] = t2;
       dp[11] = t3;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
       t0 = *(mlib_u32 *) ((mlib_u8 *) tab0 + ((s0 >> 22) & 0x3FC));
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 >> 22) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 >> 22) & 0x3FC));
@@ -3796,7 +3796,7 @@
       t1 = *(mlib_u32 *) ((mlib_u8 *) tab1 + ((s0 << 2) & 0x3FC));
       t2 = *(mlib_u32 *) ((mlib_u8 *) tab2 + ((s0 << 2) & 0x3FC));
       t3 = *(mlib_u32 *) ((mlib_u8 *) tab3 + ((s0 << 2) & 0x3FC));
-#endif /* _LITTLE_ENDIAN */
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
       dp[12] = t0;
       dp[13] = t1;
       dp[14] = t2;
--- ./jdk/src/share/native/sun/awt/medialib/mlib_image.h	2011-05-26 18:54:59.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_image.h	2011-04-22 23:08:36.000000000 -0700
@@ -27,6 +27,16 @@
 #ifndef MLIB_IMAGE_H
 #define MLIB_IMAGE_H
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#endif
+#ifdef _ALLBSD_SOURCE
+#include <machine/endian.h>
+#elif __linux__
+#define __USE_BSD 1
+#include <endian.h>
+#endif
+
 #include <mlib_types.h>
 #include <mlib_status.h>
 #include <mlib_sys.h>
--- ./jdk/src/share/native/sun/awt/medialib/mlib_sys.c	2011-05-26 18:54:59.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_sys.c	2011-04-22 23:08:36.000000000 -0700
@@ -26,9 +26,15 @@
 
 #include <stdlib.h>
 #include <string.h>
+#ifdef _ALLBSD_SOURCE
+#include <unistd.h>
+#endif
 #include <mlib_types.h>
 #include <mlib_sys_proto.h>
 #include "mlib_SysMath.h"
+#if defined(_ALLBSD_SOURCE)
+#include <sys/param.h>
+#endif
 
 /***************************************************************/
 
@@ -86,7 +92,12 @@
    * alignment. -- from stdlib.h of MS VC++5.0.
    */
   return (void *) malloc(size);
-#else /* _MSC_VER */
+#elif defined(__FreeBSD__) && (__FreeBSD_version >= 700013)
+  void *ret;
+  return posix_memalign(&ret, 8, size) ? NULL : ret;
+#elif defined(_ALLBSD_SOURCE)
+  return valloc(size);
+#else
   return (void *) memalign(8, size);
 #endif /* _MSC_VER */
 }
--- ./jdk/src/share/native/sun/awt/medialib/mlib_types.h	2011-05-26 18:55:00.000000000 -0700
+++ ./jdk/src/share/native/sun/awt/medialib/mlib_types.h	2011-04-22 23:08:36.000000000 -0700
@@ -59,7 +59,10 @@
 
 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__GNUC__)
 
-#if defined(__linux__)
+#if defined(_ALLBSD_SOURCE)
+#include <stddef.h>                     /* for ptrdiff_t */
+#include <stdint.h>                     /* for uintptr_t */
+#elif defined(__linux__)
 #include <stdint.h>                     /* for uintptr_t */
 #include <malloc.h>                     /* for ptrdiff_t */
 #else
--- ./jdk/src/share/native/sun/font/AccelGlyphCache.c	2011-05-26 18:55:01.000000000 -0700
+++ ./jdk/src/share/native/sun/font/AccelGlyphCache.c	2011-04-22 23:08:36.000000000 -0700
@@ -23,7 +23,11 @@
  * questions.
  */
 
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 #include "jni.h"
 #include "AccelGlyphCache.h"
 #include "Trace.h"
--- ./jdk/src/share/native/sun/font/DrawGlyphList.c	2011-05-26 18:55:01.000000000 -0700
+++ ./jdk/src/share/native/sun/font/DrawGlyphList.c	2011-04-22 23:08:36.000000000 -0700
@@ -26,7 +26,11 @@
 #include "jlong.h"
 #include "math.h"
 #include "string.h"
+#ifdef _ALLBSD_SOURCE
+#include "stdlib.h"
+#else
 #include "malloc.h"
+#endif
 #include "sunfontids.h"
 #include "fontscalerdefs.h"
 #include "glyphblitting.h"
--- ./jdk/src/share/native/sun/font/sunFont.c	2011-05-26 18:55:15.000000000 -0700
+++ ./jdk/src/share/native/sun/font/sunFont.c	2011-04-22 23:08:36.000000000 -0700
@@ -24,7 +24,9 @@
  */
 
 #include "stdlib.h"
+#ifndef _ALLBSD_SOURCE
 #include "malloc.h"
+#endif
 #include "string.h"
 #include "gdefs.h"
 #include "jlong.h"
--- ./jdk/src/share/native/sun/java2d/SurfaceData.c	2011-05-26 18:55:16.000000000 -0700
+++ ./jdk/src/share/native/sun/java2d/SurfaceData.c	2011-04-22 23:08:36.000000000 -0700
@@ -28,7 +28,11 @@
 #include "jni_util.h"
 #include "Disposer.h"
 
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include "malloc.h"
+#endif
 #include "string.h"
 
 /**
--- ./jdk/src/share/native/sun/java2d/opengl/OGLFuncs.h	2011-05-26 18:55:27.000000000 -0700
+++ ./jdk/src/share/native/sun/java2d/opengl/OGLFuncs.h	2011-04-22 23:08:36.000000000 -0700
@@ -26,6 +26,9 @@
 #ifndef OGLFuncs_h_Included
 #define OGLFuncs_h_Included
 
+#ifdef _ALLBSD_SOURCE
+#include <dlfcn.h>
+#endif
 #include "jni.h"
 #include "J2D_GL/gl.h"
 #include "J2D_GL/glext.h"
--- ./jdk/src/share/native/sun/java2d/opengl/OGLRenderQueue.c	2011-05-26 18:55:28.000000000 -0700
+++ ./jdk/src/share/native/sun/java2d/opengl/OGLRenderQueue.c	2011-04-22 23:08:36.000000000 -0700
@@ -25,7 +25,11 @@
 
 #ifndef HEADLESS
 
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 
 #include "sun_java2d_pipe_BufferedOpCodes.h"
 
--- ./jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c	2011-05-26 18:55:28.000000000 -0700
+++ ./jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c	2011-04-22 23:08:36.000000000 -0700
@@ -25,7 +25,11 @@
 
 #ifndef HEADLESS
 
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 #include <math.h>
 #include <jlong.h>
 
--- ./jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c	2011-05-26 18:55:31.000000000 -0700
+++ ./jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c	2011-05-20 20:04:18.000000000 -0700
@@ -28,6 +28,7 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #else
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
--- ./jdk/src/share/native/sun/security/ec/impl/ecc_impl.h	2011-05-26 18:55:33.000000000 -0700
+++ ./jdk/src/share/native/sun/security/ec/impl/ecc_impl.h	2011-04-22 23:08:36.000000000 -0700
@@ -76,6 +76,14 @@
 typedef enum { B_FALSE, B_TRUE } boolean_t;
 #endif /* __linux__ */
 
+#ifdef _ALLBSD_SOURCE
+#include <stdint.h>
+#define B_FALSE FALSE
+#define B_TRUE TRUE
+typedef unsigned long ulong_t;
+typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
+#endif /* _ALLBSD_SOURCE */
+
 #ifdef _WIN32
 typedef unsigned char uint8_t;
 typedef unsigned long ulong_t;
--- ./jdk/src/share/native/sun/security/ec/impl/ecdecode.c	2011-05-26 18:55:33.000000000 -0700
+++ ./jdk/src/share/native/sun/security/ec/impl/ecdecode.c	2011-04-22 23:08:36.000000000 -0700
@@ -58,9 +58,9 @@
 #include <sys/types.h>
 
 #ifndef _WIN32
-#ifndef __linux__
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
 #include <sys/systm.h>
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 #include <sys/param.h>
 #endif /* _WIN32 */
 
--- ./jdk/src/share/native/sun/security/ec/impl/oid.c	2011-05-26 18:55:35.000000000 -0700
+++ ./jdk/src/share/native/sun/security/ec/impl/oid.c	2011-04-22 23:08:36.000000000 -0700
@@ -57,9 +57,9 @@
 #include <sys/types.h>
 
 #ifndef _WIN32
-#ifndef __linux__
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
 #include <sys/systm.h>
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 #include <sys/param.h>
 #endif /* _WIN32 */
 
--- ./jdk/src/share/native/sun/security/ec/impl/secitem.c	2011-05-26 18:55:35.000000000 -0700
+++ ./jdk/src/share/native/sun/security/ec/impl/secitem.c	2011-04-22 23:08:36.000000000 -0700
@@ -62,9 +62,9 @@
 #include <sys/types.h>
 
 #ifndef _WIN32
-#ifndef __linux__
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
 #include <sys/systm.h>
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 #include <sys/param.h>
 #endif /* _WIN32 */
 
--- ./jdk/src/share/transport/socket/socketTransport.c	2011-05-26 18:55:52.000000000 -0700
+++ ./jdk/src/share/transport/socket/socketTransport.c	2011-04-22 23:08:37.000000000 -0700
@@ -65,6 +65,9 @@
 #define HEADER_SIZE     11
 #define MAX_DATA_SIZE 1000
 
+static jint recv_fully(int, char *, int);
+static jint send_fully(int, char *, int);
+
 /*
  * Record the last error for this thread.
  */
@@ -155,7 +158,7 @@
         }
         buf = b;
         buf += received;
-        n = dbgsysRecv(fd, buf, helloLen-received, 0);
+        n = recv_fully(fd, buf, helloLen-received);
         if (n == 0) {
             setLastError(0, "handshake failed - connection prematurally closed");
             return JDWPTRANSPORT_ERROR_IO_ERROR;
@@ -180,7 +183,7 @@
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
 
-    if (dbgsysSend(fd, (char*)hello, helloLen, 0) != helloLen) {
+    if (send_fully(fd, (char*)hello, helloLen) != helloLen) {
         RETURN_IO_ERROR("send failed during handshake");
     }
     return JDWPTRANSPORT_ERROR_NONE;
@@ -555,19 +558,19 @@
     /* Do one send for short packets, two for longer ones */
     if (data_len <= MAX_DATA_SIZE) {
         memcpy(header + HEADER_SIZE, data, data_len);
-        if (dbgsysSend(socketFD, (char *)&header, HEADER_SIZE + data_len, 0) !=
+        if (send_fully(socketFD, (char *)&header, HEADER_SIZE + data_len) != 
             HEADER_SIZE + data_len) {
             RETURN_IO_ERROR("send failed");
         }
     } else {
         memcpy(header + HEADER_SIZE, data, MAX_DATA_SIZE);
-        if (dbgsysSend(socketFD, (char *)&header, HEADER_SIZE + MAX_DATA_SIZE, 0) !=
+        if (send_fully(socketFD, (char *)&header, HEADER_SIZE + MAX_DATA_SIZE) != 
             HEADER_SIZE + MAX_DATA_SIZE) {
             RETURN_IO_ERROR("send failed");
         }
         /* Send the remaining data bytes right out of the data area. */
-        if (dbgsysSend(socketFD, (char *)data + MAX_DATA_SIZE,
-                       data_len - MAX_DATA_SIZE, 0) != data_len - MAX_DATA_SIZE) {
+        if (send_fully(socketFD, (char *)data + MAX_DATA_SIZE, 
+                       data_len - MAX_DATA_SIZE) != data_len - MAX_DATA_SIZE) {
             RETURN_IO_ERROR("send failed");
         }
     }
@@ -575,13 +578,33 @@
     return JDWPTRANSPORT_ERROR_NONE;
 }
 
-static jint
+jint
 recv_fully(int f, char *buf, int len)
 {
     int nbytes = 0;
     while (nbytes < len) {
         int res = dbgsysRecv(f, buf + nbytes, len - nbytes, 0);
         if (res < 0) {
+	    if (errno == EINTR)
+		continue;
+            return res;
+        } else if (res == 0) {
+            break; /* eof, return nbytes which is less than len */
+        }
+        nbytes += res;
+    }
+    return nbytes;
+}
+
+jint
+send_fully(int f, char *buf, int len)
+{
+    int nbytes = 0;
+    while (nbytes < len) {
+        int res = dbgsysSend(f, buf + nbytes, len - nbytes, 0);
+        if (res < 0) {
+	    if (errno == EINTR)
+		continue;
             return res;
         } else if (res == 0) {
             break; /* eof, return nbytes which is less than len */
--- ./jdk/src/solaris/back/exec_md.c	2011-05-26 18:55:52.000000000 -0700
+++ ./jdk/src/solaris/back/exec_md.c	2011-04-22 23:08:37.000000000 -0700
@@ -30,7 +30,7 @@
 #include "sys.h"
 #include "util.h"
 
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
   /* Linux */
   #define FORK() fork()
 #else
--- ./jdk/src/solaris/back/linker_md.c	2011-05-26 18:55:52.000000000 -0700
+++ ./jdk/src/solaris/back/linker_md.c	2011-04-22 23:08:37.000000000 -0700
@@ -48,6 +48,12 @@
 #include "threads_md.h"
 #endif
 
+#ifdef __APPLE__
+#define LIB_SUFFIX "dylib"
+#else
+#define LIB_SUFFIX "so"
+#endif
+
 /*
  * create a string for the JNI native function name by adding the
  * appropriate decorations.
@@ -77,9 +83,9 @@
     }
 
     if (pnamelen == 0) {
-        (void)snprintf(holder, holderlen, "lib%s.so", fname);
+        (void)snprintf(holder, holderlen, "lib%s." LIB_SUFFIX, fname);
     } else {
-        (void)snprintf(holder, holderlen, "%s/lib%s.so", pname, fname);
+        (void)snprintf(holder, holderlen, "%s/lib%s." LIB_SUFFIX, pname, fname);
     }
 }
 
--- ./jdk/src/solaris/back/util_md.h	2011-05-26 18:55:53.000000000 -0700
+++ ./jdk/src/solaris/back/util_md.h	2011-04-22 23:08:37.000000000 -0700
@@ -31,6 +31,11 @@
 
 #include <limits.h>
 #include <sys/types.h>
+#ifdef _ALLBSD_SOURCE
+#include <machine/endian.h>
+#elif __linux__
+#include <endian.h>
+#endif
 
 #ifdef _LP64
 typedef unsigned long UNSIGNED_JLONG;
@@ -46,7 +51,7 @@
 
 /* On little endian machines, convert java big endian numbers. */
 
-#if defined(_LITTLE_ENDIAN)
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 #define HOST_TO_JAVA_CHAR(x) (((x & 0xff) << 8) | ((x >> 8) & (0xff)))
 #define HOST_TO_JAVA_SHORT(x) (((x & 0xff) << 8) | ((x >> 8) & (0xff)))
--- ./jdk/src/solaris/bin/ergo.c	2011-05-26 18:55:53.000000000 -0700
+++ ./jdk/src/solaris/bin/ergo.c	2011-04-22 23:08:37.000000000 -0700
@@ -100,14 +100,39 @@
 /* Compute physical memory by asking the OS */
 uint64_t
 physical_memory(void) {
+  uint64_t result;
+
+# define UINT64_FORMAT "%" PRIu64
+
+#if defined(_ALLBSD_SOURCE)
+#ifdef HW_PHYSMEM64
+  int64_t physmem;
+  int name[2] = { CTL_HW, HW_PHYSMEM64 };
+#else
+  unsigned long physmem;
+  int name[2] = { CTL_HW, HW_PHYSMEM };
+#endif
+  size_t physmem_len = sizeof(physmem);
+
+  if (sysctl(name, 2, &physmem, &physmem_len, NULL, 0) == -1)
+	physmem = 256 * MB;
+
+  result = (uint64_t)physmem;
+
+  JLI_TraceLauncher("physical memory: " UINT64_FORMAT " (%.3fGB)\n",
+           result, result / (double) GB);
+  return result;
+
+#else /* !_ALLBSD_SOURCE */
+
   const uint64_t pages     = (uint64_t) sysconf(_SC_PHYS_PAGES);
   const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE);
-  const uint64_t result    = pages * page_size;
-# define UINT64_FORMAT "%" PRIu64
+  result    = pages * page_size;
 
   JLI_TraceLauncher("pages: " UINT64_FORMAT
           "  page_size: " UINT64_FORMAT
           "  physical memory: " UINT64_FORMAT " (%.3fGB)\n",
            pages, page_size, result, result / (double) GB);
   return result;
+#endif /* _ALLBSD_SOURCE */
 }
--- ./jdk/src/solaris/bin/ergo.h	2011-05-26 18:55:53.000000000 -0700
+++ ./jdk/src/solaris/bin/ergo.h	2011-04-22 23:08:37.000000000 -0700
@@ -33,6 +33,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/types.h>
+#ifdef _ALLBSD_SOURCE
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
 
 #include "java.h"
 
--- ./jdk/src/solaris/bin/ergo_i586.c	2011-05-26 18:55:53.000000000 -0700
+++ ./jdk/src/solaris/bin/ergo_i586.c	2011-04-22 23:08:37.000000000 -0700
@@ -106,7 +106,7 @@
 
 #endif /* __solaris__ */
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 
 /*
  * A utility method for asking the CPU about itself.
@@ -170,7 +170,9 @@
   *edxp = value_of_edx;
 #endif /* _LP64 */
 }
+#endif /* __linux__ || _ALLBSD_SOURCE */
 
+#ifdef __linux__
 /* The definition of a server-class machine for linux-i586 */
 jboolean
 ServerClassMachineImpl(void) {
@@ -199,6 +201,37 @@
 }
 #endif /* __linux__ */
 
+#if defined(_ALLBSD_SOURCE)
+
+/* The definition of a server-class machine for bsd-i586 */
+jboolean
+ServerClassMachineImpl(void) {
+  jboolean            result            = JNI_FALSE;
+  /* How big is a server class machine? */
+  const unsigned long server_processors = 2UL;
+  const uint64_t      server_memory     = 2UL * GB;
+  /*
+   * We seem not to get our full complement of memory.
+   *     We allow some part (1/8?) of the memory to be "missing",
+   *     based on the sizes of DIMMs, and maybe graphics cards.
+   */
+  const uint64_t      missing_memory    = 256UL * MB;
+  const uint64_t      actual_memory     = physical_memory();
+
+  /* Is this a server class machine? */
+  if (actual_memory >= (server_memory - missing_memory)) {
+    const unsigned long actual_processors = physical_processors();
+    if (actual_processors >= server_processors) {
+      result = JNI_TRUE;
+    }
+  }
+  JLI_TraceLauncher("bsd_" LIBARCHNAME "_ServerClassMachine: %s\n",
+           (result == JNI_TRUE ? "true" : "false"));
+  return result;
+}
+
+#endif /* _ALLBSD_SOURCE */
+
 /*
  * Routines shared by solaris-i586 and linux-i586.
  */
@@ -308,6 +341,14 @@
 /* Compute the number of physical processors, not logical processors */
 static unsigned long
 physical_processors(void) {
+#if defined(_ALLBSD_SOURCE)
+  unsigned long result;
+  int name[2] = { CTL_HW, HW_NCPU };
+  size_t rlen = sizeof(result);
+
+  if (sysctl(name, 2, &result, &rlen, NULL, 0) == -1)
+	result = 1;
+#else /* !_ALLBSD_SOURCE */
   const long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
   unsigned long result      = sys_processors;
 
@@ -318,6 +359,7 @@
       result = (unsigned long) sys_processors / logical_processors;
     }
   }
+#endif /* _ALLBSD_SOURCE */
   JLI_TraceLauncher("physical processors: %lu\n", result);
   return result;
 }
--- ./jdk/src/solaris/bin/java_md.c	2011-05-26 18:55:54.000000000 -0700
+++ ./jdk/src/solaris/bin/java_md.c	2011-05-07 21:54:10.000000000 -0700
@@ -24,6 +24,7 @@
  */
 
 #include "java.h"
+#include "jvm_md.h"
 #include <dirent.h>
 #include <dlfcn.h>
 #include <fcntl.h>
@@ -34,17 +35,30 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/types.h>
+#if defined(_ALLBSD_SOURCE)
+#include <sys/time.h>
+#endif
+
 #include "manifest_info.h"
 #include "version_comp.h"
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <pthread.h>
 #else
 #include <thread.h>
 #endif
 
+#ifdef __APPLE__
+#define JVM_DLL "libjvm.dylib"
+#define JAVA_DLL "libjava.dylib"
+/* FALLBACK avoids naming conflicts with system libraries
+ * (eg, ImageIO's libJPEG.dylib) */
+#define LD_LIBRARY_PATH "DYLD_FALLBACK_LIBRARY_PATH"
+#else
 #define JVM_DLL "libjvm.so"
 #define JAVA_DLL "libjava.so"
+#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
+#endif
 
 /* help jettison the LD_LIBRARY_PATH settings in the future */
 #ifndef SETENV_REQUIRED
@@ -75,14 +89,31 @@
 #endif
 
 /* pointer to environment */
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char **environ;
+#endif
 
 /*
  *      A collection of useful strings. One should think of these as #define
  *      entries, but actual strings can be more efficient (with many compilers).
  */
-#ifdef __linux__
-static const char *system_dir   = "/usr/java";
+#if defined(__FreeBSD__)
+static const char *system_dir	= PACKAGE_PATH "/openjdk7";
+static const char *user_dir	= "/java";
+#elif defined(__NetBSD__)
+static const char *system_dir	= PACKAGE_PATH "/openjdk7";
+static const char *user_dir	= "/java";
+#elif defined(__OpenBSD__)
+static const char *system_dir	= PACKAGE_PATH "/openjdk7";
+static const char *user_dir	= "/java";
+#elif defined(__APPLE__)
+static const char *system_dir	= PACKAGE_PATH "/openjdk7";
+static const char *user_dir	= "/java";
+#elif defined(__linux__)
+static const char *system_dir   = PACKAGE_PATH "/java";
 static const char *user_dir     = "/java";
 #else /* Solaris */
 static const char *system_dir   = "/usr/jdk";
@@ -1397,9 +1428,23 @@
     return(borrowed_unsetenv(name));
 }
 
+#if defined(_ALLBSD_SOURCE)
+/*
+ * BSD's implementation of CounterGet()
+ */
+int64_t
+CounterGet()
+{
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return (tv.tv_sec * 1000) + tv.tv_usec;
+}
+#endif
+
+
 /* --- Splash Screen shared library support --- */
 
-static const char* SPLASHSCREEN_SO = "libsplashscreen.so";
+static const char* SPLASHSCREEN_SO = JNI_LIB_NAME("splashscreen");
 
 static void* hSplashLib = NULL;
 
@@ -1435,7 +1480,7 @@
 int
 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
     int rslt;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     pthread_t tid;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
--- ./jdk/src/solaris/bin/java_md.h	2011-05-26 18:55:54.000000000 -0700
+++ ./jdk/src/solaris/bin/java_md.h	2011-04-22 23:08:37.000000000 -0700
@@ -47,10 +47,14 @@
 #include <sys/time.h>
 #define CounterGet()              (gethrtime()/1000)
 #define Counter2Micros(counts)    (counts)
+#elif defined(_ALLBSD_SOURCE)
+/* CounterGet() is implemented in java_md.c */
+int64_t CounterGet(void);
+#define Counter2Micros(counts)    (counts)
 #else
 #define CounterGet()              (0)
 #define Counter2Micros(counts)    (1)
-#endif /* HAVE_GETHRTIME */
+#endif /* HAVE_GETHRTIME || _ALLBSD_SOURCE */
 
 /*
  * Function prototypes.
--- ./jdk/src/solaris/classes/sun/awt/X11/XWM.java	2011-05-26 18:56:06.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/awt/X11/XWM.java	2011-04-22 23:08:38.000000000 -0700
@@ -101,7 +101,8 @@
         ICE_WM = 10,
         METACITY_WM = 11,
         COMPIZ_WM = 12,
-        LG3D_WM = 13;
+        LG3D_WM = 13,
+        CWM_WM = 14;
     public String toString() {
         switch  (WMID) {
           case NO_WM:
@@ -128,6 +129,8 @@
               return "Compiz";
           case LG3D_WM:
               return "LookingGlass";
+          case CWM_WM:
+              return "CWM";
           case UNDETERMINED_WM:
           default:
               return "Undetermined WM";
@@ -555,6 +558,10 @@
         return isNetWMName("LG3D");
     }
 
+    static boolean isCWM() {
+        return isNetWMName("CWM");
+    }
+
     /*
      * Is Metacity running?
      */
@@ -567,7 +574,7 @@
     }
 
     static boolean isNonReparentingWM() {
-        return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
+        return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM || XWM.getWMID() == XWM.CWM_WM);
     }
 
     /*
@@ -743,6 +750,8 @@
                 awt_wmgr = XWM.COMPIZ_WM;
             } else if (isLookingGlass()) {
                 awt_wmgr = LG3D_WM;
+            } else if (isCWM()) {
+                awt_wmgr = CWM_WM;
             } else if (doIsIceWM && isIceWM()) {
                 awt_wmgr = XWM.ICE_WM;
             }
--- ./jdk/src/solaris/classes/sun/awt/X11FontManager.java	2011-05-26 18:56:09.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/awt/X11FontManager.java	2011-04-22 23:08:38.000000000 -0700
@@ -213,7 +213,7 @@
         if (fontID != null) {
             fileName = (String)fontNameMap.get(fontID);
             /* On Linux check for the Lucida Oblique fonts */
-            if (fileName == null && FontUtilities.isLinux && !isOpenJDK()) {
+            if (fileName == null && (FontUtilities.isLinux || FontUtilities.isBSD) && !isOpenJDK()) {
                 if (oblmap == null) {
                     initObliqueLucidaFontMap();
                 }
@@ -712,7 +712,7 @@
         if (fontConfigDirs == null) {
             return;
         }
-        if (FontUtilities.isLinux) {
+        if (FontUtilities.isLinux || FontUtilities.isBSD) {
             fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts");
         }
         fontdirs = (String[])fontConfigDirs.toArray(new String[0]);
@@ -740,7 +740,7 @@
          */
         FontConfiguration mFontConfig = new MFontConfiguration(this);
         if (FontUtilities.isOpenSolaris ||
-            (FontUtilities.isLinux &&
+            ((FontUtilities.isLinux || FontUtilities.isBSD) &&
              (!mFontConfig.foundOsSpecificFile() ||
               !mFontConfig.fontFilesArePresent()) ||
              (FontUtilities.isSolaris && !mFontConfig.fontFilesArePresent()))) {
--- ./jdk/src/solaris/classes/sun/awt/fontconfigs/bsd.fontconfig.Fedora.properties	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/awt/fontconfigs/bsd.fontconfig.Fedora.properties	1969-12-31 16:00:00.000000000 -0800
@@ -1,377 +0,0 @@
-#
-# 
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code 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 General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Version
-
-# Uses Fedora 9 fonts and file paths.
-version=1
-
-# Component Font Mappings
-
-dialog.plain.latin-1=DejaVu Sans
-dialog.plain.japanese-x0208=Sazanami Gothic
-dialog.plain.korean=Baekmuk Gulim
-dialog.plain.chinese-big5=AR PL ShanHeiSun Uni
-dialog.plain.chinese-gb18030=AR PL ShanHeiSun Uni
-dialog.plain.bengali=Lohit Bengali
-dialog.plain.gujarati=Lohit Gujarati
-dialog.plain.hindi=Lohit Hindi
-dialog.plain.malayalam=Lohit Malayalam
-dialog.plain.oriya=Lohit Oriya
-dialog.plain.punjabi=Lohit Punjabi
-dialog.plain.tamil=Lohit Tamil
-dialog.plain.telugu=Lohit Telugu
-dialog.plain.sinhala=LKLUG
-
-dialog.bold.latin-1=DejaVu Sans Bold
-dialog.bold.japanese-x0208=Sazanami Gothic
-dialog.bold.korean=Baekmuk Gulim
-dialog.bold.chinese-big5=AR PL ShanHeiSun Uni
-dialog.bold.chinese-gb18030=AR PL ShanHeiSun Uni
-dialog.bold.bengali=Lohit Bengali
-dialog.bold.gujarati=Lohit Gujarati
-dialog.bold.hindi=Lohit Hindi
-dialog.bold.malayalam=Lohit Malayalam
-dialog.bold.oriya=Lohit Oriya
-dialog.bold.punjabi=Lohit Punjabi
-dialog.bold.tamil=Lohit Tamil
-dialog.bold.telugu=Lohit Telugu
-dialog.bold.sinhala=LKLUG
-
-dialog.italic.latin-1=DejaVu Sans Oblique
-dialog.italic.japanese-x0208=Sazanami Gothic
-dialog.italic.korean=Baekmuk Gulim
-dialog.italic.chinese-big5=AR PL ShanHeiSun Uni
-dialog.italic.chinese-gb18030=AR PL ShanHeiSun Uni
-dialog.italic.bengali=Lohit Bengali
-dialog.italic.gujarati=Lohit Gujarati
-dialog.italic.hindi=Lohit Hindi
-dialog.italic.malayalam=Lohit Malayalam
-dialog.italic.oriya=Lohit Oriya
-dialog.italic.punjabi=Lohit Punjabi
-dialog.italic.tamil=Lohit Tamil
-dialog.italic.telugu=Lohit Telugu
-dialog.italic.sinhala=LKLUG
-
-dialog.bolditalic.latin-1=DejaVu Sans Bold Oblique
-dialog.bolditalic.japanese-x0208=Sazanami Gothic
-dialog.bolditalic.korean=Baekmuk Gulim
-dialog.bolditalic.chinese-big5=AR PL ShanHeiSun Uni
-dialog.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni
-dialog.bolditalic.bengali=Lohit Bengali
-dialog.bolditalic.gujarati=Lohit Gujarati
-dialog.bolditalic.hindi=Lohit Hindi
-dialog.bolditalic.malayalam=Lohit Malayalam
-dialog.bolditalic.oriya=Lohit Oriya
-dialog.bolditalic.punjabi=Lohit Punjabi
-dialog.bolditalic.tamil=Lohit Tamil
-dialog.bolditalic.telugu=Lohit Telugu
-dialog.bolditalic.sinhala=LKLUG
-
-sansserif.plain.latin-1=DejaVu Sans
-sansserif.plain.japanese-x0208=Sazanami Gothic
-sansserif.plain.korean=Baekmuk Gulim
-sansserif.plain.chinese-big5=AR PL ShanHeiSun Uni
-sansserif.plain.chinese-gb18030=AR PL ShanHeiSun Uni
-sansserif.plain.bengali=Lohit Bengali
-sansserif.plain.gujarati=Lohit Gujarati
-sansserif.plain.hindi=Lohit Hindi
-sansserif.plain.malayalam=Lohit Malayalam
-sansserif.plain.oriya=Lohit Oriya
-sansserif.plain.punjabi=Lohit Punjabi
-sansserif.plain.tamil=Lohit Tamil
-sansserif.plain.telugu=Lohit Telugu
-sansserif.plain.sinhala=LKLUG
-
-sansserif.bold.latin-1=DejaVu Sans Bold
-sansserif.bold.japanese-x0208=Sazanami Gothic
-sansserif.bold.korean=Baekmuk Gulim
-sansserif.bold.chinese-big5=AR PL ShanHeiSun Uni
-sansserif.bold.chinese-gb18030=AR PL ShanHeiSun Uni
-sansserif.bold.bengali=Lohit Bengali
-sansserif.bold.gujarati=Lohit Gujarati
-sansserif.bold.hindi=Lohit Hindi
-sansserif.bold.malayalam=Lohit Malayalam
-sansserif.bold.oriya=Lohit Oriya
-sansserif.bold.punjabi=Lohit Punjabi
-sansserif.bold.tamil=Lohit Tamil
-sansserif.bold.telugu=Lohit Telugu
-sansserif.bold.sinhala=LKLUG
-
-sansserif.italic.latin-1=DejaVu Sans Oblique
-sansserif.italic.japanese-x0208=Sazanami Gothic
-sansserif.italic.korean=Baekmuk Gulim
-sansserif.italic.chinese-big5=AR PL ShanHeiSun Uni
-sansserif.italic.chinese-gb18030=AR PL ShanHeiSun Uni
-sansserif.italic.bengali=Lohit Bengali
-sansserif.italic.gujarati=Lohit Gujarati
-sansserif.italic.hindi=Lohit Hindi
-sansserif.italic.malayalam=Lohit Malayalam
-sansserif.italic.oriya=Lohit Oriya
-sansserif.italic.punjabi=Lohit Punjabi
-sansserif.italic.tamil=Lohit Tamil
-sansserif.italic.telugu=Lohit Telugu
-sansserif.italic.sinhala=LKLUG
-
-sansserif.bolditalic.latin-1=DejaVu Sans Bold Oblique
-sansserif.bolditalic.japanese-x0208=Sazanami Gothic
-sansserif.bolditalic.korean=Baekmuk Gulim
-sansserif.bolditalic.chinese-big5=AR PL ShanHeiSun Uni
-sansserif.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni
-sansserif.bolditalic.bengali=Lohit Bengali
-sansserif.bolditalic.gujarati=Lohit Gujarati
-sansserif.bolditalic.hindi=Lohit Hindi
-sansserif.bolditalic.malayalam=Lohit Malayalam
-sansserif.bolditalic.oriya=Lohit Oriya
-sansserif.bolditalic.punjabi=Lohit Punjabi
-sansserif.bolditalic.tamil=Lohit Tamil
-sansserif.bolditalic.telugu=Lohit Telugu
-sansserif.bolditalic.sinhala=LKLUG
-
-serif.plain.latin-1=DejaVu Serif
-serif.plain.japanese-x0208=Sazanami Mincho
-serif.plain.korean=Baekmuk Batang
-serif.plain.chinese-big5=AR PL ZenKai Uni
-serif.plain.chinese-gb18030=AR PL ZenKai Uni
-serif.plain.bengali=Lohit Bengali
-serif.plain.gujarati=Lohit Gujarati
-serif.plain.hindi=Lohit Hindi
-serif.plain.malayalam=Lohit Malayalam
-serif.plain.oriya=Lohit Oriya
-serif.plain.punjabi=Lohit Punjabi
-serif.plain.tamil=Lohit Tamil
-serif.plain.telugu=Lohit Telugu
-serif.plain.sinhala=LKLUG
-
-serif.bold.latin-1=DejaVu Serif Bold
-serif.bold.japanese-x0208=Sazanami Mincho
-serif.bold.korean=Baekmuk Batang
-serif.bold.chinese-big5=AR PL ZenKai Uni
-serif.bold.chinese-gb18030=AR PL ZenKai Uni
-serif.bold.bengali=Lohit Bengali
-serif.bold.gujarati=Lohit Gujarati
-serif.bold.hindi=Lohit Hindi
-serif.bold.malayalam=Lohit Malayalam
-serif.bold.oriya=Lohit Oriya
-serif.bold.punjabi=Lohit Punjabi
-serif.bold.tamil=Lohit Tamil
-serif.bold.telugu=Lohit Telugu
-serif.bold.sinhala=LKLUG
-
-serif.italic.latin-1=DejaVu Serif Oblique
-serif.italic.japanese-x0208=Sazanami Mincho
-serif.italic.korean=Baekmuk Batang
-serif.italic.chinese-big5=AR PL ZenKai Uni
-serif.italic.chinese-gb18030=AR PL ZenKai Uni
-serif.italic.bengali=Lohit Bengali
-serif.italic.gujarati=Lohit Gujarati
-serif.italic.hindi=Lohit Hindi
-serif.italic.malayalam=Lohit Malayalam
-serif.italic.oriya=Lohit Oriya
-serif.italic.punjabi=Lohit Punjabi
-serif.italic.tamil=Lohit Tamil
-serif.italic.telugu=Lohit Telugu
-serif.italic.sinhala=LKLUG
-
-serif.bolditalic.latin-1=DejaVu Serif Bold Oblique
-serif.bolditalic.japanese-x0208=Sazanami Mincho
-serif.bolditalic.korean=Baekmuk Batang
-serif.bolditalic.chinese-big5=AR PL ZenKai Uni
-serif.bolditalic.chinese-gb18030=AR PL ZenKai Uni
-serif.bolditalic.bengali=Lohit Bengali
-serif.bolditalic.gujarati=Lohit Gujarati
-serif.bolditalic.hindi=Lohit Hindi
-serif.bolditalic.malayalam=Lohit Malayalam
-serif.bolditalic.oriya=Lohit Oriya
-serif.bolditalic.punjabi=Lohit Punjabi
-serif.bolditalic.tamil=Lohit Tamil
-serif.bolditalic.telugu=Lohit Telugu
-serif.bolditalic.sinhala=LKLUG
-
-monospaced.plain.latin-1=DejaVu Sans Mono
-monospaced.plain.japanese-x0208=Sazanami Gothic
-monospaced.plain.korean=Baekmuk Gulim
-monospaced.plain.chinese-big5=AR PL ShanHeiSun Uni
-monospaced.plain.chinese-gb18030=AR PL ShanHeiSun Uni
-monospaced.plain.bengali=Lohit Bengali
-monospaced.plain.gujarati=Lohit Gujarati
-monospaced.plain.hindi=Lohit Hindi
-monospaced.plain.malayalam=Lohit Malayalam
-monospaced.plain.oriya=Lohit Oriya
-monospaced.plain.punjabi=Lohit Punjabi
-monospaced.plain.tamil=Lohit Tamil
-monospaced.plain.telugu=Lohit Telugu
-monospaced.plain.sinhala=LKLUG
-
-monospaced.bold.latin-1=DejaVu Sans Mono Bold
-monospaced.bold.japanese-x0208=Sazanami Gothic
-monospaced.bold.korean=Baekmuk Gulim
-monospaced.bold.chinese-big5=AR PL ShanHeiSun Uni
-monospaced.bold.chinese-gb18030=AR PL ShanHeiSun Uni
-monospaced.bold.bengali=Lohit Bengali
-monospaced.bold.gujarati=Lohit Gujarati
-monospaced.bold.hindi=Lohit Hindi
-monospaced.bold.malayalam=Lohit Malayalam
-monospaced.bold.oriya=Lohit Oriya
-monospaced.bold.punjabi=Lohit Punjabi
-monospaced.bold.tamil=Lohit Tamil
-monospaced.bold.telugu=Lohit Telugu
-monospaced.bold.sinhala=LKLUG
-
-monospaced.italic.latin-1=DejaVu Sans Mono Oblique
-monospaced.italic.japanese-x0208=Sazanami Gothic
-monospaced.italic.korean=Baekmuk Gulim
-monospaced.italic.chinese-big5=AR PL ShanHeiSun Uni
-monospaced.italic.chinese-gb18030=AR PL ShanHeiSun Uni
-monospaced.italic.bengali=Lohit Bengali
-monospaced.italic.gujarati=Lohit Gujarati
-monospaced.italic.hindi=Lohit Hindi
-monospaced.italic.malayalam=Lohit Malayalam
-monospaced.italic.oriya=Lohit Oriya
-monospaced.italic.punjabi=Lohit Punjabi
-monospaced.italic.tamil=Lohit Tamil
-monospaced.italic.telugu=Lohit Telugu
-monospaced.italic.sinhala=LKLUG
-
-monospaced.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique
-monospaced.bolditalic.japanese-x0208=Sazanami Gothic
-monospaced.bolditalic.korean=Baekmuk Gulim
-monospaced.bolditalic.chinese-big5=AR PL ShanHeiSun Uni
-monospaced.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni
-monospaced.bolditalic.bengali=Lohit Bengali
-monospaced.bolditalic.gujarati=Lohit Gujarati
-monospaced.bolditalic.hindi=Lohit Hindi
-monospaced.bolditalic.malayalam=Lohit Malayalam
-monospaced.bolditalic.oriya=Lohit Oriya
-monospaced.bolditalic.punjabi=Lohit Punjabi
-monospaced.bolditalic.tamil=Lohit Tamil
-monospaced.bolditalic.telugu=Lohit Telugu
-monospaced.bolditalic.sinhala=LKLUG
-
-dialoginput.plain.latin-1=DejaVu Sans Mono
-dialoginput.plain.japanese-x0208=Sazanami Gothic
-dialoginput.plain.korean=Baekmuk Gulim
-dialoginput.plain.chinese-big5=AR PL ShanHeiSun Uni
-dialoginput.plain.chinese-gb18030=AR PL ShanHeiSun Uni
-dialoginput.plain.bengali=Lohit Bengali
-dialoginput.plain.gujarati=Lohit Gujarati
-dialoginput.plain.hindi=Lohit Hindi
-dialoginput.plain.malayalam=Lohit Malayalam
-dialoginput.plain.oriya=Lohit Oriya
-dialoginput.plain.punjabi=Lohit Punjabi
-dialoginput.plain.tamil=Lohit Tamil
-dialoginput.plain.telugu=Lohit Telugu
-dialoginput.plain.sinhala=LKLUG
-
-dialoginput.bold.latin-1=DejaVu Sans Mono Bold
-dialoginput.bold.japanese-x0208=Sazanami Gothic
-dialoginput.bold.korean=Baekmuk Gulim
-dialoginput.bold.chinese-big5=AR PL ShanHeiSun Uni
-dialoginput.bold.chinese-gb18030=AR PL ShanHeiSun Uni
-dialoginput.bold.bengali=Lohit Bengali
-dialoginput.bold.gujarati=Lohit Gujarati
-dialoginput.bold.hindi=Lohit Hindi
-dialoginput.bold.malayalam=Lohit Malayalam
-dialoginput.bold.oriya=Lohit Oriya
-dialoginput.bold.punjabi=Lohit Punjabi
-dialoginput.bold.tamil=Lohit Tamil
-dialoginput.bold.telugu=Lohit Telugu
-dialoginput.bold.sinhala=LKLUG
-
-dialoginput.italic.latin-1=DejaVu Sans Mono Oblique
-dialoginput.italic.japanese-x0208=Sazanami Gothic
-dialoginput.italic.korean=Baekmuk Gulim
-dialoginput.italic.chinese-big5=AR PL ShanHeiSun Uni
-dialoginput.italic.chinese-gb18030=AR PL ShanHeiSun Uni
-dialoginput.italic.bengali=Lohit Bengali
-dialoginput.italic.gujarati=Lohit Gujarati
-dialoginput.italic.hindi=Lohit Hindi
-dialoginput.italic.malayalam=Lohit Malayalam
-dialoginput.italic.oriya=Lohit Oriya
-dialoginput.italic.punjabi=Lohit Punjabi
-dialoginput.italic.tamil=Lohit Tamil
-dialoginput.italic.telugu=Lohit Telugu
-dialoginput.italic.sinhala=LKLUG
-
-dialoginput.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique
-dialoginput.bolditalic.japanese-x0208=Sazanami Gothic
-dialoginput.bolditalic.korean=Baekmuk Gulim
-dialoginput.bolditalic.chinese-big5=AR PL ShanHeiSun Uni
-dialoginput.bolditalic.chinese-gb18030=AR PL ShanHeiSun Uni
-dialoginput.bolditalic.bengali=Lohit Bengali
-dialoginput.bolditalic.gujarati=Lohit Gujarati
-dialoginput.bolditalic.hindi=Lohit Hindi
-dialoginput.bolditalic.malayalam=Lohit Malayalam
-dialoginput.bolditalic.oriya=Lohit Oriya
-dialoginput.bolditalic.punjabi=Lohit Punjabi
-dialoginput.bolditalic.tamil=Lohit Tamil
-dialoginput.bolditalic.telugu=Lohit Telugu
-dialoginput.bolditalic.sinhala=LKLUG
-
-# Search Sequences
-
-sequence.allfonts=latin-1
-sequence.allfonts.Big5=chinese-big5,latin-1
-sequence.allfonts.x-euc-jp-bsd=japanese-x0208,latin-1
-sequence.allfonts.EUC-KR=korean,latin-1
-sequence.allfonts.GB18030=chinese-gb18030,latin-1
-sequence.fallback=chinese-big5,chinese-gb18030,japanese-x0208,korean,bengali,gujarati,hindi,oriya,punjabi,malayalam,tamil,telugu,sinhala
-
-# Font File Names
-
-filename.DejaVu_Sans=/usr/share/fonts/dejavu/DejaVuSans.ttf
-filename.DejaVu_Sans_Bold=/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf
-filename.DejaVu_Sans_Oblique=/usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf
-filename.DejaVu_Sans_Bold_Oblique=/usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf
-
-filename.DejaVu_Sans_Mono=/usr/share/fonts/dejavu/DejaVuSansMono.ttf
-filename.DejaVu_Sans_Mono_Bold=/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf
-filename.DejaVu_Sans_Mono_Oblique=/usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf
-filename.DejaVu_Sans_Mono_Bold_Oblique=/usr/share/fonts/dejavu/DejaVuSansMono-BoldOblique.ttf
-
-filename.DejaVu_Serif=/usr/share/fonts/dejavu/DejaVuSerif.ttf
-filename.DejaVu_Serif_Bold=/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf
-filename.DejaVu_Serif_Oblique=/usr/share/fonts/dejavu/DejaVuSerif-Oblique.ttf
-filename.DejaVu_Serif_Bold_Oblique=/usr/share/fonts/dejavu/DejaVuSerif-BoldOblique.ttf
-
-filename.Sazanami_Gothic=/usr/share/fonts/sazanami-fonts-gothic/sazanami-gothic.ttf
-filename.Sazanami_Mincho=/usr/share/fonts/sazanami-fonts-mincho/sazanami-mincho.ttf
-filename.AR_PL_ShanHeiSun_Uni=/usr/share/fonts/cjkunifonts-uming/uming.ttc
-filename.AR_PL_ZenKai_Uni=/usr/share/fonts/cjkunifonts-ukai/ukai.ttc
-filename.Baekmuk_Gulim=/usr/share/fonts/baekmuk-ttf-gulim/gulim.ttf
-filename.Baekmuk_Batang=/usr/share/fonts/baekmuk-ttf-batang/batang.ttf
-
-filename.Lohit_Bengali=/usr/share/fonts/lohit-bengali/lohit_bn.ttf
-filename.Lohit_Gujarati=/usr/share/fonts/lohit-gujarati/lohit_gu.ttf
-filename.Lohit_Hindi=/usr/share/fonts/lohit-hindi/lohit_hi.ttf
-filename.Lohit_Kannda=/usr/share/fonts/lohit-kannada/lohit_kn.ttf
-filename.Lohit_Malayalam=/usr/share/fonts/lohit-malayalam/lohit_ml.ttf
-filename.Lohit_Oriya=/usr/share/fonts/lohit-oriya/lohit_or.ttf
-filename.Lohit_Punjabi=/usr/share/fonts/lohit-punjabi/lohit_pa.ttf
-filename.Lohit_Tamil=/usr/share/fonts/lohit-tamil/lohit_ta.ttf
-filename.Lohit_Telugu=/usr/share/fonts/lohit-telugu/lohit_te.ttf
-filename.LKLUG=/usr/share/fonts/lklug/lklug.ttf
-
--- ./jdk/src/solaris/classes/sun/awt/fontconfigs/bsd.fontconfig.SuSE.properties	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/awt/fontconfigs/bsd.fontconfig.SuSE.properties	1969-12-31 16:00:00.000000000 -0800
@@ -1,154 +0,0 @@
-#
-# 
-# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code 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 General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Version
-
-# Uses SuSE 10.2 fonts and file paths.
-version=1
-
-# Component Font Mappings
-
-dialog.plain.latin-1=Albany AMT
-dialog.plain.japanese-x0208=Sazanami Gothic
-dialog.plain.korean=UnDotum
-
-dialog.bold.latin-1=Albany AMT Bold
-dialog.bold.japanese-x0208=Sazanami Gothic
-dialog.bold.korean=UnDotum Bold
-
-dialog.italic.latin-1=Albany AMT Italic
-dialog.italic.japanese-x0208=Sazanami Gothic
-dialog.italic.korean=UnDotum
-
-dialog.bolditalic.latin-1=Albany AMT Bold Italic
-dialog.bolditalic.japanese-x0208=Sazanami Gothic
-dialog.bolditalic.korean=UnDotum Bold
-
-
-sansserif.plain.latin-1=Albany AMT
-sansserif.plain.japanese-x0208=Sazanami Gothic
-sansserif.plain.korean=UnDotum
-
-sansserif.bold.latin-1=Albany AMT Bold
-sansserif.bold.japanese-x0208=Sazanami Gothic
-sansserif.bold.korean=UnDotum Bold
-
-sansserif.italic.latin-1=Albany AMT Italic
-sansserif.italic.japanese-x0208=Sazanami Gothic
-sansserif.italic.korean=UnDotum
-
-sansserif.bolditalic.latin-1=Albany AMT Bold Italic
-sansserif.bolditalic.japanese-x0208=Sazanami Gothic
-sansserif.bolditalic.korean=UnDotum Bold
-
-
-serif.plain.latin-1=Thorndale AMT
-serif.plain.japanese-x0208=Sazanami Mincho
-serif.plain.korean=UnBatang
-
-serif.bold.latin-1=Thorndale AMT Bold
-serif.bold.japanese-x0208=Sazanami Mincho
-serif.bold.korean=UnBatang Bold
-
-serif.italic.latin-1=Thorndale AMT Italic
-serif.italic.japanese-x0208=Sazanami Mincho
-serif.italic.korean=UnBatang
-
-serif.bolditalic.latin-1=Thorndale AMT Bold Italic
-serif.bolditalic.japanese-x0208=Sazanami Mincho
-serif.bolditalic.korean=UnBatang Bold
-
-
-monospaced.plain.latin-1=Cumberland AMT
-monospaced.plain.japanese-x0208=Sazanami Gothic
-monospaced.plain.korean=UnDotum
-
-monospaced.bold.latin-1=Cumberland AMT Bold
-monospaced.bold.japanese-x0208=Sazanami Gothic
-monospaced.bold.korean=UnDotum Bold
-
-monospaced.italic.latin-1=Cumberland AMT Italic
-monospaced.italic.japanese-x0208=Sazanami Gothic
-monospaced.italic.korean=UnDotum
-
-monospaced.bolditalic.latin-1=Cumberland AMT Bold Italic
-monospaced.bolditalic.japanese-x0208=Sazanami Gothic
-monospaced.bolditalic.korean=UnDotum Bold
-
-
-dialoginput.plain.latin-1=Cumberland AMT
-dialoginput.plain.japanese-x0208=Sazanami Gothic
-dialoginput.plain.korean=UnDotum
-
-dialoginput.bold.latin-1=Cumberland AMT Bold
-dialoginput.bold.japanese-x0208=Sazanami Gothic
-dialoginput.bold.korean=UnDotum Bold
-
-dialoginput.italic.latin-1=Cumberland AMT Italic
-dialoginput.italic.japanese-x0208=Sazanami Gothic
-dialoginput.italic.korean=UnDotum
-
-dialoginput.bolditalic.latin-1=Cumberland AMT Bold Italic
-dialoginput.bolditalic.japanese-x0208=Sazanami Gothic
-dialoginput.bolditalic.korean=UnDotum Bold
-
-allfonts.chinese-big5=AR PL Mingti2L Big5
-allfonts.chinese-gb18030=AR PL SungtiL GB
-
-# Search Sequences
-
-sequence.allfonts=latin-1
-sequence.allfonts.Big5=chinese-big5,latin-1
-sequence.allfonts.x-euc-jp-bsd=japanese-x0208,latin-1
-sequence.allfonts.EUC-KR=korean,latin-1
-sequence.allfonts.GB18030=chinese-gb18030,latin-1
-sequence.fallback=chinese-big5,chinese-gb18030,japanese-x0208,korean
-
-# Font File Names
-
-filename.Albany_AMT=/usr/share/fonts/truetype/albw.ttf
-filename.Albany_AMT_Bold=/usr/share/fonts/truetype/albwb.ttf
-filename.Albany_AMT_Italic=/usr/share/fonts/truetype/albwb.ttf
-filename.Albany_AMT_Bold_Italic=/usr/share/fonts/truetype/albwbi.ttf
-
-filename.Thorndale_AMT=/usr/share/fonts/truetype/thowr___.ttf
-filename.Thorndale_AMT_Bold=/usr/share/fonts/truetype/thowb___.ttf
-filename.Thorndale_AMT_Italic=/usr/share/fonts/truetype/thowi___.ttf
-filename.Thorndale_AMT_Bold_Italic=/usr/share/fonts/truetype/thowbi__.ttf
-
-filename.Cumberland_AMT=/usr/share/fonts/truetype/cumbwr__.ttf
-filename.Cumberland_AMT_Bold=/usr/share/fonts/truetype/cumbwb__.ttf
-filename.Cumberland_AMT_Italic=/usr/share/fonts/truetype/cumbwi__.ttf
-filename.Cumberland_AMT_Bold_Italic=/usr/share/fonts/truetype/cumbwbi_.ttf
-
-filename.Sazanami_Gothic=/usr/share/fonts/truetype/sazanami-gothic.ttf
-filename.Sazanami_Mincho=/usr/share/fonts/truetype/sazanami-mincho.ttf
-filename.AR_PL_SungtiL_GB=/usr/share/fonts/truetype/gbsn00lp.ttf
-filename.AR_PL_Mingti2L_Big5=/usr/share/fonts/truetype/bsmi00lp.ttf
-filename.UnDotum=/usr/share/fonts/truetype/UnDotum.ttf
-filename.UnDotum_Bold=/usr/share/fonts/truetype/UnDotumBold.ttf
-filename.UnBatang=/usr/share/fonts/truetype/UnBatang.ttf
-filename.UnBatang_Bold=/usr/share/fonts/truetype/UnBatangBold.ttf
--- ./jdk/src/solaris/classes/sun/awt/fontconfigs/bsd.fontconfig.Ubuntu.properties	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/awt/fontconfigs/bsd.fontconfig.Ubuntu.properties	1969-12-31 16:00:00.000000000 -0800
@@ -1,348 +0,0 @@
-#
-# 
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code 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 General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Version
-
-# Uses Ubuntu 8.04 (hardy), Debian 6.0 (Squeeze) (and more recent releases) fonts and file paths.
-version=1
-
-# Component Font Mappings
-
-# Chinese fonts
-allfonts.umingcn=AR PL UMing CN
-#allfonts.umingcn.motif=AR PL UMing CN
-allfonts.uminghk=AR PL UMing HK
-#allfonts.uminghk.motif=AR PL UMing HK
-allfonts.umingtw=AR PL UMing TW
-#allfonts.umingtw.motif=AR PL UMing TW
-allfonts.wqy-zenhei=WenQuanYi Zen Hei
-#allfonts.wqy-zenhei.motif=WenQuanYi Zen Hei
-allfonts.shanheisun=AR PL ShanHeiSun Uni
-#allfonts.shanheisun.motif=AR PL ShanHeiSun Uni
-
-# Indic scripts
-allfonts.bengali=Lohit Bengali
-allfonts.gujarati=Lohit Gujarati
-allfonts.hindi=Lohit Hindi
-#allfonts.malayalam=Lohit Malayalam
-allfonts.oriya=Lohit Oriya
-allfonts.punjabi=Lohit Punjabi
-allfonts.tamil=Lohit Tamil
-allfonts.telugu=Lohit Telugu
-allfonts.sinhala=LKLUG
-
-
-serif.plain.latin-1=DejaVu Serif
-#serif.plain.latin-1.motif=LuxiSerif-Regular
-serif.plain.japanese-kochi=Kochi Mincho
-serif.plain.japanese-sazanami=Sazanami Mincho
-serif.plain.japanese-vlgothic=Sazanami Mincho
-serif.plain.korean-baekmuk=Baekmuk Batang
-#serif.plain.korean-baekmuk.motif=Baekmuk Batang
-serif.plain.korean-un=UnBatang
-#serif.plain.korean-un.motif=UnBatang
-
-serif.bold.latin-1=DejaVu Serif Bold
-#serif.bold.latin-1.motif=LuxiSerif-Bold
-serif.bold.japanese-kochi=Kochi Mincho
-serif.bold.japanese-sazanami=Sazanami Mincho
-serif.bold.japanese-vlgothic=Sazanami Mincho
-serif.bold.korean-baekmuk=Baekmuk Batang
-#serif.bold.korean-baekmuk.motif=Baekmuk Batang
-serif.bold.korean-un=UnBatang Bold
-#serif.bold.korean-un.motif=UnBatang Bold
-
-serif.italic.latin-1=DejaVu Serif Oblique
-#serif.italic.latin-1.motif=LuxiSerif-Oblique
-serif.italic.japanese-kochi=Kochi Mincho
-serif.italic.japanese-sazanami=Sazanami Mincho
-serif.italic.japanese-vlgothic=Sazanami Mincho
-serif.italic.korean-baekmuk=Baekmuk Batang
-#serif.italic.korean-baekmuk.motif=Baekmuk Batang
-serif.italic.korean-un=UnBatang
-#serif.italic.korean-un.motif=UnBatang
-
-serif.bolditalic.latin-1=DejaVu Serif Bold Oblique
-#serif.bolditalic.latin-1.motif=LuxiSerif-BoldOblique
-serif.bolditalic.japanese-kochi=Kochi Mincho
-serif.bolditalic.japanese-sazanami=Sazanami Mincho
-serif.bolditalic.japanese-vlgothic=Sazanami Mincho
-serif.bolditalic.korean-baekmuk=Baekmuk Batang
-#serif.bolditalic.korean-baekmuk.motif=Baekmuk Batang
-serif.bolditalic.korean-un=UnBatang Bold
-#serif.bolditalic.korean-un.motif=UnBatang Bold
-
-sansserif.plain.latin-1=DejaVu Sans
-#sansserif.plain.latin-1.motif=LuxiSans-Regular
-sansserif.plain.japanese-kochi=Kochi Gothic
-sansserif.plain.japanese-sazanami=Sazanami Gothic
-sansserif.plain.japanese-vlgothic=VL PGothic
-sansserif.plain.korean-baekmuk=Baekmuk Gulim
-#sansserif.plain.korean-baekmuk.motif=Baekmuk Gulim
-sansserif.plain.korean-un=UnDotum
-#sansserif.plain.korean-un.motif=UnDotum
-
-sansserif.bold.latin-1=DejaVu Sans Bold
-#sansserif.bold.latin-1.motif=LuxiSans-Bold
-sansserif.bold.japanese-kochi=Kochi Gothic
-sansserif.bold.japanese-sazanami=Sazanami Gothic
-sansserif.bold.japanese-vlgothic=VL PGothic
-sansserif.bold.korean-baekmuk=Baekmuk Gulim
-#sansserif.bold.korean-baekmuk.motif=Baekmuk Gulim
-sansserif.bold.korean-un=UnDotum Bold
-#sansserif.bold.korean-un.motif=UnDotum Bold
-
-sansserif.italic.latin-1=DejaVu Sans Oblique
-#sansserif.italic.latin-1.motif=LuxiSans-Oblique
-sansserif.italic.japanese-kochi=Kochi Gothic
-sansserif.italic.japanese-sazanami=Sazanami Gothic
-sansserif.italic.japanese-vlgothic=VL PGothic
-sansserif.italic.korean-baekmuk=Baekmuk Gulim
-#sansserif.italic.korean-baekmuk.motif=Baekmuk Gulim
-sansserif.italic.korean-un=UnDotum
-#sansserif.italic.korean-un.motif=UnDotum
-
-sansserif.bolditalic.latin-1=DejaVu Sans Bold Oblique
-#sansserif.bolditalic.latin-1.motif=LuxiSans-BoldOblique
-sansserif.bolditalic.japanese-kochi=Kochi Gothic
-sansserif.bolditalic.japanese-sazanami=Sazanami Gothic
-sansserif.bolditalic.japanese-vlgothic=VL PGothic
-sansserif.bolditalic.korean-baekmuk=Baekmuk Gulim
-#sansserif.bolditalic.korean-baekmuk.motif=Baekmuk Gulim
-sansserif.bolditalic.korean-un=UnDotum Bold
-#sansserif.bolditalic.korean-un.motif=UnDotum Bold
-
-monospaced.plain.latin-1=DejaVu Sans Mono
-#monospaced.plain.latin-1.motif=LuxiMono-Regular
-monospaced.plain.japanese-kochi=Kochi Gothic
-monospaced.plain.japanese-sazanami=Sazanami Gothic
-monospaced.plain.japanese-vlgothic=VL Gothic
-monospaced.plain.korean-baekmuk=Baekmuk Gulim
-#monospaced.plain.korean-baekmuk.motif=Baekmuk Gulim
-monospaced.plain.korean-un=UnDotum
-#monospaced.plain.korean-un.motif=UnDotum
-
-monospaced.bold.latin-1=DejaVu Sans Mono Bold
-#monospaced.bold.latin-1.motif=LuxiMono-Bold
-monospaced.bold.japanese-kochi=Kochi Gothic
-monospaced.bold.japanese-sazanami=Sazanami Gothic
-monospaced.bold.japanese-vlgothic=VL Gothic
-monospaced.bold.korean-baekmuk=Baekmuk Gulim
-#monospaced.bold.korean-baekmuk.motif=Baekmuk Gulim
-monospaced.bold.korean-un=UnDotum Bold
-#monospaced.bold.korean-un.motif=UnDotum Bold
-
-monospaced.italic.latin-1=DejaVu Sans Mono Oblique
-#monospaced.italic.latin-1.motif=LuxiMono-Oblique
-monospaced.italic.japanese-kochi=Kochi Gothic
-monospaced.italic.japanese-sazanami=Sazanami Gothic
-monospaced.italic.japanese-vlgothic=VL Gothic
-monospaced.italic.korean-baekmuk=Baekmuk Gulim
-#monospaced.italic.korean-baekmuk.motif=Baekmuk Gulim
-monospaced.italic.korean-un=UnDotum
-#monospaced.italic.korean-un.motif=UnDotum
-
-monospaced.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique
-#monospaced.bolditalic.latin-1.motif=LuxiMono-BoldOblique
-monospaced.bolditalic.japanese-kochi=Kochi Gothic
-monospaced.bolditalic.japanese-sazanami=Sazanami Gothic
-monospaced.bolditalic.japanese-vlgothic=VL Gothic
-monospaced.bolditalic.korean-baekmuk=Baekmuk Gulim
-#monospaced.bolditalic.korean-baekmuk.motif=Baekmuk Gulim
-monospaced.bolditalic.korean-un=UnDotum Bold
-#monospaced.bolditalic.korean-un.motif=UnDotum Bold
-
-dialog.plain.latin-1=DejaVu Sans
-#dialog.plain.latin-1.motif=LuxiSans-Regular
-dialog.plain.japanese-kochi=Kochi Gothic
-dialog.plain.japanese-sazanami=Sazanami Gothic
-dialog.plain.japanese-vlgothic=VL PGothic
-dialog.plain.korean-baekmuk=Baekmuk Gulim
-#dialog.plain.korean-baekmuk.motif=Baekmuk Gulim
-dialog.plain.korean-un=UnDotum
-#dialog.plain.korean-un.motif=UnDotum
-
-dialog.bold.latin-1=DejaVu Sans Bold
-#dialog.bold.latin-1.motif=LuxiSans-Bold
-dialog.bold.japanese-kochi=Kochi Gothic
-dialog.bold.japanese-sazanami=Sazanami Gothic
-dialog.bold.japanese-vlgothic=VL PGothic
-dialog.bold.korean-baekmuk=Baekmuk Gulim
-#dialog.bold.korean-baekmuk.motif=Baekmuk Gulim
-dialog.bold.korean-un=UnDotum Bold
-#dialog.bold.korean-un.motif=UnDotum Bold
-
-dialog.italic.latin-1=DejaVu Sans Oblique
-#dialog.italic.latin-1.motif=LuxiSans-Oblique
-dialog.italic.japanese-kochi=Kochi Gothic
-dialog.italic.japanese-sazanami=Sazanami Gothic
-dialog.italic.japanese-vlgothic=VL PGothic
-dialog.italic.korean-baekmuk=Baekmuk Gulim
-#dialog.italic.korean-baekmuk.motif=Baekmuk Gulim
-dialog.italic.korean-un=UnDotum
-#dialog.italic.korean-un.motif=UnDotum
-
-dialog.bolditalic.latin-1=DejaVu Sans Bold Oblique
-#dialog.bolditalic.latin-1.motif=LuxiSans-BoldOblique
-dialog.bolditalic.japanese-kochi=Kochi Gothic
-dialog.bolditalic.japanese-sazanami=Sazanami Gothic
-dialog.bolditalic.japanese-vlgothic=VL PGothic
-dialog.bolditalic.korean-baekmuk=Baekmuk Gulim
-#dialog.bolditalic.korean-baekmuk.motif=Baekmuk Gulim
-dialog.bolditalic.korean-un=UnDotum Bold
-#dialog.bolditalic.korean-un.motif=UnDotum Bold
-
-dialoginput.plain.latin-1=DejaVu Sans Mono
-#dialoginput.plain.latin-1.motif=LuxiMono-Regular
-dialoginput.plain.japanese-kochi=Kochi Gothic
-dialoginput.plain.japanese-sazanami=Sazanami Gothic
-dialoginput.plain.japanese-vlgothic=VL Gothic
-dialoginput.plain.korean-baekmuk=Baekmuk Gulim
-#dialoginput.plain.korean-baekmuk.motif=Baekmuk Gulim
-dialoginput.plain.korean-un=UnDotum
-#dialoginput.plain.korean-un.motif=UnDotum
-
-dialoginput.bold.latin-1=DejaVu Sans Mono Bold
-#dialoginput.bold.latin-1.motif=LuxiMono-Bold
-dialoginput.bold.japanese-kochi=Kochi Gothic
-dialoginput.bold.japanese-sazanami=Sazanami Gothic
-dialoginput.bold.japanese-vlgothic=VL Gothic
-dialoginput.bold.korean-baekmuk=Baekmuk Gulim
-#dialoginput.bold.korean-baekmuk.motif=Baekmuk Gulim
-dialoginput.bold.korean-un=UnDotum Bold
-#dialoginput.bold.korean-un.motif=UnDotum Bold
-
-dialoginput.italic.latin-1=DejaVu Sans Mono Oblique
-#dialoginput.italic.latin-1.motif=LuxiMono-Oblique
-dialoginput.italic.japanese-kochi=Kochi Gothic
-dialoginput.italic.japanese-sazanami=Sazanami Gothic
-dialoginput.italic.japanese-vlgothic=VL Gothic
-dialoginput.italic.korean-baekmuk=Baekmuk Gulim
-#dialoginput.italic.korean-baekmuk.motif=Baekmuk Gulim
-dialoginput.italic.korean-un=UnDotum
-#dialoginput.italic.korean-un.motif=UnDotum
-
-dialoginput.bolditalic.latin-1=DejaVu Sans Mono Bold Oblique
-#dialoginput.bolditalic.latin-1.motif=LuxiMono-BoldOblique
-dialoginput.bolditalic.japanese-kochi=Kochi Gothic
-dialoginput.bolditalic.japanese-sazanami=Sazanami Gothic
-dialoginput.bolditalic.japanese-vlgothic=VL Gothic
-dialoginput.bolditalic.korean-baekmuk=Baekmuk Gulim
-#dialoginput.bolditalic.korean-baekmuk.motif=Baekmuk Gulim
-dialoginput.bolditalic.korean-un=UnDotum Bold
-#dialoginput.bolditalic.korean-un.motif=UnDotum Bold
-
-# Search Sequences
-
-sequence.allfonts=latin-1
-sequence.allfonts.GB18030=latin-1,umingcn,shanheisun,wqy-zenhei
-sequence.allfonts.GB2312=latin-1,umingcn,shanheisun,wqy-zenhei
-sequence.allfonts.GBK=latin-1,umingcn,shanheisun,wqy-zenhei
-sequence.allfonts.x-euc-jp-bsd=latin-1,japanese-vlgothic,japanese-sazanami,japanese-kochi
-sequence.allfonts.EUC-KR=latin-1,korean-un,korean-baekmuk
-sequence.allfonts.Big5=latin-1,umingtw,shanheisun,wqy-zenhei
-sequence.allfonts.Big5-HKSCS=latin-1,uminghk,shanheisun,wqy-zenhei
-#sequence.fallback=uminghk,shanheisun,wqy-zenhei,japanese-vlgothic,japanese-kochi,japanese-sazanami,korean-un,korean-baekmuk,bengali,gujarati,hindi,oriya,punjabi,malayalam,tamil,telugu,sinhala
-sequence.fallback=uminghk,shanheisun,wqy-zenhei,japanese-vlgothic,japanese-sazanami,japanese-kochi,korean-un,korean-baekmuk,bengali,gujarati,hindi,oriya,punjabi,tamil,telugu
-
-# Exclusion Ranges
-
-exclusion.japanese-kochi=0390-03d6,2200-22ef,2701-27be
-exclusion.japanese-sazanami=0390-03d6,2200-22ef,2701-27be
-exclusion.japanese-vlgothic=0390-03d6,2200-22ef,2701-27be
-
-# Font File Names
-
-filename.DejaVu_Sans=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
-filename.DejaVu_Sans_Bold=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf
-filename.DejaVu_Sans_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf
-filename.DejaVu_Sans_Bold_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-BoldOblique.ttf
-
-filename.DejaVu_Sans_Mono=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf
-filename.DejaVu_Sans_Mono_Bold=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf
-filename.DejaVu_Sans_Mono_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Oblique.ttf
-filename.DejaVu_Sans_Mono_Bold_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-BoldOblique.ttf
-
-filename.DejaVu_Serif=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf
-filename.DejaVu_Serif_Bold=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf
-filename.DejaVu_Serif_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Oblique.ttf
-filename.DejaVu_Serif_Bold_Oblique=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-BoldOblique.ttf
-
-filename.AR_PL_UMing_CN=/usr/share/fonts/truetype/arphic/uming.ttc
-filename.AR_PL_UMing_HK=/usr/share/fonts/truetype/arphic/uming.ttc
-filename.AR_PL_UMing_TW=/usr/share/fonts/truetype/arphic/uming.ttc
-filename.AR_PL_ShanHeiSun_Uni=/usr/share/fonts/truetype/arphic/uming.ttf
-
-filename.WenQuanYi_Zen_Hei=/usr/share/fonts/truetype/wqy/wqy-zenhei.ttf
-filename.Baekmuk_Batang=/usr/share/fonts/truetype/baekmuk/batang.ttf
-filename.UnBatang=/usr/share/fonts/truetype/unfonts/UnBatang.ttf
-filename.UnBatang_Bold=/usr/share/fonts/truetype/unfonts/UnBatangBold.ttf
-filename.Baekmuk_Gulim=/usr/share/fonts/truetype/baekmuk/gulim.ttf
-filename.UnDotum=/usr/share/fonts/truetype/unfonts/UnDotum.ttf
-filename.UnDotum_Bold=/usr/share/fonts/truetype/unfonts/UnDotumBold.ttf
-filename.Kochi_Gothic=/usr/share/fonts/truetype/kochi/kochi-gothic.ttf
-filename.Sazanami_Gothic=/usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf
-filename.Kochi_Mincho=/usr/share/fonts/truetype/kochi/kochi-mincho.ttf
-filename.Sazanami_Mincho=/usr/share/fonts/truetype/sazanami/sazanami-mincho.ttf
-filename.VL_Gothic=/usr/share/fonts/truetype/vlgothic/VL-Gothic-Regular.ttf
-filename.VL_PGothic=/usr/share/fonts/truetype/vlgothic/VL-PGothic-Regular.ttf
-
-filename.Lohit_Bengali=/usr/share/fonts/truetype/ttf-bengali-fonts/lohit_bn.ttf
-filename.Lohit_Gujarati=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_gu.ttf
-filename.Lohit_Hindi=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf
-filename.Lohit_Kannda=/usr/share/fonts/truetype/ttf-kannada-fonts/lohit_kn.ttf
-#filename.Lohit_Malayalam=/usr/share/fonts/lohit-malayalam/lohit_ml.ttf
-filename.Lohit_Oriya=/usr/share/fonts/truetype/ttf-oriya-fonts/lohit_or.ttf
-filename.Lohit_Punjabi=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf
-filename.Lohit_Tamil=/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf
-filename.Lohit_Telugu=/usr/share/fonts/truetype/ttf-telugu-fonts/lohit_te.ttf
-filename.LKLUG=/usr/share/fonts/truetype/ttf-sinhala-lklug/lklug.ttf
-
-filename.LuxiSans-Regular=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisr.ttf
-filename.LuxiSans-Bold=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisb.ttf
-filename.LuxiSans-Oblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisri.ttf
-filename.LuxiSans-BoldOblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxisbi.ttf
-filename.LuxiMono-Regular=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximr.ttf
-filename.LuxiMono-Bold=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximb.ttf
-filename.LuxiMono-Oblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximri.ttf
-filename.LuxiMono-BoldOblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luximbi.ttf
-filename.LuxiSerif-Regular=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirr.ttf
-filename.LuxiSerif-Bold=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirb.ttf
-filename.LuxiSerif-Oblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirri.ttf
-filename.LuxiSerif-BoldOblique=/usr/share/fonts/truetype/ttf-xfree86-nonfree/luxirbi.ttf
-
-# AWT X11 font paths
-awtfontpath.latin-1=/usr/share/fonts/X11/Type1
-awtfontpath.umingcn=/usr/share/fonts/truetype/arphic
-awtfontpath.uminghk=/usr/share/fonts/truetype/arphic
-awtfontpath.umingtw=/usr/share/fonts/truetype/arphic
-awtfontpath.shanheisun=/usr/share/fonts/truetype/arphic
-awtfontpath.wqy-zenhei=/usr/share/fonts/truetype/wqy
-awtfontpath.japanese-kochi=/usr/share/fonts/truetype/kochi
-awtfontpath.japanese-sazanami=/usr/share/fonts/truetype/sazanami
-awtfontpath.japanese-vlgothic=/usr/share/fonts/truetype/vlgothic
-awtfontpath.korean-baekmuk=/usr/share/fonts/truetype/baekmuk
-awtfontpath.korean-un=/usr/share/fonts/truetype/unfonts
--- ./jdk/src/solaris/classes/sun/nio/ch/BsdAsynchronousChannelProvider.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/ch/BsdAsynchronousChannelProvider.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.ch;
-
-import java.nio.channels.*;
-import java.nio.channels.spi.AsynchronousChannelProvider;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ThreadFactory;
-import java.io.IOException;
-
-public class BsdAsynchronousChannelProvider
-    extends AsynchronousChannelProvider
-{
-    private static volatile EPollPort defaultPort;
-
-    private EPollPort defaultEventPort() throws IOException {
-        if (defaultPort == null) {
-            synchronized (BsdAsynchronousChannelProvider.class) {
-                if (defaultPort == null) {
-                    defaultPort = new EPollPort(this, ThreadPool.getDefault()).start();
-                }
-            }
-        }
-        return defaultPort;
-    }
-
-    public BsdAsynchronousChannelProvider() {
-    }
-
-    @Override
-    public AsynchronousChannelGroup openAsynchronousChannelGroup(int nThreads, ThreadFactory factory)
-        throws IOException
-    {
-        return new EPollPort(this, ThreadPool.create(nThreads, factory)).start();
-    }
-
-    @Override
-    public AsynchronousChannelGroup openAsynchronousChannelGroup(ExecutorService executor, int initialSize)
-        throws IOException
-    {
-        return new EPollPort(this, ThreadPool.wrap(executor, initialSize)).start();
-    }
-
-    private Port toPort(AsynchronousChannelGroup group) throws IOException {
-        if (group == null) {
-            return defaultEventPort();
-        } else {
-            if (!(group instanceof EPollPort))
-                throw new IllegalChannelGroupException();
-            return (Port)group;
-        }
-    }
-
-    @Override
-    public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel(AsynchronousChannelGroup group)
-        throws IOException
-    {
-        return new UnixAsynchronousServerSocketChannelImpl(toPort(group));
-    }
-
-    @Override
-    public AsynchronousSocketChannel openAsynchronousSocketChannel(AsynchronousChannelGroup group)
-        throws IOException
-    {
-        return new UnixAsynchronousSocketChannelImpl(toPort(group));
-    }
-}
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdDosFileAttributeView.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdDosFileAttributeView.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,281 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.fs;
-
-import java.nio.file.attribute.*;
-import java.util.Map;
-import java.util.Set;
-import java.io.IOException;
-import sun.misc.Unsafe;
-
-import static sun.nio.fs.UnixNativeDispatcher.*;
-import static sun.nio.fs.UnixConstants.*;
-
-/**
- * Bsd implementation of DosFileAttributeView for use on file systems such
- * as ext3 that have extended attributes enabled and SAMBA configured to store
- * DOS attributes.
- */
-
-class BsdDosFileAttributeView
-    extends UnixFileAttributeViews.Basic implements DosFileAttributeView
-{
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
-
-    private static final String READONLY_NAME = "readonly";
-    private static final String ARCHIVE_NAME = "archive";
-    private static final String SYSTEM_NAME = "system";
-    private static final String HIDDEN_NAME = "hidden";
-
-    private static final String DOS_XATTR_NAME = "user.DOSATTRIB";
-    private static final byte[] DOS_XATTR_NAME_AS_BYTES = DOS_XATTR_NAME.getBytes();
-
-    private static final int DOS_XATTR_READONLY = 0x01;
-    private static final int DOS_XATTR_HIDDEN   = 0x02;
-    private static final int DOS_XATTR_SYSTEM   = 0x04;
-    private static final int DOS_XATTR_ARCHIVE  = 0x20;
-
-    // the names of the DOS attributes (includes basic)
-    private static final Set<String> dosAttributeNames =
-        Util.newSet(basicAttributeNames, READONLY_NAME, ARCHIVE_NAME, SYSTEM_NAME, HIDDEN_NAME);
-
-    BsdDosFileAttributeView(UnixPath file, boolean followLinks) {
-        super(file, followLinks);
-    }
-
-    @Override
-    public String name() {
-        return "dos";
-    }
-
-    @Override
-    public void setAttribute(String attribute, Object value)
-        throws IOException
-    {
-        if (attribute.equals(READONLY_NAME)) {
-            setReadOnly((Boolean)value);
-            return;
-        }
-        if (attribute.equals(ARCHIVE_NAME)) {
-            setArchive((Boolean)value);
-            return;
-        }
-        if (attribute.equals(SYSTEM_NAME)) {
-            setSystem((Boolean)value);
-            return;
-        }
-        if (attribute.equals(HIDDEN_NAME)) {
-            setHidden((Boolean)value);
-            return;
-        }
-        super.setAttribute(attribute, value);
-    }
-
-    @Override
-    public Map<String,Object> readAttributes(String[] attributes)
-        throws IOException
-    {
-        AttributesBuilder builder =
-            AttributesBuilder.create(dosAttributeNames, attributes);
-        DosFileAttributes attrs = readAttributes();
-        addRequestedBasicAttributes(attrs, builder);
-        if (builder.match(READONLY_NAME))
-            builder.add(READONLY_NAME, attrs.isReadOnly());
-        if (builder.match(ARCHIVE_NAME))
-            builder.add(ARCHIVE_NAME, attrs.isArchive());
-        if (builder.match(SYSTEM_NAME))
-            builder.add(SYSTEM_NAME, attrs.isSystem());
-        if (builder.match(HIDDEN_NAME))
-            builder.add(HIDDEN_NAME, attrs.isHidden());
-        return builder.unmodifiableMap();
-    }
-
-    @Override
-    public DosFileAttributes readAttributes() throws IOException {
-        file.checkRead();
-
-        int fd = file.openForAttributeAccess(followLinks);
-        try {
-             final UnixFileAttributes attrs = UnixFileAttributes.get(fd);
-             final int dosAttribute = getDosAttribute(fd);
-
-             return new DosFileAttributes() {
-                @Override
-                public FileTime lastModifiedTime() {
-                    return attrs.lastModifiedTime();
-                }
-                @Override
-                public FileTime lastAccessTime() {
-                    return attrs.lastAccessTime();
-                }
-                @Override
-                public FileTime creationTime() {
-                    return attrs.creationTime();
-                }
-                @Override
-                public boolean isRegularFile() {
-                    return attrs.isRegularFile();
-                }
-                @Override
-                public boolean isDirectory() {
-                    return attrs.isDirectory();
-                }
-                @Override
-                public boolean isSymbolicLink() {
-                    return attrs.isSymbolicLink();
-                }
-                @Override
-                public boolean isOther() {
-                    return attrs.isOther();
-                }
-                @Override
-                public long size() {
-                    return attrs.size();
-                }
-                @Override
-                public Object fileKey() {
-                    return attrs.fileKey();
-                }
-                @Override
-                public boolean isReadOnly() {
-                    return (dosAttribute & DOS_XATTR_READONLY) != 0;
-                }
-                @Override
-                public boolean isHidden() {
-                    return (dosAttribute & DOS_XATTR_HIDDEN) != 0;
-                }
-                @Override
-                public boolean isArchive() {
-                    return (dosAttribute & DOS_XATTR_ARCHIVE) != 0;
-                }
-                @Override
-                public boolean isSystem() {
-                    return (dosAttribute & DOS_XATTR_SYSTEM) != 0;
-                }
-             };
-
-        } catch (UnixException x) {
-            x.rethrowAsIOException(file);
-            return null;    // keep compiler happy
-        } finally {
-            close(fd);
-        }
-    }
-
-    @Override
-    public void setReadOnly(boolean value) throws IOException {
-        updateDosAttribute(DOS_XATTR_READONLY, value);
-    }
-
-    @Override
-    public void setHidden(boolean value) throws IOException {
-        updateDosAttribute(DOS_XATTR_HIDDEN, value);
-    }
-
-    @Override
-    public void setArchive(boolean value) throws IOException {
-        updateDosAttribute(DOS_XATTR_ARCHIVE, value);
-    }
-
-    @Override
-    public void setSystem(boolean value) throws IOException {
-        updateDosAttribute(DOS_XATTR_SYSTEM, value);
-    }
-
-    /**
-     * Reads the value of the user.DOSATTRIB extended attribute
-     */
-    private int getDosAttribute(int fd) throws UnixException {
-        final int size = 24;
-
-        NativeBuffer buffer = NativeBuffers.getNativeBuffer(size);
-        try {
-            int len = BsdNativeDispatcher
-                .fgetxattr(fd, DOS_XATTR_NAME_AS_BYTES, buffer.address(), size);
-
-            if (len > 0) {
-                // ignore null terminator
-                if (unsafe.getByte(buffer.address()+len-1) == 0)
-                    len--;
-
-                // convert to String and parse
-                byte[] buf = new byte[len];
-                unsafe.copyMemory(null, buffer.address(), buf,
-                    Unsafe.ARRAY_BYTE_BASE_OFFSET, len);
-                String value = new String(buf); // platform encoding
-
-                // should be something like 0x20
-                if (value.length() >= 3 && value.startsWith("0x")) {
-                    try {
-                        return Integer.parseInt(value.substring(2), 16);
-                    } catch (NumberFormatException x) {
-                        // ignore
-                    }
-                }
-            }
-            throw new UnixException("Value of " + DOS_XATTR_NAME + " attribute is invalid");
-        } catch (UnixException x) {
-            // default value when attribute does not exist
-            if (x.errno() == ENODATA)
-                return 0;
-            throw x;
-        } finally {
-            buffer.release();
-        }
-    }
-
-    /**
-     * Updates the value of the user.DOSATTRIB extended attribute
-     */
-    private void updateDosAttribute(int flag, boolean enable) throws IOException {
-        file.checkWrite();
-
-        int fd = file.openForAttributeAccess(followLinks);
-        try {
-            int oldValue = getDosAttribute(fd);
-            int newValue = oldValue;
-            if (enable) {
-                newValue |= flag;
-            } else {
-                newValue &= ~flag;
-            }
-            if (newValue != oldValue) {
-                byte[] value = ("0x" + Integer.toHexString(newValue)).getBytes();
-                NativeBuffer buffer = NativeBuffers.asNativeBuffer(value);
-                try {
-                    BsdNativeDispatcher.fsetxattr(fd, DOS_XATTR_NAME_AS_BYTES,
-                        buffer.address(), value.length+1);
-                } finally {
-                    buffer.release();
-                }
-            }
-        } catch (UnixException x) {
-            x.rethrowAsIOException(file);
-        } finally {
-            close(fd);
-        }
-    }
-}
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdFileStore.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdFileStore.java	2011-04-22 23:08:38.000000000 -0700
@@ -36,10 +36,6 @@
 class BsdFileStore
     extends UnixFileStore
 {
-    // used when checking if extended attributes are enabled or not
-    private volatile boolean xattrChecked;
-    private volatile boolean xattrEnabled;
-
     BsdFileStore(UnixPath file) throws IOException {
         super(file);
     }
@@ -54,7 +50,7 @@
      */
     @Override
     UnixMountEntry findMountEntry() throws IOException {
-        BsdFileSystem fs = (BsdFileSystem)file().getFileSystem();
+        UnixFileSystem fs = file().getFileSystem();
 
         // step 1: get realpath
         UnixPath path = null;
@@ -80,20 +76,20 @@
             parent = parent.getParent();
         }
 
-        // step 3: lookup mounted file systems (use /proc/mounts to ensure we
-        // find the file system even when not in /etc/mtab)
+        // step 3: lookup mounted file systems
         byte[] dir = path.asByteArray();
-        for (UnixMountEntry entry: fs.getMountEntries("/proc/mounts")) {
+        for (UnixMountEntry entry: fs.getMountEntries()) {
             if (Arrays.equals(dir, entry.dir()))
                 return entry;
         }
 
-        throw new IOException("Mount point not found");
+        throw new IOException("Mount point not found in fstab");
     }
 
     // returns true if extended attributes enabled on file system where given
     // file resides, returns false if disabled or unable to determine.
     private boolean isExtendedAttributesEnabled(UnixPath path) {
+/*
         try {
             int fd = path.openForAttributeAccess(false);
             try {
@@ -110,11 +106,13 @@
         } catch (IOException ignore) {
             // nothing we can do
         }
+*/
         return false;
     }
 
     @Override
     public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
+/*
         // support DosFileAttributeView and UserDefinedAttributeView if extended
         // attributes enabled
         if (type == DosFileAttributeView.class ||
@@ -145,15 +143,18 @@
             }
             return xattrEnabled;
         }
+*/
         return super.supportsFileAttributeView(type);
     }
 
     @Override
     public boolean supportsFileAttributeView(String name) {
+/*
         if (name.equals("dos"))
             return supportsFileAttributeView(DosFileAttributeView.class);
         if (name.equals("user"))
             return supportsFileAttributeView(UserDefinedFileAttributeView.class);
+*/
         return super.supportsFileAttributeView(name);
     }
 }
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdFileSystem.java	2011-04-22 23:08:38.000000000 -0700
@@ -28,13 +28,15 @@
 import java.nio.file.*;
 import java.io.IOException;
 import java.util.*;
-import static sun.nio.fs.BsdNativeDispatcher.*;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
 
 /**
  * Bsd implementation of FileSystem
  */
 
 class BsdFileSystem extends UnixFileSystem {
+
     BsdFileSystem(UnixFileSystemProvider provider, String dir) {
         super(provider, dir);
     }
@@ -43,21 +45,17 @@
     public WatchService newWatchService()
         throws IOException
     {
-        // assume 2.6.13 or newer
-        return new BsdWatchService(this);
+        // use polling implementation until we implement a BSD/kqueue one
+        return new PollingWatchService();
     }
 
-
     // lazy initialization of the list of supported attribute views
     private static class SupportedFileFileAttributeViewsHolder {
         static final Set<String> supportedFileAttributeViews =
             supportedFileAttributeViews();
         private static Set<String> supportedFileAttributeViews() {
-            Set<String> result = new HashSet<>();
+            Set<String> result = new HashSet<String>();
             result.addAll(standardFileAttributeViews());
-            // additional Bsd-specific views
-            result.add("dos");
-            result.add("user");
             return Collections.unmodifiableSet(result);
         }
     }
@@ -69,26 +67,26 @@
 
     @Override
     void copyNonPosixAttributes(int ofd, int nfd) {
-        BsdUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
     }
 
     /**
-     * Returns object to iterate over the mount entries in the given fstab file.
+     * Returns object to iterate over mount entries
      */
-    Iterable<UnixMountEntry> getMountEntries(String fstab) {
-        ArrayList<UnixMountEntry> entries = new ArrayList<>();
+    @Override
+    Iterable<UnixMountEntry> getMountEntries() {
+        ArrayList<UnixMountEntry> entries = new ArrayList<UnixMountEntry>();
         try {
-            long fp = setmntent(fstab.getBytes(), "r".getBytes());
+            long iter = BsdNativeDispatcher.getfsstat();
             try {
                 for (;;) {
                     UnixMountEntry entry = new UnixMountEntry();
-                    int res = getextmntent(fp, entry);
+                    int res = BsdNativeDispatcher.fsstatEntry(iter, entry);
                     if (res < 0)
                         break;
                     entries.add(entry);
                 }
             } finally {
-                endmntent(fp);
+                BsdNativeDispatcher.endfsstat(iter);
             }
 
         } catch (UnixException x) {
@@ -97,14 +95,6 @@
         return entries;
     }
 
-    /**
-     * Returns object to iterate over the mount entries in /etc/mtab
-     */
-    @Override
-    Iterable<UnixMountEntry> getMountEntries() {
-        return getMountEntries("/etc/mtab");
-    }
-
 
 
     @Override
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdFileSystemProvider.java	2011-04-22 23:08:38.000000000 -0700
@@ -54,14 +54,6 @@
                                                                 Class<V> type,
                                                                 LinkOption... options)
     {
-        if (type == DosFileAttributeView.class) {
-            return (V) new BsdDosFileAttributeView(UnixPath.toUnixPath(obj),
-                                                     Util.followLinks(options));
-        }
-        if (type == UserDefinedFileAttributeView.class) {
-            return (V) new BsdUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
-                                                             Util.followLinks(options));
-        }
         return super.getFileAttributeView(obj, type, options);
     }
 
@@ -70,14 +62,6 @@
                                                          String name,
                                                          LinkOption... options)
     {
-        if (name.equals("dos")) {
-            return new BsdDosFileAttributeView(UnixPath.toUnixPath(obj),
-                                                 Util.followLinks(options));
-        }
-        if (name.equals("user")) {
-            return new BsdUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
-                                                         Util.followLinks(options));
-        }
         return super.getFileAttributeView(obj, name, options);
     }
 
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdNativeDispatcher.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdNativeDispatcher.java	2011-04-22 23:08:38.000000000 -0700
@@ -36,84 +36,23 @@
     private BsdNativeDispatcher() { }
 
    /**
-    * FILE *setmntent(const char *filename, const char *type);
+    * struct fsstat_iter *getfsstat();
     */
-    static long setmntent(byte[] filename, byte[] type) throws UnixException {
-        NativeBuffer pathBuffer = NativeBuffers.asNativeBuffer(filename);
-        NativeBuffer typeBuffer = NativeBuffers.asNativeBuffer(type);
-        try {
-            return setmntent0(pathBuffer.address(), typeBuffer.address());
-        } finally {
-            typeBuffer.release();
-            pathBuffer.release();
-        }
-    }
-    private static native long setmntent0(long pathAddress, long typeAddress)
-        throws UnixException;
+    static native long getfsstat() throws UnixException;
 
    /**
-    * int endmntent(FILE* filep);
+    * int fsstatEntry(struct fsstat_iter * iter, UnixMountEntry entry);
     */
-    static native void endmntent(long stream) throws UnixException;
-
-    /**
-     * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size);
-     */
-    static int fgetxattr(int filedes, byte[] name, long valueAddress,
-                         int valueLen) throws UnixException
-    {
-        NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
-        try {
-            return fgetxattr0(filedes, buffer.address(), valueAddress, valueLen);
-        } finally {
-            buffer.release();
-        }
-    }
-
-    private static native int fgetxattr0(int filedes, long nameAddress,
-        long valueAdddress, int valueLen) throws UnixException;
-
-    /**
-     *  fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags);
-     */
-    static void fsetxattr(int filedes, byte[] name, long valueAddress,
-        int valueLen) throws UnixException
-    {
-        NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
-        try {
-            fsetxattr0(filedes, buffer.address(), valueAddress, valueLen);
-        } finally {
-            buffer.release();
-        }
-    }
-
-    private static native void fsetxattr0(int filedes, long nameAddress,
-        long valueAdddress, int valueLen) throws UnixException;
-
-
-    /**
-     * fremovexattr(int filedes, const char *name);
-     */
-    static void fremovexattr(int filedes, byte[] name) throws UnixException {
-        NativeBuffer buffer = NativeBuffers.asNativeBuffer(name);
-        try {
-            fremovexattr0(filedes, buffer.address());
-        } finally {
-            buffer.release();
-        }
-    }
-
-    private static native void fremovexattr0(int filedes, long nameAddress)
+    static native int fsstatEntry(long iter, UnixMountEntry entry)
         throws UnixException;
 
-    /**
-     * size_t flistxattr(int filedes, const char *list, size_t size)
-     */
-    static native int flistxattr(int filedes, long listAddress, int size)
-        throws UnixException;
+   /**
+    * void endfsstat(struct fsstat_iter * iter);
+    */
+    static native void endfsstat(long iter) throws UnixException;
 
-    // initialize
-    private static native void init();
+    // initialize field IDs
+    private static native void initIDs();
 
     static {
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
@@ -121,6 +60,6 @@
                 System.loadLibrary("nio");
                 return null;
         }});
-        init();
+        initIDs();
     }
 }
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdUserDefinedFileAttributeView.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdUserDefinedFileAttributeView.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,350 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.fs;
-
-import java.nio.file.*;
-import java.nio.ByteBuffer;
-import java.io.IOException;
-import java.util.*;
-import sun.misc.Unsafe;
-
-import static sun.nio.fs.UnixConstants.*;
-import static sun.nio.fs.BsdNativeDispatcher.*;
-
-/**
- * Bsd implementation of UserDefinedFileAttributeView using extended attributes.
- */
-
-class BsdUserDefinedFileAttributeView
-    extends AbstractUserDefinedFileAttributeView
-{
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
-
-    // namespace for extended user attributes
-    private static final String USER_NAMESPACE = "user.";
-
-    // maximum bytes in extended attribute name (includes namespace)
-    private static final int XATTR_NAME_MAX = 255;
-
-    private byte[] nameAsBytes(UnixPath file, String name) throws IOException {
-        if (name == null)
-            throw new NullPointerException("'name' is null");
-        name = USER_NAMESPACE + name;
-        byte[] bytes = name.getBytes();
-        if (bytes.length > XATTR_NAME_MAX) {
-            throw new FileSystemException(file.getPathForExecptionMessage(),
-                null, "'" + name + "' is too big");
-        }
-        return bytes;
-    }
-
-    // Parses buffer as array of NULL-terminated C strings.
-    private List<String> asList(long address, int size) {
-        List<String> list = new ArrayList<>();
-        int start = 0;
-        int pos = 0;
-        while (pos < size) {
-            if (unsafe.getByte(address + pos) == 0) {
-                int len = pos - start;
-                byte[] value = new byte[len];
-                unsafe.copyMemory(null, address+start, value,
-                    Unsafe.ARRAY_BYTE_BASE_OFFSET, len);
-                String s = new String(value);
-                if (s.startsWith(USER_NAMESPACE)) {
-                    s = s.substring(USER_NAMESPACE.length());
-                    list.add(s);
-                }
-                start = pos + 1;
-            }
-            pos++;
-        }
-        return list;
-    }
-
-    private final UnixPath file;
-    private final boolean followLinks;
-
-    BsdUserDefinedFileAttributeView(UnixPath file, boolean followLinks) {
-        this.file = file;
-        this.followLinks = followLinks;
-    }
-
-    @Override
-    public List<String> list() throws IOException  {
-        if (System.getSecurityManager() != null)
-            checkAccess(file.getPathForPermissionCheck(), true, false);
-
-        int fd = file.openForAttributeAccess(followLinks);
-        NativeBuffer buffer = null;
-        try {
-            int size = 1024;
-            buffer = NativeBuffers.getNativeBuffer(size);
-            for (;;) {
-                try {
-                    int n = flistxattr(fd, buffer.address(), size);
-                    List<String> list = asList(buffer.address(), n);
-                    return Collections.unmodifiableList(list);
-                } catch (UnixException x) {
-                    // allocate larger buffer if required
-                    if (x.errno() == ERANGE && size < 32*1024) {
-                        buffer.release();
-                        size *= 2;
-                        buffer = null;
-                        buffer = NativeBuffers.getNativeBuffer(size);
-                        continue;
-                    }
-                    throw new FileSystemException(file.getPathForExecptionMessage(),
-                        null, "Unable to get list of extended attributes: " +
-                        x.getMessage());
-                }
-            }
-        } finally {
-            if (buffer != null)
-                buffer.release();
-            close(fd);
-        }
-    }
-
-    @Override
-    public int size(String name) throws IOException  {
-        if (System.getSecurityManager() != null)
-            checkAccess(file.getPathForPermissionCheck(), true, false);
-
-        int fd = file.openForAttributeAccess(followLinks);
-        try {
-            // fgetxattr returns size if called with size==0
-            return fgetxattr(fd, nameAsBytes(file,name), 0L, 0);
-        } catch (UnixException x) {
-            throw new FileSystemException(file.getPathForExecptionMessage(),
-                null, "Unable to get size of extended attribute '" + name +
-                "': " + x.getMessage());
-        } finally {
-            close(fd);
-        }
-    }
-
-    @Override
-    public int read(String name, ByteBuffer dst) throws IOException {
-        if (System.getSecurityManager() != null)
-            checkAccess(file.getPathForPermissionCheck(), true, false);
-
-        if (dst.isReadOnly())
-            throw new IllegalArgumentException("Read-only buffer");
-        int pos = dst.position();
-        int lim = dst.limit();
-        assert (pos <= lim);
-        int rem = (pos <= lim ? lim - pos : 0);
-
-        NativeBuffer nb;
-        long address;
-        if (dst instanceof sun.nio.ch.DirectBuffer) {
-            nb = null;
-            address = ((sun.nio.ch.DirectBuffer)dst).address() + pos;
-        } else {
-            // substitute with native buffer
-            nb = NativeBuffers.getNativeBuffer(rem);
-            address = nb.address();
-        }
-
-        int fd = file.openForAttributeAccess(followLinks);
-        try {
-            try {
-                int n = fgetxattr(fd, nameAsBytes(file,name), address, rem);
-
-                // if remaining is zero then fgetxattr returns the size
-                if (rem == 0) {
-                    if (n > 0)
-                        throw new UnixException(ERANGE);
-                    return 0;
-                }
-
-                // copy from buffer into backing array if necessary
-                if (nb != null) {
-                    int off = dst.arrayOffset() + pos + Unsafe.ARRAY_BYTE_BASE_OFFSET;
-                    unsafe.copyMemory(null, address, dst.array(), off, n);
-                }
-                dst.position(pos + n);
-                return n;
-            } catch (UnixException x) {
-                String msg = (x.errno() == ERANGE) ?
-                    "Insufficient space in buffer" : x.getMessage();
-                throw new FileSystemException(file.getPathForExecptionMessage(),
-                    null, "Error reading extended attribute '" + name + "': " + msg);
-            } finally {
-                close(fd);
-            }
-        } finally {
-            if (nb != null)
-                nb.release();
-        }
-    }
-
-    @Override
-    public int write(String name, ByteBuffer src) throws IOException {
-        if (System.getSecurityManager() != null)
-            checkAccess(file.getPathForPermissionCheck(), false, true);
-
-        int pos = src.position();
-        int lim = src.limit();
-        assert (pos <= lim);
-        int rem = (pos <= lim ? lim - pos : 0);
-
-        NativeBuffer nb;
-        long address;
-        if (src instanceof sun.nio.ch.DirectBuffer) {
-            nb = null;
-            address = ((sun.nio.ch.DirectBuffer)src).address() + pos;
-        } else {
-            // substitute with native buffer
-            nb = NativeBuffers.getNativeBuffer(rem);
-            address = nb.address();
-
-            if (src.hasArray()) {
-                // copy from backing array into buffer
-                int off = src.arrayOffset() + pos + Unsafe.ARRAY_BYTE_BASE_OFFSET;
-                unsafe.copyMemory(src.array(), off, null, address, rem);
-            } else {
-                // backing array not accessible so transfer via temporary array
-                byte[] tmp = new byte[rem];
-                src.get(tmp);
-                src.position(pos);  // reset position as write may fail
-                unsafe.copyMemory(tmp, Unsafe.ARRAY_BYTE_BASE_OFFSET, null,
-                    address, rem);
-            }
-        }
-
-        int fd = file.openForAttributeAccess(followLinks);
-        try {
-            try {
-                fsetxattr(fd, nameAsBytes(file,name), address, rem);
-                src.position(pos + rem);
-                return rem;
-            } catch (UnixException x) {
-                throw new FileSystemException(file.getPathForExecptionMessage(),
-                    null, "Error writing extended attribute '" + name + "': " +
-                    x.getMessage());
-            } finally {
-                close(fd);
-            }
-        } finally {
-            if (nb != null)
-                nb.release();
-        }
-    }
-
-    @Override
-    public void delete(String name) throws IOException {
-        if (System.getSecurityManager() != null)
-            checkAccess(file.getPathForPermissionCheck(), false, true);
-
-        int fd = file.openForAttributeAccess(followLinks);
-        try {
-            fremovexattr(fd, nameAsBytes(file,name));
-        } catch (UnixException x) {
-            throw new FileSystemException(file.getPathForExecptionMessage(),
-                null, "Unable to delete extended attribute '" + name + "': " + x.getMessage());
-        } finally {
-            close(fd);
-        }
-    }
-
-    /**
-     * Used by copyTo/moveTo to copy extended attributes from source to target.
-     *
-     * @param   ofd
-     *          file descriptor for source file
-     * @param   nfd
-     *          file descriptor for target file
-     */
-    static void copyExtendedAttributes(int ofd, int nfd) {
-        NativeBuffer buffer = null;
-        try {
-
-            // call flistxattr to get list of extended attributes.
-            int size = 1024;
-            buffer = NativeBuffers.getNativeBuffer(size);
-            for (;;) {
-                try {
-                    size = flistxattr(ofd, buffer.address(), size);
-                    break;
-                } catch (UnixException x) {
-                    // allocate larger buffer if required
-                    if (x.errno() == ERANGE && size < 32*1024) {
-                        buffer.release();
-                        size *= 2;
-                        buffer = null;
-                        buffer = NativeBuffers.getNativeBuffer(size);
-                        continue;
-                    }
-
-                    // unable to get list of attributes
-                    return;
-                }
-            }
-
-            // parse buffer as array of NULL-terminated C strings.
-            long address = buffer.address();
-            int start = 0;
-            int pos = 0;
-            while (pos < size) {
-                if (unsafe.getByte(address + pos) == 0) {
-                    // extract attribute name and copy attribute to target.
-                    // FIXME: We can avoid needless copying by using address+pos
-                    // as the address of the name.
-                    int len = pos - start;
-                    byte[] name = new byte[len];
-                    unsafe.copyMemory(null, address+start, name,
-                        Unsafe.ARRAY_BYTE_BASE_OFFSET, len);
-                    try {
-                        copyExtendedAttribute(ofd, name, nfd);
-                    } catch (UnixException ignore) {
-                        // ignore
-                    }
-                    start = pos + 1;
-                }
-                pos++;
-            }
-
-        } finally {
-            if (buffer != null)
-                buffer.release();
-        }
-    }
-
-    private static void copyExtendedAttribute(int ofd, byte[] name, int nfd)
-        throws UnixException
-    {
-        int size = fgetxattr(ofd, name, 0L, 0);
-        NativeBuffer buffer = NativeBuffers.getNativeBuffer(size);
-        try {
-            long address = buffer.address();
-            size = fgetxattr(ofd, name, address, size);
-            fsetxattr(nfd, name, address, size);
-        } finally {
-            buffer.release();
-        }
-    }
-}
--- ./jdk/src/solaris/classes/sun/nio/fs/BsdWatchService.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/BsdWatchService.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,463 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.fs;
-
-import java.nio.file.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import java.io.IOException;
-import sun.misc.Unsafe;
-
-import static sun.nio.fs.UnixNativeDispatcher.*;
-import static sun.nio.fs.UnixConstants.*;
-
-/**
- * Bsd implementation of WatchService based on inotify.
- *
- * In summary a background thread polls inotify plus a socket used for the wakeup
- * mechanism. Requests to add or remove a watch, or close the watch service,
- * cause the thread to wakeup and process the request. Events are processed
- * by the thread which causes it to signal/queue the corresponding watch keys.
- */
-
-class BsdWatchService
-    extends AbstractWatchService
-{
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
-
-    // background thread to read change events
-    private final Poller poller;
-
-    BsdWatchService(UnixFileSystem fs) throws IOException {
-        // initialize inotify
-        int ifd = - 1;
-        try {
-            ifd = inotifyInit();
-        } catch (UnixException x) {
-            throw new IOException(x.errorString());
-        }
-
-        // configure inotify to be non-blocking
-        // create socketpair used in the close mechanism
-        int sp[] = new int[2];
-        try {
-            configureBlocking(ifd, false);
-            socketpair(sp);
-            configureBlocking(sp[0], false);
-        } catch (UnixException x) {
-            UnixNativeDispatcher.close(ifd);
-            throw new IOException(x.errorString());
-        }
-
-        this.poller = new Poller(fs, this, ifd, sp);
-        this.poller.start();
-    }
-
-    @Override
-    WatchKey register(Path dir,
-                      WatchEvent.Kind<?>[] events,
-                      WatchEvent.Modifier... modifiers)
-         throws IOException
-    {
-        // delegate to poller
-        return poller.register(dir, events, modifiers);
-    }
-
-    @Override
-    void implClose() throws IOException {
-        // delegate to poller
-        poller.close();
-    }
-
-    /**
-     * WatchKey implementation
-     */
-    private static class BsdWatchKey extends AbstractWatchKey {
-        // inotify descriptor
-        private final int ifd;
-        // watch descriptor
-        private volatile int wd;
-
-        BsdWatchKey(UnixPath dir, BsdWatchService watcher, int ifd, int wd) {
-            super(dir, watcher);
-            this.ifd = ifd;
-            this.wd = wd;
-        }
-
-        int descriptor() {
-            return wd;
-        }
-
-        void invalidate(boolean remove) {
-            if (remove) {
-                try {
-                    inotifyRmWatch(ifd, wd);
-                } catch (UnixException x) {
-                    // ignore
-                }
-            }
-            wd = -1;
-        }
-
-        @Override
-        public boolean isValid() {
-            return (wd != -1);
-        }
-
-        @Override
-        public void cancel() {
-            if (isValid()) {
-                // delegate to poller
-                ((BsdWatchService)watcher()).poller.cancel(this);
-            }
-        }
-    }
-
-    /**
-     * Background thread to read from inotify
-     */
-    private static class Poller extends AbstractPoller {
-        /**
-         * struct inotify_event {
-         *     int          wd;
-         *     uint32_t     mask;
-         *     uint32_t     len;
-         *     char name    __flexarr;  // present if len > 0
-         * } act_t;
-         */
-        private static final int SIZEOF_INOTIFY_EVENT  = eventSize();
-        private static final int[] offsets             = eventOffsets();
-        private static final int OFFSETOF_WD           = offsets[0];
-        private static final int OFFSETOF_MASK         = offsets[1];
-        private static final int OFFSETOF_LEN          = offsets[3];
-        private static final int OFFSETOF_NAME         = offsets[4];
-
-        private static final int IN_MODIFY          = 0x00000002;
-        private static final int IN_ATTRIB          = 0x00000004;
-        private static final int IN_MOVED_FROM      = 0x00000040;
-        private static final int IN_MOVED_TO        = 0x00000080;
-        private static final int IN_CREATE          = 0x00000100;
-        private static final int IN_DELETE          = 0x00000200;
-
-        private static final int IN_UNMOUNT         = 0x00002000;
-        private static final int IN_Q_OVERFLOW      = 0x00004000;
-        private static final int IN_IGNORED         = 0x00008000;
-
-        // sizeof buffer for when polling inotify
-        private static final int BUFFER_SIZE = 8192;
-
-        private final UnixFileSystem fs;
-        private final BsdWatchService watcher;
-
-        // inotify file descriptor
-        private final int ifd;
-        // socketpair used to shutdown polling thread
-        private final int socketpair[];
-        // maps watch descriptor to Key
-        private final Map<Integer,BsdWatchKey> wdToKey;
-        // address of read buffer
-        private final long address;
-
-        Poller(UnixFileSystem fs, BsdWatchService watcher, int ifd, int[] sp) {
-            this.fs = fs;
-            this.watcher = watcher;
-            this.ifd = ifd;
-            this.socketpair = sp;
-            this.wdToKey = new HashMap<Integer,BsdWatchKey>();
-            this.address = unsafe.allocateMemory(BUFFER_SIZE);
-        }
-
-        @Override
-        void wakeup() throws IOException {
-            // write to socketpair to wakeup polling thread
-            try {
-                write(socketpair[1], address, 1);
-            } catch (UnixException x) {
-                throw new IOException(x.errorString());
-            }
-        }
-
-        @Override
-        Object implRegister(Path obj,
-                            Set<? extends WatchEvent.Kind<?>> events,
-                            WatchEvent.Modifier... modifiers)
-        {
-            UnixPath dir = (UnixPath)obj;
-
-            int mask = 0;
-            for (WatchEvent.Kind<?> event: events) {
-                if (event == StandardWatchEventKinds.ENTRY_CREATE) {
-                    mask |= IN_CREATE | IN_MOVED_TO;
-                    continue;
-                }
-                if (event == StandardWatchEventKinds.ENTRY_DELETE) {
-                    mask |= IN_DELETE | IN_MOVED_FROM;
-                    continue;
-                }
-                if (event == StandardWatchEventKinds.ENTRY_MODIFY) {
-                    mask |= IN_MODIFY | IN_ATTRIB;
-                    continue;
-                }
-            }
-
-            // no modifiers supported at this time
-            if (modifiers.length > 0) {
-                for (WatchEvent.Modifier modifier: modifiers) {
-                    if (modifier == null)
-                        return new NullPointerException();
-                    if (modifier instanceof com.sun.nio.file.SensitivityWatchEventModifier)
-                        continue; // ignore
-                    return new UnsupportedOperationException("Modifier not supported");
-                }
-            }
-
-            // check file is directory
-            UnixFileAttributes attrs = null;
-            try {
-                attrs = UnixFileAttributes.get(dir, true);
-            } catch (UnixException x) {
-                return x.asIOException(dir);
-            }
-            if (!attrs.isDirectory()) {
-                return new NotDirectoryException(dir.getPathForExecptionMessage());
-            }
-
-            // register with inotify (replaces existing mask if already registered)
-            int wd = -1;
-            try {
-                NativeBuffer buffer =
-                    NativeBuffers.asNativeBuffer(dir.getByteArrayForSysCalls());
-                try {
-                    wd = inotifyAddWatch(ifd, buffer.address(), mask);
-                } finally {
-                    buffer.release();
-                }
-            } catch (UnixException x) {
-                if (x.errno() == ENOSPC) {
-                    return new IOException("User limit of inotify watches reached");
-                }
-                return x.asIOException(dir);
-            }
-
-            // ensure watch descriptor is in map
-            BsdWatchKey key = wdToKey.get(wd);
-            if (key == null) {
-                key = new BsdWatchKey(dir, watcher, ifd, wd);
-                wdToKey.put(wd, key);
-            }
-            return key;
-        }
-
-        // cancel single key
-        @Override
-        void implCancelKey(WatchKey obj) {
-            BsdWatchKey key = (BsdWatchKey)obj;
-            if (key.isValid()) {
-                wdToKey.remove(key.descriptor());
-                key.invalidate(true);
-            }
-        }
-
-        // close watch service
-        @Override
-        void implCloseAll() {
-            // invalidate all keys
-            for (Map.Entry<Integer,BsdWatchKey> entry: wdToKey.entrySet()) {
-                entry.getValue().invalidate(true);
-            }
-            wdToKey.clear();
-
-            // free resources
-            unsafe.freeMemory(address);
-            UnixNativeDispatcher.close(socketpair[0]);
-            UnixNativeDispatcher.close(socketpair[1]);
-            UnixNativeDispatcher.close(ifd);
-        }
-
-        /**
-         * Poller main loop
-         */
-        @Override
-        public void run() {
-            try {
-                for (;;) {
-                    int nReady, bytesRead;
-
-                    // wait for close or inotify event
-                    nReady = poll(ifd, socketpair[0]);
-
-                    // read from inotify
-                    try {
-                        bytesRead = read(ifd, address, BUFFER_SIZE);
-                    } catch (UnixException x) {
-                        if (x.errno() != EAGAIN)
-                            throw x;
-                        bytesRead = 0;
-                    }
-
-                    // process any pending requests
-                    if ((nReady > 1) || (nReady == 1 && bytesRead == 0)) {
-                        try {
-                            read(socketpair[0], address, BUFFER_SIZE);
-                            boolean shutdown = processRequests();
-                            if (shutdown)
-                                break;
-                        } catch (UnixException x) {
-                            if (x.errno() != UnixConstants.EAGAIN)
-                                throw x;
-                        }
-                    }
-
-                    // iterate over buffer to decode events
-                    int offset = 0;
-                    while (offset < bytesRead) {
-                        long event = address + offset;
-                        int wd = unsafe.getInt(event + OFFSETOF_WD);
-                        int mask = unsafe.getInt(event + OFFSETOF_MASK);
-                        int len = unsafe.getInt(event + OFFSETOF_LEN);
-
-                        // file name
-                        UnixPath name = null;
-                        if (len > 0) {
-                            int actual = len;
-
-                            // null-terminated and maybe additional null bytes to
-                            // align the next event
-                            while (actual > 0) {
-                                long last = event + OFFSETOF_NAME + actual - 1;
-                                if (unsafe.getByte(last) != 0)
-                                    break;
-                                actual--;
-                            }
-                            if (actual > 0) {
-                                byte[] buf = new byte[actual];
-                                unsafe.copyMemory(null, event + OFFSETOF_NAME,
-                                    buf, Unsafe.ARRAY_BYTE_BASE_OFFSET, actual);
-                                name = new UnixPath(fs, buf);
-                            }
-                        }
-
-                        // process event
-                        processEvent(wd, mask, name);
-
-                        offset += (SIZEOF_INOTIFY_EVENT + len);
-                    }
-                }
-            } catch (UnixException x) {
-                x.printStackTrace();
-            }
-        }
-
-
-        /**
-         * map inotify event to WatchEvent.Kind
-         */
-        private WatchEvent.Kind<?> maskToEventKind(int mask) {
-            if ((mask & IN_MODIFY) > 0)
-                return StandardWatchEventKinds.ENTRY_MODIFY;
-            if ((mask & IN_ATTRIB) > 0)
-                return StandardWatchEventKinds.ENTRY_MODIFY;
-            if ((mask & IN_CREATE) > 0)
-                return StandardWatchEventKinds.ENTRY_CREATE;
-            if ((mask & IN_MOVED_TO) > 0)
-                return StandardWatchEventKinds.ENTRY_CREATE;
-            if ((mask & IN_DELETE) > 0)
-                return StandardWatchEventKinds.ENTRY_DELETE;
-            if ((mask & IN_MOVED_FROM) > 0)
-                return StandardWatchEventKinds.ENTRY_DELETE;
-            return null;
-        }
-
-        /**
-         * Process event from inotify
-         */
-        private void processEvent(int wd, int mask, final UnixPath name) {
-            // overflow - signal all keys
-            if ((mask & IN_Q_OVERFLOW) > 0) {
-                for (Map.Entry<Integer,BsdWatchKey> entry: wdToKey.entrySet()) {
-                    entry.getValue()
-                        .signalEvent(StandardWatchEventKinds.OVERFLOW, null);
-                }
-                return;
-            }
-
-            // lookup wd to get key
-            BsdWatchKey key = wdToKey.get(wd);
-            if (key == null)
-                return; // should not happen
-
-            // file deleted
-            if ((mask & IN_IGNORED) > 0) {
-                wdToKey.remove(wd);
-                key.invalidate(false);
-                key.signal();
-                return;
-            }
-
-            // event for directory itself
-            if (name == null)
-                return;
-
-            // map to event and queue to key
-            WatchEvent.Kind<?> kind = maskToEventKind(mask);
-            if (kind != null) {
-                key.signalEvent(kind, name);
-            }
-        }
-    }
-
-    // -- native methods --
-
-    // sizeof inotify_event
-    private static native int eventSize();
-
-    // offsets of inotify_event
-    private static native int[] eventOffsets();
-
-    private static native int inotifyInit() throws UnixException;
-
-    private static native int inotifyAddWatch(int fd, long pathAddress, int mask)
-        throws UnixException;
-
-    private static native void inotifyRmWatch(int fd, int wd)
-        throws UnixException;
-
-    private static native void configureBlocking(int fd, boolean blocking)
-        throws UnixException;
-
-    private static native void socketpair(int[] sv) throws UnixException;
-
-    private static native int poll(int fd1, int fd2) throws UnixException;
-
-    static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
-    }
-}
--- ./jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java	2011-05-26 18:56:22.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java	2011-04-22 23:08:38.000000000 -0700
@@ -68,6 +68,8 @@
             return createProvider("sun.nio.fs.SolarisFileSystemProvider");
         if (osname.equals("Linux"))
             return createProvider("sun.nio.fs.LinuxFileSystemProvider");
+        if (osname.endsWith("BSD") || osname.equals("Darwin"))
+            return createProvider("sun.nio.fs.BsdFileSystemProvider");
         throw new AssertionError("Platform not recognized");
     }
 }
--- ./jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	2011-05-26 18:56:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java	2011-04-22 23:08:38.000000000 -0700
@@ -119,7 +119,11 @@
     }
 
     static boolean isBSD() {
-        return osname.equals("Linux");
+	return (osname.equals("Linux") ||
+		osname.equals("FreeBSD") ||
+		osname.equals("Darwin") ||
+		osname.equals("NetBSD") ||
+		osname.equals("OpenBSD"));
     }
 
     static final int UNINITIALIZED = -1;
@@ -134,8 +138,8 @@
     };
 
     String[] lpcAllCom = {
-        "/usr/sbin/lpc status | grep : | sed -e 's/://'",
-        "/usr/sbin/lpc -a status | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}' | sort"
+        "/usr/sbin/lpc status all | grep : | sed -e 's/://'",
+        "/usr/sbin/lpc status all | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}' | sort"
     };
 
     String[] lpcNameCom = {
@@ -145,7 +149,7 @@
 
 
     static int getBSDCommandIndex() {
-        String command  = "/usr/sbin/lpc status";
+        String command  = "/usr/sbin/lpc status all";
         String[] names = execCmd(command);
 
         if ((names == null) || (names.length == 0)) {
--- ./jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java	2011-04-22 23:08:38.000000000 -0700
@@ -40,9 +40,6 @@
     // temp directory for socket file
     private static final String tmpdir = System.getProperty("java.io.tmpdir");
 
-    // Indicates if this machine uses the old BsdThreads
-    static boolean isBsdThreads;
-
     // The patch to the socket file created by the target VM
     String path;
 
@@ -67,25 +64,10 @@
         // Then we attempt to find the socket file again.
         path = findSocketFile(pid);
         if (path == null) {
-            File f = createAttachFile(pid);
+            File f = new File(tmpdir, ".attach_pid" + pid);
+	    createAttachFile(f.getPath());
             try {
-                // On BsdThreads each thread is a process and we don't have the
-                // pid of the VMThread which has SIGQUIT unblocked. To workaround
-                // this we get the pid of the "manager thread" that is created
-                // by the first call to pthread_create. This is parent of all
-                // threads (except the initial thread).
-                if (isBsdThreads) {
-                    int mpid;
-                    try {
-                        mpid = getBsdThreadsManager(pid);
-                    } catch (IOException x) {
-                        throw new AttachNotSupportedException(x.getMessage());
-                    }
-                    assert(mpid >= 1);
-                    sendQuitToChildrenOf(mpid);
-                } else {
-                    sendQuitTo(pid);
-                }
+                sendQuitTo(pid);
 
                 // give the target VM time to start the attach mechanism
                 int i = 0;
@@ -267,31 +249,8 @@
         // First check for a .java_pid<pid> file in the working directory
         // of the target process
         String fn = ".java_pid" + pid;
-        String path = "/proc/" + pid + "/cwd/" + fn;
-        File f = new File(path);
-        if (!f.exists()) {
-            // Not found, so try temp directory
-            f = new File(tmpdir, fn);
-            path = f.exists() ? f.getPath() : null;
-        }
-        return path;
-    }
-
-    // On Solaris/Bsd a simple handshake is used to start the attach mechanism
-    // if not already started. The client creates a .attach_pid<pid> file in the
-    // target VM's working directory (or temp directory), and the SIGQUIT handler
-    // checks for the file.
-    private File createAttachFile(int pid) throws IOException {
-        String fn = ".attach_pid" + pid;
-        String path = "/proc/" + pid + "/cwd/" + fn;
-        File f = new File(path);
-        try {
-            f.createNewFile();
-        } catch (IOException x) {
-            f = new File(tmpdir, fn);
-            f.createNewFile();
-        }
-        return f;
+        File f = new File(tmpdir, path);
+	return f.exists() ? f.getPath() : null;
     }
 
     /*
@@ -316,12 +275,6 @@
 
     //-- native methods
 
-    static native boolean isBsdThreads();
-
-    static native int getBsdThreadsManager(int pid) throws IOException;
-
-    static native void sendQuitToChildrenOf(int pid) throws IOException;
-
     static native void sendQuitTo(int pid) throws IOException;
 
     static native void checkPermissions(String path) throws IOException;
@@ -336,8 +289,9 @@
 
     static native void write(int fd, byte buf[], int off, int bufLen) throws IOException;
 
+    static native void createAttachFile(String path);
+
     static {
         System.loadLibrary("attach");
-        isBsdThreads = isBsdThreads();
     }
 }
--- ./jdk/src/solaris/demo/jvmti/hprof/hprof_md.c	2011-05-26 18:56:26.000000000 -0700
+++ ./jdk/src/solaris/demo/jvmti/hprof/hprof_md.c	2011-04-22 23:08:38.000000000 -0700
@@ -33,7 +33,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#ifndef LINUX
+#if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
 #include <procfs.h>
 #endif
 
@@ -53,6 +53,7 @@
 #include <time.h>
 
 #include "jni.h"
+#include "jvm_md.h"
 #include "hprof.h"
 
 int
@@ -76,7 +77,7 @@
 void
 md_init(void)
 {
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     /* No Hi-Res timer option? */
 #else
     if ( gdata->micro_state_accounting ) {
@@ -238,7 +239,7 @@
 jlong
 md_get_microsecs(void)
 {
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     return (jlong)(md_timeofday() * (jlong)1000); /* Milli to micro */
 #else
     return (jlong)(gethrtime()/(hrtime_t)1000); /* Nano seconds to micro seconds */
@@ -256,7 +257,7 @@
 jlong
 md_get_thread_cpu_timemillis(void)
 {
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     return md_timeofday();
 #else
     return (jlong)(gethrvtime()/1000); /* Nano seconds to milli seconds */
@@ -271,7 +272,7 @@
     Dl_info dlinfo;
 
     libdir[0] = 0;
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
     addr = (void*)&Agent_OnLoad;
 #else
     /* Just using &Agent_OnLoad will get the first external symbol with
@@ -379,9 +380,9 @@
 
     /* Construct path to library */
     if (pnamelen == 0) {
-        (void)snprintf(holder, holderlen, "lib%s.so", fname);
+        (void)snprintf(holder, holderlen, "lib%s" JNI_LIB_SUFFIX, fname);
     } else {
-        (void)snprintf(holder, holderlen, "%s/lib%s.so", pname, fname);
+        (void)snprintf(holder, holderlen, "%s/lib%s" JNI_LIB_SUFFIX, pname, fname);
     }
 }
 
--- ./jdk/src/solaris/instrument/EncodingSupport_md.c	2011-05-26 18:56:34.000000000 -0700
+++ ./jdk/src/solaris/instrument/EncodingSupport_md.c	2011-04-22 23:08:38.000000000 -0700
@@ -28,7 +28,10 @@
 #include <string.h>
 #include <ctype.h>
 #include <locale.h>
+#ifndef __OpenBSD__
+#define HAVE_NL_LANGINFO
 #include <langinfo.h>
+#endif
 #include <iconv.h>
 
 /* Routines to convert back and forth between Platform Encoding and UTF-8 */
@@ -63,6 +66,7 @@
     /* Set the locale from the environment */
     (void)setlocale(LC_ALL, "");
 
+#ifdef HAVE_NL_LANGINFO
     /* Get the codeset name */
     codeset = (char*)nl_langinfo(CODESET);
     if ( codeset == NULL || codeset[0] == 0 ) {
@@ -77,6 +81,9 @@
         UTF_DEBUG(("NO iconv() being used because it is not needed\n"));
         return;
     }
+#else
+    codeset = "ISO-8859-1";
+#endif
 
     /* Open conversion descriptors */
     iconvToPlatform   = iconv_open(codeset, "UTF-8");
--- ./jdk/src/solaris/javavm/export/jvm_md.h	2011-05-26 18:56:34.000000000 -0700
+++ ./jdk/src/solaris/javavm/export/jvm_md.h	2011-04-22 23:08:38.000000000 -0700
@@ -41,7 +41,14 @@
 #define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}
 
 #define JNI_LIB_PREFIX "lib"
+#ifdef __APPLE__
+#define JNI_LIB_SUFFIX ".dylib"
+#define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME "." VERSION JNI_LIB_SUFFIX
+#else
 #define JNI_LIB_SUFFIX ".so"
+#define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX "." VERSION
+#endif
+#define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX
 
 #define JVM_MAXPATHLEN MAXPATHLEN
 
@@ -68,7 +75,7 @@
 #define JVM_O_O_APPEND   O_APPEND
 #define JVM_O_EXCL       O_EXCL
 #define JVM_O_CREAT      O_CREAT
-#define JVM_O_DELETE     0x10000
+#define JVM_O_DELETE     0x10000000
 
 /* Signals */
 
--- ./jdk/src/solaris/native/com/sun/management/BsdOperatingSystem.c	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/native/com/sun/management/BsdOperatingSystem.c	1969-12-31 16:00:00.000000000 -0800
@@ -1,332 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <pthread.h>
-#include "com_sun_management_UnixOperatingSystem.h"
-
-struct ticks {
-    uint64_t  used;
-    uint64_t  usedKernel;
-    uint64_t  total;
-};
-
-typedef struct ticks ticks;
-
-typedef enum {
-    CPU_LOAD_VM_ONLY,
-    CPU_LOAD_GLOBAL,
-} CpuLoadTarget;
-
-static struct perfbuf {
-    int   nProcs;
-    ticks jvmTicks;
-    ticks cpuTicks;
-    ticks *cpus;
-} counters;
-
-#define DEC_64 "%lld"
-
-static void next_line(FILE *f) {
-    while (fgetc(f) != '\n');
-}
-
-/**
- * Return the total number of ticks since the system was booted.
- * If the usedTicks parameter is not NULL, it will be filled with
- * the number of ticks spent on actual processes (user, system or
- * nice processes) since system boot. Note that this is the total number
- * of "executed" ticks on _all_ CPU:s, that is on a n-way system it is
- * n times the number of ticks that has passed in clock time.
- *
- * Returns a negative value if the reading of the ticks failed.
- */
-static int get_totalticks(int which, ticks *pticks) {
-    FILE         *fh;
-    uint64_t        userTicks, niceTicks, systemTicks, idleTicks;
-    int             n;
-
-    if((fh = fopen("/proc/stat", "r")) == NULL) {
-        return -1;
-    }
-
-    n = fscanf(fh, "cpu " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64,
-           &userTicks, &niceTicks, &systemTicks, &idleTicks);
-
-    // Move to next line
-    next_line(fh);
-
-    //find the line for requested cpu faster to just iterate linefeeds?
-    if (which != -1) {
-        int i;
-        for (i = 0; i < which; i++) {
-            if (fscanf(fh, "cpu%*d " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64, &userTicks, &niceTicks, &systemTicks, &idleTicks) != 4) {
-                fclose(fh);
-                return -2;
-            }
-            next_line(fh);
-        }
-        n = fscanf(fh, "cpu%*d " DEC_64 " " DEC_64 " " DEC_64 " " DEC_64 "\n",
-           &userTicks, &niceTicks, &systemTicks, &idleTicks);
-    }
-
-    fclose(fh);
-    if (n != 4) {
-        return -2;
-    }
-
-    pticks->used       = userTicks + niceTicks;
-    pticks->usedKernel = systemTicks;
-    pticks->total      = userTicks + niceTicks + systemTicks + idleTicks;
-
-    return 0;
-}
-
-static int vread_statdata(const char *procfile, const char *fmt, va_list args) {
-    FILE    *f;
-    int     n;
-    char     buf[2048];
-
-    if ((f = fopen(procfile, "r")) == NULL) {
-        return -1;
-    }
-
-    if ((n = fread(buf, 1, sizeof(buf), f)) != -1) {
-    char *tmp;
-
-    buf[n-1] = '\0';
-    /** skip through pid and exec name. the exec name _could be wacky_ (renamed) and
-     *  make scanf go mupp.
-     */
-    if ((tmp = strrchr(buf, ')')) != NULL) {
-        // skip the ')' and the following space but check that the buffer is long enough
-        tmp += 2;
-        if (tmp < buf + n) {
-        n = vsscanf(tmp, fmt, args);
-        }
-    }
-    }
-
-    fclose(f);
-
-    return n;
-}
-
-static int read_statdata(const char *procfile, const char *fmt, ...) {
-    int       n;
-    va_list args;
-
-    va_start(args, fmt);
-    n = vread_statdata(procfile, fmt, args);
-    va_end(args);
-    return n;
-}
-
-/** read user and system ticks from a named procfile, assumed to be in 'stat' format then. */
-static int read_ticks(const char *procfile, uint64_t *userTicks, uint64_t *systemTicks) {
-    return read_statdata(procfile, "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u "DEC_64" "DEC_64,
-             userTicks, systemTicks
-             );
-}
-
-/**
- * Return the number of ticks spent in any of the processes belonging
- * to the JVM on any CPU.
- */
-static int get_jvmticks(ticks *pticks) {
-    uint64_t userTicks;
-    uint64_t systemTicks;
-
-    if (read_ticks("/proc/self/stat", &userTicks, &systemTicks) < 0) {
-        return -1;
-    }
-
-    // get the total
-    if (get_totalticks(-1, pticks) < 0) {
-        return -1;
-    }
-
-    pticks->used       = userTicks;
-    pticks->usedKernel = systemTicks;
-
-    return 0;
-}
-
-/**
- * This method must be called first, before any data can be gathererd.
- */
-int perfInit() {
-    static int initialized=1;
-
-    if (!initialized) {
-        int  i;
-
-        int n = sysconf(_SC_NPROCESSORS_ONLN);
-        if (n <= 0) {
-            n = 1;
-        }
-
-        counters.cpus = calloc(n,sizeof(ticks));
-        if (counters.cpus != NULL)  {
-            // For the CPU load
-            get_totalticks(-1, &counters.cpuTicks);
-
-            for (i = 0; i < n; i++) {
-                get_totalticks(i, &counters.cpus[i]);
-            }
-            // For JVM load
-            get_jvmticks(&counters.jvmTicks);
-            initialized = 1;
-        }
-    }
-
-    return initialized ? 0 : -1;
-}
-
-#define MAX(a,b) (a>b?a:b)
-#define MIN(a,b) (a<b?a:b)
-
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-
-/**
- * Return the load of the CPU as a double. 1.0 means the CPU process uses all
- * available time for user or system processes, 0.0 means the CPU uses all time
- * being idle.
- *
- * Returns a negative value if there is a problem in determining the CPU load.
- */
-
-static double get_cpuload_internal(int which, double *pkernelLoad, CpuLoadTarget target) {
-    uint64_t udiff, kdiff, tdiff;
-    ticks *pticks, tmp;
-    double user_load = -1.0;
-    int failed = 0;
-
-    *pkernelLoad = 0.0;
-
-    pthread_mutex_lock(&lock);
-
-    if(perfInit() == 0) {
-
-        if (target == CPU_LOAD_VM_ONLY) {
-            pticks = &counters.jvmTicks;
-        } else if (which == -1) {
-            pticks = &counters.cpuTicks;
-        } else {
-            pticks = &counters.cpus[which];
-        }
-
-        tmp = *pticks;
-
-        if (target == CPU_LOAD_VM_ONLY) {
-            if (get_jvmticks(pticks) != 0) {
-                failed = 1;
-            }
-        } else if (get_totalticks(which, pticks) < 0) {
-            failed = 1;
-        }
-
-        if(!failed) {
-            // seems like we sometimes end up with less kernel ticks when
-            // reading /proc/self/stat a second time, timing issue between cpus?
-            if (pticks->usedKernel < tmp.usedKernel) {
-                kdiff = 0;
-            } else {
-                kdiff = pticks->usedKernel - tmp.usedKernel;
-            }
-            tdiff = pticks->total - tmp.total;
-            udiff = pticks->used - tmp.used;
-
-            if (tdiff == 0) {
-                user_load = 0;
-            } else {
-                if (tdiff < (udiff + kdiff)) {
-                    tdiff = udiff + kdiff;
-                }
-                *pkernelLoad = (kdiff / (double)tdiff);
-                // BUG9044876, normalize return values to sane values
-                *pkernelLoad = MAX(*pkernelLoad, 0.0);
-                *pkernelLoad = MIN(*pkernelLoad, 1.0);
-
-                user_load = (udiff / (double)tdiff);
-                user_load = MAX(user_load, 0.0);
-                user_load = MIN(user_load, 1.0);
-            }
-        }
-    }
-    pthread_mutex_unlock(&lock);
-    return user_load;
-}
-
-double get_cpu_load(int which) {
-    double u, s;
-    u = get_cpuload_internal(which, &s, CPU_LOAD_GLOBAL);
-    if (u < 0) {
-        return -1.0;
-    }
-    // Cap total systemload to 1.0
-    return MIN((u + s), 1.0);
-}
-
-double get_process_load() {
-    double u, s;
-    u = get_cpuload_internal(-1, &s, CPU_LOAD_VM_ONLY);
-    if (u < 0) {
-        return -1.0;
-    }
-    return u + s;
-}
-
-JNIEXPORT jdouble JNICALL
-Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
-(JNIEnv *env, jobject dummy)
-{
-    if(perfInit() == 0) {
-        return get_cpu_load(-1);
-    } else {
-        return -1.0;
-    }
-}
-
-JNIEXPORT jdouble JNICALL
-Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
-(JNIEnv *env, jobject dummy)
-{
-    if(perfInit() == 0) {
-        return get_process_load();
-    } else {
-        return -1.0;
-    }
-}
--- ./jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	2011-05-26 18:56:35.000000000 -0700
+++ ./jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	2011-04-22 23:08:38.000000000 -0700
@@ -32,10 +32,16 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#if defined(_ALLBSD_SOURCE)
+#include <sys/sysctl.h>
+#else
 #include <sys/swap.h>
+#endif
 #include <sys/resource.h>
 #include <sys/times.h>
+#ifndef _ALLBSD_SOURCE
 #include <sys/sysinfo.h>
+#endif
 #include <ctype.h>
 #include <dirent.h>
 #include <errno.h>
@@ -46,16 +52,22 @@
 
 static jlong page_size = 0;
 
+#if defined(_ALLBSD_SOURCE)
+#define MB	(1024UL * 1024UL)
+#else
+
 /* This gets us the new structured proc interfaces of 5.6 & later */
 /* - see comment in <sys/procfs.h> */
 #define _STRUCTURED_PROC 1
 #include <sys/procfs.h>
 
+#endif /* _ALLBSD_SOURCE */
+
 static struct dirent* read_dir(DIR* dirp, struct dirent* entry) {
 #ifdef __solaris__
     struct dirent* dbuf = readdir(dirp);
     return dbuf;
-#else /* __linux__ */
+#else /* __linux__ || _ALLBSD_SOURCE */
     struct dirent* p;
     if (readdir_r(dirp, entry, &p) == 0) {
         return p;
@@ -124,7 +136,7 @@
     free(strtab);
     return available ? ((jlong)avail * page_size) :
                        ((jlong)total * page_size);
-#else /* __linux__ */
+#elif defined(__linux__)
     int ret;
     FILE *fp;
     jlong total = 0, avail = 0;
@@ -138,6 +150,13 @@
     avail = (jlong)si.freeswap * si.mem_unit;
 
     return available ? avail : total;
+#else /* _ALLBSD_SOURCE */
+    /*
+     * XXXBSD: there's no way available to get swap info in
+     *         FreeBSD.  Usage of libkvm is not an option here
+     */
+    // throw_internal_error(env, "Unimplemented in FreeBSD");
+    return (0);
 #endif
 }
 
@@ -179,7 +198,7 @@
 
     JVM_Close(fd);
     return (jlong) psinfo.pr_size * 1024;
-#else /* __linux__ */
+#elif defined(__linux__)
     FILE *fp;
     unsigned long vsize = 0;
 
@@ -197,6 +216,12 @@
 
     fclose(fp);
     return (jlong)vsize;
+#else /* _ALLBSD_SOURCE */
+    /*
+     * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
+     */
+    // throw_internal_error(env, "Unimplemented in FreeBSD");
+    return (64 * MB);
 #endif
 }
 
@@ -222,9 +247,13 @@
     jlong cpu_time_ns;
     struct tms time;
 
-#ifdef __solaris__
+    /*
+     * BSDNOTE: FreeBSD implements _SC_CLK_TCK since FreeBSD 5, so
+     *          add a magic to handle it
+     */
+#if defined(__solaris__) || defined(_SC_CLK_TCK)
     clk_tck = (jlong) sysconf(_SC_CLK_TCK);
-#else /* __linux__ */
+#elif defined(__linux__) || defined(_ALLBSD_SOURCE)
     clk_tck = 100;
 #endif
     if (clk_tck == -1) {
@@ -244,22 +273,51 @@
 Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
   (JNIEnv *env, jobject mbean)
 {
+#ifdef _ALLBSD_SOURCE
+    /*
+     * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
+     */
+    // throw_internal_error(env, "Unimplemented in FreeBSD");
+    return (128 * MB);
+#else
     jlong num_avail_physical_pages = sysconf(_SC_AVPHYS_PAGES);
     return (num_avail_physical_pages * page_size);
+#endif
 }
 
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_UnixOperatingSystem_getTotalPhysicalMemorySize
   (JNIEnv *env, jobject mbean)
 {
+#ifdef _ALLBSD_SOURCE
+    jlong result;
+    int mib[2];
+    size_t rlen;
+
+    mib[0] = CTL_HW;
+    mib[1] = HW_PHYSMEM;
+    rlen = sizeof(result);
+    if (sysctl(mib, 2, &result, &rlen, NULL, 0) == -1)
+	result = 256 * MB;
+
+    return (result);
+#else
     jlong num_physical_pages = sysconf(_SC_PHYS_PAGES);
     return (num_physical_pages * page_size);
+#endif
 }
 
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
   (JNIEnv *env, jobject mbean)
 {
+#ifdef _ALLBSD_SOURCE
+    /*
+     * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
+     */
+    // throw_internal_error(env, "Unimplemented in FreeBSD");
+    return (100);
+#else /* solaris/linux */
     DIR *dirp;
     struct dirent dbuf;
     struct dirent* dentp;
@@ -282,6 +340,7 @@
     closedir(dirp);
     // subtract by 1 which was the fd open for this implementation
     return (fds - 1);
+#endif
 }
 
 JNIEXPORT jlong JNICALL
--- ./jdk/src/solaris/native/java/io/UnixFileSystem_md.c	2011-05-26 18:56:38.000000000 -0700
+++ ./jdk/src/solaris/native/java/io/UnixFileSystem_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -41,6 +41,12 @@
 #include "java_io_FileSystem.h"
 #include "java_io_UnixFileSystem.h"
 
+#if defined(_ALLBSD_SOURCE)
+#define dirent64 dirent
+#define readdir64_r readdir_r
+#define stat64 stat
+#define statvfs64 statvfs
+#endif
 
 /* -- Field IDs -- */
 
@@ -140,7 +146,6 @@
     return rv;
 }
 
-
 JNIEXPORT jboolean JNICALL
 Java_java_io_UnixFileSystem_setPermission(JNIEnv *env, jobject this,
                                           jobject file,
--- ./jdk/src/solaris/native/java/io/canonicalize_md.c	2011-05-26 18:56:38.000000000 -0700
+++ ./jdk/src/solaris/native/java/io/canonicalize_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -33,7 +33,9 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <limits.h>
+#if !defined(_ALLBSD_SOURCE)
 #include <alloca.h>
+#endif
 
 
 /* Note: The comments in this file use the terminology
--- ./jdk/src/solaris/native/java/io/io_util_md.c	2011-05-26 18:56:38.000000000 -0700
+++ ./jdk/src/solaris/native/java/io/io_util_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -36,7 +36,7 @@
     WITH_PLATFORM_STRING(env, path, ps) {
         FD fd;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
         /* Remove trailing slashes, since the kernel won't */
         char *p = (char *)ps + strlen(ps) - 1;
         while ((p > ps) && (*p == '/'))
--- ./jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -28,6 +28,11 @@
 #include "jni.h"
 #include "jni_util.h"
 
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#endif
+
 JNIEXPORT jobjectArray JNICALL
 Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign)
 {
@@ -37,7 +42,9 @@
      * no standard (not even de-facto) header file where the
      * declaration is to be found.  See:
      * http://www.opengroup.org/onlinepubs/007908799/xbd/envvar.html */
+#ifndef __APPLE__
     extern char ** environ; /* environ[i] looks like: VAR=VALUE\0 */
+#endif
 
     jsize count = 0;
     jsize i, j;
@@ -46,7 +53,7 @@
 
     for (i = 0; environ[i]; i++) {
         /* Ignore corrupted environment variables */
-        if (strchr(environ[i], '=') != NULL)
+        if (strchr(environ[i], '=') != NULL && *environ[i] != '=')
             count++;
     }
 
@@ -56,7 +63,7 @@
     for (i = 0, j = 0; environ[i]; i++) {
         const char * varEnd = strchr(environ[i], '=');
         /* Ignore corrupted environment variables */
-        if (varEnd != NULL) {
+        if (varEnd != NULL && varEnd != environ[i]) {
             jbyteArray var, val;
             const char * valBeg = varEnd + 1;
             jsize varLength = varEnd - environ[i];
--- ./jdk/src/solaris/native/java/lang/UNIXProcess_md.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/lang/UNIXProcess_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -40,7 +40,11 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <ctype.h>
+#ifdef _ALLBSD_SOURCE
+#include <sys/wait.h>
+#else
 #include <wait.h>
+#endif
 #include <signal.h>
 #include <string.h>
 #include <errno.h>
@@ -49,6 +53,17 @@
 #include <fcntl.h>
 #include <limits.h>
 
+#ifdef __FreeBSD__
+#include <dlfcn.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#endif
+
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#endif
+
 /*
  * There are 3 possible strategies we might use to "fork":
  *
@@ -385,6 +400,32 @@
   return c >= '0' && c <= '9';
 }
 
+#if defined(__OpenBSD__)
+/*
+ * Directly call _thread_sys_closefrom() so the child process
+ * doesn't reset the parrent's file descriptors to be blocking.
+ * This function is only called from the child process which
+ * is single threaded and about to call execvp() so it is
+ * safe to bypass the threaded closefrom().
+ */
+int _thread_sys_closefrom(int);
+
+static int
+closeDescriptors(void)
+{
+  return _thread_sys_closefrom(FAIL_FILENO + 1);
+}
+
+#else
+
+#ifdef _ALLBSD_SOURCE
+#define FD_DIR "/dev/fd"
+#define dirent64 dirent
+#define readdir64 readdir
+#else
+#define FD_DIR "/proc/self/fd"
+#endif
+
 static int
 closeDescriptors(void)
 {
@@ -402,7 +443,7 @@
     restartableClose(from_fd);          /* for possible use by opendir() */
     restartableClose(from_fd + 1);      /* another one for good luck */
 
-    if ((dp = opendir("/proc/self/fd")) == NULL)
+    if ((dp = opendir(FD_DIR)) == NULL)
         return 0;
 
     /* We use readdir64 instead of readdir to work around Solaris bug
@@ -419,6 +460,7 @@
 
     return 1;
 }
+#endif /* !__OpenBSD__ */
 
 static int
 moveDescriptor(int fd_from, int fd_to)
@@ -556,6 +598,21 @@
             const char *argv[],
             const char *const envp[])
 {
+    /* This is one of the rare times it's more portable to declare an
+     * external symbol explicitly, rather than via a system header.
+     * The declaration is standardized as part of UNIX98, but there is
+     * no standard (not even de-facto) header file where the
+     * declaration is to be found.  See:
+     * http://www.opengroup.org/onlinepubs/009695399/functions/environ.html
+     * http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html
+     *
+     * "All identifiers in this volume of IEEE Std 1003.1-2001, except
+     * environ, are defined in at least one of the headers" (!)
+     */
+#ifndef __APPLE__
+    extern char **environ;
+#endif
+
     if (envp == NULL || (char **) envp == environ) {
         execvp(file, (char **) argv);
         return;
--- ./jdk/src/solaris/native/java/lang/java_props_md.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/lang/java_props_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -23,7 +23,7 @@
  * questions.
  */
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <stdio.h>
 #include <ctype.h>
 #endif
@@ -42,9 +42,17 @@
 #include <time.h>
 #include <errno.h>
 
+#if defined(_ALLBSD_SOURCE)
+#if !defined(P_tmpdir)
+#include <paths.h>
+#define P_tmpdir _PATH_VARTMP
+#endif
+#endif
+
 #include "locale_str.h"
 #include "java_props.h"
 
+#if !defined(_ALLBSD_SOURCE)
 #ifdef __linux__
   #ifndef CODESET
   #define CODESET _NL_CTYPE_CODESET_NAME
@@ -54,6 +62,7 @@
 #define CODESET ALT_CODESET_KEY
 #endif
 #endif
+#endif /* !_ALLBSD_SOURCE */
 
 #ifdef JAVASE_EMBEDDED
 #include <dlfcn.h>
@@ -437,6 +446,13 @@
     sprops.display_variant = sprops.variant;
     sprops.sun_jnu_encoding = sprops.encoding;
 
+#ifdef _ALLBSD_SOURCE
+#if BYTE_ORDER == _LITTLE_ENDIAN
+     sprops.unicode_encoding = "UnicodeLittle";
+ #else
+     sprops.unicode_encoding = "UnicodeBig";
+ #endif
+#else /* !_ALLBSD_SOURCE */
 #ifdef __linux__
 #if __BYTE_ORDER == __LITTLE_ENDIAN
     sprops.unicode_encoding = "UnicodeLittle";
@@ -446,6 +462,7 @@
 #else
     sprops.unicode_encoding = "UnicodeBig";
 #endif
+#endif /* _ALLBSD_SOURCE */
 
     /* user properties */
     {
@@ -482,12 +499,14 @@
     sprops.path_separator = ":";
     sprops.line_separator = "\n";
 
+#if !defined(_ALLBSD_SOURCE)
     /* Append CDE message and resource search path to NLSPATH and
      * XFILESEARCHPATH, in order to pick localized message for
      * FileSelectionDialog window (Bug 4173641).
      */
     setPathEnvironment("NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat");
     setPathEnvironment("XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt");
+#endif
 
     return &sprops;
 }
--- ./jdk/src/solaris/native/java/net/Inet4AddressImpl.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/Inet4AddressImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -36,12 +36,288 @@
 #include <stdlib.h>
 #include <ctype.h>
 
+#ifdef _ALLBSD_SOURCE
+#include <unistd.h>
+#include <sys/param.h>
+#endif
+
 #include "jvm.h"
 #include "jni_util.h"
 #include "net_util.h"
 
 #include "java_net_Inet4AddressImpl.h"
 
+#if defined(__GLIBC__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 601104))
+#define HAS_GLIBC_GETHOSTBY_R	1
+#endif
+
+#if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R)
+/* Use getaddrinfo(3), which is thread safe */
+/************************************************************************
+ * Inet4AddressImpl
+ */
+
+/*
+ * Class:     java_net_Inet4AddressImpl
+ * Method:    getLocalHostName
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
+    char hostname[NI_MAXHOST+1];
+
+    hostname[0] = '\0';
+    if (JVM_GetHostName(hostname, NI_MAXHOST)) {
+	/* Something went wrong, maybe networking is not setup? */
+	strcpy(hostname, "localhost");
+    } else {
+	 struct addrinfo  hints, *res;
+	 int error;
+
+	 memset(&hints, 0, sizeof(hints));
+	 hints.ai_flags = AI_CANONNAME;
+	 hints.ai_family = AF_UNSPEC;
+
+	 error = getaddrinfo(hostname, NULL, &hints, &res);
+
+	 if (error == 0) {
+	     /* host is known to name service */
+	     error = getnameinfo(res->ai_addr,
+				 res->ai_addrlen,
+				 hostname,
+				 NI_MAXHOST,
+				 NULL,
+				 0,
+				 NI_NAMEREQD);
+
+	     /* if getnameinfo fails hostname is still the value
+	        from gethostname */
+
+	     freeaddrinfo(res);
+	}
+    }
+    return (*env)->NewStringUTF(env, hostname);
+}
+
+static jclass ni_iacls;
+static jclass ni_ia4cls;
+static jmethodID ni_ia4ctrID;
+static jfieldID ni_iaaddressID;
+static jfieldID ni_iahostID;
+static jfieldID ni_iafamilyID;
+static int initialized = 0;
+
+/*
+ * Find an internet address for a given hostname.  Note that this
+ * code only works for addresses of type INET. The translation
+ * of %d.%d.%d.%d to an address (int) occurs in java now, so the
+ * String "host" shouldn't *ever* be a %d.%d.%d.%d string
+ *
+ * Class:     java_net_Inet4AddressImpl
+ * Method:    lookupAllHostAddr
+ * Signature: (Ljava/lang/String;)[[B
+ */
+
+JNIEXPORT jobjectArray JNICALL
+Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
+						jstring host) {
+    const char *hostname;
+    jobject name;
+    jobjectArray ret = 0;
+    int retLen = 0;
+
+    int error=0;
+    struct addrinfo hints, *res, *resNew = NULL;
+
+    if (!initialized) {
+      ni_iacls = (*env)->FindClass(env, "java/net/InetAddress");
+      ni_iacls = (*env)->NewGlobalRef(env, ni_iacls);
+      ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address");
+      ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls);
+      ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
+      ni_iaaddressID = (*env)->GetFieldID(env, ni_iacls, "address", "I");
+      ni_iafamilyID = (*env)->GetFieldID(env, ni_iacls, "family", "I");
+      ni_iahostID = (*env)->GetFieldID(env, ni_iacls, "hostName", "Ljava/lang/String;");
+      initialized = 1;
+    }
+
+    if (IS_NULL(host)) {
+	JNU_ThrowNullPointerException(env, "host is null");
+	return 0;
+    }
+    hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
+    CHECK_NULL_RETURN(hostname, NULL);
+
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_flags = AI_CANONNAME;
+    hints.ai_family = AF_INET;
+
+    /*
+     * Workaround for Solaris bug 4160367 - if a hostname contains a
+     * white space then 0.0.0.0 is returned
+     */
+    if (isspace((unsigned char)hostname[0])) {
+	JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
+			(char *)hostname);
+	JNU_ReleaseStringPlatformChars(env, host, hostname);
+	return NULL;
+    }
+	
+    error = getaddrinfo(hostname, NULL, &hints, &res);
+	
+    if (error) {
+	/* report error */
+	JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
+			(char *)hostname);
+	JNU_ReleaseStringPlatformChars(env, host, hostname);
+	return NULL;
+    } else {
+	int i = 0;
+	struct addrinfo *itr, *last = NULL, *iterator = res;
+	while (iterator != NULL) {
+	    int skip = 0;
+	    itr = resNew;
+
+	    while (itr != NULL) {
+		struct sockaddr_in *addr1, *addr2;
+
+		addr1 = (struct sockaddr_in *)iterator->ai_addr;
+		addr2 = (struct sockaddr_in *)itr->ai_addr;
+		if (addr1->sin_addr.s_addr ==
+		    addr2->sin_addr.s_addr) {
+		    skip = 1;
+		    break;
+		}
+		     
+		itr = itr->ai_next;
+	    }
+		
+	    if (!skip) {
+		struct addrinfo *next
+	            = (struct addrinfo*) malloc(sizeof(struct addrinfo));
+		if (!next) {
+		    JNU_ThrowOutOfMemoryError(env, "heap allocation failed");
+		    ret = NULL;
+		    goto cleanupAndReturn;
+		}
+		memcpy(next, iterator, sizeof(struct addrinfo));
+		next->ai_next = NULL;
+		if (resNew == NULL) {
+		    resNew = next;
+		} else {
+		    last->ai_next = next;
+		}
+		last = next;
+		i++;
+	    }
+	    iterator = iterator->ai_next;
+	}
+
+	retLen = i;
+	iterator = resNew;
+	i = 0;
+
+        name = (*env)->NewStringUTF(env, hostname);
+        if (IS_NULL(name)) {
+          goto cleanupAndReturn;
+        }
+
+	ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL);
+	if (IS_NULL(ret)) {
+	    /* we may have memory to free at the end of this */
+	    goto cleanupAndReturn;
+	}
+
+	while (iterator != NULL) {
+	    /* We need 4 bytes to store ipv4 address; */
+	    int len = 4;
+		
+            jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
+	    if (IS_NULL(iaObj)) {
+		/* we may have memory to free at the end of this */
+		ret = NULL;
+		goto cleanupAndReturn;
+	    }
+            (*env)->SetIntField(env, iaObj, ni_iaaddressID,
+                                ntohl(((struct sockaddr_in*)(iterator->ai_addr))->sin_addr.s_addr));
+            (*env)->SetObjectField(env, iaObj, ni_iahostID, name);
+            (*env)->SetObjectArrayElement(env, ret, retLen - i -1, iaObj);
+	    i++;
+	    iterator = iterator->ai_next;
+	}
+    }
+    
+cleanupAndReturn:
+    {
+	struct addrinfo *iterator, *tmp;
+	iterator = resNew;
+	while (iterator != NULL) {
+	    tmp = iterator;
+	    iterator = iterator->ai_next;
+	    free(tmp);
+	}
+	JNU_ReleaseStringPlatformChars(env, host, hostname);
+    }
+   
+    freeaddrinfo(res);
+    
+    return ret;
+
+}
+
+/*
+ * Class:     java_net_Inet4AddressImpl
+ * Method:    getHostByAddr
+ * Signature: (I)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
+					    jbyteArray addrArray) {
+    jstring ret = NULL;
+
+    char host[NI_MAXHOST+1];
+    jfieldID fid;
+    int error = 0;
+    jint family;
+    struct sockaddr *him ; 
+    int len = 0;
+    jbyte caddr[4];
+    jint addr;
+
+    struct sockaddr_in him4;
+    struct sockaddr *sa;
+
+    /* 
+	 * For IPv4 addresses construct a sockaddr_in structure.
+	 */
+    (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
+    addr = ((caddr[0]<<24) & 0xff000000);
+    addr |= ((caddr[1] <<16) & 0xff0000);
+    addr |= ((caddr[2] <<8) & 0xff00);
+    addr |= (caddr[3] & 0xff);
+    memset((char *) &him4, 0, sizeof(him4));
+    him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+    him4.sin_family = AF_INET;
+    sa = (struct sockaddr *) &him4;
+    len = sizeof(him4);
+    
+    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
+			       NI_NAMEREQD);
+
+    if (!error) {
+	ret = (*env)->NewStringUTF(env, host);
+    }
+
+    if (ret == NULL) {
+	JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL);
+    }
+
+    return ret;
+
+}
+
+#else /* defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R) */
+
 /* the initial size of our hostent buffers */
 #define HENT_BUF_SIZE 1024
 #define BIG_HENT_BUF_SIZE 10240  /* a jumbo-sized one */
@@ -86,13 +362,13 @@
         // ensure null-terminated
         hostname[MAXHOSTNAMELEN] = '\0';
 
-#ifdef __GLIBC__
+#ifdef HAS_GLIBC_GETHOSTBY_R
         gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error);
 #else
         hp = gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &h_error);
 #endif
         if (hp) {
-#ifdef __GLIBC__
+#ifdef HAS_GLIBC_GETHOSTBY_R
             gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET,
                             &res2, (char*)buf2, sizeof(buf2), &hp, &h_error);
 #else
@@ -182,7 +458,7 @@
 #endif
 
     /* Try once, with our static buffer. */
-#ifdef __GLIBC__
+#ifdef HAS_GLIBC_GETHOSTBY_R
     gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error);
 #else
     hp = gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &h_error);
@@ -195,7 +471,7 @@
      */
     if (hp == NULL && errno == ERANGE) {
         if ((tmp = (char*)malloc(BIG_HENT_BUF_SIZE))) {
-#ifdef __GLIBC__
+#ifdef HAS_GLIBC_GETHOSTBY_R
             gethostbyname_r(hostname, &res, tmp, BIG_HENT_BUF_SIZE,
                             &hp, &h_error);
 #else
@@ -280,7 +556,7 @@
     addr |= ((caddr[2] <<8) & 0xff00);
     addr |= (caddr[3] & 0xff);
     addr = htonl(addr);
-#ifdef __GLIBC__
+#ifdef HAS_GLIBC_GETHOSTBY_R
     gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent,
                     (char*)buf, sizeof(buf), &hp, &h_error);
 #else
@@ -294,7 +570,7 @@
      */
     if (hp == NULL && errno == ERANGE) {
         if ((tmp = (char*)malloc(BIG_HENT_BUF_SIZE))) {
-#ifdef __GLIBC__
+#ifdef HAS_GLIBC_GETHOSTBY_R
             gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET,
                             &hent, tmp, BIG_HENT_BUF_SIZE, &hp, &h_error);
 #else
@@ -316,6 +592,8 @@
     return ret;
 }
 
+#endif /* _ALLBSD_SOURCE */
+
 #define SET_NONBLOCKING(fd) {           \
         int flags = fcntl(fd, F_GETFL); \
         flags |= O_NONBLOCK;            \
--- ./jdk/src/solaris/native/java/net/Inet6AddressImpl.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/Inet6AddressImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -33,6 +33,9 @@
 #include <strings.h>
 #include <stdlib.h>
 #include <ctype.h>
+#ifdef _ALLBSD_SOURCE
+#include <unistd.h> /* gethostname */
+#endif
 
 #include "jvm.h"
 #include "jni_util.h"
@@ -70,10 +73,18 @@
     } else {
         // ensure null-terminated
         hostname[NI_MAXHOST] = '\0';
-#ifdef __linux__
-        /* On Linux gethostname() says "host.domain.sun.com".  On
+#if defined(__linux__) && defined(_ALLBSD_SOURCE)
+	/* On Linux/FreeBSD gethostname() says "host.domain.sun.com".  On
          * Solaris gethostname() says "host", so extra work is needed.
          */
+        /*
+         * XXXBSD: Though on FreeBSD it's possible case then hostname does
+         * not contain '.' (depends on previous sethostname() call).  Maybe
+         * we need to proceed with Solaris way, but using getnameinfo()
+         * in conjunction with gethostby*() breaks thread-safeness, so
+         * we need to protect all calls to gethostby*() and getnameinfo()
+         * using same mutex.
+         */
 #else
         /* Solaris doesn't want to give us a fully qualified domain name.
          * We do a reverse lookup to try and get one.  This works
@@ -109,7 +120,7 @@
             }
         }
 #endif /* AF_INET6 */
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
     }
     return (*env)->NewStringUTF(env, hostname);
 }
--- ./jdk/src/solaris/native/java/net/NetworkInterface.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/NetworkInterface.c	2011-04-22 23:08:39.000000000 -0700
@@ -26,6 +26,9 @@
 
 #include <errno.h>
 #include <strings.h>
+#if defined(_ALLBSD_SOURCE) && defined(__OpenBSD__)
+#include <sys/types.h>
+#endif
 #include <netinet/in.h>
 #include <stdlib.h>
 #include <string.h>
@@ -53,6 +56,23 @@
 #define _PATH_PROCNET_IFINET6           "/proc/net/if_inet6"
 #endif
 
+#if defined(_ALLBSD_SOURCE)
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/sockio.h>
+#if defined(__FreeBSD__) || defined(__APPLE__)
+#include <net/ethernet.h>
+#include <net/if_var.h>
+#elif defined(__OpenBSD__)
+#include <netinet/if_ether.h>
+#elif defined(__NetBSD__)
+#include <net/if_ether.h>
+#endif
+#include <net/if_dl.h>
+#include <netinet/in_var.h>
+#include <ifaddrs.h>
+#endif
+
 #include "jvm.h"
 #include "jni_util.h"
 #include "net_util.h"
@@ -820,11 +840,11 @@
     netif *currif = ifs, *parent;
     netaddr *addrP;
 
-    #ifdef __solaris__
+#ifdef LIFNAMSIZ
     char name[LIFNAMSIZ],  vname[LIFNAMSIZ];
-    #else
+#else
     char name[IFNAMSIZ],  vname[IFNAMSIZ];
-    #endif
+#endif
 
     char  *name_colonP;
     int mask;
@@ -1648,3 +1668,307 @@
 #endif
 
 
+/** BSD **/
+#ifdef _ALLBSD_SOURCE
+/* Open socket for further ioct calls, try v4 socket first and
+ * if it falls return v6 socket
+ */
+
+#ifdef AF_INET6
+static int openSocketWithFallback(JNIEnv *env, const char *ifname){
+    int sock;
+    struct ifreq if2;
+
+     if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+         if (errno == EPROTONOSUPPORT){
+              if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
+                 NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
+                 return -1;
+              }
+         }
+         else{ // errno is not NOSUPPORT
+             NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
+             return -1;
+         }
+   }
+
+   return sock;
+}
+
+#else
+static int openSocketWithFallback(JNIEnv *env, const char *ifname){
+    return openSocket(env,AF_INET);
+}
+#endif
+
+/*
+ * Enumerates and returns all IPv4 interfaces
+ */
+static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
+    struct ifaddrs *ifa, *origifa;
+
+    if (getifaddrs(&origifa) != 0) {
+        NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException",
+                         "getifaddrs() function failed");
+	return ifs;
+    }
+
+    for (ifa = origifa; ifa != NULL; ifa = ifa->ifa_next) {
+
+	/*
+	 * Skip non-AF_INET entries.
+	 */
+	if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET)
+	    continue;
+
+	/*
+	 * Add to the list.
+	 */
+	ifs = addif(env, sock, ifa->ifa_name, ifs, ifa->ifa_addr, AF_INET, 0);
+
+	/*
+	 * If an exception occurred then free the list.
+	 */
+	if ((*env)->ExceptionOccurred(env)) {
+	    freeifaddrs(origifa);
+	    freeif(ifs);
+	    return NULL;
+	}
+    }
+
+    /*
+     * Free socket and buffer
+     */
+    freeifaddrs(origifa);
+    return ifs;
+}
+
+
+/*
+ * Enumerates and returns all IPv6 interfaces on Linux
+ */
+
+#ifdef AF_INET6
+/*
+ * Determines the prefix on BSD for IPv6 interfaces.
+ */
+static
+int prefix(void *val, int size) {
+    u_char *name = (u_char *)val;
+    int byte, bit, plen = 0;
+
+    for (byte = 0; byte < size; byte++, plen += 8)
+        if (name[byte] != 0xff)
+            break;
+    if (byte == size)
+        return (plen);
+    for (bit = 7; bit != 0; bit--, plen++)
+        if (!(name[byte] & (1 << bit)))
+            break;
+    for (; bit != 0; bit--)
+        if (name[byte] & (1 << bit))
+            return (0);
+    byte++;
+    for (; byte < size; byte++)
+        if (name[byte])
+            return (0);
+    return (plen);
+}
+
+/*
+ * Enumerates and returns all IPv6 interfaces on BSD
+ */
+static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
+    struct ifaddrs *ifa, *origifa;
+    struct sockaddr_in6 *sin6;
+    struct in6_ifreq ifr6;
+
+    if (getifaddrs(&origifa) != 0) {
+        NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException",
+                         "getifaddrs() function failed");
+	return ifs;
+    }
+
+    for (ifa = origifa; ifa != NULL; ifa = ifa->ifa_next) {
+
+	/*
+	 * Skip non-AF_INET6 entries.
+	 */
+	if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET6)
+	    continue;
+
+	memset(&ifr6, 0, sizeof(ifr6));
+	strlcpy(ifr6.ifr_name, ifa->ifa_name, sizeof(ifr6.ifr_name));
+	memcpy(&ifr6.ifr_addr, ifa->ifa_addr, MIN(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len));
+
+	if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) {
+	    NET_ThrowByNameWithLastError(env , JNU_JAVANETPKG "SocketException",
+                             "ioctl SIOCGIFNETMASK_IN6 failed");
+	    freeifaddrs(origifa);
+	    freeif(ifs);
+	    return NULL;
+	}
+
+	/* Add to the list.  */
+	sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
+	ifs = addif(env, sock, ifa->ifa_name, ifs, ifa->ifa_addr, AF_INET6,
+		    prefix(&sin6->sin6_addr, sizeof(struct in6_addr)));
+
+	/* If an exception occurred then free the list.  */
+	if ((*env)->ExceptionOccurred(env)) {
+	    freeifaddrs(origifa);
+	    freeif(ifs);
+	    return NULL;
+	}
+    }
+
+    /*
+     * Free socket and ifaddrs buffer
+     */
+    freeifaddrs(origifa);
+    return ifs;
+}
+#endif
+
+static int getIndex(int sock, const char *name){
+#ifdef __FreeBSD__
+     /*
+      * Try to get the interface index
+      * (Not supported on Solaris 2.6 or 7)
+      */
+    struct ifreq if2;
+    strcpy(if2.ifr_name, name);
+
+    if (ioctl(sock, SIOCGIFINDEX, (char *)&if2) < 0) {
+        return -1;
+    }
+
+    return if2.ifr_index;
+#else
+    /*
+     * Try to get the interface index using BSD specific if_nametoindex
+     */
+    int index = if_nametoindex(name);
+    return (index == 0) ? -1 : index;
+#endif
+}
+
+/**
+ * Returns the IPv4 broadcast address of a named interface, if it exists.
+ * Returns 0 if it doesn't have one.
+ */
+static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *ifname, struct sockaddr *brdcast_store) {
+  struct sockaddr *ret = NULL;
+  struct ifreq if2;
+
+  memset((char *) &if2, 0, sizeof(if2));
+  strcpy(if2.ifr_name, ifname);
+
+  /* Let's make sure the interface does have a broadcast address */
+  if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
+      NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL SIOCGIFFLAGS failed");
+      return ret;
+  }
+
+  if (if2.ifr_flags & IFF_BROADCAST) {
+      /* It does, let's retrieve it*/
+      if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
+          NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL SIOCGIFBRDADDR failed");
+	  return ret;
+      }
+
+      ret = brdcast_store;
+      memcpy(ret, &if2.ifr_broadaddr, sizeof(struct sockaddr));
+  }
+
+  return ret;
+}
+
+/**
+ * Returns the IPv4 subnet prefix length (aka subnet mask) for the named
+ * interface, if it has one, otherwise return -1.
+ */
+static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
+    unsigned int mask;
+    short ret;
+    struct ifreq if2;
+
+    memset((char *) &if2, 0, sizeof(if2));
+    strcpy(if2.ifr_name, ifname);
+
+    if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL SIOCGIFNETMASK failed");
+        return -1;
+    }
+
+    mask = ntohl(((struct sockaddr_in*)&(if2.ifr_addr))->sin_addr.s_addr);
+    ret = 0;
+    while (mask) {
+       mask <<= 1;
+       ret++;
+    }
+
+    return ret;
+}
+
+/**
+ * Get the Hardware address (usually MAC address) for the named interface.
+ * return puts the data in buf, and returns the length, in byte, of the
+ * MAC address. Returns -1 if there is no hardware address on that interface.
+ */
+static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf) {
+    struct ifaddrs *ifa0, *ifa;
+    struct sockaddr *saddr;
+    int i;
+
+    /* Grab the interface list */
+    if (!getifaddrs(&ifa0)) {
+        /* Cycle through the interfaces */
+        for (i = 0, ifa = ifa0; ifa != NULL; ifa = ifa->ifa_next, i++) {
+            saddr = ifa->ifa_addr;
+            /* Link layer contains the MAC address */
+            if (saddr->sa_family == AF_LINK && !strcmp(ifname, ifa->ifa_name)) {
+                struct sockaddr_dl *sadl = (struct sockaddr_dl *) saddr;
+                /* Check the address is the correct length */
+                if (sadl->sdl_alen == ETHER_ADDR_LEN) {
+                    memcpy(buf, (sadl->sdl_data + sadl->sdl_nlen), ETHER_ADDR_LEN);
+                    freeifaddrs(ifa0);
+                    return ETHER_ADDR_LEN;
+                }
+            }
+        }
+        freeifaddrs(ifa0);
+    }
+
+    return -1;
+}
+
+static int getMTU(JNIEnv *env, int sock,  const char *ifname) {
+    struct ifreq if2;
+
+    memset((char *) &if2, 0, sizeof(if2));
+    strcpy(if2.ifr_name, ifname);
+
+    if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL SIOCGIFMTU failed");
+        return -1;
+    }
+
+    return  if2.ifr_mtu;
+}
+
+static int getFlags(int sock, const char *ifname) {
+  struct ifreq if2;
+  int ret = -1;
+
+  memset((char *) &if2, 0, sizeof(if2));
+  strcpy(if2.ifr_name, ifname);
+
+  if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0){
+      return -1;
+  }
+
+  return if2.ifr_flags;
+}
+
+#endif
--- ./jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -23,12 +23,12 @@
  * questions.
  */
 
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 
 #ifdef __solaris__
 #include <fcntl.h>
@@ -331,7 +331,7 @@
     /* The fdObj'fd */
     jint fd;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     SOCKADDR addr;
     int len;
 #endif
@@ -341,26 +341,39 @@
     }
     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
 
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #ifdef __linux__
     if (isOldKernel) {
         int t = 1;
         setsockopt(fd, SOL_SOCKET, SO_BSDCOMPAT, (char*) &t, sizeof(int));
     } else {
+#endif /* __linux__ */
         memset(&addr, 0, sizeof(addr));
 #ifdef AF_INET6
         if (ipv6_available()) {
             struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)&addr;
+#ifdef __FreeBSD__
+            him6->sin6_family = AF_INET6;
+#else
             him6->sin6_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in6);
         } else
 #endif
         {
             struct sockaddr_in *him4 = (struct sockaddr_in*)&addr;
+#ifdef __FreeBSD__
+            him4->sin_family = AF_INET;
+#else
             him4->sin_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in);
         }
         JVM_Connect(fd, (struct sockaddr *)&addr, len);
+	/* XXXBSD: here we can get EADDRNOTAVAIL which need to be ignored
+	   but since return value is not checked, ignore it */
 
+#ifdef __linux__
         // After disconnecting a UDP socket, Linux kernel will set
         // local port to zero if the port number comes from implicit
         // bind. Successive send/recv on the same socket will fail.
@@ -383,6 +396,7 @@
             NET_Bind(fd, (struct sockaddr *)&addr, len);
         }
     }
+#endif
 #else
     JVM_Connect(fd, 0, 0);
 #endif
@@ -2400,18 +2414,30 @@
             mname6.ipv6mr_interface = idx;
         }
 
+#if defined(_ALLBSD_SOURCE)
+#define ADD_MEMBERSHIP		IPV6_JOIN_GROUP
+#define DRP_MEMBERSHIP		IPV6_LEAVE_GROUP
+#define S_ADD_MEMBERSHIP	"IPV6_JOIN_GROUP"
+#define S_DRP_MEMBERSHIP	"IPV6_LEAVE_GROUP"
+#else
+#define ADD_MEMBERSHIP		IPV6_ADD_MEMBERSHIP
+#define DRP_MEMBERSHIP		IPV6_DROP_MEMBERSHIP
+#define S_ADD_MEMBERSHIP	"IPV6_ADD_MEMBERSHIP"
+#define S_DRP_MEMBERSHIP	"IPV6_DROP_MEMBERSHIP"
+#endif
+
         /* Join the multicast group */
-        if (JVM_SetSockOpt(fd, IPPROTO_IPV6, (join ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP),
+        if (JVM_SetSockOpt(fd, IPPROTO_IPV6, (join ? ADD_MEMBERSHIP : DRP_MEMBERSHIP),
                            (char *) &mname6, sizeof (mname6)) < 0) {
 
             if (join) {
-                NET_ThrowCurrent(env, "setsockopt IPV6_ADD_MEMBERSHIP failed");
+                NET_ThrowCurrent(env, "setsockopt " S_ADD_MEMBERSHIP " failed");
             } else {
                 if (errno == ENOENT) {
                    JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                         "Not a member of the multicast group");
                 } else {
-                    NET_ThrowCurrent(env, "setsockopt IPV6_DROP_MEMBERSHIP failed");
+                    NET_ThrowCurrent(env, "setsockopt " S_DRP_MEMBERSHIP " failed");
                 }
             }
         }
--- ./jdk/src/solaris/native/java/net/PlainSocketImpl.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/PlainSocketImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -483,9 +483,11 @@
         if (connect_rv == JVM_IO_INTR) {
             JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
                             "operation interrupted");
+#if defined(EPROTO)
         } else if (errno == EPROTO) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ProtocolException",
                            "Protocol error");
+#endif
         } else if (errno == ECONNREFUSED) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
                            "Connection refused");
@@ -1001,7 +1003,7 @@
      */
     if (cmd == java_net_SocketOptions_SO_BINDADDR) {
         SOCKADDR him;
-        socklen_t len = 0;
+        socklen_t len;
         int port;
         jobject iaObj;
         jclass iaCntrClass;
--- ./jdk/src/solaris/native/java/net/bsd_close.c	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/bsd_close.c	2011-04-22 23:08:39.000000000 -0700
@@ -57,7 +57,7 @@
 /*
  * Signal to unblock thread
  */
-static int sigWakeup = (__SIGRTMAX - 2);
+static int sigWakeup = SIGIO;
 
 /*
  * The fd table and the number of file descriptors
@@ -281,9 +281,7 @@
 
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
        struct sockaddr *from, int *fromlen) {
-    socklen_t socklen = *fromlen;
-    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
-    *fromlen = socklen;
+    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
 }
 
 int NET_Send(int s, void *msg, int len, unsigned int flags) {
@@ -300,9 +298,11 @@
 }
 
 int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
-    socklen_t socklen = *addrlen;
-    BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
-    *addrlen = socklen;
+    socklen_t len = *addrlen;
+    int error = accept(s, addr, &len);
+    if (error != -1)
+	*addrlen = (int)len;
+    BLOCKING_IO_RETURN_INT( s, error );
 }
 
 int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
--- ./jdk/src/solaris/native/java/net/net_util_md.c	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/net_util_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -33,7 +33,16 @@
 #include <netdb.h>
 #include <stdlib.h>
 #include <dlfcn.h>
-#include <values.h>
+#include <limits.h>
+
+#ifdef _ALLBSD_SOURCE
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
+#ifdef __OpenBSD__
+#include <sys/socketvar.h>
+#endif
 
 #ifdef __solaris__
 #include <sys/sockio.h>
@@ -127,7 +136,7 @@
 
 static int findMaxBuf(int fd, int opt, int sotype) {
     int a = 0;
-    int b = MAXINT;
+    int b = INT_MAX;
     int initial_guess;
     int limit = -1;
 
@@ -272,6 +281,14 @@
     return (*env)->GetFieldID(env, cls, "fd", "I");
 }
 
+#if defined(DONT_ENABLE_IPV6)
+jint  IPv6_supported()
+{
+    return JNI_FALSE;
+}
+
+#else /* !DONT_ENABLE_IPV6 */
+
 jint  IPv6_supported()
 {
 #ifndef AF_INET6
@@ -410,6 +427,7 @@
     return JNI_TRUE;
 #endif /* AF_INET6 */
 }
+#endif /* DONT_ENABLE_IPV6 */
 
 void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
                                            const char* hostname,
@@ -772,6 +790,10 @@
         him6->sin6_family = AF_INET6;
         *len = sizeof(struct sockaddr_in6) ;
 
+#if defined(_ALLBSD_SOURCE) && defined(_AF_INET6)
+// XXXBSD: should we do something with scope id here ? see below linux comment
+#endif
+
         /*
          * On Linux if we are connecting to a link-local address
          * we need to specify the interface in the scope_id (2.4 kernel only)
@@ -1178,7 +1200,6 @@
         *len = socklen;
     }
 #endif
-
     if (rv < 0) {
         return rv;
     }
@@ -1224,6 +1245,24 @@
 #define IPTOS_PREC_MASK 0xe0
 #endif
 
+#if defined(_ALLBSD_SOURCE)
+#if defined(KIPC_MAXSOCKBUF)
+    int mib[3];
+    size_t rlen;
+#endif
+
+    int *bufsize;
+
+#ifdef __APPLE__
+    static int maxsockbuf = -1;
+#else
+    static long maxsockbuf = -1;
+#endif
+
+    int addopt;
+    struct linger *ling;
+#endif
+
     /*
      * IPPROTO/IP_TOS :-
      * 1. IPv6 on Solaris: no-op and will be set in flowinfo
@@ -1256,6 +1295,10 @@
         *iptos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
     }
 
+#if defined(AF_INET6) && defined(_ALLBSD_SOURCE)
+// XXXBSD: to be implemented ?
+#endif
+
     /*
      * SOL_SOCKET/{SO_SNDBUF,SO_RCVBUF} - On Solaris we may need to clamp
      * the value when it exceeds the system limit.
@@ -1263,7 +1306,8 @@
 #ifdef __solaris__
     if (level == SOL_SOCKET) {
         if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
-            int sotype=0, arglen;
+            int sotype = 0;
+            socklen_t arglen;
             int *bufsize, maxbuf;
             int ret;
 
@@ -1329,6 +1373,84 @@
     }
 #endif
 
+#if defined(_ALLBSD_SOURCE)
+    /*
+     * SOL_SOCKET/{SO_SNDBUF,SO_RCVBUF} - On FreeBSD need to
+     * ensure that value is <= kern.ipc.maxsockbuf as otherwise we get
+     * an ENOBUFS error.
+     */
+    if (level == SOL_SOCKET) {
+        if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
+#ifdef KIPC_MAXSOCKBUF
+            if (maxsockbuf == -1) {
+               mib[0] = CTL_KERN;
+               mib[1] = KERN_IPC;
+               mib[2] = KIPC_MAXSOCKBUF;
+               rlen = sizeof(maxsockbuf);
+               if (sysctl(mib, 3, &maxsockbuf, &rlen, NULL, 0) == -1)
+                   maxsockbuf = 1024;
+
+#if 1
+               /* XXXBSD: This is a hack to workaround mb_max/mb_max_adj
+                  problem.  It should be removed when kern.ipc.maxsockbuf
+                  will be real value. */
+               maxsockbuf = (maxsockbuf/5)*4;
+#endif
+           }
+#elif defined(__OpenBSD__)
+	   maxsockbuf = SB_MAX;
+#else
+	   maxsockbuf = 64 * 1024;	/* XXX: NetBSD */
+#endif
+
+           bufsize = (int *)arg;
+           if (*bufsize > maxsockbuf) {
+               *bufsize = maxsockbuf;
+           }
+
+	   if (opt == SO_RCVBUF && *bufsize < 1024) {
+		*bufsize = 1024;
+	   }
+
+        }
+    }
+
+    /*
+     * On Solaris, SO_REUSEADDR will allow multiple datagram
+     * sockets to bind to the same port.  The network jck tests
+     * for this "feature", so we need to emulate it by turning on
+     * SO_REUSEPORT as well for that combination.
+     */
+    if (level == SOL_SOCKET && opt == SO_REUSEADDR) {
+        int sotype;
+        socklen_t arglen;
+
+        arglen = sizeof(sotype);
+        if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) {
+            return -1;
+        }
+
+        if (sotype == SOCK_DGRAM) {
+            addopt = SO_REUSEPORT;
+            setsockopt(fd, level, addopt, arg, len);
+        }
+    }
+
+    /*
+     * Don't allow SO_LINGER value to be too big.
+     * Current max value (240) is empiric value based on tcp_timer.h's
+     * constant TCP_LINGERTIME, which was doubled.
+     *
+     * XXXBSD: maybe we should step it down to 120 ?
+     */
+    if (level == SOL_SOCKET && opt == SO_LINGER) {
+        ling = (struct linger *)arg;
+       if (ling->l_linger > 240 || ling->l_linger < 0) {
+           ling->l_linger = 240;
+       }
+    }
+#endif
+
     return setsockopt(fd, level, opt, arg, len);
 }
 
@@ -1379,7 +1501,8 @@
      * corresponding IPv4 port is in use.
      */
     if (ipv6_available()) {
-        int arg, len;
+        int arg;
+        socklen_t len;
 
         len = sizeof(arg);
         if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg,
--- ./jdk/src/solaris/native/java/net/net_util_md.h	2011-05-26 18:56:39.000000000 -0700
+++ ./jdk/src/solaris/native/java/net/net_util_md.h	2011-04-22 23:08:39.000000000 -0700
@@ -37,7 +37,7 @@
 #endif
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
 extern int NET_Timeout(int s, long timeout);
 extern int NET_Read(int s, void* buf, size_t len);
 extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
--- ./jdk/src/solaris/native/java/util/FileSystemPreferences.c	2011-05-26 18:56:40.000000000 -0700
+++ ./jdk/src/solaris/native/java/util/FileSystemPreferences.c	2011-04-22 23:08:39.000000000 -0700
@@ -47,8 +47,11 @@
     return (jint) result;
 }
 
-
+#if defined(_ALLBSD_SOURCE)
+typedef struct flock FLOCK;
+#else
 typedef struct flock64 FLOCK;
+#endif
 
 /**
  * Try to open a named lock file.
@@ -86,7 +89,11 @@
     if (fd < 0) {
         result[0] = 0;
     } else {
+#if defined(_ALLBSD_SOURCE)
+        rc = fcntl(fd, F_SETLK, &fl); 
+#else
         rc = fcntl(fd, F_SETLK64, &fl);
+#endif
         result[1] = errno;
         if (rc < 0) {
             result[0]= 0;
@@ -116,7 +123,11 @@
     fl.l_start = 0;
     fl.l_type = F_UNLCK;
 
+#if defined(_ALLBSD_SOURCE)
+    rc = fcntl(fd, F_SETLK, &fl);
+#else
     rc = fcntl(fd, F_SETLK64, &fl);
+#endif
 
     if (rc < 0) {
         close(fd);
--- ./jdk/src/solaris/native/java/util/TimeZone_md.c	2011-05-26 18:56:40.000000000 -0700
+++ ./jdk/src/solaris/native/java/util/TimeZone_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -31,7 +31,7 @@
 #include <errno.h>
 #include <stddef.h>
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <string.h>
 #include <dirent.h>
 #include <sys/stat.h>
@@ -49,7 +49,11 @@
 #define fileclose       fclose
 #endif
 
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+
 #ifdef __linux__
+static const char *sysconfig_clock_file = "/etc/sysconfig/clock";
+#endif
 
 static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
 static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
@@ -199,7 +203,9 @@
     int fd;
     char *buf;
     size_t size;
+    char zoneinfo_file[PATH_MAX+1];
 
+#ifdef __linux__
     /*
      * Try reading the /etc/timezone file for Debian distros. There's
      * no spec of the file format available. This parsing assumes that
@@ -223,6 +229,7 @@
             return tz;
         }
     }
+#endif /* __linux__ */
 
     /*
      * Next, try /etc/localtime to find the zone ID.
@@ -231,6 +238,10 @@
         return NULL;
     }
 
+    strncpy(zoneinfo_file, DEFAULT_ZONEINFO_FILE, PATH_MAX);
+    zoneinfo_file[PATH_MAX] = '\0';
+
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     /*
      * If it's a symlink, get the link name and its zone ID part. (The
      * older versions of timeconfig created a symlink as described in
@@ -239,21 +250,25 @@
      * from /etc/localtime.)
      */
     if (S_ISLNK(statbuf.st_mode)) {
-        char linkbuf[PATH_MAX+1];
         int len;
 
-        if ((len = readlink(DEFAULT_ZONEINFO_FILE, linkbuf, sizeof(linkbuf)-1)) == -1) {
+	if ((len = readlink(DEFAULT_ZONEINFO_FILE, zoneinfo_file, sizeof(zoneinfo_file)-1)) == -1) {
             jio_fprintf(stderr, (const char *) "can't get a symlink of %s\n",
                         DEFAULT_ZONEINFO_FILE);
             return NULL;
         }
-        linkbuf[len] = '\0';
-        tz = getZoneName(linkbuf);
+	zoneinfo_file[len] = '\0';
+	tz = getZoneName(zoneinfo_file);
         if (tz != NULL) {
             tz = strdup(tz);
+	    return tz;
+	} else {
+	    if (lstat(zoneinfo_file, &statbuf) == -1) {
+		return NULL;
+	    }
         }
-        return tz;
     }
+#endif /* __linux__ || _ALLBSD_SOURCE */
 
     /*
      * If it's a regular file, we need to find out the same zoneinfo file
@@ -264,7 +279,7 @@
     if (buf == NULL) {
         return NULL;
     }
-    if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) {
+    if ((fd = open(zoneinfo_file, O_RDONLY)) == -1) {
         free((void *) buf);
         return NULL;
     }
@@ -493,7 +508,7 @@
 
     tz = getenv("TZ");
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     if (tz == NULL) {
 #else
 #ifdef __solaris__
@@ -532,19 +547,32 @@
 {
     time_t offset;
     char sign, buf[16];
+#if defined(_ALLBSD_SOURCE)
+    struct tm *local_tm;
+    time_t clock;
+ 
+    clock = time(NULL);
+    tzset();
+    local_tm = localtime(&clock);
+    if (local_tm->tm_gmtoff >= 0) {
+	offset = (time_t) local_tm->tm_gmtoff;
+	sign = "+";
+    } else {
+	offset = (time_t) -local_tm->tm_gmtoff;
+	sign = "-";
+    }
+#else
 
     if (timezone == 0) {
         return strdup("GMT");
-    }
-
-    /* Note that the time offset direction is opposite. */
-    if (timezone > 0) {
+    } else if (timezone > 0) {
         offset = timezone;
         sign = '-';
     } else {
         offset = -timezone;
         sign = '+';
     }
+#endif
     sprintf(buf, (const char *)"GMT%c%02d:%02d",
             sign, (int)(offset/3600), (int)((offset%3600)/60));
     return strdup(buf);
--- ./jdk/src/solaris/native/sun/awt/CUPSfuncs.c	2011-05-26 18:56:40.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/CUPSfuncs.c	2011-04-22 23:08:39.000000000 -0700
@@ -25,6 +25,7 @@
 
 #include <jni.h>
 #include <jni_util.h>
+#include <jvm_md.h>
 #include <dlfcn.h>
 #include <cups/cups.h>
 #include <cups/ppd.h>
@@ -65,10 +66,11 @@
 JNIEXPORT jboolean JNICALL
 Java_sun_print_CUPSPrinter_initIDs(JNIEnv *env,
                                          jobject printObj) {
-  void *handle = dlopen("libcups.so.2", RTLD_LAZY | RTLD_GLOBAL);
+  void *handle = dlopen(VERSIONED_JNI_LIB_NAME("cups", "2"),
+                        RTLD_LAZY | RTLD_GLOBAL);
 
   if (handle == NULL) {
-    handle = dlopen("libcups.so", RTLD_LAZY | RTLD_GLOBAL);
+    handle = dlopen(JNI_LIB_NAME("cups"), RTLD_LAZY | RTLD_GLOBAL);
     if (handle == NULL) {
       return JNI_FALSE;
     }
--- ./jdk/src/solaris/native/sun/awt/VDrawingArea.c	2011-05-26 18:56:40.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/VDrawingArea.c	2011-04-22 23:08:39.000000000 -0700
@@ -31,7 +31,11 @@
 #endif /* !HEADLESS */
 
 #include <stdio.h>
+#if defined(_ALLBSD_SOURCE)
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 
 #ifdef __linux__
 /* XXX: Shouldn't be necessary. */
--- ./jdk/src/solaris/native/sun/awt/X11Color.c	2011-05-26 18:56:40.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/X11Color.c	2011-04-22 23:08:39.000000000 -0700
@@ -33,7 +33,9 @@
 #include <math.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#if !defined(_ALLBSD_SOURCE)
 #include <alloca.h>
+#endif
 #ifndef HEADLESS
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
--- ./jdk/src/solaris/native/sun/awt/XDrawingArea.c	2011-05-26 18:56:40.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/XDrawingArea.c	2011-04-22 23:08:39.000000000 -0700
@@ -31,7 +31,11 @@
 #include <Xm/XmP.h>
 
 #include <stdio.h>
+#if defined(_ALLBSD_SOURCE)
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 
 #ifdef DEBUG
 #include <jvm.h>  /* To get jio_fprintf() */
--- ./jdk/src/solaris/native/sun/awt/awt_Font.c	2011-05-26 18:56:42.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_Font.c	2011-04-22 23:08:39.000000000 -0700
@@ -334,7 +334,7 @@
             if (strcmp(style, "regular") == 0) {
                 altstyle = "roman";
             }
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
             if (!strcmp(family, "lucidasans")) {
                 family = "lucida";
             }
--- ./jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	2011-05-26 18:56:43.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c	2011-04-22 23:08:39.000000000 -0700
@@ -40,6 +40,7 @@
 #include <jni.h>
 #include <jni_util.h>
 #include <jvm.h>
+#include <jvm_md.h>
 #include <jlong.h>
 
 #include <stdlib.h>
@@ -122,7 +123,7 @@
  */
 
 #define MAXFRAMEBUFFERS 16
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 typedef struct {
    int   screen_number;
    short x_org;
@@ -427,6 +428,11 @@
     {
         xrenderLibHandle = dlopen("libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL);
 
+        if (xrenderLibHandle == NULL) {
+            xrenderLibHandle = dlopen("libXrender.so",
+                                      RTLD_LAZY | RTLD_GLOBAL);
+        }
+
 #ifndef __linux__ /* SOLARIS */
         if (xrenderLibHandle == NULL) {
             xrenderLibHandle = dlopen("/usr/sfw/lib/libXrender.so.1",
@@ -640,19 +646,22 @@
 #endif /* HEADLESS */
 
 #ifndef HEADLESS
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 static void xinerama_init_linux()
 {
-    void* libHandle = 0;
-    char* XineramaLibName= "libXinerama.so.1";
+    void* libHandle = NULL;
     int32_t locNumScr = 0;
     XineramaScreenInfo *xinInfo;
     char* XineramaQueryScreensName = "XineramaQueryScreens";
     XineramaQueryScreensFunc* XineramaQueryScreens = NULL;
 
     /* load library */
-    libHandle = dlopen(XineramaLibName, RTLD_LAZY | RTLD_GLOBAL);
-    if (libHandle != 0) {
+    libHandle = dlopen(VERSIONED_JNI_LIB_NAME("Xinerama", "1"),
+                       RTLD_LAZY | RTLD_GLOBAL);
+    if (libHandle == NULL) {
+        libHandle = dlopen(JNI_LIB_NAME("Xinerama"), RTLD_LAZY | RTLD_GLOBAL);
+    }
+    if (libHandle != NULL) {
         XineramaQueryScreens = (XineramaQueryScreensFunc*)
             dlsym(libHandle, XineramaQueryScreensName);
 
@@ -688,11 +697,10 @@
     }
 }
 #endif
-#ifndef __linux__ /* Solaris */
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE) /* Solaris */
 static void xinerama_init_solaris()
 {
-    void* libHandle = 0;
-    char* XineramaLibName= "libXext.so";
+    void* libHandle = NULL;
     unsigned char fbhints[MAXFRAMEBUFFERS];
     int32_t locNumScr = 0;
     /* load and run XineramaGetInfo */
@@ -701,8 +709,8 @@
     XineramaGetInfoFunc* XineramaSolarisFunc = NULL;
 
     /* load library */
-    libHandle = dlopen(XineramaLibName, RTLD_LAZY | RTLD_GLOBAL);
-    if (libHandle != 0) {
+    libHandle = dlopen(JNI_LIB_NAME("Xext"), RTLD_LAZY | RTLD_GLOBAL);
+    if (libHandle != NULL) {
         XineramaSolarisFunc = (XineramaGetInfoFunc*)dlsym(libHandle, XineramaGetInfoName);
         XineramaSolarisCenterFunc =
             (XineramaGetCenterHintFunc*)dlsym(libHandle, XineramaGetCenterHintName);
@@ -749,11 +757,11 @@
     }
 
     DTRACE_PRINTLN("Xinerama extension is available");
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     xinerama_init_linux();
 #else /* Solaris */
     xinerama_init_solaris();
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 }
 #endif /* HEADLESS */
 
@@ -1628,7 +1636,7 @@
 {
     jobject point = NULL;
 #ifndef HEADLESS    /* return NULL in HEADLESS, Linux */
-#ifndef __linux__
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
     int x,y;
 
     AWT_LOCK();
@@ -1641,7 +1649,7 @@
         DTRACE_PRINTLN("unable to call XineramaSolarisCenterFunc: symbol is null");
     }
     AWT_FLUSH_UNLOCK();
-#endif /* __linux __ */
+#endif /* __linux __ || _ALLBSD_SOURCE */
 #endif /* HEADLESS */
     return point;
 }
@@ -1711,7 +1719,11 @@
 {
     int rr_maj_ver = 0, rr_min_ver = 0;
 
-    void *pLibRandR = dlopen("libXrandr.so.2", RTLD_LAZY | RTLD_LOCAL);
+    void *pLibRandR = dlopen(VERSIONED_JNI_LIB_NAME("Xrandr", "2"),
+                             RTLD_LAZY | RTLD_LOCAL);
+    if (pLibRandR == NULL) {
+        pLibRandR = dlopen(JNI_LIB_NAME("Xrandr"), RTLD_LAZY | RTLD_LOCAL);
+    }
     if (pLibRandR == NULL) {
         J2dRlsTraceLn(J2D_TRACE_ERROR,
                       "X11GD_InitXrandrFuncs: Could not open libXrandr.so.2");
--- ./jdk/src/solaris/native/sun/awt/awt_InputMethod.c	2011-05-26 18:56:43.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_InputMethod.c	2011-04-22 23:08:39.000000000 -0700
@@ -67,7 +67,7 @@
                                 XIMPreeditDrawCallbackStruct *);
 static void PreeditCaretCallback(XIC, XPointer,
                                  XIMPreeditCaretCallbackStruct *);
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 static void StatusStartCallback(XIC, XPointer, XPointer);
 static void StatusDoneCallback(XIC, XPointer, XPointer);
 static void StatusDrawCallback(XIC, XPointer,
@@ -81,7 +81,7 @@
 #define PreeditDoneIndex        1
 #define PreeditDrawIndex        2
 #define PreeditCaretIndex       3
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #define StatusStartIndex        4
 #define StatusDoneIndex         5
 #define StatusDrawIndex         6
@@ -99,14 +99,14 @@
     (XIMProc)PreeditDoneCallback,
     (XIMProc)PreeditDrawCallback,
     (XIMProc)PreeditCaretCallback,
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     (XIMProc)StatusStartCallback,
     (XIMProc)StatusDoneCallback,
     (XIMProc)StatusDrawCallback,
 #endif
 };
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #define MAX_STATUS_LEN  100
 typedef struct {
     Window   w;                /*status window id        */
@@ -146,7 +146,7 @@
 #endif /* XAWT */
     jobject     x11inputmethod; /* global ref to X11InputMethod instance */
                                 /* associated with the XIC */
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     StatusWindow *statusWindow; /* our own status window  */
 #else
 #ifndef XAWT
@@ -425,7 +425,7 @@
 static void
 freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     if (pX11IMData->statusWindow != NULL){
         StatusWindow *sw = pX11IMData->statusWindow;
         XFreeGC(awt_display, sw->lightGC);
@@ -531,7 +531,7 @@
     pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
 
     if (pX11IMData == NULL) {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
         return False;
 #else
         return result;
@@ -539,7 +539,7 @@
     }
 
     if ((ic = pX11IMData->current_ic) == (XIC)0){
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
         return False;
 #else
         return result;
@@ -648,7 +648,7 @@
     return result;
 }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 static StatusWindow *createStatusWindow(
 #ifdef XAWT
                                 Window parent) {
@@ -993,7 +993,7 @@
         }
     }
 }
-#endif  /*__linux__*/
+#endif  /* __linux__ || _ALLBSD_SOURCE */
 /*
  * Creates two XICs, one for active clients and the other for passive
  * clients. All information on those XICs are stored in the
@@ -1050,7 +1050,7 @@
         return FALSE ;
     }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     on_the_spot_styles |= XIMStatusNothing;
 
     /*kinput does not support XIMPreeditCallbacks and XIMStatusArea
@@ -1063,7 +1063,7 @@
             break;
         }
     }
-#else /*! __linux__ */
+#else /*! __linux__ && !_ALLBSD_SOURCE */
 #ifdef XAWT
     on_the_spot_styles |= XIMStatusNothing;
 #else /* !XAWT */
@@ -1086,7 +1086,7 @@
         on_the_spot_styles |= XIMStatusNothing;
 
 #endif /* XAWT */
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 
     for (i = 0; i < im_styles->count_styles; i++) {
         active_styles |= im_styles->supported_styles[i] & on_the_spot_styles;
@@ -1134,7 +1134,7 @@
                         NULL);
         if (preedit == (XVaNestedList)NULL)
             goto err;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
         /*always try XIMStatusCallbacks for active client...*/
         {
             status = (XVaNestedList)XVaCreateNestedList(0,
@@ -1156,7 +1156,7 @@
             XFree((void *)status);
             XFree((void *)preedit);
         }
-#else /* !__linux__ */
+#else /* !__linux__ && !_ALLBSD_SOURCE */
 #ifndef XAWT
         if (on_the_spot_styles & XIMStatusArea) {
             Widget parent;
@@ -1184,7 +1184,7 @@
         }
 #endif /* XAWT */
         XFree((void *)preedit);
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
         pX11IMData->ic_passive = XCreateIC(X11im,
                                            XNClientWindow, w,
                                            XNFocusWindow, w,
@@ -1343,7 +1343,7 @@
 
 }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 static void
 StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data)
 {
@@ -1411,7 +1411,7 @@
  finally:
     AWT_UNLOCK();
 }
-#endif /*__linux__*/
+#endif /* __linux__ || _ALLBSD_SOURCE */
 
 static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_data) {
     JNIEnv *env = GetJNIEnv();
@@ -1517,14 +1517,14 @@
 /* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
    (4768335)
 */
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
                      NULL, (XIDProc)OpenXIMCallback, NULL);
     if (!registered) {
         /* directly call openXIM callback */
 #endif
         OpenXIMCallback(dpy, NULL, NULL);
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     }
 #endif
 
@@ -1588,13 +1588,13 @@
 #endif /* XAWT */
     globalRef = (*env)->NewGlobalRef(env, this);
     pX11IMData->x11inputmethod = globalRef;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     pX11IMData->statusWindow = NULL;
-#else /* __linux__ */
+#else /* !__linux__ && !_ALLBSD_SOURCE */
 #ifndef XAWT
     pX11IMData->statusWidget = (Widget) NULL;
 #endif /* XAWT */
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 
     pX11IMData->lookup_buf = 0;
     pX11IMData->lookup_buf_len = 0;
@@ -1741,14 +1741,14 @@
         setXICFocus(pX11IMData->current_ic, req);
         currentX11InputMethodInstance = pX11IMData->x11inputmethod;
         currentFocusWindow =  w;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
         if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
             onoffStatusWindow(pX11IMData, w, True);
 #endif
     } else {
         currentX11InputMethodInstance = NULL;
         currentFocusWindow = 0;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
         onoffStatusWindow(pX11IMData, 0, False);
         if (pX11IMData->current_ic != NULL)
 #endif
@@ -1765,7 +1765,7 @@
 Java_sun_awt_X11InputMethod_turnoffStatusWindow(JNIEnv *env,
                                                 jobject this)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     X11InputMethodData *pX11IMData;
     StatusWindow *statusWindow;
 
@@ -1862,7 +1862,7 @@
     X11InputMethodData *pX11IMData;
     XVaNestedList status;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
       /*do nothing for linux? */
 #else
     AWT_LOCK();
@@ -1968,7 +1968,7 @@
 JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
   (JNIEnv *env, jobject this, jlong window)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     AWT_LOCK();
     adjustStatusWindow(window);
     AWT_UNLOCK();
--- ./jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c	2011-05-26 18:56:43.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c	2011-05-07 22:00:01.000000000 -0700
@@ -130,10 +130,10 @@
 
     /* Calculate library name to load */
     if (AWTIsHeadless()) {
-        strncpy(p, "/headless/libmawt.so", MAXPATHLEN-len-1);
+        strncpy(p, "/headless/libmawt" JNI_LIB_SUFFIX, MAXPATHLEN-len-1);
     } else {
         /* Default AWT Toolkit on Linux and Solaris is XAWT. */
-        strncpy(p, "/xawt/libmawt.so", MAXPATHLEN-len-1);
+        strncpy(p, "/xawt/libmawt" JNI_LIB_SUFFIX, MAXPATHLEN-len-1);
     }
 
     if (toolkit) {
--- ./jdk/src/solaris/native/sun/awt/awt_MToolkit.c	2011-05-26 18:56:43.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_MToolkit.c	2011-04-22 23:08:39.000000000 -0700
@@ -63,8 +63,9 @@
 extern JavaVM *jvm;
 
 #ifndef HEADLESS
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 extern void statusWindowEventHandler(XEvent event);
+Boolean awt_dnd_process_event(XEvent* event);
 #endif
 #endif /* !HEADLESS */
 
@@ -1642,7 +1643,7 @@
               */
               Widget widget=XtWindowToWidget(awt_display, xev.xany.window);
               eventNumber++;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
               statusWindowEventHandler(xev);
 #endif
               xembed_eventHandler(&xev);
--- ./jdk/src/solaris/native/sun/awt/awt_Mlib.c	2011-05-26 18:56:44.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_Mlib.c	2011-04-22 23:08:39.000000000 -0700
@@ -32,6 +32,7 @@
 #include <dlfcn.h>
 #include "jni.h"
 #include <jni_util.h>
+#include "jvm_md.h"
 #include "awt_Mlib.h"
 #include "java_awt_image_BufferedImage.h"
 
@@ -67,11 +68,11 @@
         ((strncmp(name.machine, "sun4v" , 5) == 0) &&
          (getenv("USE_VIS_ON_SUN4V") != NULL)))
     {
-        handle = dlopen("libmlib_image_v.so", RTLD_LAZY);
+        handle = dlopen(JNI_LIB_NAME("mlib_image_v"), RTLD_LAZY);
     }
 
     if (handle == NULL) {
-        handle = dlopen("libmlib_image.so", RTLD_LAZY);
+        handle = dlopen(JNI_LIB_NAME("mlib_image"), RTLD_LAZY);
     }
 
     if (handle == NULL) {
--- ./jdk/src/solaris/native/sun/awt/awt_Robot.c	2011-05-26 18:56:44.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_Robot.c	2011-05-20 20:09:20.000000000 -0700
@@ -45,7 +45,7 @@
 #include "wsutils.h"
 #include "list.h"
 #include "multiVis.h"
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <sys/socket.h>
 #endif
 
@@ -196,7 +196,6 @@
     AWT_UNLOCK();
 }
 
-
 JNIEXPORT void JNICALL
 Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
                              jclass cls,
--- ./jdk/src/solaris/native/sun/awt/awt_util.h	2011-05-26 18:56:45.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_util.h	2011-04-22 23:08:39.000000000 -0700
@@ -187,15 +187,20 @@
 #ifdef __solaris__
 extern Widget awt_util_getXICStatusAreaWindow(Widget w);
 #else
+#if defined(_ALLBSD_SOURCE)
+int32_t awt_util_getIMStatusHeight(Widget vw);
+Widget awt_util_getXICStatusAreaWindow(Widget w);
+#else
 int32_t awt_util_getIMStatusHeight(Widget vw);
 XVaNestedList awt_util_getXICStatusAreaList(Widget w);
 Widget awt_util_getXICStatusAreaWindow(Widget w);
 #endif
+#endif
 
 
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 typedef struct _XmImRefRec {
   Cardinal      num_refs;       /* Number of referencing widgets. */
   Cardinal      max_refs;       /* Maximum length of refs array. */
--- ./jdk/src/solaris/native/sun/awt/awt_wm.c	2011-05-26 18:56:45.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_wm.c	2011-04-22 23:08:39.000000000 -0700
@@ -121,12 +121,19 @@
 static Atom XA_KWM_WIN_MAXIMIZED;
 
 /* OpenLook */
+static Atom _XA_OL_DECOR_ADD;
 static Atom _XA_OL_DECOR_DEL;
 static Atom _XA_OL_DECOR_HEADER;
 static Atom _XA_OL_DECOR_RESIZE;
 static Atom _XA_OL_DECOR_PIN;
 static Atom _XA_OL_DECOR_CLOSE;
 
+/* AfterStep */
+static Atom _XA_AS_STYLE;
+
+/* WindowMaker */
+static Atom _XA_WINDOWMAKER_STATE;
+
 /* For _NET_WM_STATE ClientMessage requests */
 #define _NET_WM_STATE_REMOVE    0 /* remove/unset property */
 #define _NET_WM_STATE_ADD       1 /* add/set property      */
@@ -193,7 +200,12 @@
         { &_XA_OL_DECOR_HEADER,              "_OL_DECOR_HEADER"              },
         { &_XA_OL_DECOR_RESIZE,              "_OL_DECOR_RESIZE"              },
         { &_XA_OL_DECOR_PIN,                 "_OL_DECOR_PIN"                 },
-        { &_XA_OL_DECOR_CLOSE,               "_OL_DECOR_CLOSE"               }
+        { &_XA_OL_DECOR_CLOSE,               "_OL_DECOR_CLOSE"               },
+	{ &_XA_OL_DECOR_ADD,		     "_OL_DECOR_ADD"		     },
+
+	{ &_XA_AS_STYLE,		     "_XA_AS_STYLE"		     },
+
+	{ &_XA_WINDOWMAKER_STATE,	     "_XA_WINDOWMAKER_STATE"	     }
     };
 #define ATOM_LIST_LENGTH (sizeof(atom_list)/sizeof(atom_list[0]))
 
@@ -942,6 +954,39 @@
     return True;
 }
 
+/*
+ * Window Maker.
+ */
+static Boolean
+awt_wm_isWindowmaker()
+{
+    if (awt_wm_atomInterned(&_XA_WINDOWMAKER_STATE, "_WINDOWMAKER_STATE"))
+        return True;
+    return False;
+}
+
+/*
+ * Afterstep.
+ */
+static Boolean
+awt_wm_isAfterstep()
+{
+    if (awt_wm_atomInterned(&_XA_AS_STYLE, "_AS_STYLE"))
+        return True;
+    return False;
+}
+
+/*
+ * FVWM 2.
+ */
+static Boolean
+awt_wm_isFvwm2()
+{
+    if (awt_wm_atomInterned(&_XA_OL_DECOR_ADD, "_OL_DECOR_ADD")
+        && !awt_wm_atomInterned(&_XA_OL_DECOR_PIN, "_OL_DECOR_PIN"))
+        return True;
+    return False;
+}
 
 static Boolean
 awt_wm_isNetWMName(char *name)
@@ -1280,6 +1325,12 @@
     else if (awt_wm_isKDE2()) {
         awt_wmgr = KDE2_WM;
     }
+    else if (awt_wm_isWindowmaker()) {
+	awt_wmgr = WINDOWMAKER_WM;
+    }
+    else if (awt_wm_isAfterstep()) {
+	awt_wmgr = AFTERSTEP_WM;
+    }
     /*
      * We don't check for legacy WM when we already know that WM
      * supports WIN or _NET wm spec.
@@ -1302,6 +1353,9 @@
         awt_wmgr = MOTIF_WM;
     }
     else if (awt_wm_isOpenLook()) {
+	awt_wmgr = OPENLOOK_WM;
+    }
+    else if (awt_wm_isFvwm2()) {
         awt_wmgr = OPENLOOK_WM;
     }
     else {
--- ./jdk/src/solaris/native/sun/awt/awt_wm.h	2011-05-26 18:56:45.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/awt_wm.h	2011-04-22 23:08:39.000000000 -0700
@@ -45,7 +45,10 @@
     KDE2_WM,
     SAWFISH_WM,
     ICE_WM,
-    METACITY_WM
+    METACITY_WM,
+    AFTERSTEP_WM,
+    WINDOWMAKER_WM,
+    FVWM2_WM
 };
 
 extern void awt_wm_init(void);
--- ./jdk/src/solaris/native/sun/awt/extutil.h	2011-05-26 18:56:45.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/extutil.h	2011-04-22 23:08:39.000000000 -0700
@@ -58,7 +58,7 @@
  */
 /* $XFree86: xc/include/extensions/extutil.h,v 1.5 2001/01/17 17:53:20 dawes Exp $ */
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 
 #ifndef _EXTUTIL_H_
 #define _EXTUTIL_H_
@@ -248,4 +248,4 @@
         char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
 #endif
 
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
--- ./jdk/src/solaris/native/sun/awt/fontpath.c	2011-05-26 18:56:46.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/fontpath.c	2011-05-12 20:55:07.000000000 -0700
@@ -23,7 +23,7 @@
  * questions.
  */
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <string.h>
 #endif /* __linux__ */
 #include <stdio.h>
@@ -40,6 +40,7 @@
 
 #include <jni.h>
 #include <jni_util.h>
+#include <jvm_md.h>
 #include <sun_font_FontManager.h>
 #ifndef HEADLESS
 #include <X11/Xlib.h>
@@ -58,10 +59,24 @@
 extern Display *awt_display;
 #endif /* !HEADLESS */
 
+#ifdef __APPLE__
+// XXXDARWIN: Hard-code the path to Apple's freetype, as it is
+// not included in the dyld search path by default, and 10.4
+// does not support -rpath.
+//
+// This ignores the build time setting of ALT_FREETYPE_LIB_PATH,
+// and should be replaced with -rpath/@rpath support on 10.5 or later,
+// or via support for a the FREETYPE_LIB_PATH define.
+#define FONTCONFIG_DLL_VERSIONED X11_PATH "/lib/" VERSIONED_JNI_LIB_NAME("fontconfig", "1")
+#define FONTCONFIG_DLL X11_PATH "/lib/" JNI_LIB_NAME("fontconfig")
+#else
+#define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
+#define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
+#endif
 
 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
 
-#ifndef __linux__
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
 /*
  * This can be set in the makefile to "/usr/X11" if so desired.
  */
@@ -111,24 +126,40 @@
     NULL, /* terminates the list */
 };
 
+#elif _ALLBSD_SOURCE
+static char *fullBSDFontPath[] = {
+    X11_PATH "/lib/X11/fonts/TrueType",
+    X11_PATH "/lib/X11/fonts/truetype",
+    X11_PATH "/lib/X11/fonts/tt",
+    X11_PATH "/lib/X11/fonts/TTF",
+    X11_PATH "/lib/X11/fonts/OTF",
+    PACKAGE_PATH "/share/fonts/TrueType",
+    PACKAGE_PATH "/share/fonts/truetype",
+    PACKAGE_PATH "/share/fonts/tt",
+    PACKAGE_PATH "/share/fonts/TTF",
+    PACKAGE_PATH "/share/fonts/OTF",
+    X11_PATH "/lib/X11/fonts/Type1",
+    PACKAGE_PATH "/share/fonts/Type1",
+    NULL, /* terminates the list */
+};
 #else /* __linux */
 /* All the known interesting locations we have discovered on
  * various flavors of Linux
  */
 static char *fullLinuxFontPath[] = {
-    "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */
-    "/usr/X11R6/lib/X11/fonts/truetype",  /* SuSE */
-    "/usr/X11R6/lib/X11/fonts/tt",
-    "/usr/X11R6/lib/X11/fonts/TTF",
-    "/usr/X11R6/lib/X11/fonts/OTF",       /* RH 9.0 (but empty!) */
-    "/usr/share/fonts/ja/TrueType",       /* RH 7.2+ */
-    "/usr/share/fonts/truetype",
-    "/usr/share/fonts/ko/TrueType",       /* RH 9.0 */
-    "/usr/share/fonts/zh_CN/TrueType",    /* RH 9.0 */
-    "/usr/share/fonts/zh_TW/TrueType",    /* RH 9.0 */
+    X11_PATH "/lib/X11/fonts/TrueType",  /* RH 7.1+ */
+    X11_PATH "/lib/X11/fonts/truetype",  /* SuSE */
+    X11_PATH "/lib/X11/fonts/tt",
+    X11_PATH "/lib/X11/fonts/TTF",
+    X11_PATH "/lib/X11/fonts/OTF",       /* RH 9.0 (but empty!) */
+    PACKAGE_PATH "/share/fonts/ja/TrueType",       /* RH 7.2+ */
+    PACKAGE_PATH "/share/fonts/truetype",
+    PACKAGE_PATH "/share/fonts/ko/TrueType",       /* RH 9.0 */
+    PACKAGE_PATH "/share/fonts/zh_CN/TrueType",    /* RH 9.0 */
+    PACKAGE_PATH "/share/fonts/zh_TW/TrueType",    /* RH 9.0 */
     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType", /* Debian */
-    "/usr/X11R6/lib/X11/fonts/Type1",
-    "/usr/share/fonts/default/Type1",     /* RH 9.0 */
+    X11_PATH "/lib/X11/fonts/Type1",
+    PACKAGE_PATH "/share/fonts/default/Type1",     /* RH 9.0 */
     NULL, /* terminates the list */
 };
 #endif
@@ -362,7 +393,7 @@
 
 #endif /* !HEADLESS */
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 /* from awt_LoadLibrary.c */
 JNIEXPORT jboolean JNICALL AWTIsHeadless();
 #endif
@@ -487,8 +518,10 @@
      */
     fcdirs = getFontConfigLocations();
 
-#ifdef __linux__
+#if defined(__linux__)
     knowndirs = fullLinuxFontPath;
+#elif defined(_ALLBSD_SOURCE)
+    knowndirs = fullBSDFontPath;
 #else /* IF SOLARIS */
     knowndirs = fullSolarisFontPath;
 #endif
@@ -499,7 +532,8 @@
      * be initialised.
      */
 #ifndef HEADLESS
-#ifdef __linux__        /* There's no headless build on linux ... */
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+    /* There's no headless build on linux ... */
     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
 #endif
       /* Using the X11 font path to locate font files is now a fallback
@@ -514,7 +548,7 @@
         x11dirs = getX11FontPath();
     }
     AWT_UNLOCK();
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     }
 #endif
 #endif /* !HEADLESS */
@@ -547,7 +581,7 @@
 }
 
 #include <dlfcn.h>
-#ifndef __linux__ /* i.e. is solaris */
+#if !(defined(__linux__) || defined(__APPLE__))
 #include <link.h>
 #endif
 
@@ -593,9 +627,9 @@
      * certain symbols - and functionality - to be available.
      * Also add explicit search for .so.1 in case .so symlink doesn't exist.
      */
-    libfontconfig = dlopen("libfontconfig.so.1", RTLD_LOCAL|RTLD_LAZY);
+    libfontconfig = dlopen(FONTCONFIG_DLL_VERSIONED, RTLD_LOCAL|RTLD_LAZY);
     if (libfontconfig == NULL) {
-        libfontconfig = dlopen("libfontconfig.so", RTLD_LOCAL|RTLD_LAZY);
+        libfontconfig = dlopen(FONTCONFIG_DLL, RTLD_LOCAL|RTLD_LAZY);
         if (libfontconfig == NULL) {
             return NULL;
         }
--- ./jdk/src/solaris/native/sun/awt/gtk2_interface.c	2011-05-26 18:56:46.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/gtk2_interface.c	2011-05-07 21:54:10.000000000 -0700
@@ -30,9 +30,12 @@
 #include <string.h>
 #include "gtk2_interface.h"
 #include "java_awt_Transparency.h"
+#include "jvm_md.h"
 
-#define GTK2_LIB "libgtk-x11-2.0.so.0"
-#define GTHREAD_LIB "libgthread-2.0.so.0"
+#define GTK2_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0")
+#define GTK2_LIB JNI_LIB_NAME("gtk-x11-2.0")
+#define GTHREAD_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gthread-2.0", "0")
+#define GTHREAD_LIB JNI_LIB_NAME("gthread-2.0")
 
 #define G_TYPE_INVALID                  G_TYPE_MAKE_FUNDAMENTAL (0)
 #define G_TYPE_NONE                     G_TYPE_MAKE_FUNDAMENTAL (1)
@@ -414,9 +417,12 @@
         void *lib = NULL;
         gboolean result = FALSE;
 
-        lib = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
+        lib = dlopen(GTK2_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
         if (lib == NULL) {
-            return FALSE;
+            lib = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
+            if (lib == NULL) {
+                return FALSE;
+            }
         }
 
         fp_gtk_check_version = dlsym(lib, "gtk_check_version");
@@ -470,11 +476,19 @@
     int (*io_handler)();
     char *gtk_modules_env;
 
-    gtk2_libhandle = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
-    gthread_libhandle = dlopen(GTHREAD_LIB, RTLD_LAZY | RTLD_LOCAL);
+    gtk2_libhandle = dlopen(GTK2_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+    if (gtk2_libhandle == NULL) {
+        gtk2_libhandle = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
+        if (gtk2_libhandle == NULL)
+            return FALSE;
+    }
 
-    if (gtk2_libhandle == NULL || gthread_libhandle == NULL)
-        return FALSE;
+    gthread_libhandle = dlopen(GTHREAD_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+    if (gthread_libhandle == NULL) {
+        gthread_libhandle = dlopen(GTHREAD_LIB, RTLD_LAZY | RTLD_LOCAL);
+        if (gthread_libhandle == NULL)
+            return FALSE;
+    }
 
     if (setjmp(j) == 0)
     {
--- ./jdk/src/solaris/native/sun/awt/list.c	2011-05-26 18:56:46.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/list.c	2011-04-22 23:08:39.000000000 -0700
@@ -66,7 +66,11 @@
   ----------------------------------------------------------------------- **/
 
 #include <stdio.h>
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 #include "list.h"
 
 
--- ./jdk/src/solaris/native/sun/awt/robot_common.c	2011-05-26 18:56:55.000000000 -0700
+++ ./jdk/src/solaris/native/sun/awt/robot_common.c	2011-04-22 23:08:39.000000000 -0700
@@ -27,6 +27,9 @@
     #error This file should not be included in headless library
 #endif
 
+#ifdef _ALLBSD_SOURCE
+#include <stdlib.h>
+#endif
 #include "robot_common.h"
 
 /*
--- ./jdk/src/solaris/native/sun/font/X11FontScaler.c	2011-05-26 18:56:56.000000000 -0700
+++ ./jdk/src/solaris/native/sun/font/X11FontScaler.c	2011-04-22 23:08:39.000000000 -0700
@@ -32,7 +32,11 @@
  * into X11FontScaler_md.c, which is compiled into another library.
  */
 #include <stdio.h>
+#if defined(_ALLBSD_SOURCE)
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 #include <ctype.h>
 #include <sys/utsname.h>
 
--- ./jdk/src/solaris/native/sun/font/X11TextRenderer.c	2011-05-26 18:56:57.000000000 -0700
+++ ./jdk/src/solaris/native/sun/font/X11TextRenderer.c	2011-04-22 23:08:39.000000000 -0700
@@ -39,7 +39,11 @@
 #include "GraphicsPrimitiveMgr.h"
 #include "glyphblitting.h"
 #include "sunfontids.h"
+#if defined(_ALLBSD_SOURCE)
+#include <stdlib.h>
+#else
 #include <malloc.h>
+#endif
 
 
 JNIEXPORT void JNICALL AWTDrawGlyphList
--- ./jdk/src/solaris/native/sun/java2d/j2d_md.h	2011-05-26 18:56:57.000000000 -0700
+++ ./jdk/src/solaris/native/sun/java2d/j2d_md.h	2011-04-22 23:08:39.000000000 -0700
@@ -28,11 +28,11 @@
 #include <sys/types.h>
 
 /*
- * Linux version of <sys/types.h> does not define intptr_t
+ * Linux and BSD's version of <sys/types.h> does not define intptr_t
  */
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <stdint.h>
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
 
 typedef unsigned char   jubyte;
 typedef unsigned short  jushort;
--- ./jdk/src/solaris/native/sun/java2d/loops/mlib_ImageZoom_NN.c	2011-05-26 18:56:57.000000000 -0700
+++ ./jdk/src/solaris/native/sun/java2d/loops/mlib_ImageZoom_NN.c	2011-04-22 23:08:39.000000000 -0700
@@ -63,6 +63,10 @@
  *    MLIB_EDGE_SRC_PADDED
  */
 
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#endif
+#include <machine/endian.h>
 #include <mlib_image.h>
 #include <mlib_ImageZoom.h>
 
@@ -99,7 +103,7 @@
 
 /***************************************************************/
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 
 static const mlib_u32 mlib_bit_mask4[16] = {
   0x00000000u, 0xFF000000u, 0x00FF0000u, 0xFFFF0000u,
@@ -108,7 +112,7 @@
   0x0000FFFFu, 0xFF00FFFFu, 0x00FFFFFFu, 0xFFFFFFFFu
 };
 
-#else /* _LITTLE_ENDIAN */
+#else /* BIG_ENDIAN */
 
 static const mlib_u32 mlib_bit_mask4[16] = {
   0x00000000u, 0x000000FFu, 0x0000FF00u, 0x0000FFFFu,
@@ -117,7 +121,7 @@
   0xFFFF0000u, 0xFFFF00FFu, 0xFFFFFF00u, 0xFFFFFFFFu
 };
 
-#endif /* _LITTLE_ENDIAN */
+#endif /* LITTLE_ENDIAN */
 
 /***************************************************************/
 
@@ -341,11 +345,11 @@
 #ifdef _NO_LONGLONG
 
 typedef struct {
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
   mlib_u32 uint1, uint0;
-#else /* _LITTLE_ENDIAN */
+#else /* BIG_ENDIAN */
   mlib_u32 uint0, uint1;
-#endif /* _LITTLE_ENDIAN */
+#endif /* LITTLE_ENDIAN */
 } two_uint;
 
 /***************************************************************/
@@ -508,11 +512,11 @@
         DTYPE mask;
         MASK(mask);
         off *= 8;
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
         LSHIFT(dd_old, da[0], 64 - off);
-#else /* _LITTLE_ENDIAN */
+#else /* BIG_ENDIAN */
         RSHIFT(dd_old, da[0], 64 - off);
-#endif /* _LITTLE_ENDIAN */
+#endif /* LITTLE_ENDIAN */
 
 #ifdef __SUNPRO_C
 #pragma pipeloop(0)
@@ -537,30 +541,30 @@
 
           res = (res & 0xff) | (res >> 8);
           dd = gray_mask[res];
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 /* *da++ = (dd_old >> (64 - off)) | (dd << off);*/
           RSHIFT(dd_old, dd_old, 64 - off);
           LSHIFT(dtmp, dd, off);
-#else /* _LITTLE_ENDIAN */
+#else /* BIG_ENDIAN */
 /* *da++ = (dd_old << (64 - off)) | (dd >> off);*/
           LSHIFT(dd_old, dd_old, 64 - off);
           RSHIFT(dtmp, dd, off);
-#endif /* _LITTLE_ENDIAN */
+#endif /* LITTLE_ENDIAN */
           LOGIC(*da++, dd_old, dtmp, |);
           dd_old = dd;
         }
 
-#ifdef _LITTLE_ENDIAN
+#if (BYTE_ORDER == LITTLE_ENDIAN)
 /* da[0] = (dd_old >> (64 - off)) | (da[0] & ((mlib_u64)((mlib_s64) -1) << off));*/
         LSHIFT(dtmp, mask, off);
         LOGIC(dtmp, da[0], dtmp, &);
         RSHIFT(dtmp1, dd_old, 64 - off);
-#else /* _LITTLE_ENDIAN */
+#else /* BIG_ENDIAN */
 /* da[0] = (dd_old << (64 - off)) | (da[0] & ((mlib_u64)((mlib_s64) -1) >> off));*/
         RSHIFT(dtmp, mask, off);
         LOGIC(dtmp, da[0], dtmp, &);
         LSHIFT(dtmp1, dd_old, 64 - off);
-#endif /* _LITTLE_ENDIAN */
+#endif /* LITTLE_ENDIAN */
         LOGIC(da[0], dtmp, dtmp1, |);
       }
       else {                                               /* aligned */
--- ./jdk/src/solaris/native/sun/java2d/loops/vis_FuncArray.c	2011-05-26 18:56:59.000000000 -0700
+++ ./jdk/src/solaris/native/sun/java2d/loops/vis_FuncArray.c	2011-04-22 23:08:39.000000000 -0700
@@ -804,7 +804,7 @@
 static int initialized;
 static int usevis = JNI_TRUE;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #   define ULTRA_CHIP   "sparc64"
 #else
 #   define ULTRA_CHIP   "sun4u"
--- ./jdk/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h	2011-05-26 18:57:01.000000000 -0700
+++ ./jdk/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h	2011-04-22 23:08:39.000000000 -0700
@@ -27,7 +27,10 @@
 #define OGLFuncs_md_h_Included
 
 #include <stdlib.h>
+#ifndef __APPLE__
 #include <link.h>
+#endif
+#include "jvm_md.h"
 #include "J2D_GL/glx.h"
 #include "OGLFuncMacros.h"
 
@@ -113,7 +116,7 @@
     { \
         char *libGLPath = getenv("J2D_ALT_LIBGL_PATH"); \
         if (libGLPath == NULL) { \
-            libGLPath = "libGL.so.1"; \
+            libGLPath = VERSIONED_JNI_LIB_NAME("GL", "1"); \
         } \
         OGL_LIB_HANDLE = dlopen(libGLPath, RTLD_LAZY | RTLD_LOCAL); \
     } \
--- ./jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	2011-05-26 18:57:01.000000000 -0700
+++ ./jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	2011-04-22 23:08:39.000000000 -0700
@@ -32,6 +32,7 @@
 #include "gdefs.h"
 
 #include "jni_util.h"
+#include "jvm_md.h"
 #include "awt_Component.h"
 #include "awt_GraphicsEnv.h"
 
@@ -163,7 +164,7 @@
 
     if (tryDGA && (getenv("NO_J2D_DGA") == NULL)) {
     /* we use RTLD_NOW because of bug 4032715 */
-        lib = dlopen("libsunwjdga.so", RTLD_NOW);
+        lib = dlopen(JNI_LIB_NAME("sunwjdga"), RTLD_NOW);
     }
 
     if (lib != NULL) {
--- ./jdk/src/solaris/native/sun/jdga/dgalock.c	2011-05-26 18:57:02.000000000 -0700
+++ ./jdk/src/solaris/native/sun/jdga/dgalock.c	2011-04-22 23:08:39.000000000 -0700
@@ -44,6 +44,7 @@
 #include <X11/Xlib.h>
 
 #include "jni.h"
+#include "jvm_md.h"
 #include "jdga.h"
 #include "jdgadevice.h"
 
@@ -84,10 +85,10 @@
 static GetVirtualDrawableFunc * GetVirtualDrawable = GetVirtualDrawableStub;
 
 static void Solaris_DGA_XineramaInit(Display *display) {
-    void * handle = 0;
+    void * handle = NULL;
     if (IsXineramaOn == NULL) {
-        handle = dlopen("libxinerama.so", RTLD_NOW);
-        if (handle != 0) {
+        handle = dlopen(JNI_LIB_NAME("xinerama"), RTLD_NOW);
+        if (handle != NULL) {
             void *sym = dlsym(handle, "IsXineramaOn");
             IsXineramaOn = (IsXineramaOnFunc *)sym;
             if (IsXineramaOn != 0 && (*IsXineramaOn)(display)) {
--- ./jdk/src/solaris/native/sun/management/FileSystemImpl.c	2011-05-26 18:57:02.000000000 -0700
+++ ./jdk/src/solaris/native/sun/management/FileSystemImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -30,6 +30,10 @@
 #include "jni_util.h"
 #include "sun_management_FileSystemImpl.h"
 
+#ifdef _ALLBSD_SOURCE
+#define stat64 stat
+#endif
+
 /*
  * Class:     sun_management_FileSystemImpl
  * Method:    isAccessUserOnly0
--- ./jdk/src/solaris/native/sun/net/dns/ResolverConfigurationImpl.c	2011-05-26 18:57:02.000000000 -0700
+++ ./jdk/src/solaris/native/sun/net/dns/ResolverConfigurationImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -33,7 +33,7 @@
 #include <strings.h>
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <string.h>
 #endif
 
--- ./jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c	2011-05-26 18:57:03.000000000 -0700
+++ ./jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c	2011-04-22 23:08:39.000000000 -0700
@@ -26,11 +26,12 @@
 #include "jni.h"
 #include "jni_util.h"
 #include "jvm.h"
+#include "jvm_md.h"
 #include "jlong.h"
 #include "sun_net_spi_DefaultProxySelector.h"
 #include <dlfcn.h>
 #include <stdio.h>
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <string.h>
 #else
 #include <strings.h>
@@ -110,8 +111,9 @@
   /**
    * Let's try to load le GConf-2 library
    */
-  if (dlopen("libgconf-2.so", RTLD_GLOBAL | RTLD_LAZY) != NULL ||
-      dlopen("libgconf-2.so.4", RTLD_GLOBAL | RTLD_LAZY) != NULL) {
+  if (dlopen(JNI_LIB_NAME("gconf-2"), RTLD_GLOBAL | RTLD_LAZY) != NULL ||
+      dlopen(VERSIONED_JNI_LIB_NAME("gconf-2", "4"),
+             RTLD_GLOBAL | RTLD_LAZY) != NULL) {
     gconf_ver = 2;
   }
   if (gconf_ver > 0) {
--- ./jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c	2011-05-26 18:57:03.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -35,7 +35,7 @@
 #include <string.h>
 #include <errno.h>
 
-#if __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <netinet/in.h>
 #endif
 
@@ -86,7 +86,7 @@
     rv = connect(fd, 0, 0);
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     {
         int len;
         SOCKADDR sa;
@@ -96,17 +96,30 @@
 #ifdef AF_INET6
         if (ipv6_available()) {
             struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)&sa;
+#if defined(_ALLBSD_SOURCE)
+	    him6->sin6_family = AF_INET6;
+#else
             him6->sin6_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in6);
         } else
 #endif
         {
             struct sockaddr_in *him4 = (struct sockaddr_in*)&sa;
+#if defined(_ALLBSD_SOURCE)
+	    him4->sin_family = AF_INET;
+#else
             him4->sin_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in);
         }
 
         rv = connect(fd, (struct sockaddr *)&sa, len);
+
+#if defined(_ALLBSD_SOURCE)
+	if (rv < 0 && errno == EADDRNOTAVAIL)
+		rv = errno = 0;
+#endif
     }
 #endif
 
--- ./jdk/src/solaris/native/sun/nio/ch/DatagramDispatcher.c	2011-05-26 18:57:03.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/DatagramDispatcher.c	2011-04-22 23:08:39.000000000 -0700
@@ -73,7 +73,7 @@
     m.msg_accrightslen = 0;
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     m.msg_control = NULL;
     m.msg_controllen = 0;
 #endif
@@ -121,7 +121,7 @@
     m.msg_accrightslen = 0;
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     m.msg_control = NULL;
     m.msg_controllen = 0;
 #endif
--- ./jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c	2011-05-26 18:57:03.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -26,9 +26,11 @@
 #include "jni.h"
 #include "jni_util.h"
 #include "jvm.h"
+#include "jvm_md.h"
 #include "jlong.h"
 #include <sys/mman.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include "sun_nio_ch_FileChannelImpl.h"
 #include "java_lang_Integer.h"
 #include "nio.h"
@@ -37,6 +39,13 @@
 
 #if defined(__linux__) || defined(__solaris__)
 #include <sys/sendfile.h>
+#elif defined(_ALLBSD_SOURCE)
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+#define lseek64 lseek
+#define mmap64 mmap
 #endif
 
 static jfieldID chan_fd;        /* jobject 'fd' in sun.io.FileChannelImpl */
@@ -192,7 +201,36 @@
         return IOS_THROWN;
     }
     return result;
+#elif defined(__APPLE__) || defined(__FreeBSD__)
+    off_t numBytes;
+    int result;
+
+    numBytes = count;
+
+#ifdef __APPLE__
+    result = sendfile(srcFD, dstFD, position, &numBytes, NULL, 0);
+#elif defined(__FreeBSD__)
+    result = sendfile(srcFD, dstFD, position, count, NULL, &numBytes, 0);
+#endif
+
+    if (numBytes > 0)
+        return numBytes;
+
+    if (result == -1) {
+        if (errno == EAGAIN)
+            return IOS_UNAVAILABLE;
+        if (errno == EOPNOTSUPP || errno == ENOTSOCK || errno == ENOTCONN)
+            return IOS_UNSUPPORTED_CASE;
+        if ((errno == EINVAL) && ((ssize_t)count >= 0))
+            return IOS_UNSUPPORTED_CASE;
+        if (errno == EINTR)
+            return IOS_INTERRUPTED;
+        JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");
+        return IOS_THROWN;
+    }
+
+    return result;
 #else
-    return IOS_UNSUPPORTED_CASE;
+    return IOS_UNSUPPORTED;
 #endif
 }
--- ./jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c	2011-05-26 18:57:04.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -33,9 +33,24 @@
 #include <sys/socket.h>
 #include <fcntl.h>
 #include <sys/uio.h>
+#include <unistd.h>
 #include "nio.h"
 #include "nio_util.h"
 
+#ifdef _ALLBSD_SOURCE
+#define stat64 stat
+#define flock64 flock
+#define off64_t off_t
+#define F_SETLKW64 F_SETLKW
+#define F_SETLK64 F_SETLK
+
+#define pread64 pread
+#define pwrite64 pwrite
+#define ftruncate64 ftruncate
+#define fstat64 fstat
+
+#define fdatasync fsync
+#endif
 
 static int preCloseFD = -1;     /* File descriptor to which we dup other fd's
                                    before closing them for real */
@@ -218,6 +233,23 @@
     fl.l_start = (off64_t)pos;
     fl.l_type = F_UNLCK;
     lockResult = fcntl(fd, cmd, &fl);
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+    /* XXXFREEBSD:  While doing of preClose0() we're closing actual fd which
+       was locked, so here we'll get an error which need to be ignored to
+       satisfy TCK FileLock test */
+    /* XXXFREEBSD: backport to 1.4.2 */
+    if (lockResult < 0 && errno == EBADF)
+	lockResult = errno = 0;
+#endif
+#if defined(__NetBSD__)
+    /* XXXNETBSD: The dup2 in preClose0 is being done onto 1 end of a
+       socketpair which isn't a valid target for F_UNLCK. No good way to see
+       this vs. a bad lock setup so just return errno = 0 there
+       to pass JCK (lock will get removed once all fd's close anyways) */
+    /* XXXNETBSD: backport to 1.4.2 */
+    if (lockResult < 0 && errno == EINVAL)
+	lockResult = errno = 0;
+#endif
     if (lockResult < 0) {
         JNU_ThrowIOExceptionWithLastError(env, "Release failed");
     }
--- ./jdk/src/solaris/native/sun/nio/ch/FileKey.c	2011-05-26 18:57:04.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/FileKey.c	2011-04-22 23:08:39.000000000 -0700
@@ -30,6 +30,12 @@
 #include "nio_util.h"
 #include "sun_nio_ch_FileKey.h"
 
+#ifdef _ALLBSD_SOURCE
+#define stat64 stat
+
+#define fstat64 fstat
+#endif
+
 static jfieldID key_st_dev;    /* id for FileKey.st_dev */
 static jfieldID key_st_ino;    /* id for FileKey.st_ino */
 
--- ./jdk/src/solaris/native/sun/nio/ch/Net.c	2011-05-26 18:57:04.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/Net.c	2011-04-22 23:08:39.000000000 -0700
@@ -116,6 +116,47 @@
 
 #endif   /* __linux__ */
 
+#ifdef _ALLBSD_SOURCE
+
+#ifndef IP_BLOCK_SOURCE
+
+#define IP_ADD_SOURCE_MEMBERSHIP        70   /* join a source-specific group */
+#define IP_DROP_SOURCE_MEMBERSHIP       71   /* drop a single source */
+#define IP_BLOCK_SOURCE                 72   /* block a source */
+#define IP_UNBLOCK_SOURCE               73   /* unblock a source */
+
+#endif  /* IP_BLOCK_SOURCE */
+
+#ifndef MCAST_BLOCK_SOURCE
+
+#define MCAST_JOIN_SOURCE_GROUP         82   /* join a source-specific group */
+#define MCAST_LEAVE_SOURCE_GROUP        83   /* leave a single source */
+#define MCAST_BLOCK_SOURCE              84   /* block a source */
+#define MCAST_UNBLOCK_SOURCE            85   /* unblock a source */
+
+#endif /* MCAST_BLOCK_SOURCE */
+
+#ifndef IPV6_ADD_MEMBERSHIP
+
+#define IPV6_ADD_MEMBERSHIP	IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP	IPV6_LEAVE_GROUP
+
+#endif /* IPV6_ADD_MEMBERSHIP */
+
+struct my_ip_mreq_source {
+        struct in_addr  imr_multiaddr;
+        struct in_addr  imr_interface;
+        struct in_addr  imr_sourceaddr;
+};
+
+struct my_group_source_req {
+        uint32_t                gsr_interface;  /* interface index */
+        struct sockaddr_storage gsr_group;      /* group address */
+        struct sockaddr_storage gsr_source;     /* source address */
+};
+
+#endif   /* _ALLBSD_SOURCE */
+
 
 #define COPY_INET6_ADDRESS(env, source, target) \
     (*env)->GetByteArrayRegion(env, source, 0, 16, target)
@@ -287,8 +328,30 @@
     SOCKADDR sa;
     socklen_t sa_len = SOCKADDR_LEN;
     if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+#ifdef _ALLBSD_SOURCE
+	/*
+	 * XXXBSD:
+	 * ECONNRESET is specific to the BSDs. We can not return an error,
+	 * as the calling Java code with raise a java.lang.Error given the expectation
+	 * that getsockname() will never fail. According to the Single UNIX Specification,
+	 * it shouldn't fail. As such, we just fill in generic Linux-compatible values.
+	 */
+	if (errno == ECONNRESET) {
+	    struct sockaddr_in *sin;
+	    sin = (struct sockaddr_in *) &sa;
+	    bzero(sin, sizeof(*sin));
+	    sin->sin_len  = sizeof(struct sockaddr_in);
+	    sin->sin_family = AF_INET;
+	    sin->sin_port = htonl(0);
+	    sin->sin_addr.s_addr = INADDR_ANY;
+	} else {
+	    handleSocketError(env, errno);
+	    return -1;
+	}
+#else /* _ALLBSD_SOURCE */
         handleSocketError(env, errno);
         return -1;
+#endif /* _ALLBSD_SOURCE */
     }
     return NET_GetPortFromSockaddr((struct sockaddr *)&sa);
 }
@@ -300,8 +363,30 @@
     socklen_t sa_len = SOCKADDR_LEN;
     int port;
     if (getsockname(fdval(env, fdo), (struct sockaddr *)&sa, &sa_len) < 0) {
+#ifdef _ALLBSD_SOURCE
+	/*
+	 * XXXBSD:
+	 * ECONNRESET is specific to the BSDs. We can not return an error,
+	 * as the calling Java code with raise a java.lang.Error with the expectation
+	 * that getsockname() will never fail. According to the Single UNIX Specification,
+	 * it shouldn't fail. As such, we just fill in generic Linux-compatible values.
+	 */
+	if (errno == ECONNRESET) {
+	    struct sockaddr_in *sin;
+	    sin = (struct sockaddr_in *) &sa;
+	    bzero(sin, sizeof(*sin));
+	    sin->sin_len  = sizeof(struct sockaddr_in);
+	    sin->sin_family = AF_INET;
+	    sin->sin_port = htonl(0);
+	    sin->sin_addr.s_addr = INADDR_ANY;
+	} else {
+	    handleSocketError(env, errno);
+	    return NULL;
+	}
+#else /* _ALLBSD_SOURCE */
         handleSocketError(env, errno);
         return NULL;
+#endif /* _ALLBSD_SOURCE */
     }
     return NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
 }
@@ -365,7 +450,8 @@
     struct linger linger;
     u_char carg;
     void *parg;
-    int arglen, n;
+    socklen_t arglen;
+    int n;
 
     /* Option value is an int except for a few specific cases */
 
@@ -528,7 +614,7 @@
 Java_sun_nio_ch_Net_setInterface4(JNIEnv* env, jobject this, jobject fdo, jint interf)
 {
     struct in_addr in;
-    int arglen = sizeof(struct in_addr);
+    socklen_t arglen = sizeof(struct in_addr);
     int n;
 
     in.s_addr = htonl(interf);
@@ -559,7 +645,7 @@
 Java_sun_nio_ch_Net_setInterface6(JNIEnv* env, jobject this, jobject fdo, jint index)
 {
     int value = (jint)index;
-    int arglen = sizeof(value);
+    socklen_t arglen = sizeof(value);
     int n;
 
     n = setsockopt(fdval(env, fdo), IPPROTO_IPV6, IPV6_MULTICAST_IF,
@@ -602,9 +688,11 @@
     switch (errorValue) {
         case EINPROGRESS:       /* Non-blocking connect */
             return 0;
+#ifdef EPROTO
         case EPROTO:
             xn = JNU_JAVANETPKG "ProtocolException";
             break;
+#endif
         case ECONNREFUSED:
             xn = JNU_JAVANETPKG "ConnectException";
             break;
--- ./jdk/src/solaris/native/sun/nio/ch/Sctp.h	2011-05-26 18:57:04.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/Sctp.h	2011-04-22 23:08:39.000000000 -0700
@@ -67,7 +67,7 @@
 
 
 
-#else /* __linux__ */
+#elif __linux__
 #include <stdint.h>
 #include <linux/types.h>
 #include <sys/socket.h>
@@ -320,8 +320,20 @@
 typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
 
 
+#elif defined(__FreeBSD__) && __FreeBSD__ >= 7
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/sctp.h>
+#include <netinet/sctp_peeloff.h>
+#include <netinet/sctp_uio.h>
+#include "jni.h"
+
 #endif /* __linux__ */
 
+#if !defined(__FreeBSD__) || __FreeBSD__ < 7
+
 sctp_getladdrs_func* nio_sctp_getladdrs;
 sctp_freeladdrs_func* nio_sctp_freeladdrs;
 sctp_getpaddrs_func* nio_sctp_getpaddrs;
@@ -329,6 +341,17 @@
 sctp_bindx_func* nio_sctp_bindx;
 sctp_peeloff_func* nio_sctp_peeloff;
 
+#else
+
+#define nio_sctp_getladdrs	sctp_getladdrs
+#define nio_sctp_freeladdrs	sctp_freeladdrs
+#define nio_sctp_getpaddrs	sctp_getpaddrs
+#define nio_sctp_freepaddrs	sctp_freepaddrs
+#define nio_sctp_bindx		sctp_bindx
+#define nio_sctp_peeloff	sctp_peeloff
+
+#endif
+
 jboolean loadSocketExtensionFuncs(JNIEnv* env);
 
 #endif /* !SUN_NIO_CH_SCTP_H */
--- ./jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c	2011-05-26 18:57:04.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c	2011-04-22 23:08:39.000000000 -0700
@@ -337,11 +337,11 @@
             break;
         case SCTP_ADDR_MADE_PRIM :
             event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_MADE_PRIM;
-#ifdef __linux__  /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
+#ifndef __solaris__  /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
             break;
         case SCTP_ADDR_CONFIRMED :
             event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_CONFIRMED;
-#endif  /* __linux__ */
+#endif  /* __solaris__ */
     }
 
     addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
--- ./jdk/src/solaris/native/sun/nio/ch/SctpNet.c	2011-05-26 18:57:04.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/ch/SctpNet.c	2011-04-22 23:08:39.000000000 -0700
@@ -58,6 +58,7 @@
  */
 jboolean loadSocketExtensionFuncs
   (JNIEnv* env) {
+#if !defined(__FreeBSD__) || __FreeBSD__ < 7 /* On FreeBSD 7.x these functions are in libc */
     if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
         JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
               dlerror());
@@ -105,6 +106,7 @@
               dlerror());
         return JNI_FALSE;
     }
+#endif /* __FreeBSD__ */
 
     funcsLoaded = JNI_TRUE;
     return JNI_TRUE;
--- ./jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c	2011-04-22 23:08:39.000000000 -0700
@@ -28,23 +28,35 @@
 #include "jvm.h"
 #include "jlong.h"
 
-#include <stdio.h>
-#include <dlfcn.h>
-#include <errno.h>
-#include <mntent.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#ifdef ST_RDONLY
+#define statfs statvfs
+#define getfsstat getvfsstat
+#define f_flags f_flag
+#define ISREADONLY ST_RDONLY
+#else
+#define ISREADONLY MNT_RDONLY
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+static jfieldID entry_name;
+static jfieldID entry_dir;
+static jfieldID entry_fstype;
+static jfieldID entry_options;
+static jfieldID entry_dev;
+
+
+struct fsstat_iter {
+    struct statfs *buf;
+    int pos;
+    int nentries;
+};
 
 #include "sun_nio_fs_BsdNativeDispatcher.h"
 
-typedef size_t fgetxattr_func(int fd, const char* name, void* value, size_t size);
-typedef int fsetxattr_func(int fd, const char* name, void* value, size_t size, int flags);
-typedef int fremovexattr_func(int fd, const char* name);
-typedef int flistxattr_func(int fd, char* list, size_t size);
-
-fgetxattr_func* my_fgetxattr_func = NULL;
-fsetxattr_func* my_fsetxattr_func = NULL;
-fremovexattr_func* my_fremovexattr_func = NULL;
-flistxattr_func* my_flistxattr_func = NULL;
-
 static void throwUnixException(JNIEnv* env, int errnum) {
     jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
         "(I)V", errnum);
@@ -53,108 +65,146 @@
     }
 }
 
+/**
+ * Initialize jfieldIDs
+ */
 JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_init(JNIEnv *env, jclass clazz)
+Java_sun_nio_fs_BsdNativeDispatcher_initIDs(JNIEnv* env, jclass this)
 {
-    my_fgetxattr_func = (fgetxattr_func*)dlsym(RTLD_DEFAULT, "fgetxattr");
-    my_fsetxattr_func = (fsetxattr_func*)dlsym(RTLD_DEFAULT, "fsetxattr");
-    my_fremovexattr_func = (fremovexattr_func*)dlsym(RTLD_DEFAULT, "fremovexattr");
-    my_flistxattr_func = (flistxattr_func*)dlsym(RTLD_DEFAULT, "flistxattr");
-}
+    jclass clazz;
 
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_fgetxattr0(JNIEnv* env, jclass clazz,
-    jint fd, jlong nameAddress, jlong valueAddress, jint valueLen)
-{
-    size_t res = -1;
-    const char* name = jlong_to_ptr(nameAddress);
-    void* value = jlong_to_ptr(valueAddress);
-
-    if (my_fgetxattr_func == NULL) {
-        errno = ENOTSUP;
-    } else {
-        /* EINTR not documented */
-        res = (*my_fgetxattr_func)(fd, name, value, valueLen);
-    }
-    if (res == (size_t)-1)
-        throwUnixException(env, errno);
-    return (jint)res;
+    clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry");
+    if (clazz == NULL) {
+        return;
+    }
+    entry_name = (*env)->GetFieldID(env, clazz, "name", "[B");
+    entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
+    entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
+    entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
+    entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
 }
 
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_fsetxattr0(JNIEnv* env, jclass clazz,
-    jint fd, jlong nameAddress, jlong valueAddress, jint valueLen)
+JNIEXPORT jlong JNICALL
+Java_sun_nio_fs_BsdNativeDispatcher_getfsstat(JNIEnv* env, jclass this)
 {
-    int res = -1;
-    const char* name = jlong_to_ptr(nameAddress);
-    void* value = jlong_to_ptr(valueAddress);
-
-    if (my_fsetxattr_func == NULL) {
-        errno = ENOTSUP;
-    } else {
-        /* EINTR not documented */
-        res = (*my_fsetxattr_func)(fd, name, value, valueLen, 0);
+    int nentries;
+    size_t bufsize;
+    struct fsstat_iter *iter = malloc(sizeof(*iter));
+
+    if (iter == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "native heap");
+        return 0;
     }
-    if (res == -1)
+
+    iter->pos = 0;
+    iter->nentries = 0;
+    iter->buf = NULL;
+
+    nentries = getfsstat(NULL, 0, MNT_NOWAIT);
+
+    if (nentries <= 0) {
+        free(iter);
         throwUnixException(env, errno);
-}
+        return 0;
+    }
 
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_fremovexattr0(JNIEnv* env, jclass clazz,
-    jint fd, jlong nameAddress)
-{
-    int res = -1;
-    const char* name = jlong_to_ptr(nameAddress);
+    // It's possible that a new filesystem gets mounted between
+    // the first getfsstat and the second so loop until consistant
+
+    while (nentries != iter->nentries) {
+        if (iter->buf != NULL)
+            free(iter->buf);
+
+        bufsize = nentries * sizeof(struct statfs);
+        iter->nentries = nentries;
+
+        iter->buf = malloc(bufsize);
+        if (iter->buf == NULL) {
+            free(iter);
+            JNU_ThrowOutOfMemoryError(env, "native heap");
+            return 0;
+        }
 
-    if (my_fremovexattr_func == NULL) {
-        errno = ENOTSUP;
-    } else {
-        /* EINTR not documented */
-        res = (*my_fremovexattr_func)(fd, name);
+        nentries = getfsstat(iter->buf, bufsize, MNT_WAIT);
+        if (nentries <= 0) {
+            free(iter->buf);
+            free(iter);
+            throwUnixException(env, errno);
+            return 0;
+        }
     }
-    if (res == -1)
-        throwUnixException(env, errno);
+
+    return (jlong)iter;
 }
 
 JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_flistxattr(JNIEnv* env, jclass clazz,
-    jint fd, jlong listAddress, jint size)
+Java_sun_nio_fs_BsdNativeDispatcher_fsstatEntry(JNIEnv* env, jclass this,
+    jlong value, jobject entry)
 {
-    size_t res = -1;
-    char* list = jlong_to_ptr(listAddress);
+    struct fsstat_iter *iter = jlong_to_ptr(value);
+    jsize len;
+    jbyteArray bytes;
+    char* name;
+    char* dir;
+    char* fstype;
+    char* options;
+    dev_t dev;
+
+    if (iter == NULL || iter->pos >= iter->nentries)
+       return -1;
+
+    name = iter->buf[iter->pos].f_mntfromname;
+    dir = iter->buf[iter->pos].f_mntonname;
+    fstype = iter->buf[iter->pos].f_fstypename;
+    if (iter->buf[iter->pos].f_flags & ISREADONLY)
+        options="ro";
+    else
+        options="";
+    dev = 0;
+
+    iter->pos++;
+
+    len = strlen(name);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
+    (*env)->SetObjectField(env, entry, entry_name, bytes);
+
+    len = strlen(dir);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
+    (*env)->SetObjectField(env, entry, entry_dir, bytes);
+
+    len = strlen(fstype);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
+    (*env)->SetObjectField(env, entry, entry_fstype, bytes);
+
+    len = strlen(options);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
+    (*env)->SetObjectField(env, entry, entry_options, bytes);
 
-    if (my_flistxattr_func == NULL) {
-        errno = ENOTSUP;
-    } else {
-        /* EINTR not documented */
-        res = (*my_flistxattr_func)(fd, list, (size_t)size);
-    }
-    if (res == (size_t)-1)
-        throwUnixException(env, errno);
-    return (jint)res;
-}
+    if (dev != 0)
+        (*env)->SetLongField(env, entry, entry_dev, (jlong)dev);
 
-JNIEXPORT jlong JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_setmntent0(JNIEnv* env, jclass this, jlong pathAddress,
-                                                 jlong modeAddress)
-{
-    FILE* fp = NULL;
-    const char* path = (const char*)jlong_to_ptr(pathAddress);
-    const char* mode = (const char*)jlong_to_ptr(modeAddress);
-
-    do {
-        fp = setmntent(path, mode);
-    } while (fp == NULL && errno == EINTR);
-    if (fp == NULL) {
-        throwUnixException(env, errno);
-    }
-    return ptr_to_jlong(fp);
+    return 0;
 }
 
 JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdNativeDispatcher_endmntent(JNIEnv* env, jclass this, jlong stream)
+Java_sun_nio_fs_BsdNativeDispatcher_endfsstat(JNIEnv* env, jclass this, jlong value)
 {
-    FILE* fp = jlong_to_ptr(stream);
-    /* FIXME - man page doesn't explain how errors are returned */
-    endmntent(fp);
+    struct fsstat_iter *iter = jlong_to_ptr(value);
+
+    if (iter != NULL) {
+        free(iter->buf);
+        free(iter);
+    }
 }
--- ./jdk/src/solaris/native/sun/nio/fs/BsdWatchService.c	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/fs/BsdWatchService.c	1969-12-31 16:00:00.000000000 -0800
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "jni.h"
-#include "jni_util.h"
-#include "jvm.h"
-#include "jlong.h"
-
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/poll.h>
-#include <sys/inotify.h>
-
-#include "sun_nio_fs_BsdWatchService.h"
-
-static void throwUnixException(JNIEnv* env, int errnum) {
-    jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
-        "(I)V", errnum);
-    if (x != NULL) {
-        (*env)->Throw(env, x);
-    }
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdWatchService_eventSize(JNIEnv *env, jclass clazz)
-{
-    return (jint)sizeof(struct inotify_event);
-}
-
-JNIEXPORT jintArray JNICALL
-Java_sun_nio_fs_BsdWatchService_eventOffsets(JNIEnv *env, jclass clazz)
-{
-    jintArray result = (*env)->NewIntArray(env, 5);
-    if (result != NULL) {
-        jint arr[5];
-        arr[0] = (jint)offsetof(struct inotify_event, wd);
-        arr[1] = (jint)offsetof(struct inotify_event, mask);
-        arr[2] = (jint)offsetof(struct inotify_event, cookie);
-        arr[3] = (jint)offsetof(struct inotify_event, len);
-        arr[4] = (jint)offsetof(struct inotify_event, name);
-        (*env)->SetIntArrayRegion(env, result, 0, 5, arr);
-    }
-    return result;
-}
-
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdWatchService_inotifyInit
-    (JNIEnv* env, jclass clazz)
-{
-    int ifd = inotify_init();
-    if (ifd == -1) {
-        throwUnixException(env, errno);
-    }
-    return (jint)ifd;
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdWatchService_inotifyAddWatch
-    (JNIEnv* env, jclass clazz, jint fd, jlong address, jint mask)
-{
-    int wfd = -1;
-    const char* path = (const char*)jlong_to_ptr(address);
-
-    wfd = inotify_add_watch((int)fd, path, mask);
-    if (wfd == -1) {
-        throwUnixException(env, errno);
-    }
-    return (jint)wfd;
-}
-
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdWatchService_inotifyRmWatch
-    (JNIEnv* env, jclass clazz, jint fd, jint wd)
-{
-    int err = inotify_rm_watch((int)fd, (int)wd);
-    if (err == -1)
-        throwUnixException(env, errno);
-}
-
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdWatchService_configureBlocking
-    (JNIEnv* env, jclass clazz, jint fd, jboolean blocking)
-{
-    int flags = fcntl(fd, F_GETFL);
-
-    if ((blocking == JNI_FALSE) && !(flags & O_NONBLOCK))
-        fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-    else if ((blocking == JNI_TRUE) && (flags & O_NONBLOCK))
-        fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
-}
-
-JNIEXPORT void JNICALL
-Java_sun_nio_fs_BsdWatchService_socketpair
-    (JNIEnv* env, jclass clazz, jintArray sv)
-{
-    int sp[2];
-    if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) == -1) {
-        throwUnixException(env, errno);
-    } else {
-        jint res[2];
-        res[0] = (jint)sp[0];
-        res[1] = (jint)sp[1];
-        (*env)->SetIntArrayRegion(env, sv, 0, 2, &res[0]);
-    }
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_BsdWatchService_poll
-    (JNIEnv* env, jclass clazz, jint fd1, jint fd2)
-{
-    struct pollfd ufds[2];
-    int n;
-
-    ufds[0].fd = fd1;
-    ufds[0].events = POLLIN;
-    ufds[1].fd = fd2;
-    ufds[1].events = POLLIN;
-
-    n = poll(&ufds[0], 2, -1);
-    if (n == -1) {
-        if (errno == EINTR) {
-            n = 0;
-        } else {
-            throwUnixException(env, errno);
-        }
-     }
-    return (jint)n;
-}
--- ./jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c	2011-05-26 18:57:05.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c	2011-04-22 23:08:39.000000000 -0700
@@ -30,7 +30,9 @@
 
 #include <stdlib.h>
 #include <dlfcn.h>
+#ifndef __APPLE__
 #include <link.h>
+#endif
 
 #ifdef __solaris__
 #include <strings.h>
--- ./jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	2011-05-26 18:57:05.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	2011-05-20 20:04:19.000000000 -0700
@@ -49,6 +49,19 @@
 #include <mntent.h>
 #endif
 
+#ifdef _ALLBSD_SOURCE
+#include <string.h>
+
+#define stat64 stat
+#define statvfs64 statvfs
+
+#define open64 open
+#define fstat64 fstat
+#define lstat64 lstat
+#define dirent64 dirent
+#define readdir64_r readdir_r
+#endif
+
 #include "jni.h"
 #include "jni_util.h"
 #include "jlong.h"
@@ -198,7 +211,7 @@
 
     /* system calls that might not be available at run time */
 
-#if defined(__solaris__) && defined(_LP64)
+#if (defined(__solaris__) && defined(_LP64)) || defined(_ALLBSD_SOURCE)
     /* Solaris 64-bit does not have openat64/fstatat64 */
     my_openat64_func = (openat64_func*)dlsym(RTLD_DEFAULT, "openat");
     my_fstatat64_func = (fstatat64_func*)dlsym(RTLD_DEFAULT, "fstatat");
@@ -224,6 +237,8 @@
         flags |= sun_nio_fs_UnixNativeDispatcher_HAS_AT_SYSCALLS;
     }
 
+    my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir");
+
     return flags;
 }
 
@@ -1068,6 +1083,10 @@
 {
 #ifdef __solaris__
     struct extmnttab ent;
+#elif defined(_ALLBSD_SOURCE)
+    char buf[1024];
+    char *str;
+    char *last;
 #else
     struct mntent ent;
     char buf[1024];
@@ -1096,6 +1115,25 @@
         throwUnixException(env, errno);
         return -1;
     }
+#elif defined(_ALLBSD_SOURCE)
+again:
+    if (!(str = fgets(buf, sizeof(buf), fp)))    
+        return -1;
+
+    name = strtok_r(str, " \t\n", &last);
+    if (name == NULL)
+        return -1;
+ 
+    // skip comments
+    if (*name == '#')
+        goto again;
+
+    dir = strtok_r((char *)NULL, " \t\n", &last);
+    fstype = strtok_r((char *)NULL, " \t\n", &last);
+    options = strtok_r((char *)NULL, " \t\n", &last);
+    if (options == NULL)
+        return -1;
+    dev = 0;
 #else
     m = getmntent_r(fp, &ent, (char*)&buf, buflen);
     if (m == NULL)
--- ./jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c	2011-05-26 18:57:05.000000000 -0700
+++ ./jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c	2011-04-22 23:08:39.000000000 -0700
@@ -63,7 +63,12 @@
     DEFX(O_EXCL);
     DEFX(O_TRUNC);
     DEFX(O_SYNC);
+#ifndef O_DSYNC
+    // At least FreeBSD doesn't define O_DSYNC
+    emit("O_DSYNC", O_SYNC);
+#else
     DEFX(O_DSYNC);
+#endif
     DEFX(O_NOFOLLOW);
 
     // mode masks
@@ -106,7 +111,12 @@
     DEF(ENOSYS);
     DEF(ELOOP);
     DEF(EROFS);
+#ifndef ENODATA
+    // Only used in Linux java source, provide any value so it compiles
+    emit("ENODATA", ELAST);
+#else
     DEF(ENODATA);
+#endif
     DEF(ERANGE);
 
     // flags used with openat/unlinkat/etc.
--- ./jdk/src/solaris/native/sun/security/jgss/wrapper/NativeFunc.c	2011-05-26 18:57:05.000000000 -0700
+++ ./jdk/src/solaris/native/sun/security/jgss/wrapper/NativeFunc.c	2011-04-22 23:08:39.000000000 -0700
@@ -26,7 +26,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <dlfcn.h>
+#ifndef __APPLE__
 #include <link.h>
+#endif
 #include "NativeFunc.h"
 
 /* standard GSS method names (ordering is from mapfile) */
--- ./jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c	2011-05-26 18:57:06.000000000 -0700
+++ ./jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -28,12 +28,19 @@
 #include <string.h>
 
 #include <dlfcn.h>
+#ifndef __APPLE__
 #include <link.h>
+#endif
 
 #include <jni_util.h>
 
 #include "j2secmod.h"
 
+#ifndef RTLD_NOLOAD
+/* A gross hack that will work if the NSS library is only opened once */
+static void *nssLibHandle = NULL;
+#endif
+
 void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
     void *hModule = (void*)jHandle;
     void *fAddress = dlsym(hModule, functionName);
@@ -51,7 +58,11 @@
 {
     const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL);
     // look up existing handle only, do not load
+#ifdef RTLD_NOLOAD
     void *hModule = dlopen(libName, RTLD_NOLOAD);
+#else
+    void *hModule = nssLibHandle;
+#endif
     dprintf2("-handle for %s: %u\n", libName, hModule);
     (*env)->ReleaseStringUTFChars(env, jLibName, libName);
     return (jlong)hModule;
@@ -65,6 +76,9 @@
 
     dprintf1("-lib %s\n", libName);
     hModule = dlopen(libName, RTLD_LAZY);
+#ifndef RTLD_NOLOAD
+    nssLibHandle = hModule;
+#endif
     (*env)->ReleaseStringUTFChars(env, jLibName, libName);
     dprintf2("-handle: %u (0X%X)\n", hModule, hModule);
 
--- ./jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	2011-05-26 18:57:06.000000000 -0700
+++ ./jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -64,7 +64,9 @@
 #include <assert.h>
 
 #include <dlfcn.h>
+#ifndef __APPLE__
 #include <link.h>
+#endif
 
 #include <jni.h>
 
--- ./jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c	2011-05-26 18:57:06.000000000 -0700
+++ ./jdk/src/solaris/native/sun/security/smartcardio/pcsc_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -29,7 +29,9 @@
 #include <assert.h>
 
 #include <dlfcn.h>
+#ifndef __APPLE__
 #include <link.h>
+#endif
 
 #include <winscard.h>
 
--- ./jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c	2011-04-22 23:08:39.000000000 -0700
@@ -1,12 +1,12 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
+ * published by the Free Software Foundation.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * by Sun in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -18,9 +18,9 @@
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
  */
 
 #include "jni.h"
@@ -35,10 +35,10 @@
 #include <dirent.h>
 #include <ctype.h>
 #include <sys/types.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
+#include <fcntl.h>
 
 #include "sun_tools_attach_BsdVirtualMachine.h"
 
@@ -49,85 +49,6 @@
 } while(0)
 
 /*
- * Defines a callback that is invoked for each process
- */
-typedef void (*ProcessCallback)(const pid_t pid, void* user_data);
-
-/*
- * Invokes the callback function for each process
- */
-static void forEachProcess(ProcessCallback f, void* user_data) {
-    DIR* dir;
-    struct dirent* ptr;
-
-    /*
-     * To locate the children we scan /proc looking for files that have a
-     * position integer as a filename.
-     */
-    if ((dir = opendir("/proc")) == NULL) {
-        return;
-    }
-    while ((ptr = readdir(dir)) != NULL) {
-        pid_t pid;
-
-        /* skip current/parent directories */
-        if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) {
-            continue;
-        }
-
-        /* skip files that aren't numbers */
-        pid = (pid_t)atoi(ptr->d_name);
-        if ((int)pid <= 0) {
-            continue;
-        }
-
-        /* invoke the callback */
-        (*f)(pid, user_data);
-    }
-    closedir(dir);
-}
-
-
-/*
- * Returns the parent pid of a given pid, or -1 if not found
- */
-static pid_t getParent(pid_t pid) {
-    char state;
-    FILE* fp;
-    char stat[2048];
-    int statlen;
-    char fn[32];
-    int i, p;
-    char* s;
-
-    /*
-     * try to open /proc/%d/stat
-     */
-    sprintf(fn, "/proc/%d/stat", pid);
-    fp = fopen(fn, "r");
-    if (fp == NULL) {
-        return -1;
-    }
-
-    /*
-     * The format is: pid (command) state ppid ...
-     * As the command could be anything we must find the right most
-     * ")" and then skip the white spaces that follow it.
-     */
-    statlen = fread(stat, 1, 2047, fp);
-    stat[statlen] = '\0';
-    fclose(fp);
-    s = strrchr(stat, ')');
-    if (s == NULL) {
-        return -1;
-    }
-    do s++; while (isspace(*s));
-    i = sscanf(s, "%c %d", &state, &p);
-    return (pid_t)p;
-}
-
-
-/*
  * Class:     sun_tools_attach_BsdVirtualMachine
  * Method:    socket
  * Signature: ()I
@@ -188,146 +109,6 @@
 
 /*
  * Class:     sun_tools_attach_BsdVirtualMachine
- * Method:    isBsdThreads
- * Signature: ()V
- */
-JNIEXPORT jboolean JNICALL Java_sun_tools_attach_BsdVirtualMachine_isBsdThreads
-  (JNIEnv *env, jclass cls)
-{
-# ifndef _CS_GNU_LIBPTHREAD_VERSION
-# define _CS_GNU_LIBPTHREAD_VERSION 3
-# endif
-    size_t n;
-    char* s;
-    jboolean res;
-
-    n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
-    if (n <= 0) {
-       /* glibc before 2.3.2 only has BsdThreads */
-       return JNI_TRUE;
-    }
-
-    s = (char *)malloc(n);
-    if (s == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "malloc failed");
-        return JNI_TRUE;
-    }
-    confstr(_CS_GNU_LIBPTHREAD_VERSION, s, n);
-
-    /*
-     * If the LIBPTHREAD version include "NPTL" then we know we
-     * have the new threads library and not BsdThreads
-     */
-    res = (jboolean)(strstr(s, "NPTL") == NULL);
-    free(s);
-    return res;
-}
-
-/*
- * Structure and callback function used to count the children of
- * a given process, and record the pid of the "manager thread".
- */
-typedef struct {
-    pid_t ppid;
-    int count;
-    pid_t mpid;
-} ChildCountContext;
-
-static void ChildCountCallback(const pid_t pid, void* user_data) {
-    ChildCountContext* context = (ChildCountContext*)user_data;
-    if (getParent(pid) == context->ppid) {
-        context->count++;
-        /*
-         * Remember the pid of the first child. If the final count is
-         * one then this is the pid of the BsdThreads manager.
-         */
-        if (context->count == 1) {
-            context->mpid = pid;
-        }
-    }
-}
-
-/*
- * Class:     sun_tools_attach_BsdVirtualMachine
- * Method:    getBsdThreadsManager
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_sun_tools_attach_BsdVirtualMachine_getBsdThreadsManager
-  (JNIEnv *env, jclass cls, jint pid)
-{
-    ChildCountContext context;
-
-    /*
-     * Iterate over all processes to find how many children 'pid' has
-     */
-    context.ppid = pid;
-    context.count = 0;
-    context.mpid = (pid_t)0;
-    forEachProcess(ChildCountCallback, (void*)&context);
-
-    /*
-     * If there's no children then this is likely the pid of the primordial
-     * created by the launcher - in that case the BsdThreads manager is the
-     * parent of this process.
-     */
-    if (context.count == 0) {
-        pid_t parent = getParent(pid);
-        if ((int)parent > 0) {
-            return (jint)parent;
-        }
-    }
-
-    /*
-     * There's one child so this is likely the embedded VM case where the
-     * the primordial thread == BsdThreads initial thread. The BsdThreads
-     * manager in that case is the child.
-     */
-    if (context.count == 1) {
-        return (jint)context.mpid;
-    }
-
-    /*
-     * If we get here it's most likely we were given the wrong pid
-     */
-    JNU_ThrowIOException(env, "Unable to get pid of BsdThreads manager thread");
-    return -1;
-}
-
-/*
- * Structure and callback function used to send a QUIT signal to all
- * children of a given process
- */
-typedef struct {
-    pid_t ppid;
-} SendQuitContext;
-
-static void SendQuitCallback(const pid_t pid, void* user_data) {
-    SendQuitContext* context = (SendQuitContext*)user_data;
-    pid_t parent = getParent(pid);
-    if (parent == context->ppid) {
-        kill(pid, SIGQUIT);
-    }
-}
-
-/*
- * Class:     sun_tools_attach_BsdVirtualMachine
- * Method:    sendQuitToChildrenOf
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_sun_tools_attach_BsdVirtualMachine_sendQuitToChildrenOf
-  (JNIEnv *env, jclass cls, jint pid)
-{
-    SendQuitContext context;
-    context.ppid = (pid_t)pid;
-
-    /*
-     * Iterate over all children of 'pid' and send a QUIT signal to each.
-     */
-    forEachProcess(SendQuitCallback, (void*)&context);
-}
-
-/*
- * Class:     sun_tools_attach_BsdVirtualMachine
  * Method:    sendQuitTo
  * Signature: (I)V
  */
@@ -350,7 +131,7 @@
     jboolean isCopy;
     const char* p = GetStringPlatformChars(env, path, &isCopy);
     if (p != NULL) {
-        struct stat64 sb;
+        struct stat sb;
         uid_t uid, gid;
         int res;
 
@@ -361,7 +142,7 @@
         uid = geteuid();
         gid = getegid();
 
-        res = stat64(p, &sb);
+        res = stat(p, &sb);
         if (res != 0) {
             /* save errno */
             res = errno;
@@ -459,3 +240,40 @@
 
     } while (remaining > 0);
 }
+
+/*
+ * Class:     sun_tools_attach_BSDVirtualMachine
+ * Method:    createAttachFile
+ * Signature: (Ljava.lang.String;)V
+ */
+JNIEXPORT void JNICALL Java_sun_tools_attach_BsdVirtualMachine_createAttachFile(JNIEnv *env, jclass cls, jstring path)
+{
+    const char* _path;
+    jboolean isCopy;
+    int fd, rc;
+
+    _path = GetStringPlatformChars(env, path, &isCopy);
+    if (_path == NULL) {
+        JNU_ThrowIOException(env, "Must specify a path");
+        return;
+    }
+
+    RESTARTABLE(open(_path, O_CREAT | O_EXCL, S_IWUSR | S_IRUSR), fd);
+    if (fd == -1) {
+        /* release p here before we throw an I/O exception */
+        if (isCopy) {
+            JNU_ReleaseStringPlatformChars(env, path, _path);
+        }
+        JNU_ThrowIOExceptionWithLastError(env, "open");
+        return;
+    }
+
+    RESTARTABLE(chown(_path, geteuid(), getegid()), rc);
+
+    RESTARTABLE(close(fd), rc);
+
+    /* release p here */
+    if (isCopy) {
+        JNU_ReleaseStringPlatformChars(env, path, _path);
+    }
+}
--- ./jdk/src/solaris/native/sun/xawt/XWindow.c	2011-05-26 18:57:07.000000000 -0700
+++ ./jdk/src/solaris/native/sun/xawt/XWindow.c	2011-04-22 23:08:39.000000000 -0700
@@ -228,10 +228,10 @@
     {java_awt_event_KeyEvent_VK_DOWN, XK_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 
     /* Keypad equivalents of Triangular Navigation Block */
-    {java_awt_event_KeyEvent_VK_KP_LEFT, XK_KP_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
-    {java_awt_event_KeyEvent_VK_KP_UP, XK_KP_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
-    {java_awt_event_KeyEvent_VK_KP_RIGHT, XK_KP_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
-    {java_awt_event_KeyEvent_VK_KP_DOWN, XK_KP_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
+    {java_awt_event_KeyEvent_VK_LEFT, XK_KP_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
+    {java_awt_event_KeyEvent_VK_UP, XK_KP_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
+    {java_awt_event_KeyEvent_VK_RIGHT, XK_KP_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
+    {java_awt_event_KeyEvent_VK_DOWN, XK_KP_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 
     /* Other vendor-specific Triangular Navigation Block */
     {java_awt_event_KeyEvent_VK_LEFT, osfXK_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
@@ -867,7 +867,7 @@
 {
     KeySym originalKeysym = *keysym;
 
-#ifndef __linux__
+#if !defined(__linux__) && !defined(_ALLBSD_SOURCE)
     /* The following code on Linux will cause the keypad keys
      * not to echo on JTextField when the NumLock is on. The
      * keysyms will be 0, because the last parameter 2 is not defined.
--- ./jdk/src/solaris/native/sun/xawt/awt_Desktop.c	2011-05-26 18:57:07.000000000 -0700
+++ ./jdk/src/solaris/native/sun/xawt/awt_Desktop.c	2011-04-22 23:08:39.000000000 -0700
@@ -24,6 +24,7 @@
  */
 
 #include <jni.h>
+#include <jvm_md.h>
 #include <dlfcn.h>
 
 typedef int gboolean;
@@ -39,12 +40,15 @@
     void *gnome_handle;
     const char *errmsg;
 
-    vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
+    vfs_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnomevfs-2", "0"), RTLD_LAZY);
     if (vfs_handle == NULL) {
+        vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY);
+        if (vfs_handle == NULL) {
 #ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not load libgnomevfs-2.so\n");
+            fprintf(stderr, "can not load libgnomevfs-2.so\n");
 #endif
-        return 0;
+            return 0;
+        }
     }
     dlerror(); /* Clear errors */
     gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
@@ -63,12 +67,15 @@
     // call gonme_vfs_init()
     (*gnome_vfs_init)();
 
-    gnome_handle = dlopen("libgnome-2.so.0", RTLD_LAZY);
+    gnome_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnome-2", "0"), RTLD_LAZY);
     if (gnome_handle == NULL) {
+        gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY);
+        if (gnome_handle == NULL) {
 #ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not load libgnome-2.so\n");
+            fprintf(stderr, "can not load libgnome-2.so\n");
 #endif
-        return 0;
+            return 0;
+        }
     }
     dlerror(); /* Clear errors */
     gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
--- ./jdk/src/solaris/npt/npt_md.h	2011-05-26 18:57:07.000000000 -0700
+++ ./jdk/src/solaris/npt/npt_md.h	2011-04-22 23:08:39.000000000 -0700
@@ -32,9 +32,10 @@
 #include <string.h>
 #include <errno.h>
 #include <dlfcn.h>
+#ifndef __APPLE__
 #include <link.h>
-
-#define NPT_LIBNAME "libnpt.so"
+#endif
+#include <jvm_md.h>
 
 #define NPT_INITIALIZE(pnpt,version,options)                            \
     {                                                                   \
@@ -43,7 +44,7 @@
                                                                         \
         if ( (pnpt) == NULL ) NPT_ERROR("NptEnv* is NULL");             \
         *(pnpt) = NULL;                                                 \
-        _handle =  dlopen(NPT_LIBNAME, RTLD_LAZY);                      \
+        _handle =  dlopen(JNI_LIB_NAME("npt"), RTLD_LAZY);              \
         if ( _handle == NULL ) NPT_ERROR("Cannot open library");        \
         _sym = dlsym(_handle, "nptInitialize");                         \
         if ( _sym == NULL ) NPT_ERROR("Cannot find nptInitialize");     \
--- ./jdk/src/solaris/transport/socket/socket_md.c	2011-05-26 18:57:10.000000000 -0700
+++ ./jdk/src/solaris/transport/socket/socket_md.c	2011-04-22 23:08:39.000000000 -0700
@@ -36,7 +36,7 @@
 #ifdef __solaris__
 #include <thread.h>
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <pthread.h>
 #include <sys/poll.h>
 #endif
@@ -283,7 +283,7 @@
 
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 int
 dbgsysTlsAlloc() {
     pthread_key_t key;
--- ./jdk/test/Makefile	2011-05-26 18:57:59.000000000 -0700
+++ ./jdk/test/Makefile	2011-04-22 23:08:40.000000000 -0700
@@ -79,6 +79,16 @@
   endif
   OS_VERSION := $(shell $(UNAME) -r)
 endif
+ifeq ($(UNAME_S), Darwin)
+  OS_NAME     = bsd
+  OS_ARCH    := $(shell $(UNAME) -m)
+  OS_VERSION := $(shell $(UNAME) -r)
+endif
+ifeq ($(findstring BSD,$(UNAME_S)), BSD)
+  OS_NAME     = bsd
+  OS_ARCH    := $(shell $(UNAME) -m)
+  OS_VERSION := $(shell $(UNAME) -r)
+endif
 ifeq ($(OS_NAME),)
   OS_NAME = windows
   # GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
--- ./jdk/test/com/sun/jdi/ImmutableResourceTest.sh	2011-05-26 18:58:11.000000000 -0700
+++ ./jdk/test/com/sun/jdi/ImmutableResourceTest.sh	2011-04-22 23:08:41.000000000 -0700
@@ -56,7 +56,7 @@
 
 OS=`uname -s`
 case "$OS" in
-   SunOS | Linux )
+   SunOS | Linux | *BSD | Darwin )
       PATHSEP=":"
       ;;
 
--- ./jdk/test/com/sun/jdi/JITDebug.sh	2011-05-26 18:58:13.000000000 -0700
+++ ./jdk/test/com/sun/jdi/JITDebug.sh	2011-04-22 23:08:41.000000000 -0700
@@ -63,7 +63,7 @@
 OS=`uname -s`
 export TRANSPORT_METHOD
 case "$OS" in
-   SunOS | Linux )
+   SunOS | Linux | *BSD | Darwin )
       PATHSEP=":"
       TRANSPORT_METHOD=dt_socket
       ;;
--- ./jdk/test/com/sun/jdi/PrivateTransportTest.sh	2011-05-26 18:58:15.000000000 -0700
+++ ./jdk/test/com/sun/jdi/PrivateTransportTest.sh	2011-04-22 23:08:41.000000000 -0700
@@ -123,10 +123,14 @@
     esac
     libloc=${jreloc}/lib/${libarch}
     ;;
-  Linux)
+  Linux | *BSD)
     xx=`find ${jreloc}/lib -name libdt_socket.so`
     libloc=`dirname ${xx}`
     ;;
+  Darwin)
+    xx=`find ${jreloc}/lib -name libdt_socket.dylib`
+    libloc=`dirname ${xx}`
+    ;;
   Windows*)
     is_windows=true
     libloc=${jreloc}/bin
--- ./jdk/test/com/sun/jdi/ShellScaffold.sh	2011-05-26 18:58:17.000000000 -0700
+++ ./jdk/test/com/sun/jdi/ShellScaffold.sh	2011-04-22 23:08:41.000000000 -0700
@@ -292,7 +292,7 @@
          psCmd=ps
          jstack=jstack.exe
          ;;
-       SunOS | Linux)
+       SunOS | Linux | *BSD | Darwin)
          transport=dt_socket
          address=
          devnull=/dev/null
--- ./jdk/test/com/sun/jdi/Solaris32AndSolaris64Test.sh	2011-05-26 18:58:17.000000000 -0700
+++ ./jdk/test/com/sun/jdi/Solaris32AndSolaris64Test.sh	2011-04-22 23:08:41.000000000 -0700
@@ -112,7 +112,7 @@
       fi
       ;;
 
-   Linux )
+   Linux | *BSD | Darwin )
       pass "This test always passes on $OS"
       ;;
 
--- ./jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh	2011-05-26 18:58:20.000000000 -0700
+++ ./jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh	2011-04-22 23:08:41.000000000 -0700
@@ -45,10 +45,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     ;;
   Windows* | CYGWIN*)
--- ./jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh	2011-05-26 18:58:24.000000000 -0700
+++ ./jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh	2011-04-22 23:08:41.000000000 -0700
@@ -83,6 +83,10 @@
        total_swap=`free -b | grep -i swap | awk '{print $2}'`
        runOne GetTotalSwapSpaceSize $total_swap 
        ;;
+     *BSD )
+       # FIXME: Determine swap space.
+       runOne GetTotalSwapSpaceSize "sanity-only"
+       ;;
     * )
        runOne GetTotalSwapSpaceSize "sanity-only"
        ;;
--- ./jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetMaxFileDescriptorCount.sh	2011-05-26 18:58:24.000000000 -0700
+++ ./jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetMaxFileDescriptorCount.sh	2011-04-22 23:08:41.000000000 -0700
@@ -48,7 +48,7 @@
 
 # Test GetMaxFileDescriptorCount if we are running on Unix
 case `uname -s` in
-    SunOS | Linux )
+    SunOS | Linux | *BSD | Darwin )
        runOne GetMaxFileDescriptorCount
        ;;
     * )
--- ./jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetOpenFileDescriptorCount.sh	2011-05-26 18:58:25.000000000 -0700
+++ ./jdk/test/com/sun/management/UnixOperatingSystemMXBean/GetOpenFileDescriptorCount.sh	2011-04-22 23:08:41.000000000 -0700
@@ -48,7 +48,7 @@
 
 # Test GetOpenFileDescriptorCount if we are running on Unix
 case `uname -s` in
-    SunOS | Linux )
+    SunOS | Linux | *BSD | Darwin )
        runOne GetOpenFileDescriptorCount
        ;;
     * )
--- ./jdk/test/com/sun/tools/attach/CommonSetup.sh	2011-05-26 18:58:40.000000000 -0700
+++ ./jdk/test/com/sun/tools/attach/CommonSetup.sh	2011-04-22 23:08:41.000000000 -0700
@@ -36,11 +36,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/awt/PrintJob/Text/stringwidth.sh	2011-05-26 18:59:08.000000000 -0700
+++ ./jdk/test/java/awt/PrintJob/Text/stringwidth.sh	2011-04-22 23:08:42.000000000 -0700
@@ -25,10 +25,11 @@
 fi
 
 
-if [ $OS = SunOS -o $OS = Linux ]
-then
-    exit 0
-fi
+case "${OS}" in
+    SunOS | Linux | *BSD | Darwin )
+        exit 0
+	;;
+esac
 # Windows
 
 if [ -z "${TESTJAVA}" ] ; then
--- ./jdk/test/java/io/File/GetXSpace.sh	2011-05-26 18:59:59.000000000 -0700
+++ ./jdk/test/java/io/File/GetXSpace.sh	2011-04-22 23:08:43.000000000 -0700
@@ -26,7 +26,7 @@
 # set platform-dependent variable
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux ) TMP=/tmp  ;;
+  SunOS | Linux | *BSD | Darwin ) TMP=/tmp  ;;
   Windows_98 )    return    ;;
   Windows* )      SID=`sid`; TMP="c:/temp"  ;;
   * )
--- ./jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh	2011-05-26 19:00:25.000000000 -0700
+++ ./jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh	2011-04-22 23:08:44.000000000 -0700
@@ -41,7 +41,7 @@
 # Need to determine the classpath separator and filepath separator based on the
 # operating system.
 case "$OS" in
-SunOS | Linux )
+SunOS | Linux | *BSD | Darwin )
   PS=":"  ;;
 Windows* | CYGWIN* )
   PS=";"  ;;
--- ./jdk/test/java/io/Serializable/serialver/classpath/run.sh	2011-05-26 19:00:34.000000000 -0700
+++ ./jdk/test/java/io/Serializable/serialver/classpath/run.sh	2011-04-22 23:08:44.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"    ;;
   Windows* | CYGWIN* )
     PS=";"    ;;
--- ./jdk/test/java/io/Serializable/serialver/nested/run.sh	2011-05-26 19:00:34.000000000 -0700
+++ ./jdk/test/java/io/Serializable/serialver/nested/run.sh	2011-04-22 23:08:44.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"    ;;
   Windows* | CYGWIN* )
     PS=";"    ;;
--- ./jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh	2011-05-26 19:00:52.000000000 -0700
+++ ./jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh	2011-04-22 23:08:44.000000000 -0700
@@ -49,10 +49,7 @@
 # set platform-specific variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     ;;
   Windows* | CYGWIN* )
--- ./jdk/test/java/lang/StringCoding/CheckEncodings.sh	2011-05-26 19:01:03.000000000 -0700
+++ ./jdk/test/java/lang/StringCoding/CheckEncodings.sh	2011-04-22 23:08:45.000000000 -0700
@@ -30,7 +30,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux ) ;;
+  SunOS | Linux | *BSD | Darwin ) ;;
   Windows* | CYGWIN* )
     echo "Passed"; exit 0 ;;
   * ) echo "Unrecognized system!" ;  exit 1 ;;
--- ./jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh	2011-05-26 19:01:09.000000000 -0700
+++ ./jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh	2011-04-22 23:08:45.000000000 -0700
@@ -44,7 +44,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/java/lang/instrument/MakeJAR2.sh	2011-05-26 19:01:13.000000000 -0700
+++ ./jdk/test/java/lang/instrument/MakeJAR2.sh	2011-04-22 23:08:45.000000000 -0700
@@ -49,7 +49,7 @@
 
 OS=`uname -s`
 case "$OS" in
-   SunOS | Linux )
+   SunOS | Linux | *BSD | Darwin )
       PATHSEP=":"
       ;;
 
--- ./jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh	2011-05-26 19:01:20.000000000 -0700
+++ ./jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh	2011-04-22 23:08:45.000000000 -0700
@@ -35,11 +35,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh	2011-05-26 19:01:28.000000000 -0700
+++ ./jdk/test/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh	2011-04-22 23:08:45.000000000 -0700
@@ -61,10 +61,7 @@
 while true; do
   echo "Run $i: TestSystemLoadAvg"
   case `uname -s` in
-       SunOS )
-         runOne GetSystemLoadAverage 
-         ;;
-       Linux )
+       SunOS | Linux | *BSD | Darwin )
          runOne GetSystemLoadAverage
          ;;
       * )
--- ./jdk/test/java/net/Authenticator/B4933582.sh	2011-05-26 19:01:39.000000000 -0700
+++ ./jdk/test/java/net/Authenticator/B4933582.sh	2011-04-22 23:08:45.000000000 -0700
@@ -26,7 +26,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.sh	2011-05-26 19:01:43.000000000 -0700
+++ ./jdk/test/java/net/DatagramSocket/SetDatagramSocketImplFactory/ADatagramSocket.sh	2011-04-22 23:08:45.000000000 -0700
@@ -27,11 +27,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/java/net/Socket/OldSocketImpl.sh	2011-05-26 19:01:53.000000000 -0700
+++ ./jdk/test/java/net/Socket/OldSocketImpl.sh	2011-04-22 23:08:45.000000000 -0700
@@ -28,7 +28,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/net/URL/B5086147.sh	2011-05-26 19:01:57.000000000 -0700
+++ ./jdk/test/java/net/URL/B5086147.sh	2011-04-22 23:08:46.000000000 -0700
@@ -26,7 +26,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     exit 0
     ;;
   CYGWIN* )
--- ./jdk/test/java/net/URL/runconstructor.sh	2011-05-26 19:02:00.000000000 -0700
+++ ./jdk/test/java/net/URL/runconstructor.sh	2011-04-22 23:08:46.000000000 -0700
@@ -27,7 +27,7 @@
 #
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/net/URLClassLoader/B5077773.sh	2011-05-26 19:02:00.000000000 -0700
+++ ./jdk/test/java/net/URLClassLoader/B5077773.sh	2011-04-22 23:08:46.000000000 -0700
@@ -34,11 +34,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/net/URLClassLoader/sealing/checksealed.sh	2011-05-26 19:02:03.000000000 -0700
+++ ./jdk/test/java/net/URLClassLoader/sealing/checksealed.sh	2011-04-22 23:08:46.000000000 -0700
@@ -27,11 +27,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"            
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"            
     ;;
--- ./jdk/test/java/net/URLConnection/6212146/test.sh	2011-05-26 19:02:03.000000000 -0700
+++ ./jdk/test/java/net/URLConnection/6212146/test.sh	2011-04-22 23:08:46.000000000 -0700
@@ -33,11 +33,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Makefile	2011-05-26 19:02:27.000000000 -0700
+++ ./jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Makefile	2011-04-22 23:08:46.000000000 -0700
@@ -71,6 +71,48 @@
   EXTRA_LIBS = -lc
 endif
 
+ifeq ($(uname), Darwin)
+  PLATFORM = bsd
+  archExpr = case "`$(UNAME) -m`" in  \
+		i[3-6]86) \
+                    $(ECHO) i586 \
+                    ;; \
+		sparc*)	 \
+                    $(ECHO) sparc \
+                    ;; \
+		*) \
+                    $(UNAME) -m	 \
+                    ;; \
+	   esac
+  ARCH	    := $(shell $(archExpr) )
+  CC = gcc
+  CFLAGS = -fno-strict-aliasing -fPIC -W -Wall
+  LD = ld
+  LDFLAGS_COMMON = -shared
+  EXTRA_LIBS = -lc
+endif
+
+ifeq ($(findstring BSD,$(uname)), BSD)
+  PLATFORM = bsd
+  archExpr = case "`$(UNAME) -m`" in  \
+		i[3-6]86) \
+                    $(ECHO) i586 \
+                    ;; \
+		sparc*)	 \
+                    $(ECHO) sparc \
+                    ;; \
+		*) \
+                    $(UNAME) -m	 \
+                    ;; \
+	   esac
+  ARCH	    := $(shell $(archExpr) )
+  CC = gcc
+  CFLAGS = -fno-strict-aliasing -fPIC -W -Wall
+  LD = ld
+  LDFLAGS_COMMON = -shared
+  EXTRA_LIBS = -lc
+endif
+
 LIBDIR=lib/$(PLATFORM)-$(ARCH)
 LAUNCHERLIB=$(LIBDIR)/libLauncher.so
 
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/lib/bsd-i586/libLauncher.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/lib/bsd-i586/libLauncher.so differ
--- ./jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	2011-05-26 19:02:29.000000000 -0700
+++ ./jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	2011-04-22 23:08:46.000000000 -0700
@@ -33,11 +33,14 @@
 # @run shell run_tests.sh
 
 os=`uname -s`
-
-if [ "$os" != "Linux" -a "$os" != "SunOS" ]; then
-    echo "Test not designed to run on this operating system, skipping..."
-    exit 0
-fi
+case "${os}" in
+    SunOS | Linux | *BSD | Darwin )
+        ;;
+    * )
+        echo "Test not designed to run on this operating system, skipping..."
+        exit 0
+        ;;
+esac
 
 
 # if TESTJAVA isn't set then we assume an interactive run. So that it's
@@ -67,7 +70,8 @@
 # On Solaris we assume 64-bit if java -d64 works.
 
 DFLAG=
-if [ "$os" = "SunOS" ]; then
+case "${os}" in
+  SunOS )
     PLATFORM=solaris
     case "`uname -p`" in
 	i[3-9]86) 
@@ -84,9 +88,9 @@
 	    fi
 	    ;;
     esac 
-fi
+    ;;
 
-if [ "$os" = "Linux" ]; then
+  Linux )
     PLATFORM=linux
     ARCH=unknown
     case "`uname -m`" in
@@ -100,7 +104,24 @@
 	    ARCH=amd64
 	    ;;
     esac
-fi
+    ;;
+
+  *BSD | Darwin )
+    PLATFORM=bsd
+    ARCH=unknown
+    case "`uname -m`" in
+	i[3-6]86)
+	    ARCH=i586
+	    ;;
+	ia64)
+	    ARCH=ia64
+	    ;;
+	x86_64)
+	    ARCH=amd64
+	    ;;
+    esac
+    ;;
+esac
 
 LIBDIR=lib/${PLATFORM}-${ARCH}
 LAUNCHERLIB=${LIBDIR}/libLauncher.so
--- ./jdk/test/java/nio/charset/Charset/default.sh	2011-05-26 19:02:30.000000000 -0700
+++ ./jdk/test/java/nio/charset/Charset/default.sh	2011-04-22 23:08:46.000000000 -0700
@@ -41,10 +41,14 @@
 fi
 
 s="`uname -s`"
-if [ "$s" != Linux -a "$s" != SunOS ]; then
-  echo "$s: locale command not supported on this system, skipping..."
-  exit 0
-fi
+case "$s" in
+  Linux|SunOS|*BSD|Darwin)
+    ;;
+  *)
+    echo "$s: locale command not supported on this system, skipping..."
+    exit 0
+    ;;
+esac
 
 JAVA=$TESTJAVA/bin/java
 
--- ./jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh	2011-05-26 19:02:31.000000000 -0700
+++ ./jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh	2011-04-22 23:08:46.000000000 -0700
@@ -34,7 +34,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux ) ;;
+  SunOS | Linux | *BSD | Darwin) ;;
   # Skip locale test for Windows
   Windows* )
     echo "Passed"; exit 0 ;;
--- ./jdk/test/java/nio/charset/spi/basic.sh	2011-05-26 19:02:32.000000000 -0700
+++ ./jdk/test/java/nio/charset/spi/basic.sh	2011-04-22 23:08:46.000000000 -0700
@@ -70,10 +70,14 @@
     L="$1"
     shift
     s=`uname -s`
-    if [ $s != Linux -a $s != SunOS ]; then
-      echo "$L: Locales not supported on this system, skipping..."
-      exit 0
-    fi
+    case "$s" in
+      Linux|SunOS|*BSD|Darwin)
+        ;;
+      *)
+        echo "$L: Locales not supported on this system, skipping..."
+        exit 0
+	;;
+    esac
     if [ "x`locale -a | grep $L`" != "x$L" ]; then
       echo "$L: Locale not supported, skipping..."
       exit 0
@@ -85,7 +89,7 @@
 cd $TMP
 
 case `uname` in
-  SunOS | Linux ) CPS=':' ;;
+  SunOS | Linux | *BSD | Darwin) CPS=':' ;;
   Windows* )      CPS=';' ;;
   *)              echo "Unknown platform: `uname`"; exit 1 ;;
 esac
--- ./jdk/test/java/nio/file/Files/CopyAndMove.java	2011-05-26 19:02:33.000000000 -0700
+++ ./jdk/test/java/nio/file/Files/CopyAndMove.java	2011-04-22 23:08:46.000000000 -0700
@@ -153,7 +153,8 @@
 
         // get file attributes of source file
         String os = System.getProperty("os.name");
-        if (os.equals("SunOS") || os.equals("Linux")) {
+        if (os.equals("SunOS") || os.equals("Linux") ||
+            os.endsWith("BSD") || os.equals("Darwin")) {
             posixAttributes = readAttributes(source, PosixFileAttributes.class, NOFOLLOW_LINKS);
             basicAttributes = posixAttributes;
         }
--- ./jdk/test/java/rmi/reliability/launch_reliability.ksh	2011-05-26 19:03:04.000000000 -0700
+++ ./jdk/test/java/rmi/reliability/launch_reliability.ksh	2011-04-22 23:08:47.000000000 -0700
@@ -84,14 +84,12 @@
 
 
 # set platform-dependent variables
-if [ `uname` = "SunOS" ] ; then
+case `uname` in
+    SunOS | Linux | *BSD | Darwin )
         PATH_SEP=":"
-
-elif [ `uname` = "Linux" ] ; then
-        PATH_SEP=":"
-else
+    * )
         PATH_SEP=";"
-fi
+esac
 
 export PATH_SEP
 mainpid=$$
--- ./jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh	2011-05-26 19:03:34.000000000 -0700
+++ ./jdk/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh	2011-04-22 23:08:48.000000000 -0700
@@ -46,11 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock.sh	2011-05-26 19:03:34.000000000 -0700
+++ ./jdk/test/java/security/Security/ClassLoaderDeadlock/Deadlock.sh	2011-04-22 23:08:48.000000000 -0700
@@ -34,11 +34,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/java/security/Security/signedfirst/Dyn.sh	2011-05-26 19:03:35.000000000 -0700
+++ ./jdk/test/java/security/Security/signedfirst/Dyn.sh	2011-04-22 23:08:48.000000000 -0700
@@ -46,11 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/java/security/Security/signedfirst/Static.sh	2011-05-26 19:03:36.000000000 -0700
+++ ./jdk/test/java/security/Security/signedfirst/Static.sh	2011-04-22 23:08:48.000000000 -0700
@@ -46,11 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/java/util/Currency/PropertiesTest.sh	2011-05-26 19:03:53.000000000 -0700
+++ ./jdk/test/java/util/Currency/PropertiesTest.sh	2011-04-22 23:08:48.000000000 -0700
@@ -30,7 +30,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/util/PluggableLocale/ExecTest.sh	2011-05-26 19:04:07.000000000 -0700
+++ ./jdk/test/java/util/PluggableLocale/ExecTest.sh	2011-04-22 23:08:48.000000000 -0700
@@ -58,7 +58,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/java/util/ResourceBundle/Bug6299235Test.sh	2011-05-26 19:04:13.000000000 -0700
+++ ./jdk/test/java/util/ResourceBundle/Bug6299235Test.sh	2011-04-22 23:08:49.000000000 -0700
@@ -31,7 +31,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh	2011-05-26 19:04:14.000000000 -0700
+++ ./jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh	2011-04-22 23:08:49.000000000 -0700
@@ -75,7 +75,7 @@
 SunOS)
     DEL=":"
     ;;
-Linux)
+Linux|*BSD|Darwin)
     DEL=":"
     HAS_S=YES
     ;;
--- ./jdk/test/java/util/ServiceLoader/basic.sh	2011-05-26 19:04:19.000000000 -0700
+++ ./jdk/test/java/util/ServiceLoader/basic.sh	2011-04-22 23:08:49.000000000 -0700
@@ -42,9 +42,7 @@
 
 OS=`uname -s`
 case "$OS" in
-    SunOS )
-      SEP=':' ;;
-    Linux )
+    SunOS | Linux | *BSD | Darwin )
       SEP=':' ;;
     * )
       SEP='\;' ;;
--- ./jdk/test/javax/crypto/SecretKeyFactory/FailOverTest.sh	2011-05-26 19:04:44.000000000 -0700
+++ ./jdk/test/javax/crypto/SecretKeyFactory/FailOverTest.sh	2011-04-22 23:08:49.000000000 -0700
@@ -51,7 +51,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/javax/script/CommonSetup.sh	2011-05-26 19:05:20.000000000 -0700
+++ ./jdk/test/javax/script/CommonSetup.sh	2011-04-22 23:08:50.000000000 -0700
@@ -36,11 +36,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/javax/security/auth/Subject/doAs/Test.sh	2011-05-26 19:05:24.000000000 -0700
+++ ./jdk/test/javax/security/auth/Subject/doAs/Test.sh	2011-04-22 23:08:50.000000000 -0700
@@ -33,12 +33,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    RM="/bin/rm -f"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     RM="/bin/rm -f"
--- ./jdk/test/jprt.config	2011-05-26 19:06:21.000000000 -0700
+++ ./jdk/test/jprt.config	2011-04-22 23:08:51.000000000 -0700
@@ -71,8 +71,8 @@
 
 # Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
 osname=`uname -s`
-if [ "${osname}" = SunOS ] ; then
-   
+case "${osname}" in
+  SunOS )
     # SOLARIS: Sparc or X86
     osarch=`uname -p`
     if [ "${osarch}" = sparc ] ; then
@@ -96,9 +96,9 @@
 
     # File creation mask
     umask 002
+    ;;
 
-elif [ "${osname}" = Linux ] ; then
-   
+  Linux | Darwin )
     # Add basic paths
     path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
@@ -107,8 +107,31 @@
     fileMustExist "${make}" make
 
     umask 002
+    ;;
+
+  FreeBSD | OpenBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
-else
+    # Find GNU make
+    make=/usr/local/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
+
+  NetBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
+
+    # Find GNU make
+    make=/usr/pkg/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
+
+  * )
 
     # Windows: Differs on CYGWIN vs. MKS.
    
@@ -150,8 +173,8 @@
     if [ "${unix_toolset}" = CYGWIN ] ; then
 	path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
     fi
-
-fi
+    ;;
+esac
 
 # Export PATH setting
 PATH="${path4sdk}"
--- ./jdk/test/lib/security/java.policy/Ext_AllPolicy.sh	2011-05-26 19:06:22.000000000 -0700
+++ ./jdk/test/lib/security/java.policy/Ext_AllPolicy.sh	2011-04-22 23:08:51.000000000 -0700
@@ -50,7 +50,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.sh	2011-05-26 19:06:34.000000000 -0700
+++ ./jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.sh	2011-04-22 23:08:51.000000000 -0700
@@ -45,37 +45,50 @@
 # has to locate libjvm.so. Also $! is not reliable on some releases of MKS.
 #{
 OS=`uname -s`
-if [ "$OS" != "Linux" -a "$OS" != "SunOS" ]; then
-    echo "Test not designed to run on this operating system, skipping..."
-    exit 0
-fi
+case "${OS}" in
+    Windows* | CYGWIN* )
+        echo "Test not designed to run on this operating system, skipping..."
+        exit 0
+        ;;
+esac
 
 #
 # Locate the custom launcher for this platform
 #
 PLATFORM=unknown
 ARCH=unknown
-if [ "$OS" = "SunOS" ]; then
-    PLATFORM=solaris
-    case "`uname -p`" in
-	i[3-9]86)
-	    ARCH=i586
-	    ;;
-	sparc)
-	    ARCH=sparc
-	    ;;
-    esac
-else
-    PLATFORM=linux
-    case "`uname -m`" in
-	i[3-6]86)
-	    ARCH=i586
-	    ;;
-	x86_64)
-	    ARCH=amd64
-	    ;;
-    esac
-fi
+case "${OS}" in
+    SunOS )
+        PLATFORM=solaris
+        case "`uname -p`" in
+            i[3-9]86)
+                ARCH=i586
+                ;;
+            sparc)
+                ARCH=sparc
+                ;;
+        esac
+        ;;
+    Linux )
+        PLATFORM=linux
+        case "`uname -m`" in
+            i[3-6]86)
+                ARCH=i586
+                ;;
+            x86_64)
+                ARCH=amd64
+                ;;
+        esac
+	;;
+    *BSD | Darwin )
+        PLATFORM=bsd
+        case "`uname -m`" in
+            i[3-6]86)
+                ARCH=i586
+                ;;
+        esac
+	;;
+esac
 
 
 #
--- ./jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh	2011-05-26 19:06:34.000000000 -0700
+++ ./jdk/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh	2011-04-22 23:08:51.000000000 -0700
@@ -35,7 +35,7 @@
 UMASK=`umask`
 
 case $OS in
-SunOS | Linux)
+SunOS | Linux | *BSD | Darwin)
     PATHSEP=":"
     FILESEP="/"
     DFILESEP=$FILESEP
--- ./jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.sh	2011-05-26 19:06:34.000000000 -0700
+++ ./jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.sh	2011-04-22 23:08:51.000000000 -0700
@@ -86,10 +86,12 @@
 #    on Windows 98.
 
 os=`uname -s`
-if [ "$os" != "Linux" -a "$os" != "SunOS" ]; then
-    echo "Test not designed to run on this operating system, skipping..."
-    exit 0
-fi
+case "${os}" in
+    Windows* | CYGWIN* )
+        echo "Test not designed to run on this operating system, skipping..."
+        exit 0
+        ;;
+esac
 
 JAVA=${TESTJAVA}/bin/java
 CLASSPATH=${TESTCLASSES}
--- ./jdk/test/sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh	2011-05-26 19:06:34.000000000 -0700
+++ ./jdk/test/sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh	2011-04-22 23:08:51.000000000 -0700
@@ -70,10 +70,12 @@
 # security the password file.
 
 os=`uname -s`
-if [ "$os" != "Linux" -a "$os" != "SunOS" ]; then
-    echo "Test not designed to run on this operating system, skipping..."
-    exit 0
-fi
+case "${os}" in
+    Windows* | CYGWIN* )
+        echo "Test not designed to run on this operating system, skipping..."
+        exit 0
+        ;;
+esac
 
 
 # Create configuration file and dummy password file
--- ./jdk/test/sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh	2011-05-26 19:06:35.000000000 -0700
+++ ./jdk/test/sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh	2011-04-22 23:08:51.000000000 -0700
@@ -69,10 +69,12 @@
 # security the password file.
 
 os=`uname -s`
-if [ "$os" != "Linux" -a "$os" != "SunOS" ]; then
-    echo "Test not designed to run on this operating system, skipping..."
-    exit 0
-fi
+case "${os}" in
+    Windows* | CYGWIN* )
+        echo "Test not designed to run on this operating system, skipping..."
+        exit 0
+        ;;
+esac
 
 # Create management and SSL configuration files
 
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/management/jmxremote/bootstrap/bsd-i586/launcher and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/management/jmxremote/bootstrap/bsd-i586/launcher differ
--- ./jdk/test/sun/misc/URLClassPath/ClassnameCharTest.sh	2011-05-26 19:06:42.000000000 -0700
+++ ./jdk/test/sun/misc/URLClassPath/ClassnameCharTest.sh	2011-04-22 23:08:52.000000000 -0700
@@ -36,11 +36,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/net/www/MarkResetTest.sh	2011-05-26 19:06:47.000000000 -0700
+++ ./jdk/test/sun/net/www/MarkResetTest.sh	2011-04-22 23:08:52.000000000 -0700
@@ -28,7 +28,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/net/www/http/HttpClient/RetryPost.sh	2011-05-26 19:06:50.000000000 -0700
+++ ./jdk/test/sun/net/www/http/HttpClient/RetryPost.sh	2011-04-22 23:08:52.000000000 -0700
@@ -28,7 +28,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/net/www/protocol/jar/B5105410.sh	2011-05-26 19:06:56.000000000 -0700
+++ ./jdk/test/sun/net/www/protocol/jar/B5105410.sh	2011-04-22 23:08:52.000000000 -0700
@@ -31,11 +31,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/net/www/protocol/jar/jarbug/run.sh	2011-05-26 19:06:57.000000000 -0700
+++ ./jdk/test/sun/net/www/protocol/jar/jarbug/run.sh	2011-04-22 23:08:52.000000000 -0700
@@ -31,11 +31,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/nio/cs/EucJpBsd0212.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/test/sun/nio/cs/EucJpBsd0212.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6350021
- * @summary Consistency checks when input buffer contains JISX0212 characters
- * @author Martin Buchholz
- */
-
-import java.io.*;
-import java.util.*;
-import java.nio.*;
-import java.nio.charset.*;
-
-public class EucJpBsd0212 {
-    private static void equal(CharBuffer b1, CharBuffer b2) {
-        equal(b1.position(), b2.position());
-        equal(b1.limit(), b2.limit());
-        System.out.printf("positions=%d %d%n", b1.position(), b2.position());
-        System.out.printf("limits=%d %d%n", b1.limit(), b2.limit());
-        for (int i = b1.position(); i < b1.limit(); i++)
-            equal((int)b1.get(i), (int)b2.get(i));
-    }
-
-    private static void realMain(String[] args) throws Throwable {
-        List<ByteBuffer> bbs = Arrays.asList(
-            ByteBuffer.allocate(10),
-            ByteBuffer.allocateDirect(10));
-        List<CharBuffer> cbs = new ArrayList<CharBuffer>();
-
-        for (ByteBuffer bb : bbs) {
-            bb.put(new byte[]{ (byte)0x8f, 0x01, 0x02,
-                               (byte)0xa1, (byte)0xc0,
-                               0x02, 0x03});
-            bb.flip();
-            CharsetDecoder decoder = Charset.forName("EUC_JP_BSD").newDecoder();
-            decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
-            CharBuffer cb = decoder.decode(bb);
-            cbs.add(cb);
-        }
-        equal(cbs.get(0), cbs.get(1));
-    }
-
-    //--------------------- Infrastructure ---------------------------
-    static volatile int passed = 0, failed = 0;
-    static void pass() {passed++;}
-    static void fail() {failed++; Thread.dumpStack();}
-    static void fail(String msg) {System.out.println(msg); fail();}
-    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
-    static void check(boolean cond) {if (cond) pass(); else fail();}
-    static void equal(Object x, Object y) {
-        if (x == null ? y == null : x.equals(y)) pass();
-        else fail(x + " not equal to " + y);}
-    public static void main(String[] args) throws Throwable {
-        try {realMain(args);} catch (Throwable t) {unexpected(t);}
-        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
-        if (failed > 0) throw new AssertionError("Some tests failed");}
-}
--- ./jdk/test/sun/nio/cs/EucJpBsdDecoderRecoveryTest.java	2011-05-29 11:28:25.000000000 -0700
+++ ./jdk/test/sun/nio/cs/EucJpBsdDecoderRecoveryTest.java	1969-12-31 16:00:00.000000000 -0800
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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 General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
-   @bug 5016049
-   @summary ensure euc-jp-bsd charset decoder recovery for unmappable input
- */
-
-import java.io.*;
-
-public class EucJpBsdDecoderRecoveryTest {
-    public static void main(String[] args) throws Exception {
-        byte[] encoded = {
-                // EUC_JP_BSD mappable JIS X 0208 range
-                (byte)0xa6, (byte)0xc5,
-                // EUC_JP_BSD Unmappable (JIS X 0212 range)
-                (byte)0x8f, (byte)0xa2, (byte)0xb7,
-                // EUC_JP_BSD mappable JIS X 0208 range
-                (byte)0xa6, (byte)0xc7 };
-
-        char[] decodedChars = new char[3];
-        char[] expectedChars =
-                        {
-                        '\u03B5',  // mapped
-                        '\ufffd',  // unmapped
-                        '\u03B7'   // mapped
-                        };
-
-        ByteArrayInputStream bais = new ByteArrayInputStream(encoded);
-        InputStreamReader isr = new InputStreamReader(bais, "EUC_JP_BSD");
-        int n = 0;   // number of chars decoded
-
-        try {
-            n = isr.read(decodedChars);
-        } catch (Exception ex) {
-            throw new Error("euc-jp-bsd decoding broken");
-        }
-
-        // check number of decoded chars is what is expected
-        if (n != expectedChars.length)
-            throw new Error("Unexpected number of chars decoded");
-
-        // Compare actual decoded with expected
-
-        for (int i = 0; i < n; i++) {
-            if (expectedChars[i] != decodedChars[i])
-                throw new Error("euc-jp-bsd decoding incorrect");
-        }
-    }
-}
--- ./jdk/test/sun/security/krb5/runNameEquals.sh	2011-05-26 19:07:30.000000000 -0700
+++ ./jdk/test/sun/security/krb5/runNameEquals.sh	2011-04-22 23:08:53.000000000 -0700
@@ -58,6 +58,11 @@
     FILESEP="/"
     NATIVE=true
     ;;
+  Darwin | *BSD )
+    PATHSEP=":"
+    FILESEP="/"
+    NATIVE=true
+    ;;
   CYGWIN* )
     PATHSEP=";"
     FILESEP="/"
--- ./jdk/test/sun/security/pkcs11/KeyStore/Basic.sh	2011-05-26 19:07:34.000000000 -0700
+++ ./jdk/test/sun/security/pkcs11/KeyStore/Basic.sh	2011-04-22 23:08:53.000000000 -0700
@@ -131,6 +131,27 @@
 	;;
     esac
     ;;
+  *BSD | Darwin )
+    ARCH=`uname -m`
+    case "$ARCH" in
+      i[3-6]86 )
+	FS="/"
+	PS=":"
+	CP="${FS}bin${FS}cp"
+	CHMOD="${FS}bin${FS}chmod"
+	;;
+      amd64* )
+	FS="/"
+	PS=":"
+	CP="${FS}bin${FS}cp"
+	CHMOD="${FS}bin${FS}chmod"
+	;;
+      * )
+	echo "Unsupported System: ${OS} ${ARCH}"
+	exit 0;
+	;;
+    esac
+    ;;
   Windows* )  
     FS="\\"
     PS=";"
--- ./jdk/test/sun/security/pkcs11/KeyStore/ClientAuth.sh	2011-05-26 19:07:37.000000000 -0700
+++ ./jdk/test/sun/security/pkcs11/KeyStore/ClientAuth.sh	2011-04-22 23:08:53.000000000 -0700
@@ -92,6 +92,27 @@
 	;;
     esac
     ;;
+  *BSD | Darwin )
+    ARCH=`uname -m`
+    case "$ARCH" in
+      i[3-6]86 )
+	FS="/"
+	PS=":"
+	CP="${FS}bin${FS}cp"
+	CHMOD="${FS}bin${FS}chmod"
+	;;
+      amd64* )
+	FS="/"
+	PS=":"
+	CP="${FS}bin${FS}cp"
+	CHMOD="${FS}bin${FS}chmod"
+	;;
+      * )
+	echo "Unsupported System: ${OS} ${ARCH}"
+	exit 0;
+	;;
+    esac
+    ;;
   Windows* )
     FS="\\"
     PS=";"
--- ./jdk/test/sun/security/pkcs11/Provider/ConfigQuotedString.sh	2011-05-26 19:07:39.000000000 -0700
+++ ./jdk/test/sun/security/pkcs11/Provider/ConfigQuotedString.sh	2011-04-22 23:08:53.000000000 -0700
@@ -50,13 +50,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    FS="/"
-    PS=":"
-    CP="${FS}bin${FS}cp"
-    CHMOD="${FS}bin${FS}chmod"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     PS=":"
     CP="${FS}bin${FS}cp"
--- ./jdk/test/sun/security/pkcs11/Provider/Login.sh	2011-05-26 19:07:40.000000000 -0700
+++ ./jdk/test/sun/security/pkcs11/Provider/Login.sh	2011-04-22 23:08:53.000000000 -0700
@@ -51,13 +51,7 @@
 
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    FS="/"
-    PS=":"
-    CP="${FS}bin${FS}cp"
-    CHMOD="${FS}bin${FS}chmod"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     PS=":"
     CP="${FS}bin${FS}cp"
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libfreebl3.chk and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libfreebl3.chk differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libfreebl3.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libfreebl3.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libnspr4.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libnspr4.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libnss3.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libnss3.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libnssckbi.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libnssckbi.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libplc4.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libplc4.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libplds4.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libplds4.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libsoftokn3.chk and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libsoftokn3.chk differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libsoftokn3.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-amd64/libsoftokn3.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libnspr4.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libnspr4.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libnss3.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libnss3.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libnssckbi.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libnssckbi.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libplc4.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libplc4.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libplds4.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libplds4.so differ
Files /tmp/openjdk_srcdir.gcBO8Zny/openjdk/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libsoftokn3.so and /home/glewis/projects/java/jdk17/openjdk7/tmp/bsd-port/jdk/test/sun/security/pkcs11/nss/lib/bsd-i586/libsoftokn3.so differ
--- ./jdk/test/sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.sh	2011-05-26 19:07:59.000000000 -0700
+++ ./jdk/test/sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.sh	2011-04-22 23:08:53.000000000 -0700
@@ -44,11 +44,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/sun/security/provider/PolicyFile/getinstance/getinstance.sh	2011-05-26 19:08:00.000000000 -0700
+++ ./jdk/test/sun/security/provider/PolicyFile/getinstance/getinstance.sh	2011-04-22 23:08:54.000000000 -0700
@@ -47,11 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh	2011-05-26 19:08:08.000000000 -0700
+++ ./jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh	2011-04-22 23:08:54.000000000 -0700
@@ -42,7 +42,7 @@
 
 OS=`uname -s`
 case "$OS" in
-    SunOS | Linux )
+    SunOS | Linux | *BSD | Darwin )
         FILESEP="/"
 	PATHSEP=":"
 	;;
--- ./jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh	2011-05-26 19:08:16.000000000 -0700
+++ ./jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh	2011-04-22 23:08:54.000000000 -0700
@@ -32,7 +32,7 @@
 HOSTNAME=`uname -n`
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh	2011-05-26 19:08:16.000000000 -0700
+++ ./jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.sh	2011-04-22 23:08:54.000000000 -0700
@@ -32,7 +32,7 @@
 HOSTNAME=`uname -n`
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./jdk/test/sun/security/tools/jarsigner/AlgOptions.sh	2011-05-26 19:08:17.000000000 -0700
+++ ./jdk/test/sun/security/tools/jarsigner/AlgOptions.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/jarsigner/PercentSign.sh	2011-05-26 19:08:18.000000000 -0700
+++ ./jdk/test/sun/security/tools/jarsigner/PercentSign.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/jarsigner/diffend.sh	2011-05-26 19:08:18.000000000 -0700
+++ ./jdk/test/sun/security/tools/jarsigner/diffend.sh	2011-04-22 23:08:54.000000000 -0700
@@ -41,7 +41,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin)
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/jarsigner/oldsig.sh	2011-05-26 19:08:18.000000000 -0700
+++ ./jdk/test/sun/security/tools/jarsigner/oldsig.sh	2011-04-22 23:08:54.000000000 -0700
@@ -42,7 +42,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/keytool/AltProviderPath.sh	2011-05-26 19:08:19.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/AltProviderPath.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/keytool/CloneKeyAskPassword.sh	2011-05-26 19:08:19.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/CloneKeyAskPassword.sh	2011-04-22 23:08:54.000000000 -0700
@@ -47,11 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
+  SunOS | Linux | *BSD | Darwin )
     PATHSEP=":"
     FILESEP="/"
     ;;
--- ./jdk/test/sun/security/tools/keytool/SecretKeyKS.sh	2011-05-26 19:08:20.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/SecretKeyKS.sh	2011-04-22 23:08:54.000000000 -0700
@@ -45,7 +45,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/keytool/StandardAlgName.sh	2011-05-26 19:08:20.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/StandardAlgName.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/keytool/autotest.sh	2011-05-26 19:08:20.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/autotest.sh	2011-04-22 23:08:54.000000000 -0700
@@ -72,6 +72,27 @@
         ;;
     esac
     ;;
+  *BSD | Darwin )
+    case "${OS}" in
+      *BSD )
+        LIBNAME=libsoftokn3.so
+        ;;
+      Darwin )
+        LIBNAME=libsoftokn3.dylib
+        ;;
+    esac
+    ARCH=`uname -m`
+    FS="/"
+    case "$ARCH" in
+      i[3-6]86 )
+        PF="bsd-i586"
+        ;;
+      * )
+        echo "Will not run test on: ${OS} ${ARCH}"
+        exit 0;
+        ;;
+    esac
+    ;;
   * )
     echo "Will not run test on: ${OS}"
     exit 0;
--- ./jdk/test/sun/security/tools/keytool/i18n.sh	2011-05-26 19:08:21.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/i18n.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/keytool/printssl.sh	2011-05-26 19:08:21.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/printssl.sh	2011-04-22 23:08:54.000000000 -0700
@@ -37,7 +37,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     ;;
   CYGWIN* )
--- ./jdk/test/sun/security/tools/keytool/resource.sh	2011-05-26 19:08:21.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/resource.sh	2011-04-22 23:08:54.000000000 -0700
@@ -43,7 +43,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     FS="/"
     TMP=/tmp
--- ./jdk/test/sun/security/tools/keytool/standard.sh	2011-05-26 19:08:21.000000000 -0700
+++ ./jdk/test/sun/security/tools/keytool/standard.sh	2011-04-22 23:08:54.000000000 -0700
@@ -44,7 +44,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows_* )
--- ./jdk/test/sun/security/tools/policytool/Alias.sh	2011-05-26 19:08:22.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/Alias.sh	2011-04-22 23:08:54.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/policytool/ChangeUI.sh	2011-05-26 19:08:22.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/ChangeUI.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/policytool/OpenPolicy.sh	2011-05-26 19:08:22.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/OpenPolicy.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/policytool/SaveAs.sh	2011-05-26 19:08:23.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/SaveAs.sh	2011-04-22 23:08:54.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/policytool/UpdatePermissions.sh	2011-05-26 19:08:23.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/UpdatePermissions.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/policytool/UsePolicy.sh	2011-05-26 19:08:23.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/UsePolicy.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/security/tools/policytool/i18n.sh	2011-05-26 19:08:23.000000000 -0700
+++ ./jdk/test/sun/security/tools/policytool/i18n.sh	2011-04-22 23:08:54.000000000 -0700
@@ -46,7 +46,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./jdk/test/sun/tools/jconsole/ImmutableResourceTest.sh	2011-05-26 19:08:30.000000000 -0700
+++ ./jdk/test/sun/tools/jconsole/ImmutableResourceTest.sh	2011-04-22 23:08:54.000000000 -0700
@@ -53,7 +53,7 @@
 
 OS=`uname -s`
 case "$OS" in
-   SunOS | Linux )
+   SunOS | Linux | *BSD | Darwin )
       PATHSEP=":"
       ;;
 
--- ./jdk/test/sun/tools/jconsole/ResourceCheckTest.sh	2011-05-26 19:08:31.000000000 -0700
+++ ./jdk/test/sun/tools/jconsole/ResourceCheckTest.sh	2011-04-22 23:08:54.000000000 -0700
@@ -54,7 +54,7 @@
 
 OS=`uname -s`
 case "$OS" in
-   SunOS | Linux )
+   SunOS | Linux | *BSD | Darwin )
       PATHSEP=":"
       ;;
 
--- ./jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	2011-05-26 19:08:42.000000000 -0700
+++ ./jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	2011-04-22 23:08:55.000000000 -0700
@@ -33,7 +33,7 @@
 
 case `uname -s` in
   Windows* | CYGWIN*) OS=Windows;;
-  SunOS|Linux) OS=Unix;;
+  SunOS|Linux|*BSD|Darwin) OS=Unix;;
 esac
 
 N2A=$TESTJAVA/bin/native2ascii
--- ./jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.sh	2011-05-26 19:08:42.000000000 -0700
+++ ./jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.sh	2011-04-22 23:08:55.000000000 -0700
@@ -56,7 +56,7 @@
 
 OS=`uname -s`
 case "$OS" in
-   SunOS | Linux )
+   SunOS | Linux | *BSD | Darwin )
       PATHSEP=":"
       ;;
 
--- ./langtools/.hgtags	2011-05-26 19:15:40.000000000 -0700
+++ ./langtools/.hgtags	2011-05-27 00:01:06.000000000 -0700
@@ -118,3 +118,4 @@
 90adb5d6adc7d99d27c8b142a31ac8921070274f jdk7-b141
 7476b164194c1814704153e74d5ff7e965c6fdbf jdk7-b142
 5faa9eedc44e201f2b13ad837e9077668b823d28 jdk7-b143
+8eb952f43b117d538f6ca5e9e43ff9ce7646c7ee jdk7-b144
--- ./langtools/.jcheck/conf	2011-05-26 19:15:40.000000000 -0700
+++ ./langtools/.jcheck/conf	1969-12-31 16:00:00.000000000 -0800
@@ -1 +0,0 @@
-project=jdk7
--- ./langtools/make/build.xml	2011-05-26 19:15:41.000000000 -0700
+++ ./langtools/make/build.xml	2011-05-07 21:54:16.000000000 -0700
@@ -186,9 +186,14 @@
     </condition>
 
     <condition property="boot.java.provides.latest.jdk">
-        <available
-            ignoresystemclasses="true"
-            classpath="${boot.java.home}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
+        <and>
+            <available
+                ignoresystemclasses="true"
+                classpath="${boot.java.home}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
+            <hasmethod
+                classpath="${boot.java.home}/jre/lib/rt.jar"
+                classname="java.nio.file.Path" method="getFileName"/>
+        </and>
     </condition>
 
     <condition property="bootstrap.exclude.files" value="" else="${require.latest.jdk.files}">
--- ./langtools/test/Makefile	2011-05-26 19:16:47.000000000 -0700
+++ ./langtools/test/Makefile	2011-04-22 23:11:42.000000000 -0700
@@ -34,6 +34,22 @@
     ARCH=i586
   endif
 endif
+ifeq ($(OSNAME), Darwin)
+  PLATFORM = bsd
+  JT_PLATFORM = linux
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH=i586
+  endif
+endif
+ifeq ($(findstring BSD,$(OSNAME)), BSD)
+  PLATFORM = bsd
+  JT_PLATFORM = linux
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH=i586
+  endif
+endif
 ifeq ($(OSNAME), Windows_NT)
   PLATFORM = windows
   JT_PLATFORM = win32
@@ -93,7 +109,7 @@
 ifdef JPRT_JAVA_HOME
   JT_JAVA = $(JPRT_JAVA_HOME)
 else
-  JT_JAVA = $(SLASH_JAVA)/re/jdk/1.6.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
+  JT_JAVA = $(TEST_ROOT)/../../build/$(PLATFORM)-$(ARCH)
 endif
 
 # Default JDK to test
@@ -188,7 +204,9 @@
 
 # The test directories to run
 DEFAULT_TESTDIRS = .
-TESTDIRS = $(DEFAULT_TESTDIRS)
+ifndef TESTDIRS
+  TESTDIRS = $(DEFAULT_TESTDIRS)
+endif
 
 # Root of all test results
 TEST_OUTPUT_DIR = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools
--- ./langtools/test/jprt.config	2011-05-26 19:17:31.000000000 -0700
+++ ./langtools/test/jprt.config	2011-04-22 23:11:43.000000000 -0700
@@ -71,8 +71,8 @@
 
 # Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
 osname=`uname -s`
-if [ "${osname}" = SunOS ] ; then
-   
+case "${osname}" in
+  SunOS)
     # SOLARIS: Sparc or X86
     osarch=`uname -p`
     if [ "${osarch}" = sparc ] ; then
@@ -96,9 +96,9 @@
 
     # File creation mask
     umask 002
+    ;;
 
-elif [ "${osname}" = Linux ] ; then
-   
+  Linux | Darwin )
     # Add basic paths
     path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
@@ -107,9 +107,31 @@
     fileMustExist "${make}" make
 
     umask 002
+    ;;
+
+  FreeBSD | OpenBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
+
+    # Find GNU make
+    make=/usr/local/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
 
-else
+  NetBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
+    # Find GNU make
+    make=/usr/pkg/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
+
+  *)
     # Windows: Differs on CYGWIN vs. MKS.
    
     # We need to determine if we are running a CYGWIN shell or an MKS shell
@@ -150,8 +172,8 @@
     if [ "${unix_toolset}" = CYGWIN ] ; then
 	path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
     fi
-
-fi
+    ;;
+esac
 
 # Export PATH setting
 PATH="${path4sdk}"
--- ./langtools/test/tools/javac/4846262/Test.sh	2011-05-26 19:17:42.000000000 -0700
+++ ./langtools/test/tools/javac/4846262/Test.sh	2011-04-22 23:11:44.000000000 -0700
@@ -44,7 +44,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     ;;
   CYGWIN* )
--- ./langtools/test/tools/javac/6302184/T6302184.sh	2011-05-26 19:17:44.000000000 -0700
+++ ./langtools/test/tools/javac/6302184/T6302184.sh	2011-04-22 23:11:44.000000000 -0700
@@ -41,7 +41,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     ;;
   CYGWIN* )
--- ./langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh	2011-05-26 19:18:02.000000000 -0700
+++ ./langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh	2011-04-22 23:11:44.000000000 -0700
@@ -56,7 +56,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     ;;
   Windows* )
--- ./langtools/test/tools/javac/ExtDirs/ExtDirs.sh	2011-05-26 19:18:15.000000000 -0700
+++ ./langtools/test/tools/javac/ExtDirs/ExtDirs.sh	2011-04-22 23:11:44.000000000 -0700
@@ -54,7 +54,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javac/MissingInclude.sh	2011-05-26 19:18:23.000000000 -0700
+++ ./langtools/test/tools/javac/MissingInclude.sh	2011-04-22 23:11:45.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows* )
--- ./langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh	2011-05-26 19:18:31.000000000 -0700
+++ ./langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh	2011-04-22 23:11:45.000000000 -0700
@@ -52,7 +52,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javac/T5090006/compiler.sh	2011-05-26 19:18:37.000000000 -0700
+++ ./langtools/test/tools/javac/T5090006/compiler.sh	2011-04-22 23:11:45.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows* )
--- ./langtools/test/tools/javac/apt.sh	2011-05-26 19:19:04.000000000 -0700
+++ ./langtools/test/tools/javac/apt.sh	2011-04-22 23:11:45.000000000 -0700
@@ -38,7 +38,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./langtools/test/tools/javac/constDebug/ConstDebug.sh	2011-05-26 19:19:13.000000000 -0700
+++ ./langtools/test/tools/javac/constDebug/ConstDebug.sh	2011-04-22 23:11:46.000000000 -0700
@@ -47,7 +47,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javac/fatalErrors/NoJavaLang.sh	2011-05-26 19:19:59.000000000 -0700
+++ ./langtools/test/tools/javac/fatalErrors/NoJavaLang.sh	2011-04-22 23:11:46.000000000 -0700
@@ -48,7 +48,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     ;;
   CYGWIN* )
--- ./langtools/test/tools/javac/innerClassFile/Driver.sh	2011-05-26 19:20:48.000000000 -0700
+++ ./langtools/test/tools/javac/innerClassFile/Driver.sh	2011-04-22 23:11:47.000000000 -0700
@@ -53,7 +53,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows* )
--- ./langtools/test/tools/javac/javazip/Test.sh	2011-05-26 19:20:49.000000000 -0700
+++ ./langtools/test/tools/javac/javazip/Test.sh	2011-04-22 23:11:47.000000000 -0700
@@ -41,7 +41,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     FS="/"
     SCR=`pwd`
     ;;
--- ./langtools/test/tools/javac/links/links.sh	2011-05-26 19:20:52.000000000 -0700
+++ ./langtools/test/tools/javac/links/links.sh	2011-04-22 23:11:47.000000000 -0700
@@ -53,7 +53,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     NULL=/dev/null
     PS=":"
     FS="/"
--- ./langtools/test/tools/javac/newlines/Newlines.sh	2011-05-26 19:21:00.000000000 -0700
+++ ./langtools/test/tools/javac/newlines/Newlines.sh	2011-04-22 23:11:48.000000000 -0700
@@ -50,7 +50,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows* )
--- ./langtools/test/tools/javac/stackmap/T4955930.sh	2011-05-26 19:21:13.000000000 -0700
+++ ./langtools/test/tools/javac/stackmap/T4955930.sh	2011-04-22 23:11:48.000000000 -0700
@@ -41,7 +41,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows_95 | Windows_98 | Windows_NT )
--- ./langtools/test/tools/javac/unicode/SupplementaryJavaID6.sh	2011-05-26 19:21:16.000000000 -0700
+++ ./langtools/test/tools/javac/unicode/SupplementaryJavaID6.sh	2011-04-22 23:11:48.000000000 -0700
@@ -66,6 +66,17 @@
         exit 0;
     fi
     ;;
+  *BSD | Darwin )
+    if [ -d /usr/share/locale/en_US.UTF-8 -o -d /usr/share/locale/en_US.utf8 ]
+    then
+        ENV="env LANG=en_US.UTF-8"
+        PS=":"
+        FS="/"
+    else
+        echo "As there is no en_US.UTF-8 locale available on this system, the compilation of the test case may or may not fail.  Ignoring this test."
+        exit 0;
+    fi
+    ;;
   Windows_98 | Windows_ME )
     echo "As Windows 98/Me do not provide Unicode-aware file system, the compilation of the test case is expected to fail on these platforms.  Ignoring this test."
     exit 0;
--- ./langtools/test/tools/javah/6257087/foo.sh	2011-05-26 19:21:30.000000000 -0700
+++ ./langtools/test/tools/javah/6257087/foo.sh	2011-04-22 23:11:49.000000000 -0700
@@ -41,7 +41,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javah/ConstMacroTest.sh	2011-05-26 19:21:31.000000000 -0700
+++ ./langtools/test/tools/javah/ConstMacroTest.sh	2011-04-22 23:11:49.000000000 -0700
@@ -56,7 +56,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux )
+  SunOS | Linux | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javah/MissingParamClassTest.sh	2011-05-26 19:21:31.000000000 -0700
+++ ./langtools/test/tools/javah/MissingParamClassTest.sh	2011-04-22 23:11:49.000000000 -0700
@@ -58,7 +58,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javah/ReadOldClass.sh	2011-05-26 19:21:31.000000000 -0700
+++ ./langtools/test/tools/javah/ReadOldClass.sh	2011-04-22 23:11:49.000000000 -0700
@@ -43,7 +43,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     PS=":"
     FS="/"
     ;;
--- ./langtools/test/tools/javap/pathsep.sh	2011-05-26 19:21:34.000000000 -0700
+++ ./langtools/test/tools/javap/pathsep.sh	2011-04-22 23:11:49.000000000 -0700
@@ -40,7 +40,7 @@
 # set platform-dependent variables
 OS=`uname -s`
 case "$OS" in
-  SunOS | Linux | CYGWIN* )
+  SunOS | Linux | CYGWIN* | *BSD | Darwin )
     FS="/"
     ;;
   Windows* )
--- ./make/Defs-internal.gmk	2011-05-26 17:05:29.000000000 -0700
+++ ./make/Defs-internal.gmk	2011-04-22 22:19:24.000000000 -0700
@@ -79,7 +79,7 @@
 # Find all build_time_* files and print their contents in a list sorted
 # on the name of the sub repository.
 define ReportBuildTimes
-$(PRINTF) "-- Build times ----------\nTarget %s\nStart %s\nEnd   %s\n%s\n%s\n-------------------------\n" \
+$(PRINTF) "## Build times ##########\nTarget %s\nStart %s\nEnd   %s\n%s\n%s\n#########################\n" \
 $1 \
 "`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \
 "`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \