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
|
diff --git a/bsd-user/arm/target_signal.h b/bsd-user/arm/target_signal.h
index 19cc188..6b7bb67 100644
--- a/bsd-user/arm/target_signal.h
+++ b/bsd-user/arm/target_signal.h
@@ -11,4 +11,29 @@ static inline abi_ulong get_sp_from_cpustate(CPUARMState *state)
#define TARGET_MINSIGSTKSZ (1024 * 4)
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
+typedef target_ulong target_mcontext_t; /* dummy */
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
+static inline int
+get_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "ARM doesn't have support for get_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
+static inline int
+set_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "ARM doesn't have support for set_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
#endif /* TARGET_SIGNAL_H */
diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
index 1edf412..b09f766 100644
--- a/bsd-user/freebsd/strace.list
+++ b/bsd-user/freebsd/strace.list
@@ -38,6 +38,7 @@
{ TARGET_FREEBSD_NR_fsync, "fsync", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_futimes, "futimes", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_getcontext, "getcontext", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_freebsd6_mmap, "freebsd6_mmap", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_getegid, "getegid", "%s()", NULL, NULL },
@@ -123,6 +124,7 @@
{ TARGET_FREEBSD_NR_semop, "semop", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sendto, "sendto", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_setcontext, "setcontext", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setegid, "setegid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_seteuid, "seteuid", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_setgid, "setgid", NULL, NULL, NULL },
@@ -160,6 +162,15 @@
{ TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_create, "thr_create", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_exit, "thr_exit", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_kill, "thr_kill", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_kill2, "thr_kill2", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_new, "thr_new", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_self, "thr_self", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_set_name, "thr_set_name", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_suspend, "thr_suspend", NULL, NULL, NULL },
+{ TARGET_FREEBSD_NR_thr_wake, "thr_wake", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_truncate, "truncate", NULL, NULL, NULL },
{ TARGET_FREEBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL },
{ TARGET_FREEBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL },
diff --git a/bsd-user/i386/target_signal.h b/bsd-user/i386/target_signal.h
index 285e7f9..28481ce 100644
--- a/bsd-user/i386/target_signal.h
+++ b/bsd-user/i386/target_signal.h
@@ -11,4 +11,29 @@ static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
#define TARGET_MINSIGSTKSZ (512 * 4)
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
+typedef target_ulong target_mcontext_t; /* dummy */
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
+static inline int
+get_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "i386 doesn't have support for get_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
+static inline int
+set_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "i386 doesn't have support for set_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
#endif /* TARGET_SIGNAL_H */
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 146f022..7a99537 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -34,6 +34,10 @@
#include "qemu/timer.h"
#include "qemu/envlist.h"
+#if defined(CONFIG_USE_NPTL) && defined(__FreeBSD__)
+#include <sys/thr.h>
+#endif
+
int singlestep;
#if defined(CONFIG_USE_GUEST_BASE)
unsigned long mmap_min_addr;
@@ -68,41 +72,185 @@ int cpu_get_pic_interrupt(CPUX86State *e
}
#endif
-/* These are no-ops because we are not threadsafe. */
-static inline void cpu_exec_start(CPUArchState *env)
+#if defined(CONFIG_USE_NPTL)
+/* Helper routines for implementing atomic operations. */
+
+/*
+ * To implement exclusive operations we force all cpus to synchronize.
+ * We don't require a full sync, only that no cpus are executing guest code.
+ * The alternative is to map target atomic ops onto host eqivalents,
+ * which requires quite a lot of per host/target work.
+ */
+static pthread_mutex_t cpu_list_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t exclusive_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t exclusive_cond = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t exclusive_resume = PTHREAD_COND_INITIALIZER;
+static int pending_cpus;
+
+/* Make sure everything is in a consistent state for calling fork(). */
+void fork_start(void)
{
+ pthread_mutex_lock(&tb_lock);
+ pthread_mutex_lock(&exclusive_lock);
+ mmap_fork_start();
}
-static inline void cpu_exec_end(CPUArchState *env)
+void fork_end(int child)
{
+ mmap_fork_end(child);
+ if (child) {
+ /*
+ * Child processes created by fork() only have a single thread.
+ * Discard information about the parent threads.
+ */
+ first_cpu = thread_env;
+ thread_env->next_cpu = NULL;
+ pending_cpus = 0;
+ pthread_mutex_init(&exclusive_lock, NULL);
+ pthread_mutex_init(&cpu_list_mutex, NULL);
+ pthread_cond_init(&exclusive_cond, NULL);
+ pthread_cond_init(&exclusive_resume, NULL);
+ pthread_mutex_init(&tb_lock, NULL);
+ gdbserver_fork(thread_env);
+ } else {
+ pthread_mutex_unlock(&exclusive_lock);
+ pthread_mutex_unlock(&tb_lock);
+ }
}
-static inline void start_exclusive(void)
+/*
+ * Wait for pending exclusive operations to complete. The exclusive lock
+ * must be held.
+ */
+static inline void
+exclusive_idle(void)
{
+ while (pending_cpus) {
+ pthread_cond_wait(&exclusive_resume, &exclusive_lock);
+ }
}
-static inline void end_exclusive(void)
+/* Start an exclusive operation. Must only be called outside of cpu_exec. */
+static inline void
+start_exclusive(void)
+{
+ CPUArchState *other;
+
+ pthread_mutex_lock(&exclusive_lock);
+ exclusive_idle();
+
+ pending_cpus = 1;
+ /* Make all other cpus stop executing. */
+ for (other = first_cpu; other; other = other->next_cpu) {
+ if (other->running) {
+ pending_cpus++;
+ cpu_exit(other);
+ }
+ }
+ if (pending_cpus > 1) {
+ pthread_cond_wait(&exclusive_cond, &exclusive_lock);
+ }
+}
+
+/* Finish an exclusive operation. */
+static inline void
+end_exclusive(void)
+{
+ pending_cpus = 0;
+ pthread_cond_broadcast(&exclusive_resume);
+ pthread_mutex_unlock(&exclusive_lock);
+}
+
+/* Wait for exclusive ops to finish, and begin cpu execution. */
+static inline void
+cpu_exec_start(CPUArchState *env)
+{
+ pthread_mutex_lock(&exclusive_lock);
+ exclusive_idle();
+ env->running = 1;
+ pthread_mutex_unlock(&exclusive_lock);
+}
+
+/* Mark cpu as not excuting, and release pending exclusive ops. */
+static inline void
+cpu_exec_end(CPUArchState *env)
+{
+ pthread_mutex_lock(&exclusive_lock);
+ env->running = 0;
+ if (pending_cpus > 1) {
+ pending_cpus--;
+ if (pending_cpus == 1) {
+ pthread_cond_signal(&exclusive_cond);
+ }
+ }
+ exclusive_idle();
+ pthread_mutex_unlock(&exclusive_lock);
+}
+
+void
+cpu_list_lock(void)
{
+ pthread_mutex_lock(&cpu_list_mutex);
}
-void fork_start(void)
+void
+cpu_list_unlock(void)
{
+ pthread_mutex_unlock(&cpu_list_mutex);
}
-void fork_end(int child)
+#else /* ! CONFIG_USE_NPTL */
+
+/* These are no-ops because we are not threadsafe. */
+void
+fork_start(void)
+{
+}
+
+void
+fork_end(int child)
{
if (child) {
gdbserver_fork(thread_env);
}
}
-void cpu_list_lock(void)
+static inline void
+exclusive_idle(void)
+{
+}
+
+static inline void
+start_exclusive(void)
+{
+}
+
+static inline void
+end_exclusive(void)
+{
+}
+
+static inline void
+cpu_exec_start(CPUArchState *env)
{
}
-void cpu_list_unlock(void)
+
+static inline void
+cpu_exec_end(CPUArchState *env)
+{
+}
+
+void
+cpu_list_lock(void)
+{
+}
+
+void
+cpu_list_unlock(void)
{
}
+#endif /* CONFIG_USE_NPTL */
#ifdef TARGET_I386
/***********************************************************/
@@ -738,7 +886,10 @@ void cpu_loop(CPUMIPSState *env)
for(;;) {
cpu_exec_start(env);
+ /* XXX there is a concurrency problem - giant lock for now */
+ pthread_mutex_lock(&exclusive_lock); /* XXX */
trapnr = cpu_mips_exec(env);
+ pthread_mutex_unlock(&exclusive_lock); /* XXX */
cpu_exec_end(env);
switch(trapnr) {
case EXCP_SYSCALL: /* syscall exception */
@@ -1204,6 +1355,18 @@ static void usage(void)
THREAD CPUArchState *thread_env;
+void task_settid(TaskState *ts)
+{
+ if (0 == ts->ts_tid) {
+#ifdef CONFIG_USE_NPTL
+ (void)thr_self(&ts->ts_tid);
+#else
+ /* When no threads then just use PID */
+ ts->ts_tid = getpid();
+#endif
+ }
+}
+
void stop_all_tasks(void)
{
/*
diff --git a/bsd-user/mips/target_signal.h b/bsd-user/mips/target_signal.h
index 28871c3..484cfd8 100644
--- a/bsd-user/mips/target_signal.h
+++ b/bsd-user/mips/target_signal.h
@@ -6,9 +6,187 @@
#define TARGET_MINSIGSTKSZ (512 * 4)
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
-static inline abi_ulong get_sp_from_cpustate(CPUMIPSState *state)
+struct target_sigcontext {
+ target_sigset_t sc_mask; /* signal mask to retstore */
+ int32_t sc_onstack; /* sigstack state to restore */
+ abi_long sc_pc; /* pc at time of signal */
+ abi_long sc_reg[32]; /* processor regs 0 to 31 */
+ abi_long mullo, mulhi; /* mullo and mulhi registers */
+ int32_t sc_fpused; /* fp has been used */
+ abi_long sc_fpregs[33]; /* fp regs 0 to 31 & csr */
+ abi_long sc_fpc_eir; /* fp exception instr reg */
+ /* int32_t reserved[8]; */
+};
+
+typedef struct target_mcontext {
+ int32_t mc_onstack; /* sigstack state to restore */
+ abi_long mc_pc; /* pc at time of signal */
+ abi_long mc_regs[32]; /* process regs 0 to 31 */
+ abi_long sr; /* status register */
+ abi_long mullo, mulhi;
+ int32_t mc_fpused; /* fp has been used */
+ abi_long mc_fpregs[33]; /* fp regs 0 to 32 & csr */
+ abi_long mc_fpc_eir; /* fp exception instr reg */
+ abi_ulong mc_tls; /* pointer to TLS area */
+} target_mcontext_t;
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
+struct target_sigframe {
+ abi_ulong sf_signum;
+ abi_ulong sf_siginfo; /* code or pointer to sf_si */
+ abi_ulong sf_ucontext; /* points to sf_uc */
+ abi_ulong sf_addr; /* undocumented 4th arg */
+ target_ucontext_t sf_uc; /* = *sf_uncontext */
+ target_siginfo_t sf_si; /* = *sf_siginfo (SA_SIGINFO case)*/
+ uint32_t __spare__[2];
+};
+
+
+/* Get the stack pointer. */
+static inline abi_ulong
+get_sp_from_cpustate(CPUMIPSState *state)
{
return state->active_tc.gpr[29];
}
+/*
+ * Compare to mips/mips/pm_machdep.c sendsig()
+ * Assumes that "frame" memory is locked.
+ */
+static inline int
+set_sigtramp_args(CPUMIPSState *regs, int sig, struct target_sigframe *frame,
+ abi_ulong frame_addr, struct target_sigaction *ka)
+{
+
+ frame->sf_signum = sig;
+ frame->sf_siginfo = 0;
+ frame->sf_ucontext = 0;
+
+ frame->sf_si.si_signo = sig;
+ frame->sf_si.si_code = TARGET_SA_SIGINFO;
+ frame->sf_si.si_addr = regs->CP0_BadVAddr;
+
+ /*
+ * Arguments to signal handler:
+ * a0 ($4) = signal number
+ * a1 ($5) = siginfo pointer
+ * a2 ($6) = ucontext pointer
+ * PC = signal handler pointer
+ * t9 ($25) = signal handler pointer
+ * $29 = point to sigframe struct
+ * ra ($31) = sigtramp at base of user stack
+ */
+ regs->active_tc.gpr[ 4] = sig;
+ regs->active_tc.gpr[ 5] = frame_addr +
+ offsetof(struct target_sigframe, sf_si);
+ regs->active_tc.gpr[25] = regs->active_tc.PC = ka->_sa_handler;
+ regs->active_tc.gpr[29] = frame_addr;
+ regs->active_tc.gpr[31] = TARGET_PS_STRINGS - TARGET_SZSIGCODE;
+
+ return (0);
+}
+
+/*
+ * Compare to mips/mips/pm_machdep.c get_mcontext()
+ * Assumes that the memory is locked if mcp points to user memory.
+ */
+static inline int
+get_mcontext(CPUMIPSState *regs, target_mcontext_t *mcp, int flags)
+{
+ int i, err = 0;
+
+ if (flags & TARGET_MC_ADD_MAGIC) {
+ mcp->mc_regs[0] = tswapal(TARGET_UCONTEXT_MAGIC);
+ } else {
+ mcp->mc_regs[0] = 0;
+ }
+
+ if (flags & TARGET_MC_SET_ONSTACK) {
+ mcp->mc_onstack = tswapal(1);
+ } else {
+ mcp->mc_onstack = 0;
+ }
+
+ for(i = 1; i < 32; i++)
+ mcp->mc_regs[i] = tswapal(regs->active_tc.gpr[i]);
+
+#if 0 /* XXX FP is not used right now. */
+ abi_ulong used_fp = used_math() ? TARGET_MDTD_FPUSED : 0;
+
+ mcp->mc_fpused = used_fp;
+ if (used_fp) {
+ preempt_disable();
+ if (!is_fpu_owner()) {
+ own_fpu();
+ for(i = 0; i < 33; i++)
+ mcp->mc_fpregs[i] = tswapal(regs->active_fpu.fpr[i]);
+ }
+ preempt_enable();
+ }
+#else
+ mcp->mc_fpused = 0;
+#endif
+
+ if (flags & TARGET_MC_GET_CLEAR_RET) {
+ mcp->mc_regs[2] = 0; /* v0 = 0 */
+ mcp->mc_regs[3] = 0; /* v1 = 0 */
+ mcp->mc_regs[7] = 0; /* a3 = 0 */
+ }
+
+ mcp->mc_pc = tswapal(regs->active_tc.PC);
+ mcp->mullo = tswapal(regs->active_tc.LO[0]);
+ mcp->mulhi = tswapal(regs->active_tc.HI[0]);
+ mcp->mc_tls = tswapal(regs->tls_value);
+
+ /* Don't do any of the status and cause registers. */
+
+ return (err);
+}
+
+/* Compare to mips/mips/pm_machdep.c set_mcontext() */
+static inline int
+set_mcontext(CPUMIPSState *regs, target_mcontext_t *mcp, int flags)
+{
+ int i, err = 0;
+
+ for(i = 1; i < 32; i++)
+ regs->active_tc.gpr[i] = tswapal(mcp->mc_regs[i]);
+
+#if 0 /* XXX FP is not used right now */
+ abi_ulong used_fp = 0;
+
+ used_fp = tswapal(mcp->mc_fpused)
+ conditional_used_math(used_fp);
+
+ preempt_disabled();
+ if (used_math()) {
+ /* restore fpu context if we have used it before */
+ own_fpu();
+ for (i = 0; i < 32; i++)
+ regs->active_fpu.fpr[i] = tswapal(mcp->mc_fpregs[i]);
+ } else {
+ /* Signal handler may have used FPU. Give it up. */
+ lose_fpu();
+ }
+ preempt_enable();
+#endif
+
+ regs->CP0_EPC = tswapal(mcp->mc_pc);
+ regs->active_tc.LO[0] = tswapal(mcp->mullo);
+ regs->active_tc.HI[0] = tswapal(mcp->mulhi);
+ regs->tls_value = tswapal(mcp->mc_tls);
+
+ /* Don't do any of the status and cause registers. */
+
+ return (err);
+}
+
#endif /* TARGET_SIGNAL_H */
diff --git a/bsd-user/mips64/target_signal.h b/bsd-user/mips64/target_signal.h
index d671f4e..e9c8a9f 100644
--- a/bsd-user/mips64/target_signal.h
+++ b/bsd-user/mips64/target_signal.h
@@ -7,11 +7,186 @@
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
#define TARGET_SZSIGCODE 16
-#define TARGET_UCONTEXT_MAGIC 0xACEDBADE
+struct target_sigcontext {
+ target_sigset_t sc_mask; /* signal mask to retstore */
+ int32_t sc_onstack; /* sigstack state to restore */
+ abi_long sc_pc; /* pc at time of signal */
+ abi_long sc_reg[32]; /* processor regs 0 to 31 */
+ abi_long mullo, mulhi; /* mullo and mulhi registers */
+ int32_t sc_fpused; /* fp has been used */
+ abi_long sc_fpregs[33]; /* fp regs 0 to 31 & csr */
+ abi_long sc_fpc_eir; /* fp exception instr reg */
+ /* int32_t reserved[8]; */
+};
-static inline abi_ulong get_sp_from_cpustate(CPUMIPSState *state)
+typedef struct target_mcontext {
+ int32_t mc_onstack; /* sigstack state to restore */
+ abi_long mc_pc; /* pc at time of signal */
+ abi_long mc_regs[32]; /* process regs 0 to 31 */
+ abi_long sr; /* status register */
+ abi_long mullo, mulhi;
+ int32_t mc_fpused; /* fp has been used */
+ abi_long mc_fpregs[33]; /* fp regs 0 to 32 & csr */
+ abi_long mc_fpc_eir; /* fp exception instr reg */
+ abi_ulong mc_tls; /* pointer to TLS area */
+} target_mcontext_t;
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
+struct target_sigframe {
+ abi_ulong sf_signum;
+ abi_ulong sf_siginfo; /* code or pointer to sf_si */
+ abi_ulong sf_ucontext; /* points to sf_uc */
+ abi_ulong sf_addr; /* undocumented 4th arg */
+ target_ucontext_t sf_uc; /* = *sf_uncontext */
+ target_siginfo_t sf_si; /* = *sf_siginfo (SA_SIGINFO case)*/
+ uint32_t __spare__[2];
+};
+
+static inline abi_ulong
+get_sp_from_cpustate(CPUMIPSState *state)
{
return state->active_tc.gpr[29];
}
+/*
+ * Compare to mips/mips/pm_machdep.c sendsig()
+ * Assumes that "frame" memory is locked.
+ */
+static inline int
+set_sigtramp_args(CPUMIPSState *regs, int sig, struct target_sigframe *frame,
+ abi_ulong frame_addr, struct target_sigaction *ka)
+{
+
+ frame->sf_signum = sig;
+ frame->sf_siginfo = 0;
+ frame->sf_ucontext = 0;
+
+ frame->sf_si.si_signo = sig;
+ frame->sf_si.si_code = TARGET_SA_SIGINFO;
+ frame->sf_si.si_addr = regs->CP0_BadVAddr;
+
+ /*
+ * Arguments to signal handler:
+ * a0 ($4) = signal number
+ * a1 ($5) = siginfo pointer
+ * a2 ($6) = ucontext pointer
+ * PC = signal handler pointer
+ * t9 ($25) = signal handler pointer
+ * $29 = point to sigframe struct
+ * ra ($31) = sigtramp at base of user stack
+ */
+ regs->active_tc.gpr[ 4] = sig;
+ regs->active_tc.gpr[ 5] = frame_addr +
+ offsetof(struct target_sigframe, sf_si);
+ regs->active_tc.gpr[25] = regs->active_tc.PC = ka->_sa_handler;
+ regs->active_tc.gpr[29] = frame_addr;
+ regs->active_tc.gpr[31] = TARGET_PS_STRINGS - TARGET_SZSIGCODE;
+
+ return (0);
+}
+
+/*
+ * Compare to mips/mips/pm_machdep.c get_mcontext()
+ * Assumes that the memory is locked if mcp points to user memory.
+ */
+static inline int
+get_mcontext(CPUMIPSState *regs, target_mcontext_t *mcp, int flags)
+{
+ int i, err = 0;
+
+ if (flags & TARGET_MC_ADD_MAGIC) {
+ mcp->mc_regs[0] = tswapal(TARGET_UCONTEXT_MAGIC);
+ } else {
+ mcp->mc_regs[0] = 0;
+ }
+
+ if (flags & TARGET_MC_SET_ONSTACK) {
+ mcp->mc_onstack = tswapal(1);
+ } else {
+ mcp->mc_onstack = 0;
+ }
+
+ for(i = 1; i < 32; i++)
+ mcp->mc_regs[i] = tswapal(regs->active_tc.gpr[i]);
+
+#if 0 /* XXX FP is not used right now */
+ abi_ulong used_fp = used_math() ? TARGET_MDTD_FPUSED : 0;
+
+ mcp->mc_fpused = used_fp;
+ if (used_fp) {
+ preempt_disable();
+ if (!is_fpu_owner()) {
+ own_fpu();
+ for(i = 0; i < 33; i++)
+ mcp->mc_fpregs[i] = tswapal(regs->active_fpu.fpr[i]);
+ }
+ preempt_enable();
+ }
+#else
+ mcp->mc_fpused = 0;
+#endif
+
+ if (flags & TARGET_MC_GET_CLEAR_RET) {
+ mcp->mc_regs[2] = 0; /* v0 = 0 */
+ mcp->mc_regs[3] = 0; /* v1 = 0 */
+ mcp->mc_regs[7] = 0; /* a3 = 0 */
+ }
+
+ mcp->mc_pc = tswapal(regs->active_tc.PC);
+ mcp->mullo = tswapal(regs->active_tc.LO[0]);
+ mcp->mulhi = tswapal(regs->active_tc.HI[0]);
+ mcp->mc_tls = tswapal(regs->tls_value);
+
+ /* Don't do any of the status and cause registers. */
+
+ return (err);
+}
+
+/* Compare to mips/mips/pm_machdep.c set_mcontext() */
+static inline int
+set_mcontext(CPUMIPSState *regs, target_mcontext_t *mcp, int flags)
+{
+ int i, err = 0;
+
+ for(i = 1; i < 32; i++)
+ regs->active_tc.gpr[i] = tswapal(mcp->mc_regs[i]);
+
+#if 0 /* XXX FP is not used right now */
+ abi_ulong used_fp = 0;
+
+ used_fp = tswapal(mcp->mc_fpused)
+ conditional_used_math(used_fp);
+
+ preempt_disabled();
+ if (used_math()) {
+ /* restore fpu context if we have used it before */
+ own_fpu();
+ for (i = 0; i < 32; i++)
+ regs->active_fpu.fpr[i] = tswapal(mcp->mc_fpregs[i]);
+ } else {
+ /* Signal handler may have used FPU. Give it up. */
+ lose_fpu();
+ }
+ preempt_enable();
+#endif
+
+ regs->CP0_EPC = tswapal(mcp->mc_pc);
+ regs->active_tc.LO[0] = tswapal(mcp->mullo);
+ regs->active_tc.HI[0] = tswapal(mcp->mulhi);
+ regs->tls_value = tswapal(mcp->mc_tls);
+
+ /* Don't do any of the status and cause registers. */
+
+ return (err);
+}
+
#endif /* TARGET_SIGNAL_H */
+
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -74,6 +74,8 @@ void mmap_unlock(void)
}
#endif
+#if 0 /* XXX not sure why we need our own g_malloc() and friends.
+ g_strdup(), however, has serious problems with this g_malloc/g_free */
static void *bsd_vmalloc(size_t size)
{
void *p;
@@ -133,6 +135,7 @@ void *g_realloc(void *ptr, size_t size)
g_free(ptr);
return new_ptr;
}
+#endif
/* NOTE: all the constants are the HOST ones, but addresses are target. */
int target_mprotect(abi_ulong start, abi_ulong len, int prot)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index ab7e18c..9d4edbf 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -80,7 +80,7 @@ struct emulated_sigtable {
typedef struct TaskState {
struct TaskState *next;
int used; /* non zero if used */
-#if 1
+ long ts_tid; /* tid (or pid) of this task */
#ifdef TARGET_ARM
int swi_errno;
#endif
@@ -90,7 +90,6 @@ typedef struct TaskState {
uint32_t heap_limit;
#endif
uint32_t stack_base;
-#endif
struct image_info *info;
struct bsd_binprm *bprm;
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 52441c4..d56837b 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -31,7 +31,7 @@
#include "qemu.h"
#include "target_signal.h"
-//#define DEBUG_SIGNAL
+// #define DEBUG_SIGNAL
#ifndef _NSIG
#define _NSIG 128
@@ -606,101 +606,31 @@ do_sigaction(int sig, const struct target_sigaction *act,
return (ret);
}
-#if defined(TARGET_MIPS64)
-static inline int
-restore_sigmcontext(CPUMIPSState *regs, target_mcontext_t *mc)
-{
- int i, err = 0;
-
- for(i = 1; i < 32; i++)
- err |= __get_user(regs->active_tc.gpr[i],
- &mc->mc_regs[i]);
- err |= __get_user(regs->CP0_EPC, &mc->mc_pc);
- err |= __get_user(regs->active_tc.LO[0], &mc->mullo);
- err |= __get_user(regs->active_tc.HI[0], &mc->mulhi);
- err |= __get_user(regs->tls_value, &mc->mc_tls); /* XXX thread tls */
-
-#if 0 /* XXX */
- int used_fp = 0;
-
- err |= __get_user(used_fp, &mc->mc_fpused);
- conditional_used_math(used_fp);
-
- preempt_disabled();
- if (used_math()) {
- /* restore fpu context if we have used it before */
- own_fpu();
- err |= restore_fp_context(mc);
- } else {
- /* signal handler may have used FPU. Give it up. */
- lose_fpu();
- }
- preempt_enable();
-#endif
-
- return (err);
-}
-
-static inline int
-setup_sigmcontext(CPUMIPSState *regs, target_mcontext_t *mc, int32_t oonstack)
-{
- int i, err = 0;
- abi_long ucontext_magic = TARGET_UCONTEXT_MAGIC;
-
- err = __put_user(oonstack ? 1 : 0, &mc->mc_onstack);
- err |= __put_user(regs->active_tc.PC, &mc->mc_pc);
- err |= __put_user(regs->active_tc.LO[0], &mc->mullo);
- err |= __put_user(regs->active_tc.HI[0], &mc->mulhi);
- err |= __put_user(regs->tls_value, &mc->mc_tls); /* XXX thread tls */
-
- err |= __put_user(ucontext_magic, &mc->mc_regs[0]);
- for(i = 1; i < 32; i++)
- err |= __put_user(regs->active_tc.gpr[i], &mc->mc_regs[i]);
-
- err |= __put_user(0, &mc->mc_fpused);
-
-#if 0 /* XXX */
- err |= __put_user(used_math(), &mc->mc_fpused);
- if (used_math())
- goto out;
-
- /*
- * Save FPU state to signal context. Signal handler will "inherit"
- * current FPU state.
- */
- preempt_disable();
-
- if (!is_fpu_owner()) {
- own_fpu();
- for(i = 0; i < 33; i++)
- err |= __put_user(regs->active_tc.fpregs[i], &mc->mc_fpregs[i]);
- }
- err |= save_fp_context(fg);
-
- preempt_enable();
-out:
-#endif
- return (err);
-}
+#if defined(TARGET_MIPS) || defined(TARGET_SPARC64)
static inline abi_ulong
-get_sigframe(struct target_sigaction *ka, CPUMIPSState *regs, size_t frame_size)
+get_sigframe(struct target_sigaction *ka, CPUArchState *regs, size_t frame_size)
{
abi_ulong sp;
/* Use default user stack */
- sp = regs->active_tc.gpr[29];
+ sp = get_sp_from_cpustate(regs);
if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags(sp) == 0)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = target_sigaltstack_used.ss_sp +
+ target_sigaltstack_used.ss_size;
}
+#if defined(TARGET_MIPS)
return ((sp - frame_size) & ~7);
+#else
+ return (sp - frame_size);
+#endif
}
-/* compare to mips/mips/pm_machdep.c sendsig() */
+/* compare to mips/mips/pm_machdep.c and sparc64/sparc64/machdep.c sendsig() */
static void setup_frame(int sig, struct target_sigaction *ka,
- target_sigset_t *set, CPUMIPSState *regs)
+ target_sigset_t *set, CPUArchState *regs)
{
struct target_sigframe *frame;
abi_ulong frame_addr;
@@ -709,54 +639,36 @@ static void setup_frame(int sig, struct target_sigaction *ka,
#ifdef DEBUG_SIGNAL
fprintf(stderr, "setup_frame()\n");
#endif
+#if defined(TARGET_SPARC64)
+ if (!sparc_user_sigtramp) {
+ /* No signal trampoline... kill the process. */
+ fprintf(stderr, "setup_frame(): no sigtramp\n");
+ force_sig(TARGET_SIGKILL);
+ }
+#endif
frame_addr = get_sigframe(ka, regs, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
- if (setup_sigmcontext(regs, &frame->sf_uc.uc_mcontext,
- ! on_sig_stack(frame_addr)))
+#if defined(TARGET_MIPS)
+ int mflags = on_sig_stack(frame_addr) ? TARGET_MC_ADD_MAGIC :
+ TARGET_MC_SET_ONSTACK | TARGET_MC_ADD_MAGIC;
+#else
+ int mflags = 0;
+#endif
+ if (get_mcontext(regs, &frame->sf_uc.uc_mcontext, mflags))
goto give_sigsegv;
for(i = 0; i < TARGET_NSIG_WORDS; i++) {
- if (__put_user(set->__bits[i], &frame->sf_uc.uc_sigmask.__bits[i]))
+ if (__put_user(set->__bits[i],
+ &frame->sf_uc.uc_sigmask.__bits[i]))
goto give_sigsegv;
}
- /* fill in sigframe structure */
- if (__put_user(sig, &frame->sf_signum))
- goto give_sigsegv;
- if (__put_user(0, &frame->sf_siginfo))
- goto give_sigsegv;
- if (__put_user(0, &frame->sf_ucontext))
+ if (set_sigtramp_args(regs, sig, frame, frame_addr, ka))
goto give_sigsegv;
- /* fill in siginfo structure */
- if (__put_user(sig, &frame->sf_si.si_signo))
- goto give_sigsegv;
- if (__put_user(TARGET_SA_SIGINFO, &frame->sf_si.si_code))
- goto give_sigsegv;
- if (__put_user(regs->CP0_BadVAddr, &frame->sf_si.si_addr))
- goto give_sigsegv;
-
- /*
- * Arguments to signal handler:
- * a0 ($4) = signal number
- * a1 ($5) = siginfo pointer
- * a2 ($6) = ucontext pointer
- * PC = signal handler pointer
- * t9 ($25) = signal handler pointer
- * $29 = point to sigframe struct
- * ra ($31) = sigtramp at base of user stack
- */
- regs->active_tc.gpr[ 4] = sig;
- regs->active_tc.gpr[ 5] = frame_addr +
- offsetof(struct target_sigframe, sf_si);
- regs->active_tc.gpr[ 6] = frame_addr +
- offsetof(struct target_sigframe, sf_uc);
- regs->active_tc.gpr[25] = regs->active_tc.PC = ka->_sa_handler;
- regs->active_tc.gpr[29] = frame_addr;
- regs->active_tc.gpr[31] = TARGET_PS_STRINGS - TARGET_SZSIGCODE;
unlock_user_struct(frame, frame_addr, 1);
return;
@@ -766,7 +678,7 @@ give_sigsegv:
}
long
-do_sigreturn(CPUMIPSState *regs, abi_ulong uc_addr)
+do_sigreturn(CPUArchState *regs, abi_ulong uc_addr)
{
target_ucontext_t *ucontext;
sigset_t blocked;
@@ -784,14 +696,17 @@ do_sigreturn(CPUMIPSState *regs, abi_ulong uc_addr)
goto badframe;
}
- if (restore_sigmcontext(regs, &ucontext->uc_mcontext))
+ if (set_mcontext(regs, &ucontext->uc_mcontext, 0))
goto badframe;
target_to_host_sigset_internal(&blocked, &target_set);
sigprocmask(SIG_SETMASK, &blocked, NULL);
- regs->active_tc.PC = regs->CP0_EPC;
- regs->CP0_EPC = 0; /* XXX for nested signals ? */
+#if defined(TARGET_MIPS)
+ CPUMIPSState *mips_regs = (CPUMIPSState *)regs;
+ mips_regs->active_tc.PC = mips_regs->CP0_EPC;
+ mips_regs->CP0_EPC = 0; /* XXX for nested signals ? */
+#endif
return (-TARGET_QEMU_ESIGRETURN);
badframe:
@@ -799,9 +714,10 @@ badframe:
return (0);
}
-#elif defined(TARGET_SPARC64)
-extern abi_ulong sparc_user_sigtramp;
+
+/* #elif defined(TARGET_SPARC64) */
+#if 0
#define mc_flags mc_global[0]
#define mc_sp mc_out[6]
@@ -1039,6 +955,7 @@ badframe:
force_sig(TARGET_SIGSEGV);
return (0);
}
+#endif
#else
diff --git a/bsd-user/sparc/target_signal.h b/bsd-user/sparc/target_signal.h
index 79dfc1e..e2fe79c 100644
--- a/bsd-user/sparc/target_signal.h
+++ b/bsd-user/sparc/target_signal.h
@@ -13,9 +13,34 @@
#define TARGET_MINSIGSTKSZ (512 * 4)
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
+typedef target_ulong target_mcontext_t; /* dummy */
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
{
return state->regwptr[UREG_FP];
}
+static inline int
+get_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "SPARC doesn't have support for get_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
+static inline int
+set_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "SPARC doesn't have support for set_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
#endif /* TARGET_SIGNAL_H */
diff --git a/bsd-user/sparc64/target_signal.h b/bsd-user/sparc64/target_signal.h
index d3e58bb..1bc7c96 100644
--- a/bsd-user/sparc64/target_signal.h
+++ b/bsd-user/sparc64/target_signal.h
@@ -10,12 +10,239 @@
#define UREG_FP UREG_I6
#endif
+#define mc_flags mc_global[0]
+#define mc_sp mc_out[6]
+#define mc_fprs mc_local[0]
+#define mc_fsr mc_local[1]
+#define mc_gsr mc_local[2]
+#define mc_tnpc mc_in[0]
+#define mc_tpc mc_in[1]
+#define mc_tstate mc_in[2]
+#define mc_y mc_in[4]
+#define mc_wstate mc_in[5]
+
+#define ureg_i0 regwptr[0 ]
+#define ureg_i1 regwptr[1 ]
+#define ureg_i2 regwptr[2 ]
+#define ureg_i3 regwptr[3 ]
+#define ureg_i4 regwptr[4 ]
+#define ureg_i5 regwptr[5 ]
+#define ureg_i6 regwptr[6 ]
+#define ureg_i7 regwptr[7 ]
+#define ureg_l0 regwptr[8 ]
+#define ureg_l1 regwptr[9 ]
+#define ureg_l2 regwptr[10]
+#define ureg_l3 regwptr[11]
+#define ureg_l4 regwptr[12]
+#define ureg_l5 regwptr[13]
+#define ureg_l6 regwptr[14]
+#define ureg_l7 regwptr[15]
+#define ureg_o0 regwptr[16]
+#define ureg_o1 regwptr[17]
+#define ureg_o2 regwptr[18]
+#define ureg_o3 regwptr[19]
+#define ureg_o4 regwptr[20]
+#define ureg_o5 regwptr[21]
+#define ureg_o6 regwptr[22]
+#define ureg_o7 regwptr[23]
+#define ureg_fp ureg_i6
+#define ureg_sp ureg_o6
+#define ureg_fprs fprs
+#define ureg_fsr fsr
+#define ureg_gsr gsr
+#define ureg_tnpc npc
+#define ureg_tpc pc
+#define ureg_y y
+
+#define TARGET_FPRS_FEF (1 << 2)
+#define TARGET_MC_VERSION 1L
+
#define TARGET_MINSIGSTKSZ (1024 * 4)
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
-static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
+#define TARGET_STACK_BIAS 2047 /* AKA. SPOFF */
+
+struct target_mcontext {
+ uint64_t mc_global[8];
+ uint64_t mc_out[8];
+ uint64_t mc_local[8];
+ uint64_t mc_in[8];
+ uint32_t mc_fp[64];
+} __aligned(64);
+
+typedef struct target_mcontext target_mcontext_t;
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
+struct target_sigframe {
+ target_ucontext_t sf_uc;
+ target_siginfo_t sf_si;
+};
+
+extern abi_ulong sparc_user_sigtramp;
+
+static inline int
+set_sigtramp_args(CPUSPARCState *regs, int sig, struct target_sigframe *frame,
+ abi_ulong frame_addr, struct target_sigaction *ka)
{
+
+ frame->sf_si.si_signo = sig;
+ frame->sf_si.si_code = TARGET_SA_SIGINFO;
+
+ /* Arguments to signal handler:
+ *
+ * i0 = signal number
+ * i1 = pointer to siginfo struct
+ * i2 = pointer to ucontext struct
+ * i3 = (not used in new style)
+ * i4 = signal handler address (called by sigtramp)
+ */
+ regs->ureg_i0 = sig;
+ regs->ureg_i1 = frame_addr +
+ offsetof(struct target_sigframe, sf_si);
+ regs->ureg_i2 = frame_addr +
+ offsetof(struct target_sigframe, sf_uc);
+ /* env->ureg_o3 used in the Old FreeBSD-style arguments. */
+ regs->ureg_i4 = ka->_sa_handler;
+ regs->ureg_tpc = sparc_user_sigtramp;
+ regs->ureg_tnpc = (regs->ureg_tpc + 4);
+ regs->ureg_sp = frame_addr - TARGET_STACK_BIAS;
+
+ return (0);
+}
+
+static inline abi_ulong
+get_sp_from_cpustate(CPUSPARCState *state)
+{
+
return state->regwptr[UREG_FP];
}
+/* compare to sparc64/sparc64/machdep.c get_mcontext() */
+static inline int
+get_mcontext(CPUSPARCState *regs, target_mcontext_t *mcp, int flags)
+{
+
+ /* Skip over the trap instruction, first. */
+ regs->pc = regs->npc;
+ regs->npc += 4;
+
+ mcp->mc_flags = TARGET_MC_VERSION; /* mc_global[0] */
+ mcp->mc_global[1] = tswapal(regs->gregs[1]);
+ mcp->mc_global[2] = tswapal(regs->gregs[2]);
+ mcp->mc_global[3] = tswapal(regs->gregs[3]);
+ mcp->mc_global[4] = tswapal(regs->gregs[4]);
+ mcp->mc_global[5] = tswapal(regs->gregs[5]);
+ mcp->mc_global[6] = tswapal(regs->gregs[6]);
+ /* skip %g7 since it is used as the userland TLS register */
+
+ if (flags & TARGET_MC_GET_CLEAR_RET) {
+ mcp->mc_out[0] = 0;
+ mcp->mc_out[1] = 0;
+ } else {
+ mcp->mc_out[0] = tswapal(regs->ureg_i0);
+ mcp->mc_out[1] = tswapal(regs->ureg_i1);
+ }
+ mcp->mc_out[2] = tswapal(regs->ureg_i2);
+ mcp->mc_out[3] = tswapal(regs->ureg_i3);
+ mcp->mc_out[4] = tswapal(regs->ureg_i4);
+ mcp->mc_out[5] = tswapal(regs->ureg_i5);
+ mcp->mc_out[6] = tswapal(regs->ureg_i6);
+ mcp->mc_out[7] = tswapal(regs->ureg_i7);
+
+ mcp->mc_fprs = tswapal(regs->fprs); /* mc_local[0] */
+ mcp->mc_fsr = tswapal(regs->fsr); /* mc_local[1] */
+ mcp->mc_gsr = tswapal(regs->gsr); /* mc_local[2] */
+
+ mcp->mc_tnpc = tswapal(regs->npc); /* mc_in[0] */
+ mcp->mc_tpc = tswapal(regs->pc); /* mc_in[1] */
+#if 0
+ mcp->mc_tstate = tswapal(regs->ureg_tstate); /* mc_in[2] */
+#else
+ abi_ulong cwp64 = cpu_get_cwp64(regs);
+ abi_ulong ccr = cpu_get_ccr(regs) << 32;
+ abi_ulong asi = (regs->asi & 0xff) << 24;
+ mcp->mc_tstate = tswapal(ccr | asi | cwp64);
+#endif
+
+ mcp->mc_y = tswapal(regs->y); /* mc_in[4] */
+
+ /* XXX
+ if ((regs->ureg_l0 & TARGET_FPRS_FEF) != 0) {
+ int i;
+
+ for(i = 0; i < 64; i++)
+ mcp->mc_fp[i] = tswapal(regs->fpr[i]);
+ }
+ */
+
+ return (0);
+}
+
+extern void helper_flushw(CPUSPARCState *env);
+
+/* compare to sparc64/sparc64/machdep.c set_mcontext() */
+static inline int
+set_mcontext(CPUSPARCState *regs, target_mcontext_t *mcp, int flags)
+{
+ /* XXX need to add version check here. */
+
+ /* Make sure the windows are spilled first. */
+ helper_flushw(regs);
+
+ regs->gregs[1] = tswapal(mcp->mc_global[1]);
+ regs->gregs[2] = tswapal(mcp->mc_global[2]);
+ regs->gregs[3] = tswapal(mcp->mc_global[3]);
+ regs->gregs[4] = tswapal(mcp->mc_global[4]);
+ regs->gregs[5] = tswapal(mcp->mc_global[5]);
+ regs->gregs[6] = tswapal(mcp->mc_global[6]);
+
+ regs->ureg_i0 = tswapal(mcp->mc_out[0]);
+ regs->ureg_i1 = tswapal(mcp->mc_out[1]);
+ regs->ureg_i2 = tswapal(mcp->mc_out[2]);
+ regs->ureg_i3 = tswapal(mcp->mc_out[3]);
+ regs->ureg_i4 = tswapal(mcp->mc_out[4]);
+ regs->ureg_i5 = tswapal(mcp->mc_out[5]);
+ regs->ureg_i6 = tswapal(mcp->mc_out[6]);
+ regs->ureg_i7 = tswapal(mcp->mc_out[7]);
+
+ regs->fprs = tswapal(mcp->mc_fprs); /* mc_local[0] */
+ regs->fsr = tswapal(mcp->mc_fsr); /* mc_local[1] */
+ regs->gsr = tswapal(mcp->mc_gsr); /* mc_local[2] */
+
+ regs->npc = tswapal(mcp->mc_tnpc); /* mc_in[0] */
+ regs->pc = tswapal(mcp->mc_tpc); /* mc_in[1] */
+
+#if 0
+ regs->ureg_tstate = tswapal(mcp->mc_tstate); /* mc_in[2] */
+#else
+ abi_ulong tstate = tswapal(mcp->mc_tstate); /* mc_in[2] */
+
+ regs->asi = (tstate >> 24) & 0xff;
+ cpu_put_ccr(regs, tstate >> 32);
+ cpu_put_cwp64(regs, tstate & 0x1f);
+
+#endif
+ regs->ureg_y = tswapal(mcp->mc_y); /* mc_in[4] */
+
+ /* XXX
+ if ((regs->ureg_fprs & TARGET_FPRS_FEF) != 0) {
+ int i;
+
+ regs->ureg_l0 = 0;
+ for(i = 0; i < 64; i++)
+ regs->fpr[i] = tswapal(mcp->mc_fp[i]);
+ }
+ */
+
+ return (0);
+}
+
#endif /* TARGET_SIGNAL_H */
diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index 625c3cf..4deb0db 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -43,6 +43,12 @@
#ifdef __FreeBSD__
#include <sys/regression.h>
#include <sys/procdesc.h>
+#include <sys/ucontext.h>
+#include <sys/thr.h>
+#include <sys/rtprio.h>
+#include <sys/umtx.h>
+#include <pthread.h>
+#include <machine/atomic.h>
#endif
#include <sys/un.h>
#include <sys/ipc.h>
@@ -251,7 +257,24 @@ static abi_long do_freebsd_sysarch(void *env, int op, abi_ulong parms)
#ifdef TARGET_MIPS
static abi_long do_freebsd_sysarch(void *env, int op, abi_ulong parms)
{
- return -TARGET_EINVAL;
+ int ret = 0;
+ CPUMIPSState *mips_env = (CPUMIPSState *)env;
+
+ switch(op) {
+ case TARGET_MIPS_SET_TLS:
+ if (get_user(mips_env->tls_value, parms, abi_ulong))
+ ret = -TARGET_EFAULT;
+ break;
+ case TARGET_MIPS_GET_TLS:
+ if (put_user(mips_env->tls_value, parms, abi_ulong))
+ ret = -TARGET_EFAULT;
+ break;
+ default:
+ ret = -TARGET_EINVAL;
+ break;
+ }
+
+ return (ret);
}
#endif
@@ -2119,6 +2142,383 @@ do_fork(CPUArchState *env, int num, int flags, int *fdp)
return (ret);
}
+#if defined(CONFIG_USE_NPTL)
+
+#define NEW_STACK_SIZE (0x40000)
+
+static pthread_mutex_t new_thread_lock = PTHREAD_MUTEX_INITIALIZER;
+typedef struct {
+ CPUArchState *env;
+ long tid;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ pthread_t thread;
+ sigset_t sigmask;
+ struct target_thr_param param;
+} new_thread_info_t;
+
+static void *
+new_thread_start(void *arg)
+{
+ new_thread_info_t *info = arg;
+ CPUArchState *env;
+ TaskState *ts;
+ long tid;
+
+ env = info->env;
+ thread_env = env;
+ ts = (TaskState *)thread_env->opaque;
+ (void)thr_self(&tid);
+ info->tid = tid;
+ task_settid(ts);
+
+ /* copy out the TID info */
+ if (info->param.child_tid)
+ put_user(tid, info->param.child_tid, abi_long);
+ if (info->param.parent_tid)
+ put_user(tid, info->param.parent_tid, abi_long);
+
+#ifdef TARGET_MIPS64
+ CPUMIPSState *regs = env;
+ regs->active_tc.gpr[25] = regs->active_tc.PC = info->param.start_func;
+ regs->active_tc.gpr[ 4] = info->param.arg;
+ regs->active_tc.gpr[29] = info->param.stack_base;
+#endif
+ /* Eenable signals */
+ sigprocmask(SIG_SETMASK, &info->sigmask, NULL);
+ /* Signal to the parent that we're ready. */
+ pthread_mutex_lock(&info->mutex);
+ pthread_cond_broadcast(&info->cond);
+ pthread_mutex_unlock(&info->mutex);
+ /* Wait until the parent has finished initializing the TLS state. */
+ pthread_mutex_lock(&new_thread_lock);
+ pthread_mutex_unlock(&new_thread_lock);
+
+ cpu_loop(env);
+ /* never exits */
+
+ return (NULL);
+}
+
+static void
+rtp_to_schedparam(const struct rtprio *rtp, int *policy, struct sched_param *param)
+{
+
+ switch(rtp->type) {
+ case RTP_PRIO_REALTIME:
+ *policy = SCHED_RR;
+ param->sched_priority = RTP_PRIO_MAX - rtp->prio;
+ break;
+
+ case RTP_PRIO_FIFO:
+ *policy = SCHED_FIFO;
+ param->sched_priority = RTP_PRIO_MAX - rtp->prio;
+ break;
+
+ default:
+ *policy = SCHED_OTHER;
+ param->sched_priority = 0;
+ break;
+ }
+}
+
+static int
+do_thr_create(CPUArchState *env, ucontext_t *ctx, long *id, int flags)
+{
+
+ return (unimplemented(TARGET_FREEBSD_NR_thr_create));
+}
+
+static int
+do_thr_new(CPUArchState *env, abi_ulong target_param_addr, int32_t param_size)
+{
+ new_thread_info_t info;
+ pthread_attr_t attr;
+ TaskState *ts;
+ CPUArchState *new_env;
+ struct target_thr_param *target_param;
+ abi_ulong target_rtp_addr;
+ struct target_rtprio *target_rtp;
+ struct rtprio *rtp_ptr, rtp;
+ TaskState *parent_ts = (TaskState *)env->opaque;
+ sigset_t sigmask;
+ struct sched_param sched_param;
+ int sched_policy;
+ int ret = 0;
+
+ memset(&info, 0, sizeof(info));
+
+ if (!lock_user_struct(VERIFY_READ, target_param, target_param_addr, 1))
+ return (-TARGET_EFAULT);
+ info.param.start_func = tswapal(target_param->start_func);
+ info.param.arg = tswapal(target_param->arg);
+ info.param.stack_base = tswapal(target_param->stack_base);
+ info.param.stack_size = tswapal(target_param->stack_size);
+ info.param.tls_base = tswapal(target_param->tls_base);
+ info.param.tls_size = tswapal(target_param->tls_size);
+ info.param.child_tid = tswapal(target_param->child_tid);
+ info.param.parent_tid = tswapal(target_param->parent_tid);
+ target_rtp_addr = info.param.rtp = tswapal(target_param->rtp);
+ unlock_user(target_param, target_param_addr, 0);
+
+ if (target_rtp_addr) {
+ if (!lock_user_struct(VERIFY_READ, target_rtp, target_rtp_addr,
+ 1))
+ return (-TARGET_EFAULT);
+ rtp.type = tswap16(target_rtp->type);
+ rtp.prio = tswap16(target_rtp->prio);
+ unlock_user(target_rtp, target_rtp_addr, 0);
+ rtp_ptr = &rtp;
+ } else {
+ rtp_ptr = NULL;
+ }
+
+ /* Create a new CPU instance. */
+ ts = g_malloc0(sizeof(TaskState));
+ init_task_state(ts);
+ new_env = cpu_copy(env);
+#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
+ cpu_reset(ENV_GET_CPU(new_env));
+#endif
+
+ /* init regs that differ from the parent thread. */
+ cpu_clone_regs(new_env, info.param.stack_base);
+ new_env->opaque = ts;
+ ts->bprm = parent_ts->bprm;
+ ts->info = parent_ts->info;
+
+#if defined(TARGET_MIPS)
+ env->tls_value = info.param.tls_base;
+ /* cpu_set_tls(new_env, info.param.tls_base); */
+#endif
+
+ /* Grab a mutex so that thread setup appears atomic. */
+ pthread_mutex_lock(&new_thread_lock);
+
+ pthread_mutex_init(&info.mutex, NULL);
+ pthread_mutex_lock(&info.mutex);
+ pthread_cond_init(&info.cond, NULL);
+ info.env = new_env;
+
+ /* XXX return value needs to be checked... */
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, NEW_STACK_SIZE);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (rtp_ptr) {
+ rtp_to_schedparam(&rtp, &sched_policy, &sched_param);
+ pthread_attr_setschedpolicy(&attr, sched_policy);
+ pthread_attr_setschedparam(&attr, &sched_param);
+ }
+
+ /*
+ * It is not safe to deliver signals until the child has finished
+ * initializing, so temporarily block all signals.
+ */
+ sigfillset(&sigmask);
+ sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
+
+ /* XXX return value needs to be checked... */
+ ret = pthread_create(&info.thread, &attr, new_thread_start, &info);
+ /* XXX Free new CPU state if thread creation fails. */
+
+ sigprocmask(SIG_SETMASK, &info.sigmask, NULL);
+ pthread_attr_destroy(&attr);
+ if (0 == ret) {
+ /* Wait for the child to initialize. */
+ pthread_cond_wait(&info.cond, &info.mutex);
+ } else {
+ /* pthread_create failed. */
+ }
+
+ pthread_mutex_unlock(&info.mutex);
+ pthread_cond_destroy(&info.cond);
+ pthread_mutex_destroy(&info.mutex);
+ pthread_mutex_unlock(&new_thread_lock);
+
+ return (ret);
+}
+
+static int
+do_thr_self(long *id)
+{
+
+ return (get_errno(thr_self(id)));
+}
+
+static void
+do_thr_exit(CPUArchState *cpu_env, abi_ulong tid_addr)
+{
+
+ if (first_cpu->next_cpu) {
+ TaskState *ts;
+ CPUArchState **lastp, *p;
+
+ /*
+ * *XXX This probably breaks if a signal arrives.
+ * We should disable signals.
+ */
+ cpu_list_lock();
+ lastp = &first_cpu;
+ p = first_cpu;
+ while (p && p != (CPUArchState *)cpu_env) {
+ lastp = &p->next_cpu;
+ p = p->next_cpu;
+ }
+ /*
+ * if we didn't find the CPU for this thread then something
+ * is horribly wrong.
+ */
+ if (!p)
+ abort();
+ /* Remove the CPU from the list. */
+ *lastp = p->next_cpu;
+ cpu_list_unlock();
+ ts = ((CPUArchState *)cpu_env)->opaque;
+
+ if (tid_addr) {
+ /* Signal target userland that it can free the stack. */
+ if (! put_user_u32(1, tid_addr))
+ _umtx_op(g2h(tid_addr), UMTX_OP_WAKE, INT_MAX,
+ NULL, NULL);
+ }
+
+ thread_env = NULL;
+ object_delete(OBJECT(ENV_GET_CPU(cpu_env)));
+ g_free(ts);
+ pthread_exit(NULL);
+ }
+}
+
+static int
+do_thr_kill(long id, int sig)
+{
+
+ return (get_errno(thr_kill(id, sig)));
+}
+
+static int
+do_thr_kill2(pid_t pid, long id, int sig)
+{
+
+ return (get_errno(thr_kill2(pid, id, sig)));
+}
+
+static int
+do_thr_suspend(const struct timespec *timeout)
+{
+
+ return (get_errno(thr_suspend(timeout)));
+}
+
+static int
+do_thr_wake(long tid)
+{
+
+ return (get_errno(thr_wake(tid)));
+}
+
+static int
+do_thr_set_name(long tid, char *name)
+{
+
+ return (get_errno(thr_set_name(tid, name)));
+}
+
+
+#else /* ! CONFIG_USE_NPTL */
+
+static int
+do_thr_create(CPUArchState *env, ucontext_t *ctx, long *id, int flags)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_create));
+}
+
+static int
+do_thr_new(CPUArchState *env, abi_ulong target_param_addr, int32_t param_size)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_new));
+}
+
+static int
+do_thr_self(long *tid)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_self));
+}
+
+static void
+do_thr_exit(CPUArchState *cpu_env, abi_ulong state_addr)
+{
+}
+
+static int
+do_thr_kill(long tid, int sig)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_kill2));
+}
+
+static int
+do_thr_kill2(pid_t pid, long tid, int sig)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_kill2));
+}
+
+static int
+do_thr_suspend(const struct timespec *timeout)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_suspend));
+}
+
+static int
+do_thr_wake(long tid)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_wake));
+}
+
+static int
+do_thr_set_name(long tid, char *name)
+{
+ return (unimplemented(TARGET_FREEBSD_NR_thr_set_name));
+}
+
+#endif /* CONFIG_USE_NPTL */
+
+static int
+do_umtx_lock(abi_ulong umtx_addr, uint32_t id)
+{
+ int ret = 0;
+
+ for (;;) {
+ ret = get_errno(_umtx_op(g2h(umtx_addr +
+ offsetof(struct target_umtx, u_owner)),
+ UMTX_OP_MUTEX_WAIT, UMTX_UNOWNED, 0, 0));
+ if (ret)
+ return (ret);
+ if (atomic_cmpset_acq_32(g2h(umtx_addr +
+ offsetof(struct target_umtx, u_owner)),
+ UMTX_UNOWNED, id))
+ return (0);
+ }
+}
+
+static int
+do_umtx_unlock(abi_ulong umtx_addr, uint32 id)
+{
+ uint32_t owner;
+
+ do {
+ if (get_user_u32(owner, umtx_addr +
+ offsetof(struct target_umtx, u_owner)))
+ return (-TARGET_EFAULT);
+ if (owner != id)
+ return (-TARGET_EPERM);
+ } while (!atomic_cmpset_rel_32(g2h(umtx_addr +
+ offsetof(struct target_umtx, u_owner)), owner,
+ UMUTEX_UNOWNED));
+
+ return (0);
+}
+
+
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
@@ -4091,6 +4491,23 @@ do_stat:
break;
#endif
+#ifdef TARGET_FREEBSD_NR_getdomainname
+ case TARGET_FREEBSD_NR_getdomainname:
+ ret = unimplemented(num);
+ break;
+#endif
+#ifdef TARGET_FREEBSD_NR_setdomainname
+ case TARGET_FREEBSD_NR_setdomainname:
+ ret = unimplemented(num);
+ break;
+#endif
+#ifdef TARGET_FREEBSD_NR_uname
+ case TARGET_FREEBSD_NR_uname:
+ ret = unimplemented(num);
+ break;
+#endif
+
+
#if 0 /* XXX not supported in libc yet, it seems (10.0 addition). */
case TARGET_FREEBSD_NR_posix_fadvise:
{
@@ -4136,6 +4553,211 @@ do_stat:
break;
#endif
+ case TARGET_FREEBSD_NR_thr_new:
+ ret = do_thr_new(cpu_env, arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_thr_create:
+ {
+ ucontext_t ucxt;
+ long tid;
+
+ ret = do_thr_create(cpu_env, &ucxt, &tid, arg3);
+ }
+ break;
+
+ case TARGET_FREEBSD_NR_thr_set_name:
+ if (!(p = lock_user_string(arg2)))
+ goto efault;
+ ret = do_thr_set_name(arg1, p);
+ unlock_user(p, arg2, 0);
+ break;
+
+ case TARGET_FREEBSD_NR_thr_self:
+ {
+ long tid;
+
+ if ((ret = do_thr_self(&tid)) == 0) {
+ if (put_user((abi_long)tid, arg1, abi_long))
+ goto efault;
+ }
+ }
+ break;
+
+ case TARGET_FREEBSD_NR_thr_suspend:
+ {
+ struct timespec ts;
+
+ if (target_to_host_timespec(&ts, arg1))
+ goto efault;
+
+ ret = do_thr_suspend(&ts);
+ }
+ break;
+
+ case TARGET_FREEBSD_NR_thr_wake:
+ ret = do_thr_wake(arg1);
+ break;
+
+ case TARGET_FREEBSD_NR_thr_kill:
+ ret = do_thr_kill(arg1, arg2);
+ break;
+
+ case TARGET_FREEBSD_NR_thr_kill2:
+ ret = do_thr_kill2(arg1, arg2, arg3);
+ break;
+
+ case TARGET_FREEBSD_NR_thr_exit:
+ ret = 0; /* suspress compile warning */
+ do_thr_exit(cpu_env, arg1);
+ /* Shouldn't be reached. */
+ break;
+
+ case TARGET_FREEBSD_NR_rtprio_thread:
+ ret = 0;
+ break;
+
+ case TARGET_FREEBSD_NR_getcontext:
+ {
+ target_ucontext_t *ucp;
+ sigset_t sigmask;
+
+ if (0 == arg1) {
+ ret = -TARGET_EINVAL;
+ } else {
+ ret = get_errno(sigprocmask(0, NULL, &sigmask));
+ if (!is_error(ret)) {
+ if (!(ucp = lock_user(VERIFY_WRITE, arg1,
+ sizeof(target_ucontext_t), 0)))
+ goto efault;
+ ret = get_mcontext(cpu_env, &ucp->uc_mcontext,
+ TARGET_MC_GET_CLEAR_RET);
+ host_to_target_sigset(&ucp->uc_sigmask,
+ &sigmask);
+ memset(ucp->__spare__, 0,
+ sizeof(ucp->__spare__));
+ unlock_user(ucp, arg1,
+ sizeof(target_ucontext_t));
+ }
+ }
+ }
+ break;
+
+ case TARGET_FREEBSD_NR_setcontext:
+ {
+ target_ucontext_t *ucp;
+ sigset_t sigmask;
+
+ if (0 == arg1) {
+ ret = -TARGET_EINVAL;
+ } else {
+ if (!(ucp = lock_user(VERIFY_READ, arg1,
+ sizeof(target_ucontext_t), 1)))
+ goto efault;
+ ret = set_mcontext(cpu_env, &ucp->uc_mcontext, 0);
+ target_to_host_sigset(&sigmask, &ucp->uc_sigmask);
+ unlock_user(ucp, arg1, sizeof(target_ucontext_t));
+ if (0 == ret)
+ (void)sigprocmask(SIG_SETMASK, &sigmask, NULL);
+ }
+ }
+ break;
+
+ case TARGET_FREEBSD_NR_swapcontext:
+ /*
+ * XXX Does anything besides old implementations of
+ * setjmp()/longjmp() uses these?
+ */
+ ret = unimplemented(num);
+ break;
+
+ case TARGET_FREEBSD_NR__umtx_lock:
+ {
+ long tid;
+
+ thr_self(&tid);
+ ret = do_umtx_lock(arg1, tswap32(tid));
+ }
+ break;
+
+ case TARGET_FREEBSD_NR__umtx_unlock:
+ {
+ long tid;
+
+ thr_self(&tid);
+ ret = do_umtx_unlock(arg1, tswap32(tid));
+ }
+ break;
+
+ case TARGET_FREEBSD_NR__umtx_op:
+ {
+ struct timespec ts;
+ void *object = NULL;
+ int operation;
+ void *addr = NULL;
+ void *addr2 = NULL;
+
+
+ /* int _umtx_op(void *obj, int op, u_long val,
+ * void *uaddr, void *uaddr2); */
+
+ abi_ulong obj = arg1;
+ int op = (int)arg2;
+ u_long val = arg3;
+ /* abi_ulong uaddr = arg4; */
+ abi_ulong uaddr2 = arg5;
+
+ switch(op) {
+ case TARGET_UMTX_OP_LOCK:
+ ret = do_umtx_lock(obj, tswap32((uint32_t)val));
+ break;
+
+ case TARGET_UMTX_OP_UNLOCK:
+ ret = do_umtx_unlock(obj, tswap32((uint32_t)val));
+ break;
+
+ case TARGET_UMTX_OP_WAIT:
+ if (uaddr2) {
+ if (target_to_host_timespec(&ts, uaddr2))
+ goto efault;
+ addr2 = (void *)&ts;
+ }
+ ret = get_errno(_umtx_op(g2h(obj), UMTX_OP_WAIT,
+ tswap32(val), addr, addr2));
+ break;
+
+ case TARGET_UMTX_OP_WAKE:
+ operation = UMTX_OP_WAKE;
+ object = g2h(obj);
+ ret = get_errno(_umtx_op(g2h(obj), UMTX_OP_WAKE,
+ val, 0, 0));
+ break;
+
+ case TARGET_UMTX_OP_MUTEX_TRYLOCK:
+ case TARGET_UMTX_OP_MUTEX_LOCK:
+ case TARGET_UMTX_OP_MUTEX_UNLOCK:
+ case TARGET_UMTX_OP_SET_CEILING:
+ case TARGET_UMTX_OP_CV_WAIT:
+ case TARGET_UMTX_OP_CV_SIGNAL:
+ case TARGET_UMTX_OP_CV_BROADCAST:
+ case TARGET_UMTX_OP_WAIT_UINT:
+ case TARGET_UMTX_OP_RW_RDLOCK:
+ case TARGET_UMTX_OP_RW_WRLOCK:
+ case TARGET_UMTX_OP_RW_UNLOCK:
+ case TARGET_UMTX_OP_WAIT_UINT_PRIVATE:
+ case TARGET_UMTX_OP_WAKE_PRIVATE:
+ case TARGET_UMTX_OP_MUTEX_WAIT:
+ case TARGET_UMTX_OP_MUTEX_WAKE:
+ case TARGET_UMTX_OP_SEM_WAIT:
+ case TARGET_UMTX_OP_SEM_WAKE:
+ case TARGET_UMTX_OP_NWAKE_PRIVATE:
+ default:
+ ret = -TARGET_EINVAL;
+ break;
+ }
+ }
+ break;
+
case TARGET_FREEBSD_NR_yield:
case TARGET_FREEBSD_NR_sched_setparam:
case TARGET_FREEBSD_NR_sched_getparam:
@@ -4146,36 +4768,18 @@ do_stat:
case TARGET_FREEBSD_NR_sched_get_priority_min:
case TARGET_FREEBSD_NR_sched_rr_get_interval:
-
case TARGET_FREEBSD_NR_reboot:
case TARGET_FREEBSD_NR_shutdown:
case TARGET_FREEBSD_NR_swapon:
case TARGET_FREEBSD_NR_swapoff:
- case TARGET_FREEBSD_NR_thr_create:
- case TARGET_FREEBSD_NR_thr_exit:
- case TARGET_FREEBSD_NR_thr_self:
- case TARGET_FREEBSD_NR_thr_suspend:
- case TARGET_FREEBSD_NR_thr_wake:
- case TARGET_FREEBSD_NR_thr_new:
- case TARGET_FREEBSD_NR_thr_set_name:
- case TARGET_FREEBSD_NR_thr_kill2:
-
- case TARGET_FREEBSD_NR_getcontext:
- case TARGET_FREEBSD_NR_setcontext:
- case TARGET_FREEBSD_NR_swapcontext:
-
- case TARGET_FREEBSD_NR_rtprio_thread:
case TARGET_FREEBSD_NR_cpuset:
case TARGET_FREEBSD_NR_cpuset_getid:
case TARGET_FREEBSD_NR_cpuset_setid:
case TARGET_FREEBSD_NR_cpuset_getaffinity:
case TARGET_FREEBSD_NR_cpuset_setaffinity:
- case TARGET_FREEBSD_NR__umtx_lock:
- case TARGET_FREEBSD_NR__umtx_unlock:
-
case TARGET_FREEBSD_NR_rctl_get_racct:
case TARGET_FREEBSD_NR_rctl_get_rules:
case TARGET_FREEBSD_NR_rctl_add_rule:
@@ -4185,16 +4789,6 @@ do_stat:
case TARGET_FREEBSD_NR_ntp_adjtime:
case TARGET_FREEBSD_NR_ntp_gettime:
-#ifdef TARGET_FREEBSD_NR_getdomainname
- case TARGET_FREEBSD_NR_getdomainname:
-#endif
-#ifdef TARGET_FREEBSD_NR_setdomainname
- case TARGET_FREEBSD_NR_setdomainname:
-#endif
-#ifdef TARGET_FREEBSD_NR_uname
- case TARGET_FREEBSD_NR_uname:
-#endif
-
case TARGET_FREEBSD_NR_sctp_peeloff:
case TARGET_FREEBSD_NR_sctp_generic_sendmsg:
case TARGET_FREEBSD_NR_sctp_generic_recvmsg:
diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
index ea1d25d..2879d83 100644
--- a/bsd-user/syscall_defs.h
+++ b/bsd-user/syscall_defs.h
@@ -416,6 +416,11 @@ struct target_shmid_ds {
abi_ulong shm_ctime; /* time of last change by shmctl() */
};
+#define TARGET_UCONTEXT_MAGIC 0xACEDBADE
+#define TARGET_MC_GET_CLEAR_RET 0x0001
+#define TARGET_MC_ADD_MAGIC 0x0002
+#define TARGET_MC_SET_ONSTACK 0x0004
+
/* this struct defines a stack used during syscall handling */
typedef struct target_sigaltstack {
abi_long ss_sp;
@@ -477,95 +482,6 @@ typedef struct target_siginfo {
} _reason;
} target_siginfo_t;
-#if defined(TARGET_MIPS)
-
-struct target_sigcontext {
- target_sigset_t sc_mask; /* signal mask to retstore */
- int32_t sc_onstack; /* sigstack state to restore */
- abi_long sc_pc; /* pc at time of signal */
- abi_long sc_reg[32]; /* processor regs 0 to 31 */
- abi_long mullo, mulhi; /* mullo and mulhi registers */
- int32_t sc_fpused; /* fp has been used */
- abi_long sc_fpregs[33]; /* fp regs 0 to 31 & csr */
- abi_long sc_fpc_eir; /* fp exception instr reg */
- /* int32_t reserved[8]; */
-};
-
-typedef struct target_mcontext {
- int32_t mc_onstack; /* sigstack state to restore */
- abi_long mc_pc; /* pc at time of signal */
- abi_long mc_regs[32]; /* process regs 0 to 31 */
- abi_long sr; /* status register */
- abi_long mullo, mulhi;
- int32_t mc_fpused; /* fp has been used */
- abi_long mc_fpregs[33]; /* fp regs 0 to 32 & csr */
- abi_long mc_fpc_eir; /* fp exception instr reg */
- abi_ulong mc_tls; /* pointer to TLS area */
-} target_mcontext_t;
-
-typedef struct target_ucontext {
- target_sigset_t uc_sigmask;
- target_mcontext_t uc_mcontext;
- target_ulong uc_link;
- target_stack_t uc_stack;
- int32_t uc_flags;
- int32_t __space__[8];
-} target_ucontext_t;
-
-struct target_sigframe {
- abi_ulong sf_signum;
- abi_ulong sf_siginfo; /* code or pointer to sf_si */
- abi_ulong sf_ucontext; /* points to sf_uc */
- abi_ulong sf_addr; /* undocumented 4th arg */
- target_ucontext_t sf_uc; /* = *sf_uncontext */
- target_siginfo_t sf_si; /* = *sf_siginfo (SA_SIGINFO case)*/
- uint32_t __spare__[2];
-};
-
-#elif defined(TARGET_SPARC64)
-
-struct target_mcontext {
- uint64_t mc_global[8];
- uint64_t mc_out[8];
- uint64_t mc_local[8];
- uint64_t mc_in[8];
- uint32_t mc_fp[64];
-} __aligned(64);
-
-typedef struct target_mcontext target_mcontext_t;
-
-typedef struct target_ucontext {
- target_sigset_t uc_sigmask;
- target_mcontext_t uc_mcontext;
- target_ulong uc_link;
- target_stack_t uc_stack;
- int32_t uc_flags;
- int32_t __space__[8];
-} target_ucontext_t;
-
-struct target_sigframe {
- target_ucontext_t sf_uc;
- target_siginfo_t sf_si;
-};
-
-#else
-
-typedef target_ulong target_mcontext_t; /* dummy */
-
-#endif
-
-/* XXX where did this come from?
-typedef struct target_ucontext {
- target_ulong uc_flags;
- target_ulong uc_link;
- target_stack_t uc_stack;
- target_mcontext_t uc_mcontext;
- target_ulong uc_filer[80];
- target_sigset_t uc_sigmask;
-} target_ucontext_t;
-*/
-
-
#ifdef BSWAP_NEEDED
static inline void
tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
@@ -603,3 +519,101 @@ void host_to_target_old_sigset(abi_ulong *old_sigset, const sigset_t *sigset);
void target_to_host_old_sigset(sigset_t *sigset, const abi_ulong *old_sigset);
int do_sigaction(int sig, const struct target_sigaction *act,
struct target_sigaction *oact);
+
+
+/*
+ * FreeBSD thread support.
+ */
+
+#define TARGET_THR_SUSPENDED 0x0001
+#define TARGET_THR_SYSTEM_SCOPE 0x0002
+
+/* sysarch() ops */
+#define TARGET_MIPS_SET_TLS 1
+#define TARGET_MIPS_GET_TLS 2
+
+struct target_thr_param {
+ abi_ulong start_func; /* thread entry function. */
+ abi_ulong arg; /* argument for entry function. */
+ abi_ulong stack_base; /* stack base address. */
+ abi_ulong stack_size; /* stack size. */
+ abi_ulong tls_base; /* tls base address. */
+ abi_ulong tls_size; /* tls size. */
+ abi_ulong child_tid; /* address to store new TID. */
+ abi_ulong parent_tid; /* parent access the new TID here. */
+ abi_ulong rtp; /* Real-time scheduling priority. */
+ abi_ulong spare[3]; /* spares. */
+};
+
+struct target_rtprio {
+ uint16_t type;
+ uint16_t prio;
+};
+
+/*
+ * sys/_umtx.h
+ */
+
+struct target_umtx {
+ uint32_t u_owner; /* Owner of the mutex. */
+};
+
+struct target_umutex {
+ uint32_t m_owner; /* Owner of the mutex */
+ uint32_t m_flags; /* Flags of the mutex */
+ uint32_t m_ceiling[2]; /* Priority protect ceiling */
+ uint32_t m_spare[4];
+};
+
+struct target_ucond {
+ uint32_t c_has_waiters; /* Has waiters in kernel */
+ uint32_t c_flags; /* Flags of the condition variable */
+ uint32_t c_clockid; /* Clock id */
+ uint32_t c_spare[1];
+};
+
+struct target_urwlock {
+ int32_t rw_state;
+ uint32_t rw_flags;
+ uint32_t rw_blocked_readers;
+ uint32_t rw_blocked_writers;
+ uint32_t rw_spare[4];
+};
+
+struct target__usem {
+ uint32_t _has_waiters;
+ uint32_t _count;
+ uint32_t _flags;
+};
+
+/*
+ * sys/utmx.h
+ */
+
+/* op code for _umtx_op */
+#define TARGET_UMTX_OP_LOCK 0
+#define TARGET_UMTX_OP_UNLOCK 1
+#define TARGET_UMTX_OP_WAIT 2
+#define TARGET_UMTX_OP_WAKE 3
+#define TARGET_UMTX_OP_MUTEX_TRYLOCK 4
+#define TARGET_UMTX_OP_MUTEX_LOCK 5
+#define TARGET_UMTX_OP_MUTEX_UNLOCK 6
+#define TARGET_UMTX_OP_SET_CEILING 7
+#define TARGET_UMTX_OP_CV_WAIT 8
+#define TARGET_UMTX_OP_CV_SIGNAL 9
+#define TARGET_UMTX_OP_CV_BROADCAST 10
+#define TARGET_UMTX_OP_WAIT_UINT 11
+#define TARGET_UMTX_OP_RW_RDLOCK 12
+#define TARGET_UMTX_OP_RW_WRLOCK 13
+#define TARGET_UMTX_OP_RW_UNLOCK 14
+#define TARGET_UMTX_OP_WAIT_UINT_PRIVATE 15
+#define TARGET_UMTX_OP_WAKE_PRIVATE 16
+#define TARGET_UMTX_OP_MUTEX_WAIT 17
+#define TARGET_UMTX_OP_MUTEX_WAKE 18
+#define TARGET_UMTX_OP_SEM_WAIT 19
+#define TARGET_UMTX_OP_SEM_WAKE 20
+#define TARGET_UMTX_OP_NWAKE_PRIVATE 21
+#define TARGET_UMTX_OP_MAX 22
+
+/* flags for UMTX_OP_CV_WAIT */
+#define TARGET_CHECK_UNPARKING 0x01
diff --git a/bsd-user/x86_64/target_signal.h b/bsd-user/x86_64/target_signal.h
index ea89f5a..a14e0b9 100644
--- a/bsd-user/x86_64/target_signal.h
+++ b/bsd-user/x86_64/target_signal.h
@@ -15,4 +15,29 @@ static inline abi_ulong get_sp_from_cpustate(CPUX86State *state)
#define TARGET_MINSIGSTKSZ (512 * 4)
#define TARGET_SIGSTKSZ (TARGET_MINSIGSTKSZ + 32768)
+typedef target_ulong target_mcontext_t; /* dummy */
+
+typedef struct target_ucontext {
+ target_sigset_t uc_sigmask;
+ target_mcontext_t uc_mcontext;
+ abi_ulong uc_link;
+ target_stack_t uc_stack;
+ int32_t uc_flags;
+ int32_t __spare__[4];
+} target_ucontext_t;
+
+static inline int
+get_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "x86_64 doesn't have support for get_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
+static inline int
+set_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flags)
+{
+ fprintf(stderr, "x86_64 doesn't have support for set_mcontext()\n");
+ return (-TARGET_ENOSYS);
+}
+
#endif /* TARGET_SIGNAL_H */
diff --git a/configure b/configure
index 34eca43..be75584 100755
--- a/configure
+++ b/configure
@@ -1386,6 +1386,11 @@ fi
if test "$nptl" != "no" ; then
cat > $TMPC <<EOF
+#ifdef __FreeBSD__
+int main(void) {
+ return (0);
+}
+#else
#include <sched.h>
#include <linux/futex.h>
int main(void) {
@@ -1394,6 +1399,7 @@ int main(void) {
#endif
return 0;
}
+#endif
EOF
if compile_object ; then
@@ -3751,5 +3757,6 @@ case "$target_arch2" in
TARGET_ARCH=mips64
TARGET_BASE_ARCH=mips
echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
+ target_nptl="yes"
target_long_alignment=8
;;
|