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
|
--- glibc-2.3.2-orig-debian/elf/dynamic-link.h 2003-10-22 01:06:09.000000000 -0400
+++ glibc-2.3.2/elf/dynamic-link.h 2003-10-22 01:11:53.000000000 -0400
@@ -39,12 +39,21 @@
elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
const ElfW(Sym) *sym, const struct r_found_version *version,
void *const reloc_addr);
+# if ELF_MACHINE_REL_RELATIVE_NEEDSLINKMAP
+auto void __attribute__((always_inline))
+elf_machine_rel_relative (struct link_map *map, ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
+ void *const reloc_addr);
+auto void __attribute__((always_inline))
+elf_machine_rela_relative (struct link_map *map, ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
+ void *const reloc_addr);
+# else
auto void __attribute__((always_inline))
elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
void *const reloc_addr);
auto void __attribute__((always_inline))
elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
void *const reloc_addr);
+# endif
# if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
auto void __attribute__((always_inline))
elf_machine_lazy_rel (struct link_map *map,
--- glibc-2.3.2-orig-debian/linuxthreads/attr.c 2003-10-22 01:06:10.000000000 -0400
+++ glibc-2.3.2/linuxthreads/attr.c 2003-10-22 01:07:38.000000000 -0400
@@ -450,12 +450,19 @@
{
/* Found the entry. Now we have the info we need. */
attr->__stacksize = rl.rlim_cur;
+#ifdef _STACK_GROWS_DOWN
attr->__stackaddr = (void *) to;
-
+#else
+ attr->__stackaddr = (void *) from;
+#endif
/* The limit might be too high. This is a bogus
situation but try to avoid making it worse. */
if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr)
+#ifdef _STACK_GROWS_DOWN
attr->__stacksize = (size_t) attr->__stackaddr;
+#else
+ attr->__stacksize = (size_t)(to - from);
+#endif
/* We succeed and no need to look further. */
ret = 0;
--- glibc-2.3.2-orig-debian/linuxthreads/descr.h 2003-10-22 01:06:10.000000000 -0400
+++ glibc-2.3.2/linuxthreads/descr.h 2003-10-22 01:07:38.000000000 -0400
@@ -71,7 +71,7 @@
/* Atomic counter made possible by compare_and_swap */
struct pthread_atomic {
long p_count;
- int p_spinlock;
+ __atomic_lock_t p_spinlock;
};
--- glibc-2.3.2-orig-debian/linuxthreads/manager.c 2003-10-22 01:06:10.000000000 -0400
+++ glibc-2.3.2/linuxthreads/manager.c 2003-10-22 01:07:38.000000000 -0400
@@ -70,8 +70,13 @@
#else
static inline pthread_descr thread_segment(int seg)
{
+# ifdef _STACK_GROWS_UP
+ return (pthread_descr)(THREAD_STACK_START_ADDRESS + (seg - 1) * STACK_SIZE)
+ + 1;
+# else
return (pthread_descr)(THREAD_STACK_START_ADDRESS - (seg - 1) * STACK_SIZE)
- 1;
+# endif
}
#endif
--- glibc-2.3.2-orig-debian/linuxthreads/oldsemaphore.c 2003-10-22 01:03:57.000000000 -0400
+++ glibc-2.3.2/linuxthreads/oldsemaphore.c 2003-10-22 01:07:38.000000000 -0400
@@ -31,7 +31,7 @@
typedef struct {
long int sem_status;
- int sem_spinlock;
+ __atomic_lock_t sem_spinlock;
} old_sem_t;
extern int __old_sem_init (old_sem_t *__sem, int __pshared, unsigned int __value);
--- glibc-2.3.2-orig-debian/linuxthreads/pt-machine.c 2003-10-22 01:03:57.000000000 -0400
+++ glibc-2.3.2/linuxthreads/pt-machine.c 2003-10-22 01:07:38.000000000 -0400
@@ -19,7 +19,9 @@
#define PT_EI
-extern long int testandset (int *spinlock);
+#include <pthread.h>
+
+extern long int testandset (__atomic_lock_t *spinlock);
extern int __compare_and_swap (long int *p, long int oldval, long int newval);
#include <pt-machine.h>
--- glibc-2.3.2-orig-debian/linuxthreads/pthread.c 2003-10-22 01:06:16.000000000 -0400
+++ glibc-2.3.2/linuxthreads/pthread.c 2003-10-22 01:07:38.000000000 -0400
@@ -300,9 +300,9 @@
pthread_descr self;
/* First of all init __pthread_handles[0] and [1] if needed. */
-# if __LT_SPINLOCK_INIT != 0
- __pthread_handles[0].h_lock = __LOCK_INITIALIZER;
- __pthread_handles[1].h_lock = __LOCK_INITIALIZER;
+# ifdef __LT_INITIALIZER_NOT_ZERO
+ __pthread_handles[0].h_lock = __LOCK_ALT_INITIALIZER;
+ __pthread_handles[1].h_lock = __LOCK_ALT_INITIALIZER;
# endif
# ifndef SHARED
/* Unlike in the dynamically linked case the dynamic linker has not
@@ -370,7 +370,7 @@
# endif
/* self->p_start_args need not be initialized, it's all zero. */
self->p_userstack = 1;
-# if __LT_SPINLOCK_INIT != 0
+# ifdef __LT_INITIALIZER_NOT_ZERO
self->p_resume_count = (struct pthread_atomic) __ATOMIC_INITIALIZER;
# endif
self->p_alloca_cutoff = __MAX_ALLOCA_CUTOFF;
@@ -384,9 +384,9 @@
#else /* USE_TLS */
/* First of all init __pthread_handles[0] and [1]. */
-# if __LT_SPINLOCK_INIT != 0
- __pthread_handles[0].h_lock = __LOCK_INITIALIZER;
- __pthread_handles[1].h_lock = __LOCK_INITIALIZER;
+# ifdef __LT_INITIALIZER_NOT_ZERO
+ __pthread_handles[0].h_lock = __LOCK_ALT_INITIALIZER;
+ __pthread_handles[1].h_lock = __LOCK_ALT_INITIALIZER;
# endif
__pthread_handles[0].h_descr = &__pthread_initial_thread;
__pthread_handles[1].h_descr = &__pthread_manager_thread;
@@ -893,7 +893,11 @@
/* __pthread_handles[0] is the initial thread, __pthread_handles[1] is
the manager threads handled specially in thread_self(), so start at 2 */
h = __pthread_handles + 2;
+# ifdef _STACK_GROWS_UP
+ while (! (sp >= (char *) h->h_descr && sp < h->h_descr->p_guardaddr)) h++;
+# else
while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom)) h++;
+# endif
return h->h_descr;
}
@@ -908,11 +912,22 @@
return manager_thread;
h = __pthread_handles + 2;
# ifdef USE_TLS
+# ifdef _STACK_GROWS_UP
+ while (h->h_descr == NULL
+ || ! (sp >= h->h_descr->p_stackaddr &&
+ sp < h->h_descr->p_guardaddr))
+# else
while (h->h_descr == NULL
- || ! (sp <= (char *) h->h_descr->p_stackaddr && sp >= h->h_bottom))
+ || ! (sp <= h->h_descr->p_stackaddr &&
+ sp >= h->h_bottom))
+# endif
h++;
# else
+# ifdef _STACK_GROWS_UP
+ while (! (sp >= (char *) h->h_descr && sp < h->h_descr->p_guardaddr))
+# else
while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom))
+# endif
h++;
# endif
return h->h_descr;
--- glibc-2.3.2-orig-debian/linuxthreads/spinlock.c 2003-10-22 01:03:57.000000000 -0400
+++ glibc-2.3.2/linuxthreads/spinlock.c 2003-10-22 01:07:38.000000000 -0400
@@ -24,9 +24,9 @@
#include "spinlock.h"
#include "restart.h"
-static void __pthread_acquire(int * spinlock);
+static void __pthread_acquire(__atomic_lock_t * spinlock);
-static inline void __pthread_release(int * spinlock)
+static inline void __pthread_release(__atomic_lock_t * spinlock)
{
WRITE_MEMORY_BARRIER();
*spinlock = __LT_SPINLOCK_INIT;
@@ -269,11 +269,11 @@
struct wait_node {
struct wait_node *next; /* Next node in null terminated linked list */
pthread_descr thr; /* The thread waiting with this node */
- int abandoned; /* Atomic flag */
+ __atomic_lock_t abandoned; /* Atomic flag */
};
static long wait_node_free_list;
-static int wait_node_free_list_spinlock;
+__pthread_lock_define_initialized(static, wait_node_free_list_spinlock);
/* Allocate a new node from the head of the free list using an atomic
operation, or else using malloc if that list is empty. A fundamental
@@ -376,7 +376,7 @@
if (self == NULL)
self = thread_self();
- wait_node.abandoned = 0;
+ wait_node.abandoned = __LT_SPINLOCK_INIT;
wait_node.next = (struct wait_node *) lock->__status;
wait_node.thr = self;
lock->__status = (long) &wait_node;
@@ -402,7 +402,7 @@
wait_node.thr = self;
newstatus = (long) &wait_node;
}
- wait_node.abandoned = 0;
+ wait_node.abandoned = __LT_SPINLOCK_INIT;
wait_node.next = (struct wait_node *) oldstatus;
/* Make sure the store in wait_node.next completes before performing
the compare-and-swap */
@@ -451,7 +451,7 @@
if (self == NULL)
self = thread_self();
- p_wait_node->abandoned = 0;
+ p_wait_node->abandoned = __LT_SPINLOCK_INIT;
p_wait_node->next = (struct wait_node *) lock->__status;
p_wait_node->thr = self;
lock->__status = (long) p_wait_node;
@@ -474,7 +474,7 @@
p_wait_node->thr = self;
newstatus = (long) p_wait_node;
}
- p_wait_node->abandoned = 0;
+ p_wait_node->abandoned = __LT_SPINLOCK_INIT;
p_wait_node->next = (struct wait_node *) oldstatus;
/* Make sure the store in wait_node.next completes before performing
the compare-and-swap */
@@ -574,7 +574,7 @@
while (p_node != (struct wait_node *) 1) {
int prio;
- if (p_node->abandoned) {
+ if (lock_held(&p_node->abandoned)) {
/* Remove abandoned node. */
#if defined TEST_FOR_COMPARE_AND_SWAP
if (!__pthread_has_cas)
@@ -662,7 +662,7 @@
#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
int __pthread_compare_and_swap(long * ptr, long oldval, long newval,
- int * spinlock)
+ __atomic_lock_t * spinlock)
{
int res;
@@ -699,7 +699,7 @@
- When nanosleep() returns, we try again, doing MAX_SPIN_COUNT
sched_yield(), then sleeping again if needed. */
-static void __pthread_acquire(int * spinlock)
+static void __pthread_acquire(__atomic_lock_t * spinlock)
{
int cnt = 0;
struct timespec tm;
--- glibc-2.3.2-orig-debian/linuxthreads/spinlock.h 2003-10-22 01:06:10.000000000 -0400
+++ glibc-2.3.2/linuxthreads/spinlock.h 2003-10-22 01:07:38.000000000 -0400
@@ -33,14 +33,28 @@
#endif
#endif
+/* Define lock_held for all arches that don't need a modified copy. */
+#ifndef __LT_INITIALIZER_NOT_ZERO
+# define lock_held(p) *(p)
+#endif
+
+/* Initliazers for possibly complex structures */
+#ifdef __LT_INITIALIZER_NOT_ZERO
+# define __pthread_lock_define_initialized(CLASS,NAME) \
+ CLASS __atomic_lock_t NAME = __LT_SPINLOCK_ALT_INIT
+#else
+# define __pthread_lock_define_initialized(CLASS,NAME) \
+ CLASS __atomic_lock_t NAME
+#endif
+
#if defined(TEST_FOR_COMPARE_AND_SWAP)
extern int __pthread_has_cas;
extern int __pthread_compare_and_swap(long * ptr, long oldval, long newval,
- int * spinlock);
+ __atomic_lock_t * spinlock);
static inline int compare_and_swap(long * ptr, long oldval, long newval,
- int * spinlock)
+ __atomic_lock_t * spinlock)
{
if (__builtin_expect (__pthread_has_cas, 1))
return __compare_and_swap(ptr, oldval, newval);
@@ -58,7 +72,7 @@
static inline int
compare_and_swap_with_release_semantics (long * ptr, long oldval,
- long newval, int * spinlock)
+ long newval, __atomic_lock_t * spinlock)
{
return __compare_and_swap_with_release_semantics (ptr, oldval,
newval);
@@ -67,7 +81,7 @@
#endif
static inline int compare_and_swap(long * ptr, long oldval, long newval,
- int * spinlock)
+ __atomic_lock_t * spinlock)
{
return __compare_and_swap(ptr, oldval, newval);
}
@@ -75,10 +89,10 @@
#else
extern int __pthread_compare_and_swap(long * ptr, long oldval, long newval,
- int * spinlock);
+ __atomic_lock_t * spinlock);
static inline int compare_and_swap(long * ptr, long oldval, long newval,
- int * spinlock)
+ __atomic_lock_t * spinlock)
{
return __pthread_compare_and_swap(ptr, oldval, newval, spinlock);
}
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/hppa/pspinlock.c 2003-10-22 01:03:57.000000000 -0400
+++ glibc-2.3.2/linuxthreads/sysdeps/hppa/pspinlock.c 2003-10-22 01:07:38.000000000 -0400
@@ -24,13 +24,10 @@
int
__pthread_spin_lock (pthread_spinlock_t *lock)
{
- unsigned int val;
+ volatile unsigned int *addr = __ldcw_align (lock);
- do
- asm volatile ("ldcw %1,%0"
- : "=r" (val), "=m" (*lock)
- : "m" (*lock));
- while (!val);
+ while (__ldcw (addr) == 0)
+ while (*addr == 0) ;
return 0;
}
@@ -40,13 +37,9 @@
int
__pthread_spin_trylock (pthread_spinlock_t *lock)
{
- unsigned int val;
+ volatile unsigned int *a = __ldcw_align (lock);
- asm volatile ("ldcw %1,%0"
- : "=r" (val), "=m" (*lock)
- : "m" (*lock));
-
- return val ? 0 : EBUSY;
+ return __ldcw (a) ? 0 : EBUSY;
}
weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
@@ -54,7 +47,9 @@
int
__pthread_spin_unlock (pthread_spinlock_t *lock)
{
- *lock = 1;
+ volatile unsigned int *a = __ldcw_align (lock);
+
+ *a = 1;
return 0;
}
weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
@@ -66,7 +61,9 @@
/* We can ignore the `pshared' parameter. Since we are busy-waiting
all processes which can access the memory location `lock' points
to can use the spinlock. */
- *lock = 1;
+ volatile unsigned int *a = __ldcw_align (lock);
+
+ *a = 1;
return 0;
}
weak_alias (__pthread_spin_init, pthread_spin_init)
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/hppa/pt-machine.h 2003-10-22 01:06:10.000000000 -0400
+++ glibc-2.3.2/linuxthreads/sysdeps/hppa/pt-machine.h 2003-10-22 01:12:51.000000000 -0400
@@ -22,41 +22,97 @@
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
+#include <sys/types.h>
#include <bits/initspin.h>
#ifndef PT_EI
# define PT_EI extern inline __attribute__ ((always_inline))
#endif
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+extern inline long int testandset (__atomic_lock_t *spinlock);
+extern inline int __compare_and_swap (long int *p, long int oldval, long int newval);
+extern inline int lock_held (__atomic_lock_t *spinlock);
+extern inline int __load_and_clear (__atomic_lock_t *spinlock);
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
#define CURRENT_STACK_FRAME stack_pointer
register char * stack_pointer __asm__ ("%r30");
+/* Get/Set thread-specific pointer. We have to call into the kernel to
+ * modify it, but we can read it in user mode. */
+
+#define THREAD_SELF __get_cr27()
+
+static inline struct _pthread_descr_struct * __get_cr27(void)
+{
+ long cr27;
+ asm("mfctl %%cr27, %0" : "=r" (cr27) : );
+ return (struct _pthread_descr_struct *) cr27;
+}
+
+#define INIT_THREAD_SELF(descr, nr) __set_cr27(descr)
+
+static inline void __set_cr27(struct _pthread_descr_struct * cr27)
+{
+ asm(
+ "ble 0xe0(%%sr2, %%r0)\n\t"
+ "copy %0, %%r26"
+ : : "r" (cr27) : "r26" );
+}
+
+/* We want the OS to assign stack addresses. */
+#define FLOATING_STACKS 1
+#define ARCH_STACK_MAX_SIZE 8*1024*1024
/* The hppa only has one atomic read and modify memory operation,
load and clear, so hppa spinlocks must use zero to signify that
- someone is holding the lock. */
+ someone is holding the lock. The address used for the ldcw
+ semaphore must be 16-byte aligned. */
+#define __ldcw(a) ({ \
+ unsigned int __ret; \
+ __asm__ __volatile__("ldcw 0(%2),%0" \
+ : "=r" (__ret), "=m" (*(a)) : "r" (a)); \
+ __ret; \
+})
+
+/* Because malloc only guarantees 8-byte alignment for malloc'd data,
+ and GCC only guarantees 8-byte alignment for stack locals, we can't
+ be assured of 16-byte alignment for atomic lock data even if we
+ specify "__attribute ((aligned(16)))" in the type declaration. So,
+ we use a struct containing an array of four ints for the atomic lock
+ type and dynamically select the 16-byte aligned int from the array
+ for the semaphore. */
+#define __PA_LDCW_ALIGNMENT 16
+#define __ldcw_align(a) ({ \
+ volatile unsigned int __ret = (unsigned int) a; \
+ if ((__ret & ~(__PA_LDCW_ALIGNMENT - 1)) < (unsigned int) a) \
+ __ret = (__ret & ~(__PA_LDCW_ALIGNMENT - 1)) + __PA_LDCW_ALIGNMENT; \
+ (unsigned int *) __ret; \
+})
-#define xstr(s) str(s)
-#define str(s) #s
/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
+PT_EI int
+__load_and_clear (__atomic_lock_t *spinlock)
{
- int ret;
+ volatile unsigned int *a = __ldcw_align (spinlock);
- __asm__ __volatile__(
- "ldcw 0(%2),%0"
- : "=r"(ret), "=m"(*spinlock)
- : "r"(spinlock));
+ return __ldcw (a);
+}
- return ret == 0;
+/* Emulate testandset */
+PT_EI long int
+testandset (__atomic_lock_t *spinlock)
+{
+ return (__load_and_clear(spinlock) == 0);
}
-#undef str
-#undef xstr
+PT_EI int
+lock_held (__atomic_lock_t *spinlock)
+{
+ volatile unsigned int *a = __ldcw_align (spinlock);
+
+ return *a == 0;
+}
+
#endif /* pt-machine.h */
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/hppa/pt-machine.h.rej 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/linuxthreads/sysdeps/hppa/pt-machine.h.rej 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,153 @@
+***************
+*** 1,6 ****
+ /* Machine-dependent pthreads configuration and inline functions.
+ hppa version.
+- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>.
+
+--- 1,6 ----
+ /* Machine-dependent pthreads configuration and inline functions.
+ hppa version.
++ Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>.
+
+***************
+*** 22,62 ****
+ #ifndef _PT_MACHINE_H
+ #define _PT_MACHINE_H 1
+
+ #include <bits/initspin.h>
+
+ #ifndef PT_EI
+ # define PT_EI extern inline
+ #endif
+
+- extern long int testandset (int *spinlock);
+- extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+ /* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+ #define CURRENT_STACK_FRAME stack_pointer
+ register char * stack_pointer __asm__ ("%r30");
+
+-
+ /* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
+- someone is holding the lock. */
+-
+- #define xstr(s) str(s)
+- #define str(s) #s
+ /* Spinlock implementation; required. */
+ PT_EI long int
+- testandset (int *spinlock)
+ {
+- int ret;
+-
+- __asm__ __volatile__(
+- "ldcw 0(%2),%0"
+- : "=r"(ret), "=m"(*spinlock)
+- : "r"(spinlock));
+-
+- return ret == 0;
+ }
+- #undef str
+- #undef xstr
+-
+ #endif /* pt-machine.h */
+--- 22,115 ----
+ #ifndef _PT_MACHINE_H
+ #define _PT_MACHINE_H 1
+
++ #include <sys/types.h>
+ #include <bits/initspin.h>
+
+ #ifndef PT_EI
+ # define PT_EI extern inline
+ #endif
+
++ extern inline long int testandset (__atomic_lock_t *spinlock);
++ extern inline int __compare_and_swap (long int *p, long int oldval, long int newval);
++ extern inline int lock_held (__atomic_lock_t *spinlock);
++ extern inline int __load_and_clear (__atomic_lock_t *spinlock);
+
+ /* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+ #define CURRENT_STACK_FRAME stack_pointer
+ register char * stack_pointer __asm__ ("%r30");
+
++ /* Get/Set thread-specific pointer. We have to call into the kernel to
++ modify it, but we can read it in user mode. */
++
++ #define THREAD_SELF __get_cr27()
++
++ static inline struct _pthread_descr_struct * __get_cr27(void)
++ {
++ long cr27;
++ asm("mfctl %%cr27, %0" : "=r" (cr27) : );
++ return (struct _pthread_descr_struct *) cr27;
++ }
++
++ #define INIT_THREAD_SELF(descr, nr) __set_cr27(descr)
++
++ static inline void __set_cr27(struct _pthread_descr_struct * cr27)
++ {
++ asm( " ble 0xe0(%%sr2, %%r0)\n"
++ " copy %0,%%r26"
++ : : "r" (cr27) : "r26" );
++ }
++
++ /* We want the OS to assign stack addresses. */
++ #define FLOATING_STACKS 1
++ #define ARCH_STACK_MAX_SIZE 8*1024*1024
++
+ /* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
++ someone is holding the lock. The address used for the ldcw
++ semaphore must be 16-byte aligned. */
++ #define __ldcw(a) ({ \
++ unsigned int __ret; \
++ __asm__ __volatile__("ldcw 0(%2),%0" \
++ : "=r" (__ret), "=m" (*(a)) : "r" (a)); \
++ __ret; \
++ })
++
++ /* Because malloc only guarantees 8-byte alignment for malloc'd data,
++ and GCC only guarantees 8-byte alignment for stack locals, we can't
++ be assured of 16-byte alignment for atomic lock data even if we
++ specify "__attribute ((aligned(16)))" in the type declaration. So,
++ we use a struct containing an array of four ints for the atomic lock
++ type and dynamically select the 16-byte aligned int from the array
++ for the semaphore. */
++ #define __PA_LDCW_ALIGNMENT 16
++ #define __ldcw_align(a) ({ \
++ volatile unsigned int __ret = (unsigned int) a; \
++ if ((__ret & ~(__PA_LDCW_ALIGNMENT - 1)) < (unsigned int) a) \
++ __ret = (__ret & ~(__PA_LDCW_ALIGNMENT - 1)) + __PA_LDCW_ALIGNMENT; \
++ (unsigned int *) __ret; \
++ })
++
+ /* Spinlock implementation; required. */
++ PT_EI int
++ __load_and_clear (__atomic_lock_t *spinlock)
++ {
++ volatile unsigned int *a = __ldcw_align (spinlock);
++ return __ldcw (a);
++ }
++
++ /* Emulate testandset */
+ PT_EI long int
++ testandset (__atomic_lock_t *spinlock)
+ {
++ return (__load_and_clear(spinlock) == 0);
+ }
++
++ PT_EI int
++ lock_held (__atomic_lock_t *spinlock)
++ {
++ volatile unsigned int *a = __ldcw_align (spinlock);
++ return *a == 0;
++ }
++
+ #endif /* pt-machine.h */
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/pthread/bits/libc-lock.h 2003-10-22 01:06:16.000000000 -0400
+++ glibc-2.3.2/linuxthreads/sysdeps/pthread/bits/libc-lock.h 2003-10-22 01:07:38.000000000 -0400
@@ -71,12 +71,12 @@
initialized locks must be set to one due to the lack of normal
atomic operations.) */
-#if __LT_SPINLOCK_INIT == 0
+#ifdef __LT_INITIALIZER_NOT_ZERO
# define __libc_lock_define_initialized(CLASS,NAME) \
- CLASS __libc_lock_t NAME;
+ CLASS __libc_lock_t NAME = PTHREAD_MUTEX_INITIALIZER;
#else
# define __libc_lock_define_initialized(CLASS,NAME) \
- CLASS __libc_lock_t NAME = PTHREAD_MUTEX_INITIALIZER;
+ CLASS __libc_lock_t NAME;
#endif
#define __libc_rwlock_define_initialized(CLASS,NAME) \
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h 2003-10-22 01:03:57.000000000 -0400
+++ glibc-2.3.2/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h 2003-10-22 01:07:38.000000000 -0400
@@ -22,12 +22,14 @@
#define __need_schedparam
#include <bits/sched.h>
+typedef int __atomic_lock_t;
+
/* Fast locks (not abstract because mutexes and conditions aren't abstract). */
struct _pthread_fastlock
{
- long int __status; /* "Free" or "taken" or head of waiting list */
- int __spinlock; /* Used by compare_and_swap emulation. Also,
- adaptive SMP lock stores spin count here. */
+ long int __status; /* "Free" or "taken" or head of waiting list */
+ __atomic_lock_t __spinlock; /* Used by compare_and_swap emulation. Also,
+ adaptive SMP lock stores spin count here. */
};
#ifndef _PTHREAD_DESCR_DEFINED
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h 2003-10-22 01:03:57.000000000 -0400
+++ glibc-2.3.2/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h 2003-10-22 01:07:38.000000000 -0400
@@ -19,9 +19,23 @@
/* Initial value of a spinlock. PA-RISC only implements atomic load
and clear so this must be non-zero. */
-#define __LT_SPINLOCK_INIT 1
+#define __LT_SPINLOCK_INIT ((__atomic_lock_t) { { 1, 1, 1, 1 } })
+
+/* Initialize global spinlocks without cast, generally macro wrapped */
+#define __LT_SPINLOCK_ALT_INIT { { 1, 1, 1, 1 } }
+
+/* Macros for lock initializers, not using the above definition.
+ The above definition is not used in the case that static initializers
+ use this value. */
+#define __LOCK_INITIALIZER { __LT_SPINLOCK_ALT_INIT, 0 }
+
+/* Used to initialize _pthread_fastlock's in non-static case */
+#define __LOCK_ALT_INITIALIZER ((struct _pthread_fastlock){ __LT_SPINLOCK_INIT, 0 })
+
+/* Used in pthread_atomic initialization */
+#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT }
+
+/* Tell the rest of the code that the initializer is non-zero without
+ explaining it's internal structure */
+#define __LT_INITIALIZER_NOT_ZERO
-/* Macros for lock initializers, using the above definition. */
-#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT }
-#define __ALT_LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT }
-#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_INIT }
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/pthreadtypes.h 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,160 @@
+/* Linuxthreads - a simple clone()-based implementation of Posix */
+/* threads for Linux. */
+/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Library General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, or (at your option) any later version. */
+/* */
+/* This program 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 Library General Public License for more details. */
+
+#if !defined _BITS_TYPES_H && !defined _PTHREAD_H
+# error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#define __need_schedparam
+#include <bits/sched.h>
+
+/* We need 128-bit alignment for the ldcw semaphore. At most, we are
+ assured of 64-bit alignment for stack locals and malloc'd data. Thus,
+ we use a struct with four ints for the atomic lock type. The locking
+ code will figure out which of the four to use for the ldcw semaphore. */
+typedef volatile struct {
+ int lock[4];
+} __attribute__ ((aligned(16))) __atomic_lock_t;
+
+/* Fast locks (not abstract because mutexes and conditions aren't abstract). */
+struct _pthread_fastlock
+{
+ __atomic_lock_t __spinlock; /* Used by compare_and_swap emulation. Also,
+ adaptive SMP lock stores spin count here. */
+ long int __status; /* "Free" or "taken" or head of waiting list */
+};
+
+#ifndef _PTHREAD_DESCR_DEFINED
+/* Thread descriptors */
+typedef struct _pthread_descr_struct *_pthread_descr;
+# define _PTHREAD_DESCR_DEFINED
+#endif
+
+
+/* Attributes for threads. */
+typedef struct __pthread_attr_s
+{
+ int __detachstate;
+ int __schedpolicy;
+ struct __sched_param __schedparam;
+ int __inheritsched;
+ int __scope;
+ size_t __guardsize;
+ int __stackaddr_set;
+ void *__stackaddr;
+ size_t __stacksize;
+} pthread_attr_t;
+
+
+/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
+
+#ifdef __GLIBC_HAVE_LONG_LONG
+__extension__ typedef long long __pthread_cond_align_t;
+#else
+typedef long __pthread_cond_align_t;
+#endif
+
+typedef struct
+{
+ struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
+ _pthread_descr __c_waiting; /* Threads waiting on this condition */
+ char __padding[48 - sizeof (struct _pthread_fastlock)
+ - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
+ __pthread_cond_align_t __align;
+} pthread_cond_t;
+
+
+/* Attribute for conditionally variables. */
+typedef struct
+{
+ int __dummy;
+} pthread_condattr_t;
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */
+/* (The layout is unnatural to maintain binary compatibility
+ with earlier releases of LinuxThreads.) */
+typedef struct
+{
+ int __m_reserved; /* Reserved for future use */
+ int __m_count; /* Depth of recursive locking */
+ _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */
+ int __m_kind; /* Mutex kind: fast, recursive or errcheck */
+ struct _pthread_fastlock __m_lock; /* Underlying fast lock */
+} pthread_mutex_t;
+
+
+/* Attribute for mutex. */
+typedef struct
+{
+ int __mutexkind;
+} pthread_mutexattr_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#ifdef __USE_UNIX98
+/* Read-write locks. */
+typedef struct _pthread_rwlock_t
+{
+ struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
+ int __rw_readers; /* Number of readers */
+ _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */
+ _pthread_descr __rw_read_waiting; /* Threads waiting for reading */
+ _pthread_descr __rw_write_waiting; /* Threads waiting for writing */
+ int __rw_kind; /* Reader/Writer preference selection */
+ int __rw_pshared; /* Shared between processes or not */
+} pthread_rwlock_t;
+
+
+/* Attribute for read-write locks. */
+typedef struct
+{
+ int __lockkind;
+ int __pshared;
+} pthread_rwlockattr_t;
+#endif
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef __atomic_lock_t pthread_spinlock_t;
+
+/* POSIX barrier. */
+typedef struct {
+ struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
+ int __ba_required; /* Threads needed for completion */
+ int __ba_present; /* Threads waiting */
+ _pthread_descr __ba_waiting; /* Queue of waiting threads */
+} pthread_barrier_t;
+
+/* barrier attribute */
+typedef struct {
+ int __pshared;
+} pthread_barrierattr_t;
+
+#endif
+
+
+/* Thread identifiers */
+typedef unsigned long int pthread_t;
+
+#endif /* bits/pthreadtypes.h */
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,73 @@
+/* HP-PARISC macro definitions for mutexes, thread-specific data
+ and parameters for malloc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MALLOC_MACHINE_H
+#define _MALLOC_MACHINE_H
+
+#undef thread_atfork_static
+
+#include <atomic.h>
+#include <bits/libc-lock.h>
+
+__libc_lock_define (typedef, mutex_t)
+
+/* Since our lock structure does not tolerate being initialized to zero, we must
+ modify the standard function calls made by malloc */
+# define mutex_init(m) \
+ __libc_maybe_call (__pthread_mutex_init, (m, NULL), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT),(*(int *)(m))) )
+# define mutex_lock(m) \
+ __libc_maybe_call (__pthread_mutex_lock, (m), \
+ (__load_and_clear(&((m)->__m_lock.__spinlock)), 0))
+# define mutex_trylock(m) \
+ __libc_maybe_call (__pthread_mutex_trylock, (m), \
+ (*(int *)(m) ? 1 : (__load_and_clear(&((m)->__m_lock.__spinlock)), 0)))
+# define mutex_unlock(m) \
+ __libc_maybe_call (__pthread_mutex_unlock, (m), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT), (*(int *)(m))) )
+
+/* This is defined by newer gcc version unique for each module. */
+extern void *__dso_handle __attribute__ ((__weak__));
+
+#include <fork.h>
+
+#ifdef SHARED
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, __dso_handle)
+#else
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, \
+ &__dso_handle == NULL ? NULL : __dso_handle)
+#endif
+
+/* thread specific data for glibc */
+
+#include <bits/libc-tsd.h>
+
+typedef int tsd_key_t[1]; /* no key data structure, libc magic does it */
+__libc_tsd_define (static, MALLOC) /* declaration/common definition */
+#define tsd_key_create(key, destr) ((void) (key))
+#define tsd_setspecific(key, data) __libc_tsd_set (MALLOC, (data))
+#define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (MALLOC))
+
+#include <sysdeps/generic/malloc-machine.h>
+
+#endif /* !defined(_MALLOC_MACHINE_H) */
--- glibc-2.3.2-orig-debian/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,190 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifndef NO_ERROR
+# define NO_ERROR -0x1000
+# endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ SINGLE_THREAD_P ASM_LINE_SEP \
+ cmpib,<> 0,%ret0,Lpseudo_cancel ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ DO_CALL(syscall_name, args) ASM_LINE_SEP \
+ /* DONE! */ ASM_LINE_SEP \
+ bv 0(2) ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ Lpseudo_cancel: ASM_LINE_SEP \
+ /* store return ptr */ ASM_LINE_SEP \
+ stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
+ /* save syscall args */ ASM_LINE_SEP \
+ PUSHARGS_##args /* MACRO */ ASM_LINE_SEP \
+ STW_PIC ASM_LINE_SEP \
+ CENABLE /* FUNC CALL */ ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ /* restore syscall args */ ASM_LINE_SEP \
+ POPARGS_##args ASM_LINE_SEP \
+ /* save r4 in arg0 stack slot */ ASM_LINE_SEP \
+ stw %r4, -36(%sr0,%sp) ASM_LINE_SEP \
+ /* save mask from cenable */ ASM_LINE_SEP \
+ copy %ret0, %r4 ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ /* pass mask as arg0 to cdisable */ ASM_LINE_SEP \
+ copy %r4, %r26 ASM_LINE_SEP \
+ copy %ret0, %r4 ASM_LINE_SEP \
+ CDISABLE ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ /* compare error */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ /* branch if no error */ ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%r4,Lpre_end ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ /* No need to LDW_PIC */ ASM_LINE_SEP \
+ /* make syscall res value positive */ ASM_LINE_SEP \
+ sub %r0, %r4, %r4 ASM_LINE_SEP \
+ /* store into errno location */ ASM_LINE_SEP \
+ stw %r4, 0(%sr0,%ret0) ASM_LINE_SEP \
+ /* return -1 */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 ASM_LINE_SEP \
+ Lpre_end: ASM_LINE_SEP \
+ ldw -20(%sr0,%sp), %rp ASM_LINE_SEP \
+ /* No need to LDW_PIC */ ASM_LINE_SEP \
+ ldw -36(%sr0,%sp), %r4 ASM_LINE_SEP
+
+/* Save arguments into our frame */
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 stw %r26, -36(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_2 PUSHARGS_1 stw %r25, -40(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_3 PUSHARGS_2 stw %r24, -44(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_4 PUSHARGS_3 stw %r23, -48(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_5 PUSHARGS_4 /* Args are on the stack... */
+# define PUSHARGS_6 PUSHARGS_5
+
+/* Bring them back from the stack */
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 ldw -36(%sr0,%sp), %r26 ASM_LINE_SEP
+# define POPARGS_2 POPARGS_1 ldw -40(%sr0,%sp), %r25 ASM_LINE_SEP
+# define POPARGS_3 POPARGS_2 ldw -44(%sr0,%sp), %r24 ASM_LINE_SEP
+# define POPARGS_4 POPARGS_3 ldw -48(%sr0,%sp), %r23 ASM_LINE_SEP
+# define POPARGS_5 POPARGS_4 ldw -52(%sr0,%sp), %r22 ASM_LINE_SEP
+# define POPARGS_6 POPARGS_5 ldw -56(%sr0,%sp), %r21 ASM_LINE_SEP
+
+# ifdef IS_IN_libpthread
+# ifdef PIC
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# elif !defined NOT_IN_libc
+# ifdef PIC
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# else
+# ifdef PIC
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# endif
+
+/* p_header.multiple_threads is +12 from the pthread_descr struct start,
+ We could have called __get_cr27() but we really want less overhead */
+# define MULTIPLE_THREADS_OFFSET 0xC
+
+/* cr27 has been initialized to 0x0 by kernel */
+# define NO_THREAD_CR27 0x0
+
+# ifdef IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+ extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+/* This ALT version requires newer kernel support */
+# define SINGLE_THREAD_P_MFCTL \
+ mfctl %cr27, %ret0 ASM_LINE_SEP \
+ cmpib,= NO_THREAD_CR27,%ret0,Lstp ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ ldw MULTIPLE_THREADS_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP \
+ Lstp: ASM_LINE_SEP
+# ifdef PIC
+/* Slower version uses GOT to get value of __local_multiple_threads */
+# define SINGLE_THREAD_P \
+ addil LT%__local_multiple_threads, %r19 ASM_LINE_SEP \
+ ldw RT%__local_multiple_threads(%sr0,%r1), %ret0 ASM_LINE_SEP \
+ ldw 0(%sr0,%ret0), %ret0 ASM_LINE_SEP
+# else
+ /* Slow non-pic version using DP */
+# define SINGLE_THREAD_P \
+ addil LR%__local_multiple_threads-$global$,%r27 ASM_LINE_SEP \
+ ldw RR%__local_multiple_threads-$global$(%sr0,%r1),%ret0 ASM_LINE_SEP
+# endif
+# endif
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
+/* !defined NOT_IN_libc || defined IS_IN_libpthread */
+
+
--- glibc-2.3.2-orig-debian/localedata/gen-locale.sh 2003-10-22 01:03:54.000000000 -0400
+++ glibc-2.3.2/localedata/gen-locale.sh 2003-10-22 01:07:38.000000000 -0400
@@ -47,6 +47,7 @@
locale=`echo $locfile|sed 's|\([^.]*\)[.].*/LC_CTYPE|\1|'`
charmap=`echo $locfile|sed 's|[^.]*[.]\(.*\)/LC_CTYPE|\1|'`
+echo "Running \"$0 $common_objpfx $localedef $locfile\""
echo "Generating locale $locale.$charmap: this might take a while..."
generate_locale `echo $charmap | sed -e s/SJIS/SHIFT_JIS/` $locale \
$locale.$charmap
--- glibc-2.3.2-orig-debian/malloc/thread-m.h 2003-10-22 01:06:10.000000000 -0400
+++ glibc-2.3.2/malloc/thread-m.h 2003-10-22 01:07:38.000000000 -0400
@@ -59,6 +59,28 @@
#define mutex_unlock(m) \
__libc_maybe_call2 (pthread_mutex_unlock, (m), (*(int *)(m) = 0))
+# if(defined __hppa__)
+/* Since our lock structure does not tolerate being initialized to zero, we must
+ modify the standard function calls made by malloc */
+# undef mutex_init
+# undef mutex_lock
+# undef mutex_trylock
+# undef mutex_unlock
+# define mutex_init(m) \
+ __libc_maybe_call (__pthread_mutex_init, (m, NULL), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT),(*(int *)(m))) )
+# define mutex_lock(m) \
+ __libc_maybe_call (__pthread_mutex_lock, (m), \
+ (__load_and_clear(&((m)->__m_lock.__spinlock)), 0))
+# define mutex_trylock(m) \
+ __libc_maybe_call (__pthread_mutex_trylock, (m), \
+ (*(int *)(m) ? 1 : (__load_and_clear(&((m)->__m_lock.__spinlock)), 0)))
+# define mutex_unlock(m) \
+ __libc_maybe_call (__pthread_mutex_unlock, (m), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT), (*(int *)(m))) )
+# endif
+/* if(defined __hppa__) */
+
#else
#define mutex_init(m) \
--- glibc-2.3.2-orig-debian/sysdeps/generic/framestate.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/generic/framestate.c 2003-10-22 01:07:38.000000000 -0400
@@ -41,7 +41,11 @@
if (handle == NULL
|| (frame_state_for
= (framesf) __libc_dlsym (handle, "__frame_state_for")) == NULL)
+#ifndef __USING_SJLJ_EXCEPTIONS__
frame_state_for = fallback_frame_state_for;
+#else
+ frame_state_for = abort;
+#endif
}
return frame_state_for (pc, frame_state);
--- glibc-2.3.2-orig-debian/sysdeps/generic/unwind-dw2.c 2003-10-22 01:06:11.000000000 -0400
+++ glibc-2.3.2/sysdeps/generic/unwind-dw2.c 2003-10-22 01:08:07.000000000 -0400
@@ -39,7 +39,6 @@
#endif
-#ifndef __USING_SJLJ_EXCEPTIONS__
#ifndef STACK_GROWS_DOWNWARD
#define STACK_GROWS_DOWNWARD 0
@@ -1287,4 +1286,3 @@
#include "unwind.inc"
#endif /* _LIBC */
-#endif /* !USING_SJLJ_EXCEPTIONS */
--- glibc-2.3.2-orig-debian/sysdeps/hppa/Dist 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/Dist 2003-10-22 01:07:38.000000000 -0400
@@ -1,2 +1,3 @@
+libgcc-compat.c
dl-symaddr.c
dl-fptr.c
--- glibc-2.3.2-orig-debian/sysdeps/hppa/Makefile 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/Makefile 2003-10-22 01:07:38.000000000 -0400
@@ -22,12 +22,19 @@
# CFLAGS-.os += -ffunction-sections
LDFLAGS-c_pic.os += -Wl,--unique=.text*
-ifeq ($(subdir),malloc)
-CFLAGS-malloc.c += -DMALLOC_ALIGNMENT=16
-endif
-
ifeq ($(subdir),elf)
CFLAGS-rtld.c += -mdisable-fpregs
dl-routines += dl-symaddr dl-fptr
rtld-routines += dl-symaddr dl-fptr
endif
+
+ifeq ($(subdir),csu)
+ifeq (yes,$(build-shared))
+# Compatibility
+ifeq (yes,$(have-protected))
+CPPFLAGS-libgcc-compat.c = -DHAVE_DOT_HIDDEN
+endif
+sysdep_routines += libgcc-compat
+shared-only-routines += libgcc-compat
+endif
+endif
--- glibc-2.3.2-orig-debian/sysdeps/hppa/Versions 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/Versions 2003-10-22 01:07:38.000000000 -0400
@@ -5,3 +5,8 @@
_dl_function_address;
}
}
+libc {
+ GLIBC_2.2 {
+ __clz_tab;
+ }
+}
--- glibc-2.3.2-orig-debian/sysdeps/hppa/atomicity.h 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/sysdeps/hppa/atomicity.h 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,55 @@
+/* Low-level functions for atomic operations. HP-PARISC version.
+ Copyright (C) 1997,2001 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 _ATOMICITY_H
+#define _ATOMICITY_H 1
+
+#include <inttypes.h>
+
+#warning stub atomicity functions are not atomic
+#warning CAO This will get implemented soon
+
+static inline int
+__attribute__ ((unused))
+exchange_and_add (volatile uint32_t *mem, int val)
+{
+ int result = *mem;
+ *mem += val;
+ return result;
+}
+
+static inline void
+__attribute__ ((unused))
+atomic_add (volatile uint32_t *mem, int val)
+{
+ *mem += val;
+}
+
+static inline int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+ if (*p != oldval)
+ return 0;
+
+ *p = newval;
+ return 1;
+}
+
+#endif /* atomicity.h */
--- glibc-2.3.2-orig-debian/sysdeps/hppa/dl-fptr.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/dl-fptr.c 2003-10-22 01:07:38.000000000 -0400
@@ -30,7 +30,7 @@
# include <pt-machine.h>
/* Remember, we use 0 to mean that a lock is taken on PA-RISC. */
-static int __hppa_fptr_lock = 1;
+static __atomic_lock_t __hppa_fptr_lock = __LT_SPINLOCK_ALT_INIT;
#endif
/* Because ld.so is now versioned, these functions can be in their own
@@ -127,7 +127,7 @@
#ifdef _LIBC_REENTRANT
/* Release the lock. Again, remember, zero means the lock is taken! */
if (mem == NULL)
- __hppa_fptr_lock = 1;
+ __hppa_fptr_lock = __LT_SPINLOCK_INIT;
#endif
/* Set bit 30 to indicate to $$dyncall that this is a PLABEL. */
@@ -180,7 +180,7 @@
#ifdef _LIBC_REENTRANT
/* Release the lock. */
- __hppa_fptr_lock = 1;
+ __hppa_fptr_lock = __LT_SPINLOCK_INIT;
#endif
}
@@ -190,6 +190,8 @@
Elf32_Addr addr = (Elf32_Addr) address;
struct hppa_fptr *f;
+ address = (void *)((unsigned long)address &~ 3); /* Clear the bottom two bits. See make_fptr. */
+
#ifdef _LIBC_REENTRANT
/* Make sure we are alone. */
while (testandset (&__hppa_fptr_lock));
@@ -204,7 +206,7 @@
#ifdef _LIBC_REENTRANT
/* Release the lock. */
- __hppa_fptr_lock = 1;
+ __hppa_fptr_lock = __LT_SPINLOCK_INIT;
#endif
return addr;
--- glibc-2.3.2-orig-debian/sysdeps/hppa/dl-machine.h 2003-10-22 01:06:11.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/dl-machine.h 2003-10-22 01:10:26.000000000 -0400
@@ -1,5 +1,5 @@
/* Machine-dependent ELF dynamic relocation inline functions. PA-RISC version.
- Copyright (C) 1995-1997,1999,2000,2001,2002, 2003
+ Copyright (C) 1995-1997,1999-2003
Free Software Foundation, Inc.
Contributed by David Huggins-Daines <dhd@debian.org>
This file is part of the GNU C Library.
@@ -29,8 +29,15 @@
#include <link.h>
#include <assert.h>
+# define VALID_ELF_OSABI(osabi) ((osabi == ELFOSABI_SYSV) || (osabi == ELFOSABI_LINUX))
+# define VALID_ELF_ABIVERSION(ver) (ver == 0)
+# define VALID_ELF_HEADER(hdr,exp,size) \
+ memcmp (hdr,exp,size-2) == 0 \
+ && VALID_ELF_OSABI (hdr[EI_OSABI]) \
+ && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
+
/* These must match the definition of the stub in bfd/elf32-hppa.c. */
-#define SIZEOF_PLT_STUB (4*4)
+#define SIZEOF_PLT_STUB (7*4)
#define GOT_FROM_PLT_STUB (4*4)
/* A PLABEL is a function descriptor. Properly they consist of just
@@ -67,45 +74,41 @@
return ehdr->e_machine == EM_PARISC;
}
-
/* Return the link-time address of _DYNAMIC. */
static inline Elf32_Addr
+elf_machine_dynamic (void) __attribute__ ((const));
+
+static inline Elf32_Addr
elf_machine_dynamic (void)
{
Elf32_Addr dynamic;
-#if 0
- /* Use this method if GOT address not yet set up. */
- asm (
-" b,l 1f,%0\n"
+ asm ("b,l 1f,%0\n"
" depi 0,31,2,%0\n"
"1: addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8),%0\n"
" ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%%r1),%0\n"
- : "=r" (dynamic) : : "r1");
-#else
- /* This works because we already have our GOT address available. */
- dynamic = (Elf32_Addr) &_DYNAMIC;
-#endif
+ : "=r" (dynamic) : : "r1");
return dynamic;
}
/* Return the run-time load address of the shared object. */
static inline Elf32_Addr
+elf_machine_load_address (void) __attribute__ ((const));
+
+static inline Elf32_Addr
elf_machine_load_address (void)
{
- Elf32_Addr dynamic, dynamic_linkaddress;
+ Elf32_Addr dynamic;
asm (
" b,l 1f,%0\n"
" depi 0,31,2,%0\n"
"1: addil L'_DYNAMIC - ($PIC_pcrel$0 - 8),%0\n"
-" ldo R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%%r1),%1\n"
-" addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 16),%0\n"
-" ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 20)(%%r1),%0\n"
- : "=r" (dynamic_linkaddress), "=r" (dynamic) : : "r1");
+" ldo R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%%r1),%0\n"
+ : "=r" (dynamic) : : "r1");
- return dynamic - dynamic_linkaddress;
+ return dynamic - elf_machine_dynamic ();
}
/* Fixup a PLT entry to bounce directly to the function at VALUE. */
@@ -168,41 +171,39 @@
fptr = (struct hppa_fptr *) (reloc->r_offset + l_addr);
if (r_sym != 0)
{
- /* Relocate the pointer to the stub. */
- fptr->func += l_addr;
- /* Instead of the LTP value, we put the reloc offset
- here. The trampoline code will load the proper
- LTP and pass the reloc offset to the fixup
- function. */
- fptr->gp = iplt - jmprel;
if (!got)
{
static union {
unsigned char c[8];
Elf32_Addr i[2];
} sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
+ const Elf32_Rela *last_rel;
+
+ last_rel = (const Elf32_Rela *) end_jmprel - 1;
+
+ /* The stub is immediately after the last .plt
+ entry. Rely on .plt relocs being ordered. */
+ if (last_rel->r_offset == 0)
+ return 0;
/* Find our .got section. It's right after the
stub. */
- got = (Elf32_Addr *) (fptr->func + GOT_FROM_PLT_STUB);
+ got = (Elf32_Addr *) (last_rel->r_offset + l_addr
+ + 8 + SIZEOF_PLT_STUB);
- /* Sanity check to see if the address we are
- going to check below is within a reasonable
- approximation of the bounds of the PLT (or,
- at least, is at an address that won't fault
- on read). Then check for the magic signature
- above. */
- if (fptr->func < (Elf32_Addr) fptr + sizeof(*fptr))
- return 0;
- if (fptr->func >
- ((Elf32_Addr) fptr
- + SIZEOF_PLT_STUB
- + ((l->l_info[DT_PLTRELSZ]->d_un.d_val / sizeof (Elf32_Rela))
- * 8)))
- return 0;
+ /* Check the magic signature. */
if (got[-2] != sig.i[0] || got[-1] != sig.i[1])
return 0; /* No lazy linking for you! */
}
+
+ /* Relocate the pointer to the stub. */
+ fptr->func = (Elf32_Addr) got - GOT_FROM_PLT_STUB;
+
+ /* Instead of the LTP value, we put the reloc offset
+ here. The trampoline code will load the proper
+ LTP and pass the reloc offset to the fixup
+ function. */
+ fptr->gp = iplt - jmprel;
}
else
{
@@ -272,22 +273,24 @@
" stw %r25,-40(%sp)\n" /* argc */ \
" stw %r24,-44(%sp)\n" /* argv */ \
\
- /* We need the LTP, and we need it now. */ \
- /* $PIC_pcrel$0 points 8 bytes past the current instruction, \
- just like a branch reloc. This sequence gets us the runtime \
- address of _DYNAMIC. */ \
+ /* We need the LTP, and we need it now. \
+ $PIC_pcrel$0 points 8 bytes past the current instruction, \
+ just like a branch reloc. This sequence gets us the \
+ runtime address of _DYNAMIC. */ \
" bl 0f,%r19\n" \
" depi 0,31,2,%r19\n" /* clear priviledge bits */ \
"0: addil L'_DYNAMIC - ($PIC_pcrel$0 - 8),%r19\n" \
" ldo R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%r1),%r26\n" \
\
- /* Also get the link time address from the first entry of the GOT. */ \
+ /* The link time address is stored in the first entry of the \
+ GOT. */ \
" addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 16),%r19\n" \
" ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 20)(%r1),%r20\n" \
\
" sub %r26,%r20,%r20\n" /* Calculate load offset */ \
\
- /* Rummage through the dynamic entries, looking for DT_PLTGOT. */ \
+ /* Rummage through the dynamic entries, looking for \
+ DT_PLTGOT. */ \
" ldw,ma 8(%r26),%r19\n" \
"1: cmpib,=,n 3,%r19,2f\n" /* tag == DT_PLTGOT? */ \
" cmpib,<>,n 0,%r19,1b\n" \
@@ -307,8 +310,8 @@
| 32 bytes of magic | \
|---------------------------------| \
| 32 bytes argument/sp save area | \
- |---------------------------------| ((current->mm->env_end) + 63 & ~63) \
- | N bytes of slack | \
+ |---------------------------------| ((current->mm->env_end) \
+ | N bytes of slack | + 63 & ~63) \
|---------------------------------| \
| envvar and arg strings | \
|---------------------------------| \
@@ -376,7 +379,7 @@
" bl _dl_init_internal,%r2\n" \
" ldo 4(%r23),%r23\n" /* delay slot */ \
\
- /* Reload argc, argv to the registers start.S expects them in (feh) */ \
+ /* Reload argc, argv to the registers start.S expects. */ \
" ldw -40(%sp),%r25\n" \
" ldw -44(%sp),%r24\n" \
\
@@ -388,8 +391,8 @@
" .word 0xdeadbeef\n" \
" .previous\n" \
\
- /* %r3 contains a function pointer, we need to mask out the lower \
- * bits and load the gp and jump address. */ \
+ /* %r3 contains a function pointer, we need to mask out the \
+ lower bits and load the gp and jump address. */ \
" depi 0,31,2,%r3\n" \
" ldw 0(%r3),%r2\n" \
" addil LT'__dl_fini_plabel,%r19\n" \
@@ -407,43 +410,41 @@
Enter with r19 = reloc offset, r20 = got-8, r21 = fixup ltp. */
#define TRAMPOLINE_TEMPLATE(tramp_name, fixup_name) \
extern void tramp_name (void); \
- asm ( "\
- /* Trampoline for " #tramp_name " */ \n\
- .globl " #tramp_name " \n\
- .type " #tramp_name ",@function \n\
-" #tramp_name ": \n\
- /* Save return pointer */ \n\
- stw %r2,-20(%sp) \n\
- /* Save argument registers in the call stack frame. */ \n\
- stw %r26,-36(%sp) \n\
- stw %r25,-40(%sp) \n\
- stw %r24,-44(%sp) \n\
- stw %r23,-48(%sp) \n\
- /* Build a call frame. */ \n\
- stwm %sp,64(%sp) \n\
- \n\
- /* Set up args to fixup func. */ \n\
- ldw 8+4(%r20),%r26 /* got[1] == struct link_map * */ \n\
- copy %r19,%r25 /* reloc offset */ \n\
- \n\
- /* Call the real address resolver. */ \n\
- bl " #fixup_name ",%r2 \n\
- copy %r21,%r19 /* delay slot, set fixup func ltp */ \n\
- \n\
- ldwm -64(%sp),%sp \n\
- /* Arguments. */ \n\
- ldw -36(%sp),%r26 \n\
- ldw -40(%sp),%r25 \n\
- ldw -44(%sp),%r24 \n\
- ldw -48(%sp),%r23 \n\
- /* Return pointer. */ \n\
- ldw -20(%sp),%r2 \n\
- /* Call the real function. */ \n\
- ldw 0(%r28),%r22 \n\
- bv %r0(%r22) \n\
- ldw 4(%r28),%r19 \n\
-");
-
+ asm (".globl " #tramp_name "\n" \
+ " .type " #tramp_name ",@function\n" \
+ #tramp_name ":\n" \
+ /* Save return pointer */ \
+ " stw %r2,-20(%sp)\n" \
+ /* Save argument registers in the call stack frame. */ \
+ " stw %r26,-36(%sp)\n" \
+ " stw %r25,-40(%sp)\n" \
+ " stw %r24,-44(%sp)\n" \
+ " stw %r23,-48(%sp)\n" \
+ /* Build a call frame, and save structure pointer. */ \
+ " stwm %r28,64(%sp)\n" \
+ \
+ /* Set up args to fixup func. */ \
+ " ldw 8+4(%r20),%r26\n" /* got[1] == struct link_map * */ \
+ " copy %r19,%r25\n" /* reloc offset */ \
+ \
+ /* Call the real address resolver. */ \
+ " bl " #fixup_name ",%r2\n" \
+ " copy %r21,%r19\n" /* delay slot, set fixup func ltp */ \
+ \
+ " ldw 0(%r28),%r22\n" /* load up the returned func ptr */ \
+ " ldw 4(%r28),%r19\n" \
+ " ldwm -64(%sp),%r28\n" \
+ /* Arguments. */ \
+ " ldw -36(%sp),%r26\n" \
+ " ldw -40(%sp),%r25\n" \
+ " ldw -44(%sp),%r24\n" \
+ " ldw -48(%sp),%r23\n" \
+ /* Call the real function. */ \
+ " bv %r0(%r22)\n" \
+ /* Return pointer. */ \
+ " ldw -20(%sp),%r2\n" \
+ );
+
#ifndef PROF
#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup); \
@@ -470,16 +471,32 @@
/* We only use RELA. */
#define ELF_MACHINE_NO_REL 1
+/* Tell dynamic-link that PA needs the extra link_map structure */
+#define ELF_MACHINE_REL_RELATIVE_NEEDSLINKMAP 1
+#define ELF_MACHINE_RELA_RELATIVE_NEEDSLINKMAP 1
+
/* Return the address of the entry point. */
#define ELF_MACHINE_START_ADDRESS(map, start) \
DL_FUNCTION_ADDRESS (map, start)
+/* We define an initialization functions. This is called very early in
+ * _dl_sysdep_start. */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+ if (GL(dl_platform) != NULL && *GL(dl_platform) == '\0')
+ /* Avoid an empty string which would disturb us. */
+ GL(dl_platform) = NULL;
+}
+
#endif /* !dl_machine_h */
/* These are only actually used where RESOLVE_MAP is defined, anyway. */
#ifdef RESOLVE_MAP
-static inline void
+auto void __attribute__((always_inline))
elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
const Elf32_Sym *sym, const struct r_found_version *version,
void *const reloc_addr_arg)
@@ -569,15 +586,15 @@
probably haven't relocated the necessary values by this
point so we have to find them ourselves. */
- asm ("bl 0f,%0 \n\
- depi 0,31,2,%0 \n\
-0: addil L'__boot_ldso_fptr - ($PIC_pcrel$0 - 8),%0 \n\
- ldo R'__boot_ldso_fptr - ($PIC_pcrel$0 - 12)(%%r1),%1 \n\
- addil L'__fptr_root - ($PIC_pcrel$0 - 16),%0 \n\
- ldo R'__fptr_root - ($PIC_pcrel$0 - 20)(%%r1),%2 \n\
- addil L'__fptr_count - ($PIC_pcrel$0 - 24),%0 \n\
- ldo R'__fptr_count - ($PIC_pcrel$0 - 28)(%%r1),%3"
- :
+ asm ("bl 0f,%0\n\t"
+ "depi 0,31,2,%0\n\t"
+ "0:\taddil L'__boot_ldso_fptr - ($PIC_pcrel$0 - 8),%0\n\t"
+ "ldo R'__boot_ldso_fptr - ($PIC_pcrel$0 - 12)(%%r1),%1\n\t"
+ "addil L'__fptr_root - ($PIC_pcrel$0 - 16),%0\n\t"
+ "ldo R'__fptr_root - ($PIC_pcrel$0 - 20)(%%r1),%2\n\t"
+ "addil L'__fptr_count - ($PIC_pcrel$0 - 24),%0\n\t"
+ "ldo R'__fptr_count - ($PIC_pcrel$0 - 28)(%%r1),%3"
+ :
"=r" (dot),
"=r" (p_boot_ldso_fptr),
"=r" (p_fptr_root),
@@ -636,7 +653,7 @@
/* hppa doesn't have an R_PARISC_RELATIVE reloc, but uses relocs with
ELF32_R_SYM (info) == 0 for a similar purpose. */
-static inline void
+auto void __attribute__((always_inline))
elf_machine_rela_relative (struct link_map *map, Elf32_Addr l_addr,
const Elf32_Rela *reloc,
void *const reloc_addr_arg)
@@ -682,7 +699,7 @@
*reloc_addr = value;
}
-static inline void
+auto void __attribute__((always_inline))
elf_machine_lazy_rel (struct link_map *map,
Elf32_Addr l_addr, const Elf32_Rela *reloc)
{
--- glibc-2.3.2-orig-debian/sysdeps/hppa/elf/entry.h 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/sysdeps/hppa/elf/entry.h 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,10 @@
+#ifndef __ASSEMBLY__
+extern void _start (void);
+#endif
+
+/* The function's entry point is stored in the first word of the
+ function descriptor (plabel) of _start(). */
+#define ENTRY_POINT ({long int *tmp = (long int *)((long)_start & ~2); tmp[0];})
+
+/* We have to provide a special declaration. */
+#define ENTRY_POINT_DECL(class) class void _start (void);
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/fclrexcpt.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/fclrexcpt.c 2003-10-22 01:07:38.000000000 -0400
@@ -29,7 +29,7 @@
__asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
/* Clear all the relevant bits. */
- sw[0] &= ~(excepts & FE_ALL_EXCEPT) << 27;
+ sw[0] &= ~((excepts & FE_ALL_EXCEPT) << 27);
__asm__ ("fldd 0(%0),%%fr0" : : "r" (sw));
/* Success. */
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/fegetenv.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/fegetenv.c 2003-10-22 01:07:38.000000000 -0400
@@ -23,11 +23,12 @@
int
fegetenv (fenv_t *envp)
{
- __asm__ (
- "fstd %%fr0,0(%2)\n"
- "fstd,ma %%fr1,8(%2)\n"
- "fstd,ma %%fr2,8(%2)\n"
- "fstd %%fr3,0(%2)\n"
- : "=m" (*envp), "=r" (envp) : "1" (envp));
+ fenv_t *temp = envp;
+ __asm__ ( "fstd,ma %%fr0,8(%1)\n"
+ "fstd,ma %%fr1,8(%1)\n"
+ "fstd,ma %%fr2,8(%1)\n"
+ "fstd %%fr3,0(%1)\n"
+ : "=m" (*temp), "+r" (temp)
+ );
return 0;
}
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/feholdexcpt.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/feholdexcpt.c 2003-10-22 01:07:38.000000000 -0400
@@ -25,36 +25,29 @@
feholdexcept (fenv_t *envp)
{
fenv_t clear;
+ fenv_t * _regs = envp;
/* Store the environment. */
- {
- fenv_t * _regs = envp;
- __asm__ (
- "fstd %%fr0,0(%2)\n"
- "fstd,ma %%fr1,8(%2)\n"
- "fstd,ma %%fr2,8(%2)\n"
- "fstd %%fr3,0(%2)\n"
- : "=m" (*_regs), "=r" (_regs) : "1" (_regs));
- memcpy (&clear, envp, sizeof (clear));
- }
+ __asm__ ( "fstd,ma %%fr0,8(%1)\n"
+ "fstd,ma %%fr1,8(%1)\n"
+ "fstd,ma %%fr2,8(%1)\n"
+ "fstd %%fr3,0(%1)\n"
+ : "=m" (*_regs), "+r" (_regs)
+ );
+
+ memcpy (&clear, envp, sizeof (clear));
- /* Now clear all exceptions. */
- clear.__status_word &= ~(FE_ALL_EXCEPT << 27);
+ /* Now clear all exceptions (Enable bits and flags) */
+ clear.__status_word &= ~((FE_ALL_EXCEPT << 27) | FE_ALL_EXCEPT);
memset (clear.__exception, 0, sizeof (clear.__exception));
- /* And set all exceptions to non-stop. */
- clear.__status_word &= ~FE_ALL_EXCEPT;
-
/* Load the new environment. */
- {
- fenv_t * _regs = &clear + 1;
- __asm__ (
- "fldd,mb -8(%2),%%fr3\n"
- "fldd,mb -8(%2),%%fr2\n"
- "fldd,mb -8(%2),%%fr1\n"
- "fldd -8(%2),%%fr0\n"
- : "=m" (*_regs), "=r" (_regs) : "1" (_regs));
- }
+ __asm__ ( "fldd,ma -8(%1),%%fr3\n"
+ "fldd,ma -8(%1),%%fr2\n"
+ "fldd,ma -8(%1),%%fr1\n"
+ "fldd 0(%1),%%fr0\n"
+ : "=m" (*_regs), "+r" (_regs)
+ );
return 0;
}
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/fesetenv.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/fesetenv.c 2003-10-22 01:07:38.000000000 -0400
@@ -26,24 +26,23 @@
fesetenv (const fenv_t *envp)
{
fenv_t temp;
+ fenv_t * _regs = &temp;
/* Install the environment specified by ENVP. But there are a few
values which we do not want to come from the saved environment.
Therefore, we get the current environment and replace the values
we want to use from the environment specified by the parameter. */
- {
- fenv_t * _regs = &temp;
- __asm__ (
- "fstd %%fr0,0(%2)\n"
- "fstd,ma %%fr1,8(%2)\n"
- "fstd,ma %%fr2,8(%2)\n"
- "fstd %%fr3,0(%2)\n"
- : "=m" (*_regs), "=r" (_regs) : "1" (_regs));
- }
- temp.__status_word &= ~(FE_ALL_EXCEPT
- | (FE_ALL_EXCEPT << 27)
- | FE_DOWNWARD);
+ __asm__ ( "fstd,ma %%fr0,8(%1)\n"
+ "fstd,ma %%fr1,8(%1)\n"
+ "fstd,ma %%fr2,8(%1)\n"
+ "fstd %%fr3,0(%1)\n"
+ : "=m" (*_regs), "+r" (_regs)
+ );
+
+ temp.__status_word &= ~((FE_ALL_EXCEPT << 27)
+ | FE_DOWNWARD
+ | FE_ALL_EXCEPT);
if (envp == FE_DFL_ENV)
;
else if (envp == FE_NOMASK_ENV)
@@ -55,16 +54,13 @@
| (FE_ALL_EXCEPT << 27)));
/* Load the new environment. */
- {
- fenv_t * _regs = &temp + 1;
- __asm__ (
- "fldd,mb -8(%2),%%fr3\n"
- "fldd,mb -8(%2),%%fr2\n"
- "fldd,mb -8(%2),%%fr1\n"
- "fldd -8(%2),%%fr0\n"
- : "=m" (*_regs), "=r" (_regs) : "1" (_regs));
- }
-
+ __asm__ ( "fldd,ma -8(%1),%%fr3\n"
+ "fldd,ma -8(%1),%%fr2\n"
+ "fldd,ma -8(%1),%%fr1\n"
+ "fldd 0(%2),%%fr0\n"
+ : "=m" (*_regs), "+r" (_regs)
+ );
+
/* Success. */
return 0;
}
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/feupdateenv.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/feupdateenv.c 2003-10-22 01:07:38.000000000 -0400
@@ -27,14 +27,12 @@
/* Get the current exception status. */
__asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
- sw[0] &= (FE_ALL_EXCEPT << 27);
-
+ sw[0] &= FE_ALL_EXCEPT;
+ envp->__status_word = envp->__status_word | sw[0];
+
/* Install new environment. */
fesetenv (envp);
- /* Raise the saved exception. */
- feraiseexcept (sw[0] >> 27);
-
/* Success. */
return 0;
}
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/fraiseexcpt.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/fraiseexcpt.c 2003-10-22 01:07:38.000000000 -0400
@@ -22,6 +22,9 @@
#include <float.h>
#include <math.h>
+/* Please see section 10,
+ page 10-5 "Delayed Trapping" in the PA-RISC 2.0 Architecture manual */
+
int
feraiseexcept (int excepts)
{
@@ -33,56 +36,64 @@
/* We do these bits in assembly to be certain GCC doesn't optimize
away something important, and so we can force delayed traps to
- occur. */
-
- /* FIXME: These all need verification! */
+ occur. */
- /* First: invalid exception. */
+ /* We use "fldd 0(%%sr0,%%sp),%0" to flush the delayed exception */
+
+ /* First: Invalid exception. */
if (excepts & FE_INVALID)
{
/* One example of a invalid operation is 0 * Infinity. */
double d = HUGE_VAL;
- __asm__ __volatile__ ("fmpy,dbl %1,%%fr0,%0\n\t"
- /* FIXME: is this a proper trap barrier? */
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d));
+ __asm__ __volatile__ (
+ " fcpy,dbl %%fr0,%%fr22\n"
+ " fmpy,dbl %0,%%fr22,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) : : "%fr22" );
}
- /* Next: division by zero. */
+ /* Second: Division by zero. */
if (excepts & FE_DIVBYZERO)
{
double d = 1.0;
- __asm__ __volatile__ ("fdiv,dbl %1,%%fr0,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d));
+ __asm__ __volatile__ (
+ " fcpy,dbl %%fr0,%%fr22\n"
+ " fdiv,dbl %0,%%fr22,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) : : "%fr22" );
}
- /* Next: overflow. */
- /* FIXME: Compare with IA-64 - do we have the same problem? */
+ /* Third: Overflow. */
if (excepts & FE_OVERFLOW)
{
double d = DBL_MAX;
-
- __asm__ __volatile__ ("fmpy,dbl %1,%1,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d));
+ __asm__ __volatile__ (
+ " fadd,dbl %0,%0,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) );
}
- /* Next: underflow. */
+ /* Fourth: Underflow. */
if (excepts & FE_UNDERFLOW)
{
double d = DBL_MIN;
- double e = 69.69;
-
- __asm__ __volatile__ ("fdiv,dbl %1,%2,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d), "f" (e));
+ double e = 3.0;
+ __asm__ __volatile__ (
+ " fdiv,dbl %0,%1,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) : "f" (e) );
}
- /* Last: inexact. */
+ /* Fifth: Inexact */
if (excepts & FE_INEXACT)
{
- double d = 1.0;
- double e = M_PI;
-
- __asm__ __volatile__ ("fdiv,dbl %1,%2,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d), "f" (e));
+ double d = M_PI;
+ double e = 69.69;
+ __asm__ __volatile__ (
+ " fdiv,dbl %0,%1,%%fr22\n"
+ " fcnvfxt,dbl,sgl %%fr22,%%fr22L\n"
+ " fldd 0(%%sr0,%%sp),%%fr22"
+ : : "f" (d), "f" (e) : "%fr22" );
}
/* Success. */
--- glibc-2.3.2-orig-debian/sysdeps/hppa/fpu/fsetexcptflg.c 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/fpu/fsetexcptflg.c 2003-10-22 01:07:38.000000000 -0400
@@ -29,8 +29,7 @@
/* Get the current status word. */
__asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
- /* Install the new exception flags bits. */
- sw[0] &= ~(excepts & (FE_ALL_EXCEPT >> 27));
+ /* Clear exception flags, and install new neable trap bits */
sw[0] |= (*flagp & excepts & FE_ALL_EXCEPT) << 27;
/* Store the new status word. */
--- glibc-2.3.2-orig-debian/sysdeps/hppa/libgcc-compat.c 1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.3.2/sysdeps/hppa/libgcc-compat.c 2003-10-22 01:07:38.000000000 -0400
@@ -0,0 +1,43 @@
+/* pre-.hidden libgcc compatibility
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Randolph Chung
+
+ 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 <stdint.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_6)
+
+symbol_version (__clz_tab_internal, __clz_tab, GLIBC_2.2);
+
+typedef unsigned int UQItype __attribute__ ((mode (QI)));
+
+const UQItype __clz_tab_internal[] =
+{
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+};
+
+#endif
--- glibc-2.3.2-orig-debian/sysdeps/hppa/sysdep.h 2003-10-22 01:03:47.000000000 -0400
+++ glibc-2.3.2/sysdeps/hppa/sysdep.h 2003-10-22 01:07:38.000000000 -0400
@@ -70,6 +70,7 @@
#define PSEUDO_END(name) \
END (name)
+#undef JUMPTARGET
#define JUMPTARGET(name) name
#define SYSCALL_PIC_SETUP /* Nothing. */
--- glibc-2.3.2-orig-debian/sysdeps/posix/getaddrinfo.c 2003-10-22 01:06:12.000000000 -0400
+++ glibc-2.3.2/sysdeps/posix/getaddrinfo.c 2003-10-22 01:07:38.000000000 -0400
@@ -53,6 +53,7 @@
#include <sys/utsname.h>
#include <net/if.h>
#include <nsswitch.h>
+#include <stdbool.h>
#define GAIH_OKIFUNSPEC 0x0100
#define GAIH_EAI ~(GAIH_OKIFUNSPEC)
--- glibc-2.3.2-orig-debian/sysdeps/unix/Makefile 2003-10-22 01:06:12.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/Makefile 2003-10-22 01:07:38.000000000 -0400
@@ -295,6 +295,7 @@
$(..)sysdeps/unix/Makefile
$(make-target-directory)
(echo '#include <errno.h>'; \
+ echo 'extern long int _no_syscall(void);'; \
echo 'long int _no_syscall (void)'; \
echo '{ __set_errno (ENOSYS); return -1L; }'; \
for call in $(unix-stub-syscalls); do \
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/hppa/clone.S 2003-10-22 01:03:48.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/hppa/clone.S 2003-10-22 01:07:38.000000000 -0400
@@ -28,6 +28,8 @@
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
+#warning CAO: __clone needs verification
+
.text
ENTRY(__clone)
/* FIXME: I have no idea how profiling works on hppa. */
@@ -42,6 +44,11 @@
stwm %arg0,64(%arg1)
stw %arg3,-60(%arg1)
+ /* Save the PIC register. */
+#ifdef PIC
+ stw %r19,-32(%sr0, %sp) /* parent */
+#endif
+
/* Do the system call */
copy %arg2,%arg0
ble 0x100(%sr2,%r0)
@@ -53,19 +60,31 @@
comib,=,n 0,%ret0,thread_start
- /* Successful return from the parent */
+ /* Successful return from the parent
+ No need to restore the PIC register,
+ since we return immediately. */
+
bv %r0(%rp)
nop
/* Something bad happened -- no child created */
.Lerror:
+
+ /* Restore the PIC register on error */
+#ifdef PIC
+ ldw -32(%sr0, %sp), %r19 /* parent */
+#endif
+
b __syscall_error
sub %r0,%ret0,%arg0
thread_start:
+
/* Load up the arguments. */
- ldw -60(%sp),%arg0
- ldw -64(%sp),%r22
+ ldw -60(%sr0, %sp),%arg0
+ ldw -64(%sr0, %sp),%r22
+
+ /* FIXME: Don't touch the childs PIC register? */
/* Call the user's function */
bl $$dyncall,%r31
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/hppa/kernel_stat.h 2003-10-22 01:03:48.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/hppa/kernel_stat.h 2003-10-22 01:07:38.000000000 -0400
@@ -1,30 +1,30 @@
-/* definition of "struct stat" from the kernel */
+/* Definition of 'struct stat' taken from kernel, please keep up to date */
struct kernel_stat {
- unsigned long st_dev; /* dev_t is 32 bits on parisc */
- unsigned long st_ino; /* 32 bits */
+ unsigned int st_dev; /* dev_t is 32 bits on parisc */
+ unsigned int st_ino; /* 32 bits */
unsigned short st_mode; /* 16 bits */
unsigned short st_nlink; /* 16 bits */
unsigned short st_reserved1; /* old st_uid */
unsigned short st_reserved2; /* old st_gid */
- unsigned long st_rdev;
- unsigned long st_size;
+ unsigned int st_rdev;
+ unsigned int st_size;
struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- long st_blksize;
- long st_blocks;
- unsigned long __unused1; /* ACL stuff */
- unsigned long __unused2; /* network */
- unsigned long __unused3; /* network */
- unsigned long __unused4; /* cnodes */
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ int st_blksize;
+ int st_blocks;
+ unsigned int __unused1; /* ACL stuff */
+ unsigned int __unused2; /* network */
+ unsigned int __unused3; /* network */
+ unsigned int __unused4; /* cnodes */
unsigned short __unused5; /* netsite */
short st_fstype;
- unsigned long st_realdev;
+ unsigned int st_realdev;
unsigned short st_basemode;
unsigned short st_spareshort;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned long st_spare4[3];
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_spare4[3];
};
#define _HAVE_STAT_NSEC
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/hppa/mmap.c 2003-10-22 01:03:48.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/hppa/mmap.c 2003-10-22 01:07:38.000000000 -0400
@@ -37,7 +37,7 @@
__ptr_t ret;
- ret = INLINE_SYSCALL(mmap, 6, addr, len, prot, flags, fd, offset);
+ ret = (__ptr_t)INLINE_SYSCALL(mmap, 6, addr, len, prot, flags, fd, offset);
/* check if it's really a negative number */
if(((unsigned long)ret & 0xfffff000) == 0xfffff000)
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/hppa/sysdep.c 2003-10-22 01:03:48.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/hppa/sysdep.c 2003-10-22 01:07:38.000000000 -0400
@@ -19,6 +19,10 @@
#include <sysdep.h>
#include <errno.h>
+extern int __syscall_error(int err_no);
+extern int syscall (int sysnum, int arg0, int arg1, int arg2,
+ int arg3, int arg4, int arg5);
+
/* This routine is jumped to by all the syscall handlers, to stash
an error number into errno. */
int
@@ -30,25 +34,31 @@
/* HPPA implements syscall() in 'C'; the assembler version would
- typically be in syscall.S. */
-
+ typically be in syscall.S. Also note that we have INLINE_SYSCALL,
+ INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
+ How often the function is used is unknown. */
int
syscall (int sysnum, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
{
- long __sys_res;
- {
- register unsigned long __res asm("r28");
- LOAD_ARGS_6(arg0, arg1, arg2, arg3, arg4, arg5)
- asm volatile ("ble 0x100(%%sr2, %%r0)\n\t"
- "copy %1, %%r20"
- : "=r" (__res)
- : "r" (sysnum) ASM_ARGS_6);
- __sys_res = __res;
- }
- if ((unsigned long) __sys_res >= (unsigned long)-4095)
- {
- __set_errno(-__sys_res);
- __sys_res = -1;
- }
- return __sys_res;
+ /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
+ long __sys_res;
+ {
+ register unsigned long __res asm("r28");
+ LOAD_ARGS_6(arg0, arg1, arg2, arg3, arg4, arg5)
+ asm volatile (
+ STW_ASM_PIC
+ " ble 0x100(%%sr2, %%r0) \n"
+ " copy %1, %%r20 \n"
+ LDW_ASM_PIC
+ : "=r" (__res)
+ : "r" (sysnum) ASM_ARGS_6
+ : CALL_CLOB_REGS CLOB_ARGS_6
+ );
+ __sys_res = __res;
+ }
+ if ((unsigned long) __sys_res >= (unsigned long)-4095){
+ __set_errno(-__sys_res);
+ __sys_res = -1;
+ }
+ return __sys_res;
}
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/hppa/sysdep.h 2003-10-22 01:06:12.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/hppa/sysdep.h 2003-10-22 01:07:38.000000000 -0400
@@ -31,6 +31,26 @@
#undef SYS_ify
#define SYS_ify(syscall_name) (__NR_##syscall_name)
+/* Included for older kernels whose headers
+ are missing the define */
+#ifndef __NR_semtimedop
+# define __NR_semtimedop 228
+#endif
+
+# ifdef PIC
+/* WARNING: CANNOT BE USED IN A NOP! */
+# define STW_PIC stw %r19, -32(%sr0, %sp) ASM_LINE_SEP
+# define LDW_PIC ldw -32(%sr0, %sp), %r19 ASM_LINE_SEP
+# define STW_ASM_PIC " copy %%r19, %%r4\n"
+# define LDW_ASM_PIC " copy %%r4, %%r19\n"
+# define USING_GR4 "%r4",
+# else
+# define STW_PIC ASM_LINE_SEP
+# define LDW_PIC ASM_LINE_SEP
+# define STW_ASM_PIC " \n"
+# define LDW_ASM_PIC " \n"
+# define USING_GR4
+# endif
#ifdef __ASSEMBLER__
@@ -77,20 +97,13 @@
.text ASM_LINE_SEP \
.export C_SYMBOL_NAME(name) ASM_LINE_SEP \
.type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
- C_LABEL(name) \
- CALL_MCOUNT
-
-#define ret \
- bv 0(2) ASM_LINE_SEP \
- nop
-
-#define ret_NOERRNO \
- bv 0(2) ASM_LINE_SEP \
- nop
+ C_LABEL(name) ASM_LINE_SEP \
+ CALL_MCOUNT ASM_LINE_SEP
#undef END
-#define END(name) \
-1: .size C_SYMBOL_NAME(name),1b-C_SYMBOL_NAME(name)
+#define END(name) \
+1: ASM_LINE_SEP \
+.size C_SYMBOL_NAME(name),1b-C_SYMBOL_NAME(name) ASM_LINE_SEP \
/* If compiled for profiling, call `mcount' at the start of each function. */
/* No, don't bother. gcc will put the call in for us. */
@@ -110,27 +123,83 @@
nop
*/
-#define PSEUDO(name, syscall_name, args) \
- ENTRY (name) \
- DO_CALL(syscall_name, args) ASM_LINE_SEP \
- nop
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ DO_CALL(syscall_name, args) ASM_LINE_SEP \
+ nop ASM_LINE_SEP
+
+#define ret \
+ /* Return value set by ERRNO code */ ASM_LINE_SEP \
+ bv 0(2) ASM_LINE_SEP \
+ nop ASM_LINE_SEP
#undef PSEUDO_END
-#define PSEUDO_END(name) \
+#define PSEUDO_END(name) \
END (name)
-#define PSEUDO_NOERRNO(name, syscall_name, args) \
- ENTRY (name) \
- DO_CALL(syscall_name, args) ASM_LINE_SEP \
- nop
+/* We don't set the errno on the return from the syscall */
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ ENTRY (name) \
+ DO_CALL_NOERRNO(syscall_name, args) ASM_LINE_SEP \
+ nop ASM_LINE_SEP
+#define ret_NOERRNO ret
+
#undef PSEUDO_END_NOERRNO
-#define PSEUDO_END_NOERRNO(name) \
+#define PSEUDO_END_NOERRNO(name) \
END (name)
+/* This has to return the error value */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ ENTRY(name) \
+ DO_CALL_ERRVAL(syscall_name, args) ASM_LINE_SEP \
+ nop ASM_LINE_SEP
+
+#define ret_ERRVAL ret
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END(name)
+
+#undef JUMPTARGET
#define JUMPTARGET(name) name
#define SYSCALL_PIC_SETUP /* Nothing. */
+
+/* All the syscall assembly macros rely on finding the approriate
+ SYSCALL_ERROR_LABEL or rather HANDLER. */
+
+/* int * __errno_location(void) so you have to store your value
+ into the return address! */
+#define DEFAULT_SYSCALL_ERROR_HANDLER \
+ .import __errno_location,code ASM_LINE_SEP \
+ /* branch to errno handler */ ASM_LINE_SEP \
+ bl __errno_location,%rp ASM_LINE_SEP
+
+/* Here are the myriad of configuration options that the above can
+ work for... what we've done is provide the framework for future
+ changes if required to each section */
+
+#ifdef PIC
+# if RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# else /* !RTLD_PRIVATE_ERRNO */
+# if defined _LIBC_REENTRANT
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# else /* !_LIBC_REENTRANT */
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# endif /* _LIBC_REENTRANT */
+# endif /* RTLD_PRIVATE_ERRNO */
+#else
+# ifndef _LIBC_REENTRANT
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# else
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# endif
+#endif
+
+
/* Linux takes system call arguments in registers:
syscall number gr20
arg 1 gr26
@@ -159,25 +228,61 @@
#undef DO_CALL
#define DO_CALL(syscall_name, args) \
- DOARGS_##args \
+ DOARGS_##args ASM_LINE_SEP \
+ STW_PIC ASM_LINE_SEP \
+ /* Do syscall, delay loads # */ ASM_LINE_SEP \
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
ldi -0x1000,%r1 ASM_LINE_SEP \
cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
- stw %rp, -20(%sr0,%r30) ASM_LINE_SEP \
- stw %ret0, -24(%sr0,%r30) ASM_LINE_SEP \
- .import __errno_location,code ASM_LINE_SEP \
- bl __errno_location,%rp ASM_LINE_SEP \
- ldo 64(%r30), %r30 ASM_LINE_SEP \
- ldo -64(%r30), %r30 ASM_LINE_SEP \
- ldw -24(%r30), %r26 ASM_LINE_SEP \
+ /* save rp or we get lost */ ASM_LINE_SEP \
+ stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
+ /* Restore r19 from frame */ ASM_LINE_SEP \
+ LDW_PIC ASM_LINE_SEP \
+ stw %ret0, -24(%sr0,%sp) ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ /* create frame */ ASM_LINE_SEP \
+ ldo 64(%sp), %sp ASM_LINE_SEP \
+ ldo -64(%sp), %sp ASM_LINE_SEP \
+ /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
+ /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
+ ldw -24(%sr0,%sp), %r26 ASM_LINE_SEP \
sub %r0, %r26, %r26 ASM_LINE_SEP \
+ /* Store into errno location */ ASM_LINE_SEP \
stw %r26, 0(%sr0,%ret0) ASM_LINE_SEP \
+ /* return -1 as error */ ASM_LINE_SEP \
ldo -1(%r0), %ret0 ASM_LINE_SEP \
- ldw -20(%r30), %rp ASM_LINE_SEP \
+ ldw -20(%sr0,%sp), %rp ASM_LINE_SEP \
0: ASM_LINE_SEP \
+ UNDOARGS_##args ASM_LINE_SEP
+
+/* We do nothing with the return, except hand it back to someone else */
+#undef DO_CALL_NOERRNO
+#define DO_CALL_NOERRNO(syscall_name, args) \
+ DOARGS_##args \
+ /* No need to store r19 */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ /* Caller will restore r19 */ ASM_LINE_SEP \
UNDOARGS_##args
+/* Here, we return the ERRVAL in assembly, note we don't call the
+ error handler function, but we do 'negate' the return _IF_
+ it's an error. Not sure if this is the right semantic. */
+
+#undef DO_CALL_ERRVAL
+#define DO_CALL_ERRVAL(syscall_name, args) \
+ DOARGS_##args ASM_LINE_SEP \
+ /* No need to store r19 */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ /* Caller will restore r19 */ ASM_LINE_SEP \
+ ldi -0x1000,%r1 ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
+ sub %r0, %ret0, %ret0 ASM_LINE_SEP \
+0: ASM_LINE_SEP \
+ UNDOARGS_##args ASM_LINE_SEP
+
#define DOARGS_0 /* nothing */
#define DOARGS_1 /* nothing */
#define DOARGS_2 /* nothing */
@@ -198,26 +303,87 @@
#else
+/* GCC has to be warned that a syscall may clobber all the ABI
+ registers listed as "caller-saves", see page 8, Table 2
+ in section 2.2.6 of the PA-RISC RUN-TIME architecture
+ document. However! r28 is the result and will conflict with
+ the clobber list so it is left out. Also the input arguments
+ registers r20 -> r26 will conflict with the list so they
+ are treated specially. Although r19 is clobbered by the syscall
+ we cannot say this because it would violate ABI, thus we say
+ r4 is clobbered and use that register to save/restore r19
+ across the syscall. */
+
+#define CALL_CLOB_REGS "%r1", "%r2", USING_GR4 \
+ "%r20", "%r29", "%r31"
+
#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) ({ \
+#define INLINE_SYSCALL(name, nr, args...) ({ \
+ long __sys_res; \
+ { \
+ register unsigned long __res asm("r28"); \
+ LOAD_ARGS_##nr(args) \
+ /* FIXME: HACK stw/ldw r19 around syscall */ \
+ asm volatile( \
+ STW_ASM_PIC \
+ " ble 0x100(%%sr2, %%r0)\n" \
+ " ldi %1, %%r20\n" \
+ LDW_ASM_PIC \
+ : "=r" (__res) \
+ : "i" (SYS_ify(name)) ASM_ARGS_##nr \
+ : CALL_CLOB_REGS CLOB_ARGS_##nr \
+ ); \
+ __sys_res = (long)__res; \
+ } \
+ if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){ \
+ __set_errno(-__sys_res); \
+ __sys_res = -1; \
+ } \
+ __sys_res; \
+})
+
+/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static
+ value to use within the context of the syscall
+ INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise
+ You are allowed to use the syscall result (val) and the DECL error variable
+ to determine what went wrong.
+ INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number.
+ In our case we just flip the sign. */
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+/* Equivalent to (val < 0)&&(val > -4095) which is what we want */
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned long)val >= (unsigned long)-4095)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+
+/* Similar to INLINE_SYSCALL but we don't set errno */
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+({ \
long __sys_res; \
{ \
register unsigned long __res asm("r28"); \
LOAD_ARGS_##nr(args) \
+ /* FIXME: HACK stw/ldw r19 around syscall */ \
asm volatile( \
- "ble 0x100(%%sr2, %%r0)\n\t" \
- " ldi %1, %%r20" \
+ STW_ASM_PIC \
+ " ble 0x100(%%sr2, %%r0)\n" \
+ " ldi %1, %%r20\n" \
+ LDW_ASM_PIC \
: "=r" (__res) \
: "i" (SYS_ify(name)) ASM_ARGS_##nr \
- ); \
- __sys_res = __res; \
- } \
- if ((unsigned long)__sys_res >= (unsigned long)-4095) { \
- __set_errno(-__sys_res); \
- __sys_res = -1; \
+ : CALL_CLOB_REGS CLOB_ARGS_##nr \
+ ); \
+ __sys_res = (long)__res; \
} \
__sys_res; \
-})
+ })
+
#define LOAD_ARGS_0()
#define LOAD_ARGS_1(r26) \
@@ -239,12 +405,22 @@
register unsigned long __r21 __asm__("r21") = (unsigned long)r21; \
LOAD_ARGS_5(r26,r25,r24,r23,r22)
-#define ASM_ARGS_0
-#define ASM_ARGS_1 , "r" (__r26)
-#define ASM_ARGS_2 , "r" (__r26), "r" (__r25)
-#define ASM_ARGS_3 , "r" (__r26), "r" (__r25), "r" (__r24)
-#define ASM_ARGS_4 , "r" (__r26), "r" (__r25), "r" (__r24), "r" (__r23)
-#define ASM_ARGS_5 , "r" (__r26), "r" (__r25), "r" (__r24), "r" (__r23), "r" (__r22)
-#define ASM_ARGS_6 , "r" (__r26), "r" (__r25), "r" (__r24), "r" (__r23), "r" (__r22), "r" (__r21)
-
+/* Even with zero args we use r20 for the syscall number */
+#define ASM_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__r26)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__r25)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__r24)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__r23)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__r22)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__r21)
+
+/* The registers not listed as inputs but clobbered */
+#define CLOB_ARGS_6
+#define CLOB_ARGS_5 CLOB_ARGS_6, "%r21"
+#define CLOB_ARGS_4 CLOB_ARGS_5, "%r22"
+#define CLOB_ARGS_3 CLOB_ARGS_4, "%r23"
+#define CLOB_ARGS_2 CLOB_ARGS_3, "%r24"
+#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
+#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
+
#endif /* __ASSEMBLER__ */
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/hppa/umount.c 2003-10-22 01:03:48.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/hppa/umount.c 2003-10-22 01:07:38.000000000 -0400
@@ -21,6 +21,7 @@
does down here. */
extern long int __umount2 (const char *name, int flags);
+extern long int __umount (const char * name);
long int
__umount (const char *name)
--- glibc-2.3.2-orig-debian/sysdeps/unix/sysv/linux/sys/sysctl.h 2003-10-22 01:06:13.000000000 -0400
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/sys/sysctl.h 2003-10-22 01:07:38.000000000 -0400
@@ -24,7 +24,9 @@
#include <stddef.h>
/* Prevent more kernel headers than necessary to be included. */
#define _LINUX_KERNEL_H 1
-#define _LINUX_TYPES_H 1
+#ifndef _LINUX_TYPES_H
+# define _LINUX_TYPES_H 1
+#endif
#define _LINUX_LIST_H 1
/* We do need this one for the declarations in <linux/sysctl.h>,
since we've elided the inclusion of <linux/kernel.h> that gets them. */
|