1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
|
2011-06-30 Ross Johnson <ross dot johnson at homemail dot com dot au>
* pthread_once.c: Tighten 'if' statement casting; fix interlocked
pointer cast for 64 bit compatibility (missed yesterday).
* create.c (stackSize): Now type size_t.
2011-06-29 Daniel Richard G. <skunk at iskunk dot org>
* ptw32_relmillisecs.c (ftime):
_ftime64_s() is only available in MSVC 2005 or later;
_ftime64() is available in MinGW or MSVC 2002 or later;
_ftime() is always available.
* pthread.h (long long): Not defined in older MSVC 6.
* implement.h (long long): Likewise.
* pthread_getunique_np.c (long long): Likewise.
2011-06-29 Ross Johnson <ross dot johnson at homemail dot com dot au>
* *.[ch] (PTW32_INTERLOCKED_*): These macros should now work for
both 32 and 64 bit builds. The MingW versions are all inlined asm
while the MSVC versions expand to their Interlocked* or Interlocked*64
counterparts appropriately. The argument type have also been changed
to cast to the appropriate value or pointer size for the architecture.
2011-05-29 Ross Johnson <ross dot johnson at homemail dot com dot au>
* *.[ch] (#ifdef): Extended cleanup to whole project.
2011-05-29 Daniel Richard G. <skunk at iskunk dot org>
* Makefile (CC): Define CC to allow use of other compatible
compilers such as the Intel compilter icl.
* implement.h (#if): Fix forms like #if HAVE_SOMETHING.
* pthread.h: Likewise.
* sched.h: Likewise; PTW32_LEVEL_* becomes PTW32_SCHED_LEVEL_*.
* semaphore.h: Likewise.
2011-05-11 Ross Johnson <ross.johnson at homemail.com.au>
* ptw32_callUserDestroyRoutines.c (terminate): Altered includes
to match ptw32_threadStart.c.
* GNUmakefile (GCE-inlined-debug, DOPT): Fixed.
2011-04-31 Ross Johnson <ross.johnson at homemail.com.au>
* (robust mutexes): Added this API. The API is not
mandatory for implementations that don't support PROCESS_SHARED
mutexes, nevertheless it was considered useful both functionally
and for source-level compatibility.
2011-03-26 Ross Johnson <ross.johnson at homemail.com.au>
* pthread_getunique_np.c: New non-POSIX interface for compatibility
with some other implementations; returns a 64 bit sequence number
that is unique to each thread in the process.
* pthread.h (pthread_getunique_np): Added.
* global.c: Add global sequence counter for above.
* implement.h: Likewise.
2011-03-25 Ross Johnson <ross.johnson at homemail.com.au>
* (cancelLock): Convert to an MCS lock and rename to stateLock.
* (threadLock): Likewise.
* (keyLock): Likewise.
* pthread_mutex*.c: First working robust mutexes.
2011-03-11 Ross Johnson <ross.johnson at homemail.com.au>
* implement.h (PTW32_INTERLOCKED_*CREMENT macros): increment/decrement
using ++/-- instead of add/subtract 1.
* ptw32_MCS_lock.c: Make casts consistent.
2011-03-09 Ross Johnson <ross.johnson at homemail.com.au>
* implement.h (ptw32_thread_t_): Add process unique sequence number.
* global.c: Replace global Critical Section objects with MCS
queue locks.
* implement.h: Likewise.
* pthread_cond_destroy.c: Likewise.
* pthread_cond_init.c: Likewise.
* pthread_detach.c: Likewise.
* pthread_join.c: Likewise.
* pthread_kill.c: Likewise.
* pthread_mutex_destroy.c: Likewise.
* pthread_rwlock_destroy.c: Likewise.
* pthread_spin_destroy.c: Likewise.
* pthread_timechange_handler_np.c: Likewise.
* ptw32_cond_check_need_init.c: Likewise.
* ptw32_mutex_check_need_init.c: Likewise.
* ptw32_processInitialize.c: Likewise.
* ptw32_processTerminate.c: Likewise.
* ptw32_reuse.c: Likewise.
* ptw32_rwlock_check_need_init.c: Likewise.
* ptw32_spinlock_check_need_init.c: Likewise.
2011-03-06 Ross Johnson <ross.johnson at homemail.com.au>
* several (MINGW64): Cast and call fixups for 64 bit compatibility;
clean build via x86_64-w64-mingw32 cross toolchain on Linux i686
targeting x86_64 win64.
* ptw32_threadStart.c (ptw32_threadStart): Routine no longer attempts
to pass [unexpected C++] exceptions out of scope but ends the thread
normally setting EINTR as the exit status.
* ptw32_throw.c: Fix C++ exception throwing warnings; ignore
informational warning.
* implement.h: Likewise with the corresponding header definition.
2011-03-04 Ross Johnson <ross.johnson at homemail.com.au>
* implement.h (PTW32_INTERLOCKED_*): Mingw32 does not provide
the __sync_* intrinsics so implemented them here as macro
assembler routines. MSVS Interlocked* are emmitted as intrinsics
wherever possible, so we want mingw to match it; Extended to
include all interlocked routines used by the library; implemented
x86_64 versions also.
* ptw32_InterlockedCompareExchange.c: No code remaining here.
* ptw32_MCS_lock.c: Converted interlocked calls to use new macros.
* pthread_barrier_wait.c: Likewise.
* pthread_once.c: Likewise.
* ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Name changed to
ptw32_mcs_node_transfer.
2011-02-28 Ross Johnson <ross.johnson at homemail.com.au>
* ptw32_relmillisecs.c: If possible, use _ftime64_s or _ftime64
before resorting to _ftime.
2011-02-27 Ross Johnson <ross.johnson at homemail.com.au>
* sched_setscheduler.c: Ensure the handle is closed after use.
* sched_getscheduler.c: Likewise.
* pthread.h: Remove POSIX compatibility macros; don't define
timespec if already defined.
* context.h: Changes for 64 bit.
* pthread_cancel.c: Likewise.
* pthread_exit.c: Likewise.
* pthread_spin_destroy.c: Likewise.
* pthread_timechange_handler_np.c: Likewise.
* ptw32_MCS_lock.c: Likewise; some of these changes may
not be compatible with pre Windows 2000 systems; reverse the order of
the includes.
* ptw32_threadStart.c: Likewise.
* ptw32_throw.c: Likewise.
2011-02-13 Ross Johnson <ross.johnson at homemail.com.au>
* pthread_self: Add comment re returning 'nil' value to
indicate failure only to win32 threads that call us.
* pthread_attr_setstackaddr: Fix comments; note this
function and it's compliment are now removed from SUSv4.
2011-02-12 Ross Johnson <ross.johnson at homemail.com.au>
README.NONPORTABLE: Record a description of an obvious
method for nulling/comparing/hashing pthread_t using a
union; plus and investigation of a change of type for
pthread_t (to a union) to neutralise any padding bits and
bytes if they occur in pthread_t (the current pthread_t struct
does not contain padding AFAIK, but porting the library to a
future architecture may introduce them). Padding affects
byte-by-byte copies and compare operations.
2010-11-16 Ross Johnson <ross.johnson at homemail.com.au>
* ChangeLog: Add this entry ;-)
Restore entries from 2007 through 2009 that went missing
at the last update.
2010-06-19 Ross Johnson <ross.johnson at homemail.com.au>
* ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Fix variable
names to avoid using C++ keyword ("new").
* implement.h (ptw32_mcs_node_substitute): Likewise.
* pthread_barrier_wait.c: Fix signed/unsigned comparison warning.
2010-06-18 Ramiro Polla <ramiro.polla at gmail.com >
* autostatic.c: New file; call pthread_win32_process_*()
libary init/cleanup routines automatically on application start
when statically linked.
* pthread.c (autostatic.c): Included.
* pthread.h (declspec): Remove import/export defines if compiler
is MINGW.
* sched.h (declspec): Likewise.
* semaphore.h (declspec): Likewise.
* need_errno.h (declspec): Likewise.
* Makefile (autostatic.obj): Add for small static builds.
* GNUmakefile (autostatic.o): Likewise.
* NEWS (Version 2.9.0): Add changes.
* README.NONPORTABLE (pthread_win32_process_*): Update
description.
2010-06-15 Ramiro Polla <ramiro.polla at gmail.com >
* Makefile: Remove linkage with the winsock library by default.
* GNUmakefile: Likewise.
* pthread_getspecific.c: Likewise by removing calls to WSA
functions.
* config.h (RETAIN_WSALASTERROR): Can be defined if necessary.
2010-01-26 Ross Johnson <ross.johnson at homemail.com.au>
* ptw32_MCS_lock.c (ptw32_mcs_node_substitute): New routine
to allow relocating the lock owners thread-local node to somewhere
else, e.g. to global space so that another thread can release the
lock. Used in pthread_barrier_wait.
(ptw32_mcs_lock_try_acquire): New routine.
* pthread_barrier_init: Only one semaphore is used now.
* pthread_barrier_wait: Added an MCS guard lock with the last thread
to leave the barrier releasing the lock. This removes a deadlock bug
observed when there are greater than barrier-count threads
attempting to cross.
* pthread_barrier_destroy: Added an MCS guard lock.
2009-03-03 Stephan O'Farrill <stephan dot ofarrill at gmail dot com>
* pthread_attr_getschedpolicy.c: Add "const" to function parameter
in accordance with SUSv3 (POSIX).
* pthread_attr_getinheritsched.c: Likewise.
* pthread_mutexattr_gettype.c: Likewise.
2008-06-06 Robert Kindred <RKindred at SwRI dot edu>
* ptw32_throw.c (ptw32_throw): Remove possible reference to NULL
pointer. (At the same time made the switch block conditionally
included only if exitCode is needed - RPJ.)
* pthread_testcancel.c (pthread_testcancel): Remove duplicate and
misplaced pthread_mutex_unlock().
2008-02-21 Sebastian Gottschalk <seppig_relay at gmx dot de>
* pthread_attr_getdetachstate.c (pthread_attr_getdetachstate):
Remove potential and superfluous null pointer assignment.
2007-11-22 Ivan Pizhenko <ivanp4 at ua dot fm>
* pthread.h (gmtime_r): gmtime returns 0 if tm represents a time
prior to 1/1/1970. Notice this to prevent raising an exception.
* pthread.h (localtime_r): Likewise for localtime.
2007-07-14 Marcel Ruff <mr at marcelruff dot info>
* errno.c (_errno): Fix test for pthread_self() success.
* need_errno.h: Remove unintentional line wrap from #if line.
2007-07-14 Mike Romanchuk <mromanchuk at empirix dot com>
* pthread.h (timespec): Fix tv_sec type.
2007-01-07 Sinan Kaya <sinan.kaya at siemens dot com>
* need_errno.h: Fix declaration of _errno - the local version of
_errno() is used, e.g. by WinCE.
2007-01-06 Ross Johnson <ross.johnson at homemail dot com dot au>
* ptw32_semwait.c: Add check for invalid sem_t after acquiring the
sem_t state guard mutex and before affecting changes to sema state.
2007-01-06 Marcel Ruff <mr at marcelruff dot info>
* error.c: Fix reference to pthread handle exitStatus member for
builds that use NEED_ERRNO (i.e. WINCE).
* context.h: Add support for ARM processor (WinCE).
* mutex.c (process.h): Exclude for WINCE.
* create.c: Likewise.
* exit.c: Likewise.
* implement.h: Likewise.
* pthread_detach.c (signal.h): Exclude for WINCE.
* pthread_join.c: Likewise.
* pthread_kill.c: Likewise.
* pthread_rwlock_init.c (errno.h): Remove - included by pthread.h.
* pthread_rwlock_destroy.c: Likewise.
* pthread_rwlock_rdlock.c: Likewise.
* pthread_rwlock_timedrdlock.c: Likewise.
* pthread_rwlock_timedwrlock.c: Likewise.
* pthread_rwlock_tryrdlock.c: Likewise.
* pthread_rwlock_trywrlock.c: likewise.
* pthread_rwlock_unlock.c: Likewise.
* pthread_rwlock_wrlock.c: Likewise.
* pthread_rwlockattr_destroy.c: Likewise.
* pthread_rwlockattr_getpshared.c: Likewise.
* pthread_rwlockattr_init.c: Likewise.
* pthread_rwlockattr_setpshared.c: Likewise.
2007-01-06 Romano Paolo Tenca <rotenca at telvia dot it>
* pthread_cond_destroy.c: Replace sem_wait() with non-cancelable
ptw32_semwait() since pthread_cond_destroy() is not a cancelation
point.
* implement.h (ptw32_spinlock_check_need_init): Add prototype.
* ptw32_MCS_lock.c: Reverse order of includes.
2007-01-06 Eric Berge <eric dot berge at quantum dot com>
* pthread_cond_destroy.c: Add LeaveCriticalSection before returning
after errors.
2007-01-04 Ross Johnson <ross.johnson at homemail dot com dot au>
* ptw32_InterlockedCompareExchange.c: Conditionally skip for
Win64 as not required.
* pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np):
Test for InterlockedCompareExchange is not required for Win64.
* context.h: New file. Included by pthread_cancel.h and any tests
that need it (e.g. context1.c).
* pthread_cancel.c: Architecture-dependent context macros moved
to context.h.
2007-01-04 Kip Streithorst <KSTREITH at ball dot com>
* implement.h (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64
support.
2006-12-20 Ross Johnson <ross.johnson at homemail.com.au>
* sem_destroy.c: Fix the race involving invalidation of the sema;
fix incorrect return of EBUSY resulting from the mutex trylock
on the private mutex guard.
* sem_wait.c: Add check for invalid sem_t after acquiring the
sem_t state guard mutex and before affecting changes to sema state.
* sem_trywait.c: Likewise.
* sem_timedwait.c: Likewise.
* sem_getvalue.c: Likewise.
* sem_post.c: Similar.
* sem_post_multiple.c: Likewise.
* sem_init.c: Set max Win32 semaphore count to SEM_VALUE_MAX (was
_POSIX_SEM_VALUE_MAX, which is a lower value - the minimum).
* pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np):
Load COREDLL.DLL under WINCE to check existence of
InterlockedCompareExchange() routine. This used to be done to test
for TryEnterCriticalSection() but was removed when this was no
longer needed.
2006-01-25 Prashant Thakre <prashant.thakre at gmail.com>
* pthread_cancel.c: Added _M_IA64 register context support.
2005-05-13 Ross Johnson <ross at callisto.canberra.edu.au>
* pthread_kill.c (pthread_kill): Remove check for Win32 thread
priority (to confirm HANDLE validity). Useless since thread HANDLEs
a not recycle-unique.
2005-05-30 Vladimir Kliatchko <vladimir at kliatchko.com>
* pthread_once.c: Re-implement using an MCS queue-based lock. The form
of pthread_once is as proposed by Alexander Terekhov (see entry of
2005-03-13). The MCS lock implementation does not require a unique
'name' to identify the lock between threads. Attempts to get the Event
or Semaphore based versions of pthread_once to a satisfactory level
of robustness have thus far failed. The last problem (avoiding races
involving non recycle-unique Win32 HANDLEs) was giving everyone
grey hair trying to solve it.
* ptw32_MCS_lock.c: New MCS queue-based lock implementation. These
locks are efficient: they have very low overhead in the uncontended case;
are efficient in contention and minimise cache-coherence updates in
managing the user level FIFO queue; do not require an ABI change in the
library.
2005-05-27 Alexander Gottwald <alexander.gottwald at s1999.tu-chemnitz.de>
* pthread.h: Some things, like HANDLE, were only defined if
PTW32_LEVEL was >= 3. They should always be defined.
2005-05-25 Vladimir Kliatchko <vladimir at kliatchko.com>
* pthread_once.c: Eliminate all priority operations and other
complexity by replacing the event with a semaphore. The advantage
of the change is the ability to release just one waiter if the
init_routine thread is cancelled yet still release all waiters when
done. Simplify once_control state checks to improve efficiency
further.
2005-05-24 Mikael Magnusson <mikaelmagnusson at glocalnet.net>
* GNUmakefile: Patched to allow cross-compile with mingw32 on Linux.
It uses macros instead of referencing dlltool, gcc and g++ directly;
added a call to ranlib. For example the GC static library can be
built with:
make CC=i586-mingw32msvc-gcc RC=i586-mingw32msvc-windres \
RANLIB=i586-mingw32msvc-ranlib clean GC-static
2005-05-13 Ross Johnson <ross at callisto.canberra.edu.au>
* pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np):
Move on-exit-only stuff from ptw32_threadDestroy() to here.
* ptw32_threadDestroy.c: It's purpose is now only to reclaim thread
resources for detached threads, or via pthread_join() or
pthread_detach() on joinable threads.
* ptw32_threadStart.c: Calling user destruct routines has moved to
pthread_win32_thread_detach_np(); call pthread_win32_thread_detach_np()
directly if statically linking, otherwise do so via dllMain; store
thread return value in thread struct for all cases, including
cancellation and exception exits; thread abnormal exits go via
pthread_win32_thread_detach_np.
* pthread_join.c (pthread_join): Don't try to get return code from
Win32 thread - always get it from he thread struct.
* pthread_detach.c (pthread_detach): reduce extent of the thread
existence check since we now don't care if the Win32 thread HANDLE has
been closed; reclaim thread resources if the thread has exited already.
* ptw32_throw.c (ptw32_throw): For Win32 threads that are not implicit,
only Call thread cleanup if statically linking, otherwise leave it to
dllMain.
* sem_post.c (_POSIX_SEM_VALUE_MAX): Change to SEM_VALUE_MAX.
* sem_post_multiple.c: Likewise.
* sem_init.c: Likewise.
2005-05-10 Ross Johnson <ross at callisto.canberra.edu.au>
* pthread_join.c (pthread_join): Add missing check for thread ID
reference count in thread existence test; reduce extent of the
existence test since we don't care if the Win32 thread HANDLE has
been closed.
2005-05-09 Ross Johnson <ross at callisto.canberra.edu.au>
* ptw32_callUserDestroyRoutines.c: Run destructor process (i.e.
loop over all keys calling destructors) up to
PTHREAD_DESTRUCTOR_ITERATIONS times if TSD value isn't NULL yet;
modify assoc management.
* pthread_key_delete.c: Modify assoc management.
* ptw32_tkAssocDestroy.c: Fix error in assoc removal from chains.
* pthread.h
(_POSIX_THREAD_DESTRUCTOR_ITERATIONS): Define to value specified by
POSIX.
(_POSIX_THREAD_KEYS_MAX): Define to value specified by POSIX.
(PTHREAD_KEYS_MAX): Redefine [upward] to minimum required by POSIX.
(SEM_NSEMS_MAX): Define to implementation value.
(SEM_VALUE_MAX): Define to implementation value.
(_POSIX_SEM_NSEMS_MAX): Redefine to value specified by POSIX.
(_POSIX_SEM_VALUE_MAX): Redefine to value specified by POSIX.
2005-05-06 Ross Johnson <ross at callisto.canberra.edu.au>
* signal.c (sigwait): Add a cancellation point to this otherwise
no-op.
* sem_init.c (sem_init): Check for and return ERANGE error.
* sem_post.c (sem_post): Likewise.
* sem_post_multiple.c (sem_post_multiple): Likewise.
* manual (directory): Added; see ChangeLog inside.
2005-05-02 Ross Johnson <ross at callisto.canberra.edu.au>
* implement.h (struct pthread_key_t_): Change threadsLock to keyLock
so as not to be confused with the per thread lock 'threadlock';
change all references to it.
* implement.h (struct ThreadKeyAssoc): Remove lock; add prevKey
and prevThread pointers; re-implemented all routines that use this
struct. The effect of this is to save one handle per association,
which could potentially equal the number of keys multiplied by the
number of threads, accumulating over time - and to free the
association memory as soon as it is no longer referenced by either
the key or the thread. Previously, the handle and memory were
released only after BOTH key and thread no longer referenced the
association. That is, often no association resources were released
until the process itself exited. In addition, at least one race
condition has been removed - where two threads could attempt to
release the association resources simultaneously - one via
ptw32_callUserDestroyRoutines and the other via
pthread_key_delete.
- thanks to Richard Hughes at Aculab for discovering the problem.
* pthread_key_create.c: See above.
* pthread_key_delete.c: See above.
* pthread_setspecific.c: See above.
* ptw32_callUserDestroyRoutines.c: See above.
* ptw32_tkAssocCreate.c: See above.
* ptw32_tkAssocDestroy.c: See above.
2005-04-27 Ross Johnson <ross at callisto.canberra.edu.au>
* sem_wait.c (ptw32_sem_wait_cleanup): after cancellation re-attempt
to acquire the semaphore to avoid a race with a late sem_post.
* sem_timedwait.c: Modify comments.
2005-04-25 Ross Johnson <ross at callisto.canberra.edu.au>
* ptw32_relmillisecs.c: New module; converts future abstime to
milliseconds relative to 'now'.
* pthread_mutex_timedlock.c: Use new ptw32_relmillisecs routine in
place of internal code; remove the NEED_SEM code - this routine is now
implemented for builds that define NEED_SEM (WinCE etc)
* sem_timedwait.c: Likewise; after timeout or cancellation,
re-attempt to acquire the semaphore in case one has been posted since
the timeout/cancel occurred. Thanks to Stefan Mueller.
* Makefile: Add ptw32_relmillisecs.c module; remove
ptw32_{in,de}crease_semaphore.c modules.
* GNUmakefile: Likewise.
* Bmakefile: Likewise.
* sem_init.c: Re-write the NEED_SEM code to be consistent with the
non-NEED_SEM code, but retaining use of an event in place of the w32 sema
for w32 systems that don't include semaphores (WinCE);
the NEED_SEM versions of semaphores has been broken for a long time but is
now fixed and supports all of the same routines as the non-NEED_SEM case.
* sem_destroy.c: Likewise.
* sem_wait.c: Likewise.
* sem_post.c: Likewise.
* sem_post_multple.c: Likewise.
* implement.h: Likewise.
* sem_timedwait.c: Likewise; this routine is now
implemented for builds that define NEED_SEM (WinCE etc).
* sem_trywait.c: Likewise.
* sem_getvalue.c: Likewise.
* pthread_once.c: Yet more changes, reverting closer to Gottlob Frege's
first design, but retaining cancellation, priority boosting, and adding
preservation of W32 error codes to make pthread_once transparent to
GetLastError.
2005-04-11 Ross Johnson <ross at callisto.canberra.edu.au>
* pthread_once.c (pthread_once): Added priority boosting to
solve starvation problem after once_routine cancellation.
See notes in file.
2005-04-06 Kevin Lussier <Kevin at codegreennetworks.com>
* Makefile: Added debug targets for all versions of the library.
2005-04-01 Ross Johnson <ross at callisto.canberra.edu.au>
* GNUmakefile: Add target to build libpthreadGC1.a as a static link
library.
* Makefile: Likewise for pthreadGC1.lib.
2005-04-01 Kevin Lussier <Kevin at codegreennetworks.com>
* sem_timedwait.c (sem_timedwait): Increase size of temp variables to
avoid int overflows for large timeout values.
* implement.h (int64_t): Include or define.
2005-03-31 Dimitar Panayotov <develop at mail.bg>^M
* pthread.h: Fix conditional defines for static linking.
* sched.h: Liekwise.
* semaphore.h: Likewise.
* dll.c (PTW32_STATIC_LIB): Module is conditionally included
in the build.
2005-03-16 Ross Johnson <ross at callisto.canberra.edu.au>^M
* pthread_setcancelstate.c: Undo the last change.
2005-03-16 Ross Johnson <ross at callisto.canberra.edu.au>^M
* pthread_setcancelstate.c: Don't check for an async cancel event
if the library is using alertable async cancel..
2005-03-14 Ross Johnson <ross at callisto.canberra.edu.au>
* pthread_once.c (pthread_once): Downgrade interlocked operations to simple
memory operations where these are protected by the critical section; edit
comments.
2005-03-13 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_once.c (pthread_once): Completely redesigned; a change was
required to the ABI (pthread_once_t_), and resulting in a version
compatibility index increment.
NOTES:
The design (based on pseudo code contributed by Gottlob Frege) avoids
creating a kernel object if there is no contention. See URL for details:-
http://sources.redhat.com/ml/pthreads-win32/2005/msg00029.html
This uses late initialisation similar to the technique already used for
pthreads-win32 mutexes and semaphores (from Alexander Terekhov).
The subsequent cancelation cleanup additions (by rpj) could not be implemented
without sacrificing some of the efficiency in Gottlob's design. In particular,
although each once_control uses it's own event to block on, a global CS is
required to manage it - since the event must be either re-usable or
re-creatable under cancelation. This is not needed in the non-cancelable
design because it is able to mark the event as closed (forever).
When uncontested, a CS operation is equivalent to an Interlocked operation
in speed. So, in the final design with cancelability, an uncontested
once_control operation involves a minimum of five interlocked operations
(including the LeaveCS operation).
ALTERNATIVES:
An alternative design from Alexander Terekhov proposed using a named mutex,
as sketched below:-
if (!once_control) { // May be in TLS
named_mutex::guard guard(&once_control2);
if (!once_control2) {
<init>
once_control2 = true;
}
once_control = true;
}
A more detailed description of this can be found here:-
http://groups.yahoo.com/group/boost/message/15442
[Although the definition of a suitable PTHREAD_ONCE_INIT precludes use of the
TLS located flag, this is not critical.]
There are three primary concerns though:-
1) The [named] mutex is 'created' even in the uncontended case.
2) A system wide unique name must be generated.
3) Win32 mutexes are VERY slow even in the uncontended case. An uncontested
Win32 mutex lock operation can be 50 (or more) times slower than an
uncontested EnterCS operation.
Ultimately, the named mutex trick is making use of the global locks maintained
by the kernel.
* pthread.h (pthread_once_t_): One flag and an event HANDLE added.
(PTHREAD_ONCE_INIT): Additional values included.
2005-03-08 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_once.c (pthread_once): Redesigned to elliminate potential
starvation problem.
- reported by Gottlob Frege <gottlobfrege at gmail.com>
* ptw32_threadDestroy.c (ptw32_threadDestroy): Implicit threads were
not closing their Win32 thread duplicate handle.
- reported by Dmitrii Semii <bogolt at gmail.com>
2005-01-25 Ralf Kubis <RKubis at mc.com>
* Attempted acquisition of recursive mutex was causing waiting
threads to not be woken when the mutex is released.
* GNUmakefile (GCE): Generate correct version resource comments.
2005-01-01 Konstantin Voronkov <beowinkle at yahoo.com>
* pthread_mutex_lock.c (pthread_mutex_lock): The new atomic exchange
mutex algorithm is known to allow a thread to steal the lock off
FIFO waiting threads. The next waiting FIFO thread gets a spurious
wake-up and must attempt to re-acquire the lock. The woken thread
was setting itself as the mutex's owner before the re-acquisition.
2004-11-22 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_cond_wait.c (ptw32_cond_wait_cleanup): Undo change
from 2004-11-02.
* Makefile (DLL_VER): Added for DLL naming suffix - see README.
* GNUmakefile (DLL_VER): Likewise.
* Wmakefile (DLL_VER): Likewise.
* Bmakefile (DLL_VER): Likewise.
* pthread.dsw (version.rc): Added to MSVS workspace.
2004-11-20 Boudewijn Dekker <b.dekker at ellipsis.nl>
* pthread_getspecific.c (pthread_getspecific): Check for
invalid (NULL) key argument.
2004-11-19 Ross Johnson <rpj at callisto.canberra.edu.au>
* config.h (PTW32_THREAD_ID_REUSE_INCREMENT): Added to allow
building the library for either unique thread IDs like Solaris
or non-unique thread IDs like Linux; allows application developers
to override the library's default insensitivity to some apps
that may not be strictly POSIX compliant.
* version.rc: New resource module to encode version information
within the DLL.
* pthread.h: Added PTW32_VERSION* defines and grouped sections
required by resource compiler together; bulk of file is skipped
if RC_INVOKED. Defined some error numbers and other names for
Borland compiler.
2004-11-02 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_cond_wait.c (ptw32_cond_wait_cleanup): Lock CV mutex at
start of cleanup handler rather than at the end.
* implement.h (PTW32_THREAD_REUSE_EMPTY): Renamed from *_BOTTOM.
(ptw32_threadReuseBottom): New global variable.
* global.c (ptw32_threadReuseBottom): Declare new variable.
* ptw32_reuse.c (ptw32_reuse): Change reuse LIFO stack to LILO queue
to more evenly distribute use of reusable thread IDs; use renamed
PTW32_THREAD_REUSE_EMPTY.
* ptw32_processTerminate.c (ptw2_processTerminate): Use renamed
PTW32_THREAD_REUSE_EMPTY.
2004-10-31 Ross Johnson <rpj at callisto.canberra.edu.au>
* implement.h (PThreadState): Add new state value
'PThreadStateCancelPending'.
* pthread_testcancel.c (pthread_testcancel): Use new thread
'PThreadStateCancelPending' state as short cut to avoid entering
kernel space via WaitForSingleObject() call. This was obviated
by user space sema acquisition in sem_wait() and sem_timedwait(),
which are also cancelation points. A call to pthread_testcancel()
was required, which introduced a kernel call, effectively nullifying
any gains made by the user space sem acquisition checks.
* pthread_cancel.c (pthread_cancel): Set new thread
'PThreadStateCancelPending' state.
2004-10-29 Ross Johnson <rpj at callisto.canberra.edu.au>
* implement.h (pthread_t): Renamed to ptw32_thread_t; struct contains
all thread state.
* pthread.h (ptw32_handle_t): New general purpose struct to serve
as a handle for various reusable object IDs - currently only used
by pthread_t; contains a pointer to ptw32_thread_t (thread state)
and a general purpose uint for use as a reuse counter or flags etc.
(pthread_t): typedef'ed to ptw32_handle_t; the uint is the reuse
counter that allows the library to maintain unique POSIX thread IDs.
When the pthread struct reuse stack was introduced, threads would
often acquire an identical ID to a previously destroyed thread. The
same was true for the pre-reuse stack library, by virtue of pthread_t
being the address of the thread struct. The new pthread_t retains
the reuse stack but provides virtually unique thread IDs.
* sem_wait.c (ptw32_sem_wait_cleanup): New routine used for
cancelation cleanup.
* sem_timedwait.c (ptw32_sem_timedwait_cleanup): Likewise.
2004-10-22 Ross Johnson <rpj at callisto.canberra.edu.au>
* sem_init.c (sem_init): Introduce a 'lock' element in order to
replace the interlocked operations with conventional serialisation.
This is needed in order to be able to atomically modify the sema
value and perform Win32 sema release operations. Win32 semaphores are
used instead of events in order to support efficient multiple posting.
If the whole modify/release isn't atomic, a race between
sem_timedwait() and sem_post() could result in a release when there is
no waiting semaphore, which would cause too many threads to proceed.
* sem_wait.c (sem_wait): Use new 'lock'element.
* sem_timedwait.c (sem_timedwait): Likewise.
* sem_trywait.c (sem_trywait): Likewise.
* sem_post.c (sem_post): Likewise.
* sem_post_multiple.c (sem_post_multiple): Likewise.
* sem_getvalue.c (sem_getvalue): Likewise.
* ptw32_semwait.c (ptw32_semwait): Likewise.
* sem_destroy.c (sem_destroy): Likewise; also tightened the conditions
for semaphore destruction; in particular, a semaphore will not be
destroyed if it has waiters.
* sem_timedwait.c (sem_timedwait): Added cancel cleanup handler to
restore sema value when cancelled.
* sem_wait.c (sem_wait): Likewise.
2004-10-21 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent()
rather than SetEvent() to reset the event if there are no waiters.
2004-10-19 Ross Johnson <rpj at callisto.canberra.edu.au>
* sem_init.c (sem_init): New semaphore model based on the same idea
as mutexes, i.e. user space interlocked check to avoid
unnecessarily entering kernel space. Wraps the Win32 semaphore and
keeps it's own counter. Although the motivation to do this has existed
for a long time, credit goes to Alexander Terekhov for providing
the logic. I have deviated slightly from AT's logic to add the waiters
count, which has made the code more complicated by adding cancelation
cleanup. This also appears to have broken the VCE (C++ EH) version of
the library (the same problem as previously reported - see BUGS #2),
only apparently not fixable using the usual workaround, nor by turning
all optimisation off. The GCE version works fine, so it is presumed to
be a bug in MSVC++ 6.0. The cancelation exception is thrown and caught
correctly, but the cleanup class destructor is never called. The failing
test is tests\semaphore4.c.
* sem_wait.c (sem_wait): Implemented user space check model.
* sem_post.c (sem_post): Likewise.
* sem_trywait.c (sem_trywait): Likewise.
* sem_timedwait.c (sem_timedwait): Likewise.
* sem_post_multiple.c (sem_post_multiple): Likewise.
* sem_getvalue.c (sem_getvalue): Likewise.
* ptw32_semwait.c (ptw32_semwait): Likewise.
* implement.h (sem_t_): Add counter element.
2004-10-15 Ross Johnson <rpj at callisto.canberra.edu.au>
* implement.h (pthread_mutex_t_): Use an event in place of
the POSIX semaphore.
* pthread_mutex_init.c: Create the event; remove semaphore init.
* pthread_mutex_destroy.c: Delete the event.
* pthread_mutex_lock.c: Replace the semaphore wait with the event wait.
* pthread_mutex_trylock.c: Likewise.
* pthread_mutex_timedlock.c: Likewise.
* pthread_mutex_unlock.c: Set the event.
2004-10-14 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_mutex_lock.c (pthread_mutex_lock): New algorithm using
Terekhov's xchg based variation of Drepper's cmpxchg model.
Theoretically, xchg uses fewer clock cycles than cmpxchg (using IA-32
as a reference), however, in my opinion bus locking dominates the
equation on smp systems, so the model with the least number of bus
lock operations in the execution path should win, which is Terekhov's
variant. On IA-32 uni-processor systems, it's faster to use the
CMPXCHG instruction without locking the bus than to use the XCHG
instruction, which always locks the bus. This makes the two variants
equal for the non-contended lock (fast lane) execution path on up
IA-32. Testing shows that the xchg variant is faster on up IA-32 as
well if the test forces higher lock contention frequency, even though
kernel calls should be dominating the times (on up IA-32, both
variants used CMPXCHG instructions and neither locked the bus).
* pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly.
* pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly.
* pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly.
* ptw32_InterlockedCompareExchange.c (ptw32_InterlockExchange): New
function.
(PTW32_INTERLOCKED_EXCHANGE): Sets up macro to use inlined
ptw32_InterlockedExchange.
* implement.h (PTW32_INTERLOCKED_EXCHANGE): Set default to
InterlockedExchange().
* Makefile: Building using /Ob2 so that asm sections within inline
functions are inlined.
2004-10-08 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_mutex_destroy.c (pthread_mutex_destroy): Critical Section
element is no longer required.
* pthread_mutex_init.c (pthread_mutex_init): Likewise.
* pthread_mutex_lock.c (pthread_mutex_lock): New algorithm following
Drepper's paper at http://people.redhat.com/drepper/futex.pdf, but
using the existing semaphore in place of the futex described in the
paper. Idea suggested by Alexander Terekhov - see:
http://sources.redhat.com/ml/pthreads-win32/2003/msg00108.html
* pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly.
* pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly.
* pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly.
* pthread_barrier_wait.c (pthread_barrier_wait): Use inlined version
of InterlockedCompareExchange() if possible - determined at
build-time.
* pthread_spin_destroy.c pthread_spin_destroy(): Likewise.
* pthread_spin_lock.c pthread_spin_lock():Likewise.
* pthread_spin_trylock.c (pthread_spin_trylock):Likewise.
* pthread_spin_unlock.c (pthread_spin_unlock):Likewise.
* ptw32_InterlockedCompareExchange.c: Sets up macro for inlined use.
* implement.h (pthread_mutex_t_): Remove Critical Section element.
(PTW32_INTERLOCKED_COMPARE_EXCHANGE): Set to default non-inlined
version of InterlockedCompareExchange().
* private.c: Include ptw32_InterlockedCompareExchange.c first for
inlining.
* GNUmakefile: Add commandline option to use inlined
InterlockedCompareExchange().
* Makefile: Likewise.
2004-09-27 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_mutex_lock.c (pthread_mutex_lock): Separate
PTHREAD_MUTEX_NORMAL logic since we do not need to keep or check some
state required by other mutex types; do not check mutex pointer arg
for validity - leave this to the system since we are only checking
for NULL pointers. This should improve speed of NORMAL mutexes and
marginally improve speed of other type.
* pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise.
* pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise; also avoid
entering the critical section for the no-waiters case, with approx.
30% reduction in lock/unlock overhead for this case.
* pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise; also
no longer keeps mutex if post-timeout second attempt succeeds - this
will assist applications that wish to impose strict lock deadlines,
rather than simply to escape from frozen locks.
2004-09-09 Tristan Savatier <tristan at mpegtv.com>
* pthread.h (struct pthread_once_t_): Qualify the 'done' element
as 'volatile'.
* pthread_once.c: Concerned about possible race condition,
specifically on MPU systems re concurrent access to multibyte types.
[Maintainer's note: the race condition is harmless on SPU systems
and only a problem on MPU systems if concurrent access results in an
exception (presumably generated by a hardware interrupt). There are
other instances of similar harmless race conditions that have not
been identified as issues.]
2004-09-09 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread.h: Declare additional types as volatile.
2004-08-27 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_barrier_wait.c (pthread_barrier_wait): Remove excessive code
by substituting the internal non-cancelable version of sem_wait
(ptw32_semwait).
2004-08-25 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_join.c (pthread_join): Rewrite and re-order the conditional
tests in an attempt to improve efficiency and remove a race
condition.
2004-08-23 Ross Johnson <rpj at callisto.canberra.edu.au>
* create.c (pthread_create): Don't create a thread if the thread
id pointer location (first arg) is inaccessible. A memory
protection fault will result if the thread id arg isn't an accessible
location. This is consistent with GNU/Linux but different to
Solaris or MKS (and possibly others), which accept NULL as meaning
'don't return the created thread's ID'. Applications that run
using pthreads-win32 will run on all other POSIX threads
implementations, at least w.r.t. this feature.
It was decided not to copy the Solaris et al behaviour because,
although it would have simplified some application porting (but only
from Solaris to Windows), the feature is not technically necessary,
and the alternative segfault behaviour helps avoid buggy application
code.
2004-07-01 Anuj Goyal <anuj.goyal at gmail.com>
* builddmc.bat: New; Windows bat file to build the library.
* config.h (__DMC__): Support for Digital Mars compiler.
* create.c (__DMC__): Likewise.
* pthread_exit.c (__DMC__): Likewise.
* pthread_join.c (__DMC__): Likewise.
* ptw32_threadDestroy.c (__DMC__): Likewise.
* ptw32_threadStart.c (__DMC__): Likewise.
* ptw32_throw.c (__DMC__): Likewise.
2004-06-29 Anuj Goyal <anuj.goyal at gmail.com>
* pthread.h (__DMC__): Initial support for Digital Mars compiler.
2004-06-29 Will Bryant <will.bryant at ecosm.com>
* README.Borland: New; description of Borland changes.
* Bmakefile: New makefile for the Borland make utility.
* ptw32_InterlockedCompareExchange.c:
Add Borland compatible asm code.
2004-06-26 Jason Bard <BardJA at Npt.NUWC.Navy.Mil>
* pthread.h (HAVE_STRUCT_TIMESPEC): If undefined, define it
to avoid timespec struct redefined errors elsewhere in an
application.
2004-06-21 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER): Mutex
initialiser added for compatibility with Linux threads and
others; currently not included in SUSV3.
* pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER): Likewise.
* pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Likewise.
* pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise.
* ptw32_mutex_check_need_init.c (ptw32_mutex_check_need_init):
Add new initialisers.
* pthread_mutex_lock.c (pthread_mutex_lock): Check for new
initialisers.
* pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise.
* pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
* pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise.
* pthread_mutex_destroy.c (pthread_mutex_destroy): Likewise.
2004-05-20 Ross Johnson <rpj at callisto.canberra.edu.au>
* README.NONPORTABLE: Document pthread_win32_test_features_np().
* FAQ: Update various answers.
2004-05-19 Ross Johnson <rpj at callisto.canberra.edu.au>
* Makefile: Don't define _WIN32_WINNT on compiler command line.
* GNUmakefile: Likewise.
2004-05-16 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_cancel.c (pthread_cancel): Adapted to use auto-detected
QueueUserAPCEx features at run-time.
(ptw32_RegisterCancelation): Drop in replacement for QueueUserAPCEx()
if it can't be used. Provides older style non-preemptive async
cancelation.
* pthread_win32_attach_detach_np.c (pthread_win32_attach_np):
Auto-detect quserex.dll and the availability of alertdrv.sys;
initialise and close on process attach/detach.
* global.c (ptw32_register_cancelation): Pointer to either
QueueUserAPCEx() or ptw32_RegisterCancelation() depending on
availability. QueueUserAPCEx makes pre-emptive async cancelation
possible.
* implement.h: Add definitions and prototypes related to QueueUserAPC.
2004-05-16 Panagiotis E. Hadjidoukas <peh at hpclab.ceid.upatras.gr>
* QueueUserAPCEx (separate contributed package): Provides preemptive
APC feature.
* pthread_cancel.c (pthread_cancel): Initial integration of
QueueUserAPCEx into pthreads-win32 to provide true pre-emptive
async cancelation of threads, including blocked threads.
2004-05-06 Makoto Kato <raven at oldskool.jp>
* pthread.h (DWORD_PTR): Define typedef for older MSVC.
* pthread_cancel.c (AMD64): Add architecture specific Context register.
* ptw32_getprocessors.c: Use correct types (DWORD_PTR) for mask
variables.
2004-04-06 P. van Bruggen <pietvb at newbridges.nl>
* ptw32_threadDestroy.c: Destroy threadLock mutex to
close a memory leak.
2004-02-13 Gustav Hallberg <gustav at virtutech.com>
* pthread_equal.c: Remove redundant equality logic.
2003-12-10 Philippe Di Cristo <philipped at voicebox.com>
* sem_timedwait.c (sem_timedwait): Fix timeout calculations.
2003-10-20 Alexander Terekhov <TEREKHOV at de.ibm.com>
* pthread_mutex_timedlock.c (ptw32_semwait): Move to individual module.
* ptw32_semwait.c: New module.
* pthread_cond_wait.c (ptw32_cond_wait_cleanup): Replace cancelable
sem_wait() call with non-cancelable ptw32_semwait() call.
* pthread.c (private.c): Re-order for inlining. GNU C warned that
function ptw32_semwait() was defined 'inline' after it was called.
* pthread_cond_signal.c (ptw32_cond_unblock): Likewise.
* pthread_delay_np.c: Disable Watcom warning with comment.
* *.c (process.h): Remove include from .c files. This is conditionally
included by the common project include files.
2003-10-20 James Ewing <james.ewing at sveasoft.com>
* ptw32_getprocessors.c: Some Win32 environments don't have
GetProcessAffinityMask(), so always return CPU count = 1 for them.
* config.h (NEED_PROCESSOR_AFFINITY_MASK): Define for WinCE.
2003-10-15 Ross Johnson <ross at callisto.canberra.edu.au>
* Re-indented all .c files using default GNU style to remove assorted
editor ugliness (used GNU indent utility in default style).
2003-10-15 Alex Blanco <Alex.Blanco at motorola.com>
* sem_init.c (sem_init): Would call CreateSemaphore even if the sema
struct calloc failed; was not freeing calloced memory if either
CreateSemaphore or CreateEvent failed.
2003-10-14 Ross Johnson <ross at callisto.canberra.edu.au>
* pthread.h: Add Watcom compiler compatibility. Esssentially just add
the cdecl attribute to all exposed function prototypes so that Watcom
generates function call code compatible with non-Watcom built libraries.
By default, Watcom uses registers to pass function args if possible rather
than pushing to stack.
* semaphore.h: Likewise.
* sched.h: Likewise.
* pthread_cond_wait.c (ptw32_cond_wait_cleanup): Define with cdecl attribute
for Watcom compatibility. This routine is called via pthread_cleanup_push so
it had to match function arg definition.
* Wmakefile: New makefile for Watcom builds.
2003-09-14 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_setschedparam.c (pthread_setschedparam): Attempt to map
all priority levels between max and min (as returned by
sched_get_priority_min/max) to reasonable Win32 priority levels - i.e.
levels between THREAD_PRIORITY_LOWEST/IDLE to THREAD_PRIORITY_LOWEST and
between THREAD_PRIORITY_HIGHEST/TIME_CRITICAL to THREAD_PRIORITY_HIGHEST
while others remain unchanged; record specified thread priority level
for return by pthread_getschedparam.
Note that, previously, specified levels not matching Win32 priority levels
would silently leave the current thread priority unaltered.
* pthread_getschedparam.c (pthread_getschedparam): Return the priority
level specified by the latest pthread_setschedparam or pthread_create rather
than the actual running thread priority as returned by GetThreadPriority - as
required by POSIX. I.e. temporary or adjusted actual priority levels are not
returned by this routine.
* pthread_create.c (pthread_create): For priority levels specified via
pthread attributes, attempt to map all priority levels between max and
min (as returned by sched_get_priority_min/max) to reasonable Win32
priority levels; record priority level given via attributes, or
inherited from parent thread, for later return by pthread_getschedparam.
* ptw32_new.c (ptw32_new): Initialise pthread_t_ sched_priority element.
* pthread_self.c (pthread_self): Set newly created implicit POSIX thread
sched_priority to Win32 thread's current actual priority. Temporarily
altered priorities can't be avoided in this case.
* implement.h (struct pthread_t_): Add new sched_priority element.
2003-09-12 Ross Johnson <rpj at callisto.canberra.edu.au>
* sched_get_priority_min.c (sched_get_priority_min): On error should return -1
with errno set.
* sched_get_priority_max.c (sched_get_priority_max): Likewise.
2003-09-03 Ross Johnson <rpj at callisto.canberra.edu.au>
* w32_cancelableWait.c (ptw32_cancelable_wait): Allow cancelation
of implicit POSIX threads as well.
2003-09-02 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np):
Add comment.
* pthread_exit.c (pthread_exit): Fix to recycle the POSIX thread handle in
addition to calling user TSD destructors. Move the implicit POSIX thread exit
handling to ptw32_throw to centralise the logic.
* ptw32_throw.c (ptw32_throw): Implicit POSIX threads have no point
to jump or throw to, so cleanup and exit the thread here in this case. For
processes using the C runtime, the exit code will be set to the POSIX
reason for the throw (i.e. PTHREAD_CANCEL or the value given to pthread_exit).
Note that pthread_exit() already had similar logic, which has been moved to
here.
* ptw32_threadDestroy.c (ptw32_threadDestroy): Don't close the Win32 handle
of implicit POSIX threads - expect this to be done by Win32?
2003-09-01 Ross Johnson <rpj at callisto.canberra.edu.au>
* pthread_self.c (pthread_self): The newly aquired pthread_t must be
assigned to the reuse stack, not freed, if the routine fails somehow.
2003-08-13 Ross Johnson <rpj at ise.canberra.edu.au>
* pthread_getschedparam.c (pthread_getschedparam): An invalid thread ID
parameter was returning an incorrect error value; now uses a more exhaustive
check for validity.
* pthread_setschedparam.c (pthread_setschedparam): Likewise.
* pthread_join.c (pthread_join): Now uses a more exhaustive
check for validity.
* pthread_detach.c (pthread_detach): Likewise.
* pthread_cancel.c (pthread_cancel): Likewise.
* ptw32_threadDestroy.c (ptw32_threadDestroy): pthread_t structs are
never freed - push them onto a stack for reuse.
* ptw32_new.c (ptw32_new): Check for reusable pthread_t before dynamically
allocating new memory for the struct.
* pthread_kill.c (pthread_kill): New file; new routine; takes only a zero
signal arg so that applications can check the thread arg for validity; checks
that the underlying Win32 thread HANDLE is valid.
* pthread.h (pthread_kill): Add prototype.
* ptw32_reuse.c (ptw32_threadReusePop): New file; new routine; pop a
pthread_t off the reuse stack. pthread_t_ structs that have been destroyed, i.e.
have exited detached or have been joined, are cleaned up and put onto a reuse
stack. Consequently, thread IDs are no longer freed once calloced. The library
will attempt to get a struct off this stack before asking the system to alloc
new memory when creating threads. The stack is guarded by a global mutex.
(ptw32_threadReusePush): New routine; push a pthread_t onto the reuse stack.
* implement.h (ptw32_threadReusePush): Add new prototype.
(ptw32_threadReusePop): Likewise.
(pthread_t): Add new element.
* ptw32_processTerminate.c (ptw32_processTerminate): Delete the thread
reuse lock; free all thread ID structs on the thread reuse stack.
* ptw32_processInitialize.c (ptw32_processInitialize): Initialise the
thread reuse lock.
2003-07-19 Ross Johnson <rpj at ise.canberra.edu.au>
* GNUmakefile: modified to work under MsysDTK environment.
* pthread_spin_lock.c (pthread_spin_lock): Check for NULL arg.
* pthread_spin_unlock.c (pthread_spin_unlock): Likewise.
* pthread_spin_trylock.c (pthread_spin_trylock): Likewise;
fix incorrect pointer value if lock is dynamically initialised by
this function.
* sem_init.c (sem_init): Initialise sem_t value to quell compiler warning.
* sem_destroy.c (sem_destroy): Likewise.
* ptw32_threadStart.c (non-MSVC code sections): Include <exception> rather
than old-style <new.h>; fix all std:: namespace entities such as
std::terminate_handler instances and associated methods.
* ptw32_callUserDestroyRoutines.c (non-MSVC code sections): Likewise.
2003-06-24 Piet van Bruggen <pietvb at newbridges.nl>
* pthread_spin_destroy.c (pthread_spin_destroy): Was not freeing the
spinlock struct.
2003-06-22 Nicolas Barry <boozai at yahoo.com>
* pthread_mutex_destroy.c (pthread_mutex_destroy): When called
with a recursive mutex that was locked by the current thread, the
function was failing with a success return code.
2003-05-15 Steven Reddie <Steven.Reddie at ca.com>
* pthread_win32_attach_detach_np.c (pthread_win32_process_detach_np):
NULLify ptw32_selfThreadKey after the thread is destroyed, otherwise
destructors calling pthreads routines might resurrect it again, creating
memory leaks. Call the underlying Win32 Tls routine directly rather than
pthread_setspecific().
(pthread_win32_thread_detach_np): Likewise.
2003-05-14 Viv <vcotirlea at hotmail.com>
* pthread.dsp: Change /MT compile flag to /MD.
2003-03-04 Alexander Terekhov <TEREKHOV at de.ibm.com>
* pthread_mutex_timedlock.c (pthread_mutex_timedlock): Fix failure to
set ownership of mutex on second grab after abstime timeout.
- bug reported by Robert Strycek <strycek at posam.sk>
2002-12-17 Thomas Pfaff <tpfaff at gmx.net>
* pthread_mutex_lock.c (ptw32_semwait): New static routine to provide
a non-cancelable sem_wait() function. This is consistent with the
way that pthread_mutex_timedlock.c does it.
(pthread_mutex_lock): Use ptw32_semwait() instead of sem_wait().
2002-12-11 Thomas Pfaff <tpfaff at gmx.net>
* pthread_mutex_trylock.c: Should return EBUSY rather than EDEADLK.
* pthread_mutex_destroy.c: Remove redundant ownership test (the
trylock call does this for us); do not destroy a recursively locked
mutex.
2002-09-20 Michael Johnson <michaelj at maine.rr.com>
* pthread_cond_destroy.c (pthread_cond_destroy):
When two different threads exist, and one is attempting to
destroy a condition variable while the other is attempting to
initialize a condition variable that was created with
PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink
the ptw32_cond_list_lock critical section to fix it.
2002-07-31 Ross Johnson <rpj at special.ise.canberra.edu.au>
* ptw32_threadStart.c (ptw32_threadStart): Thread cancelLock
destruction moved to ptw32_threadDestroy().
* ptw32_threadDestroy.c (ptw32_threadDestroy): Destroy
the thread's cancelLock. Moved here from ptw32_threadStart.c
to cleanup implicit threads as well.
2002-07-30 Alexander Terekhov <TEREKHOV at de.ibm.com>
* pthread_cond_wait.c (ptw32_cond_wait_cleanup):
Remove code designed to avoid/prevent spurious wakeup
problems. It is believed that the sem_timedwait() call
is consuming a CV signal that it shouldn't and this is
breaking the avoidance logic.
2002-07-30 Ross Johnson <rpj at ise.canberra.edu.au>
* sem_timedwait.c (sem_timedwait): Tighten checks for
unreasonable abstime values - that would result in
unexpected timeout values.
* w32_CancelableWait.c (ptw32_cancelable_wait):
Tighten up return value checking and add comments.
2002-06-08 Ross Johnson <rpj at special.ise.canberra.edu.au>
* sem_getvalue.c (sem_getvalue): Now returns a value for the
NEED_SEM version (i.e. earlier versions of WinCE).
2002-06-04 Rob Fanner <rfanner at stonethree.com>
* sem_getvalue.c (sem_getvalue): The Johnson M. Hart
approach didn't work - we are forced to take an
intrusive approach. We try to decrement the sema
and then immediately release it again to get the
value. There is a small probability that this may
block other threads, but only momentarily.
2002-06-03 Ross Johnson <rpj at ise.canberra.edu.au>
* sem_init.c (sem_init): Initialise Win32 semaphores
to _POSIX_SEM_VALUE_MAX (which this implementation
defines in pthread.h) so that sem_getvalue() can use
the trick described in the comments in sem_getvalue().
* pthread.h (_POSIX_SEM_VALUE_MAX): Defined.
(_POSIX_SEM_NSEMS_MAX): Defined - not used but may be
useful for source code portability.
2002-06-03 Rob Fanner <rfanner at stonethree.com>
* sem_getvalue.c (sem_getvalue): Did not work on NT.
Use approach suggested by Johnson M. Hart in his book
"Win32 System Programming".
2002-02-28 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* errno.c: Compiler directive was incorrectly including code.
* pthread.h: Conditionally added some #defines from config.h
needed when not building the library. e.g. NEED_ERRNO, NEED_SEM.
(PTW32_DLLPORT): Now only defined if _DLL defined.
(_errno): Compiler directive was incorrectly including prototype.
* sched.h: Conditionally added some #defines from config.h
needed when not building the library.
* semaphore.h: Replace an instance of NEED_SEM that should
have been NEED_ERRNO. This change currently has nil effect.
* GNUmakefile: Correct some recent changes.
* Makefile: Add rule to generate pre-processor output.
2002-02-23 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* pthread_rwlock_timedrdlock.c: New - untested.
* pthread_rwlock_timedwrlock.c: New - untested.
* Testsuite passed (except known MSVC++ problems)
* pthread_cond_destroy.c: Expand the time change
critical section to solve deadlock problem.
* pthread.c: Add all remaining C modules.
* pthread.h: Use dllexport/dllimport attributes on functions
to avoid using pthread.def.
* sched.h: Likewise.
* semaphore.h: Likewise.
* GNUmakefile: Add new targets for single translation
unit build to maximise inlining potential; generate
pthread.def automatically.
* Makefile: Likewise, but no longer uses pthread.def.
2002-02-20 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* pthread_cond_destroy.c (pthread_cond_destroy):
Enter the time change critical section earlier.
2002-02-17 Ross Johnson <rpj at setup1.ise.canberra.edu.au
* Testsuite passed.
* pthread_timechange_handler_np.c: New; following
a suggestion from Alexander Terekhov that CVs should
be broadcast so that they all re-evaluate their
condition variables and reset a new timeout if
required, whenever an application receives a
WM_TIMECHANGE message. This message indicates that
the system time has been changed. Therefore, CVs
waiting for a timeout set as an abs_time will possibly
not wake up at the expected time. Some applications
may not be tolerant of this.
* pthread_cond_init.c: Add CV to linked list.
* pthread_cond_destroy.c: Remove CV from linked list.
* global.c (ptw32_cond_list_head): New variable.
(ptw32_cond_list_tail): New variable.
(ptw32_cond_list_cs): New critical section.
* ptw32_processInitialize (ptw32_cond_list_cs): Initialize.
* ptw32_processTerminate (ptw32_cond_list_cs): Delete.
* Reduce executable size.
-----------------------
When linking with the static library, only those
routines actually called, either directly or indirectly
should be included.
[Gcc has the -ffunction-segments option to do this but MSVC
doesn't have this feature as far as I can determine. Other
compilers are undetermined as well. - rpj]
* spin.c: Split file into function segments.
* ptw32_spinlock_check_need_init.c: Separated routine from spin.c.
* pthread_spin_init.c: Likewise.
* pthread_spin_destroy.c: Likewise.
* pthread_spin_lock.c: Likewise.
* pthread_spin_unlock.c: Likewise.
* pthread_spin_trylock.c: Likewise.
* sync.c: Split file into function segments.
* pthread_detach.c: Separated routine from sync.c.
* pthread_join.c: Likewise.
* tsd.c: Split file into function segments.
* pthread_key_create.c: Separated routine from tsd.c.
* pthread_key_delete.c: Likewise.
* pthread_setspecific.c: Likewise.
* pthread_getspecific.c: Likewise.
* sched.c: Split file into function segments.
* pthread_attr_setschedpolicy.c: Separated routine from sched.c.
* pthread_attr_getschedpolicy.c: Likewise.
* pthread_attr_setschedparam.c: Likewise.
* pthread_attr_getschedparam.c: Likewise.
* pthread_attr_setinheritsched.c: Likewise.
* pthread_attr_getinheritsched.c: Likewise.
* pthread_setschedparam.c: Likewise.
* pthread_getschedparam.c: Likewise.
* sched_get_priority_max.c: Likewise.
* sched_get_priority_min.c: Likewise.
* sched_setscheduler.c: Likewise.
* sched_getscheduler.c: Likewise.
* sched_yield.c: Likewise.
2002-02-16 Ross Johnson <rpj at setup1.ise.canberra.edu.au
Reduce executable size.
-----------------------
When linking with the static library, only those
routines actually called, either directly or indirectly
should be included.
[Gcc has the -ffunction-segments option to do this but MSVC
doesn't have this feature as far as I can determine. Other
compilers are undetermined as well. - rpj]
* mutex.c: Split file into function segments.
* pthread_mutexattr_destroy.c: Separated routine from mutex.c
* pthread_mutexattr_getpshared.c: Likewise.
* pthread_mutexattr_gettype.c: Likewise.
* pthread_mutexattr_init.c: Likewise.
* pthread_mutexattr_setpshared.c: Likewise.
* pthread_mutexattr_settype.c: Likewise.
* ptw32_mutex_check_need_init.c: Likewise.
* pthread_mutex_destroy.c: Likewise.
* pthread_mutex_init.c: Likewise.
* pthread_mutex_lock.c: Likewise.
* pthread_mutex_timedlock.c: Likewise.
* pthread_mutex_trylock.c: Likewise.
* pthread_mutex_unlock.c: Likewise.
* private.c: Split file into function segments.
* ptw32_InterlockedCompareExchange.c: Separated routine from private.c
* ptw32_callUserDestroyRoutines.c: Likewise.
* ptw32_getprocessors.c: Likewise.
* ptw32_processInitialize.c: Likewise.
* ptw32_processTerminate.c: Likewise.
* ptw32_threadDestroy.c: Likewise.
* ptw32_threadStart.c: Likewise.
* ptw32_throw.c: Likewise.
* ptw32_timespec.c: Likewise.
* ptw32_tkAssocCreate.c: Likewise.
* ptw32_tkAssocDestroy.c: Likewise.
* rwlock.c: Split file into function segments.
* pthread_rwlockattr_destroy.c: Separated routine from rwlock.c
* pthread_rwlockattr_getpshared.c: Likewise.
* pthread_rwlockattr_init.c: Likewise.
* pthread_rwlockattr_setpshared.c: Likewise.
* ptw32_rwlock_check_need_init.c: Likewise.
* pthread_rwlock_destroy.c: Likewise.
* pthread_rwlock_init.c: Likewise.
* pthread_rwlock_rdlock.c: Likewise.
* pthread_rwlock_tryrdlock.c: Likewise.
* pthread_rwlock_trywrlock.c: Likewise.
* pthread_rwlock_unlock.c: Likewise.
* pthread_rwlock_wrlock.c: Likewise.
2002-02-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au
Reduce executable size.
-----------------------
When linking with the static library, only those
routines actually called, either directly or indirectly
should be included.
[Gcc has the -ffunction-segments option to do this but MSVC
doesn't have this feature as far as I can determine. Other
compilers are undetermined as well. - rpj]
* nonportable.c: Split file into function segments.
* np_delay.c: Separated routine from nonportable.c
* np_getw32threadhandle.c: Likewise.
* np_mutexattr_setkind.c: Likewise.
* np_mutexattr_getkind.c: Likewise.
* np_num_processors.c: Likewise.
* np_win32_attach_detach.c: Likewise.
* misc.c: Split file into function segments.
* pthread_equal.c: Separated routine from nonportable.c.
* pthread_getconcurrency.c: Likewise.
* pthread_once.c: Likewise.
* pthread_self.c: Likewise.
* pthread_setconcurrency.c: Likewise.
* ptw32_calloc.c: Likewise.
* ptw32_new.c: Likewise.
* w32_CancelableWait.c: Likewise.
2002-02-09 Ross Johnson <rpj at setup1.ise.canberra.edu.au
Reduce executable size.
-----------------------
When linking with the static library, only those
routines actually called, either directly or indirectly
should be included.
[Gcc has the -ffunction-segments option to do this but MSVC
doesn't have this feature as far as I can determine. Other
compilers are undetermined as well. - rpj]
* condvar.c: Split file into function segments.
* pthread_condattr_destroy.c: Separated routine from condvar.c.
* pthread_condattr_getpshared.c: Likewise.
* pthread_condattr_init.c: Likewise.
* pthread_condattr_setpshared.c: Likewise.
* ptw32_cond_check_need_init.c: Likewise.
* pthread_cond_destroy.c: Likewise.
* pthread_cond_init.c: Likewise.
* pthread_cond_signal.c: Likewise.
* pthread_cond_wait.c: Likewise.
2002-02-07 Alexander Terekhov<TEREKHOV at de.ibm.com>
* nonportable.c (pthread_delay_np): Make a true
cancelation point. Deferred cancels will interrupt the
wait.
2002-02-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au
* misc.c (ptw32_new): Add creation of cancelEvent so that
implicit POSIX threads (Win32 threads with a POSIX face)
are cancelable; mainly so that pthread_delay_np doesn't fail
if called from the main thread.
* create.c (pthread_create): Remove creation of cancelEvent
from here; now in ptw32_new().
Reduce executable size.
-----------------------
When linking with the static library, only those
routines actually called, either directly or indirectly
should be included.
[Gcc has the -ffunction-segments option to do this but MSVC
doesn't have this feature as far as I can determine. Other
compilers are undetermined as well. - rpj]
* barrier.c: All routines are now in separate compilation units;
This file is used to congregate the separate modules for
potential inline optimisation and backward build compatibility.
* cancel.c: Likewise.
* pthread_barrierattr_destroy.c: Separated routine from cancel.c.
* pthread_barrierattr_getpshared.c: Likewise.
* pthread_barrierattr_init.c: Likewise.
* pthread_barrierattr_setpshared.c: Likewise.
* pthread_barrier_destroy.c: Likewise.
* pthread_barrier_init.c: Likewise.
* pthread_barrier_wait.c: Likewise.
* pthread_cancel.c: Likewise.
* pthread_setcancelstate.c: Likewise.
* pthread_setcanceltype.c: Likewise.
* pthread_testcancel.c: Likewise.
2002-02-04 Max Woodbury <mtew at cds.duke.edu>
Reduced name space pollution.
-----------------------------
When the appropriate symbols are defined, the headers
will restrict the definitions of new names. In particular,
it must be possible to NOT include the <windows.h>
header and related definitions with some combination
of symbol definitions. Secondly, it should be possible
that additional definitions should be limited to POSIX
compliant symbols by the definition of appropriate symbols.
* pthread.h: POSIX conditionals.
* sched.h: POSIX conditionals.
* semaphore.h: POSIX conditionals.
* semaphore.c: Included <limits.h>.
(sem_init): Changed magic 0x7FFFFFFFL to INT_MAX.
(sem_getvalue): Trial version.
Reduce executable size.
-----------------------
When linking with the static library, only those
routines actually called, either directly or indirectly
should be included.
[Gcc has the -ffunction-segments option to do this but MSVC
doesn't have this feature as far as I can determine. Other
compilers are undetermined as well. - rpj]
* semaphore.c: All routines are now in separate compilation units;
This file is used to congregate the separate modules for
potential inline optimisation and backward build compatibility.
* sem_close.c: Separated routine from semaphore.c.
* ptw32_decrease_semaphore.c: Likewise.
* sem_destroy.c: Likewise.
* sem_getvalue.c: Likewise.
* ptw32_increase_semaphore.c: Likewise.
* sem_init.c: Likewise.
* sem_open.c: Likewise.
* sem_post.c: Likewise.
* sem_post_multiple.c: Likewise.
* sem_timedwait.c: Likewise.
* sem_trywait.c: Likewise.
* sem_unlink.c: Likewise.
* sem_wait.c: Likewise.
2002-02-04 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
The following extends the idea above to the rest of pthreads-win32 - rpj
* attr.c: All routines are now in separate compilation units;
This file is used to congregate the separate modules for
potential inline optimisation and backward build compatibility.
* pthread_attr_destroy.c: Separated routine from attr.c.
* pthread_attr_getdetachstate.c: Likewise.
* pthread_attr_getscope.c: Likewise.
* pthread_attr_getstackaddr.c: Likewise.
* pthread_attr_getstacksize.c: Likewise.
* pthread_attr_init.c: Likewise.
* pthread_attr_is_attr.c: Likewise.
* pthread_attr_setdetachstate.c: Likewise.
* pthread_attr_setscope.c: Likewise.
* pthread_attr_setstackaddr.c: Likewise.
* pthread_attr_setstacksize.c: Likewise.
* pthread.c: Agregation of agregate modules for super-inlineability.
2002-02-02 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* cancel.c: Rearranged some code and introduced checks
to disable cancelation at the start of a thread's cancelation
run to prevent double cancelation. The main problem
arises if a thread is canceling and then receives a subsequent
async cancel request.
* private.c: Likewise.
* condvar.c: Place pragmas around cleanup_push/pop to turn
off inline optimisation (/Obn where n>0 - MSVC only). Various
optimisation switches in MSVC turn this on, which interferes with
the way that cleanup handlers are run in C++ EH and SEH
code. Application code compiled with inline optimisation must
also wrap cleanup_push/pop blocks with the pragmas, e.g.
#pragma inline_depth(0)
pthread_cleanup_push(...)
...
pthread_cleanup_pop(...)
#pragma inline_depth(8)
* rwlock.c: Likewise.
* mutex.c: Remove attempts to inline some functions.
* signal.c: Modify misleading comment.
2002-02-01 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* semaphore.c (sem_trywait): Fix missing errno return
for systems that define NEED_SEM (e.g. early WinCE).
* mutex.c (pthread_mutex_timedlock): Return ENOTSUP
for systems that define NEED_SEM since they don't
have sem_trywait().
2002-01-27 Ross Johnson <rpj at special.ise.canberra.edu.au>
* mutex.c (pthread_mutex_timedlock): New function suggested by
Alexander Terekhov. The logic required to implement this
properly came from Alexander, with some collaboration
with Thomas Pfaff.
(pthread_mutex_unlock): Wrap the waiters check and sema
post in a critical section to prevent a race with
pthread_mutex_timedlock.
(ptw32_timed_semwait): New function;
returns a special result if the absolute timeout parameter
represents a time already passed when called; used by
pthread_mutex_timedwait(). Have deliberately not reused
the name "ptw32_sem_timedwait" because they are not the same
routine.
* condvar.c (ptw32_cond_timedwait): Use the new sem_timedwait()
instead of ptw32_sem_timedwait(), which now has a different
function. See previous.
* implement.h: Remove prototype for ptw32_sem_timedwait.
See next.
(pthread_mutex_t_): Add critical section element for access
to lock_idx during mutex post-timeout processing.
* semaphore.h (sem_timedwait): See next.
* semaphore.c (sem_timedwait): See next.
* private.c (ptw32_sem_timedwait): Move to semaphore.c
and rename as sem_timedwait().
2002-01-18 Ross Johnson <rpj at special.ise.canberra.edu.au>
* sync.c (pthread_join): Was getting the exit code from the
calling thread rather than the joined thread if
defined(__MINGW32__) && !defined(__MSVCRT__).
2002-01-15 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.h: Unless the build explicitly defines __CLEANUP_SEH,
__CLEANUP_CXX, or __CLEANUP_C, then the build defaults to
__CLEANUP_C style cleanup. This style uses setjmp/longjmp
in the cancelation and thread exit implementations and therefore
won't do stack unwinding if linked to applications that have it
(e.g. C++ apps). This is currently consistent with most/all
commercial Unix POSIX threads implementations.
* spin.c (pthread_spin_init): Edit renamed function call.
* nonportable.c (pthread_num_processors_np): New.
(pthread_getprocessors_np): Renamed to ptw32_getprocessors
and moved to private.c.
* private.c (pthread_getprocessors): Moved here from
nonportable.c.
* pthread.def (pthread_getprocessors_np): Removed
from export list.
* rwlock.c (pthread_rwlockattr_init): New.
(pthread_rwlockattr_destroy): New.
(pthread_rwlockattr_getpshared): New.
(pthread_rwlockattr_setpshared): New.
2002-01-14 Ross Johnson <rpj at special.ise.canberra.edu.au>
* attr.c (pthread_attr_setscope): Fix struct pointer
indirection error introduced 2002-01-04.
(pthread_attr_getscope): Likewise.
2002-01-12 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.dsp (SOURCE): Add missing source files.
2002-01-08 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* mutex.c (pthread_mutex_trylock): use
ptw32_interlocked_compare_exchange function pointer
rather than ptw32_InterlockedCompareExchange() directly
to retain portability to non-iX86 processors,
e.g. WinCE etc. The pointer will point to the native
OS version of InterlockedCompareExchange() if the
OS supports it (see ChangeLog entry of 2001-10-17).
2002-01-07 Thomas Pfaff <tpfaff at gmx.net>, Alexander Terekhov <TEREKHOV at de.ibm.com>
* mutex.c (pthread_mutex_init): Remove critical
section calls.
(pthread_mutex_destroy): Likewise.
(pthread_mutex_unlock): Likewise.
(pthread_mutex_trylock): Likewise; uses
ptw32_InterlockedCompareExchange() to avoid need for
critical section; library is no longer i386 compatible;
recursive mutexes now increment the lock count rather
than return EBUSY; errorcheck mutexes return EDEADLCK
rather than EBUSY. This behaviour is consistent with the
Solaris pthreads implementation.
* implement.h (pthread_mutex_t_): Remove critical
section element - no longer needed.
2002-01-04 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* attr.c (pthread_attr_setscope): Add more error
checking and actually store the scope value even
though it's not really necessary.
(pthread_attr_getscope): Return stored value.
* implement.h (pthread_attr_t_): Add new scope element.
* ANNOUNCE: Fix out of date comment next to
pthread_attr_setscope in conformance section.
2001-12-21 Alexander Terekhov <TEREKHOV at de.ibm.com>
* mutex.c (pthread_mutex_lock): Decrementing lock_idx was
not thread-safe.
(pthread_mutex_trylock): Likewise.
2001-10-26 prionx@juno.com
* semaphore.c (sem_init): Fix typo and missing bracket
in conditionally compiled code. Only older versions of
WinCE require this code, hence it doesn't normally get
tested; somehow when sem_t reverted to an opaque struct
the calloc NULL check was left in the conditionally included
section.
(sem_destroy): Likewise, the calloced sem_t wasn't being freed.
2001-10-25 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* GNUmakefile (libwsock32): Add to linker flags for
WSAGetLastError() and WSASetLastError().
* Makefile (wsock32.lib): Likewise.
* create.c: Minor mostly inert changes.
* implement.h (PTW32_MAX): Move into here and renamed
from sched.h.
(PTW32_MIN): Likewise.
* GNUmakefile (TEST_ICE): Define if testing internal
implementation of InterlockedCompareExchange.
* Makefile (TEST_ICE): Likewise.
* private.c (TEST_ICE): Likewise.
2001-10-24 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* attr.c (pthread_attr_setstacksize): Quell warning
from LCC by conditionally compiling the stacksize
validity check. LCC correctly warns that the condition
(stacksize < PTHREAD_STACK_MIN) is suspicious
because STACK_MIN is 0 and stacksize is of type
size_t (or unsigned int).
2001-10-17 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* barrier.c: Move _LONG and _LPLONG defines into
implement.h; rename to PTW32_INTERLOCKED_LONG and
PTW32_INTERLOCKED_LPLONG respectively.
* spin.c: Likewise; ptw32_interlocked_compare_exchange used
in place of InterlockedCompareExchange directly.
* global.c (ptw32_interlocked_compare_exchange): Add
prototype for this new routine pointer to be used when
InterlockedCompareExchange isn't supported by Windows.
* nonportable.c (pthread_win32_process_attach_np): Check for
support of InterlockedCompareExchange in kernel32 and assign its
address to ptw32_interlocked_compare_exchange if it exists, or
our own ix86 specific implementation ptw32_InterlockedCompareExchange.
*private.c (ptw32_InterlockedCompareExchange): An
implementation of InterlockedCompareExchange() which is
specific to ix86; written directly in assembler for either
MSVC or GNU C; needed because Windows 95 doesn't support
InterlockedCompareExchange().
* sched.c (sched_get_priority_min): Extend to return
THREAD_PRIORITY_IDLE.
(sched_get_priority_max): Extend to return
THREAD_PRIORITY_CRITICAL.
2001-10-15 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* spin.c (pthread_spin_lock): PTHREAD_SPINLOCK_INITIALIZER
was causing a program fault.
(pthread_spin_init): Could have alloced memory
without freeing under some error conditions.
* mutex.c (pthread_mutex_init): Move memory
allocation of mutex struct after checking for
PROCESS_SHARED.
2001-10-12 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* spin.c (pthread_spin_unlock): Was not returning
EPERM if the spinlock was not locked, for multi CPU
machines.
2001-10-08 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* spin.c (pthread_spin_trylock): Was not returning
EBUSY for multi CPU machines.
2001-08-24 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* condvar.c (pthread_cond_destroy): Remove cv element
that is no longer used.
* implement.h: Likewise.
2001-08-23 Alexander Terekhov <TEREKHOV at de.ibm.com>
* condvar.c (pthread_cond_destroy): fix bug with
respect to deadlock in the case of concurrent
_destroy/_unblock; a condition variable can be destroyed
immediately after all the threads that are blocked on
it are awakened.
2001-08-23 Phil Frisbie, Jr. <phil at hawksoft.com>
* tsd.c (pthread_getspecific): Preserve the last
winsock error [from WSAGetLastError()].
2001-07-18 Scott McCaskill <scott at magruder.org>
* mutex.c (pthread_mutexattr_init): Return ENOMEM
immediately and don't dereference the NULL pointer
if calloc fails.
(pthread_mutexattr_getpshared): Don't dereference
a pointer that is possibly NULL.
* barrier.c (pthread_barrierattr_init): Likewise
(pthread_barrierattr_getpshared): Don't dereference
a pointer that is possibly NULL.
* condvar.c (pthread_condattr_getpshared): Don't dereference
a pointer that is possibly NULL.
2001-07-15 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* rwlock.c (pthread_rwlock_wrlock): Is allowed to be
a cancelation point; re-enable deferred cancelability
around the CV call.
2001-07-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* barrier.c: Still more revamping. The exclusive access
mutex isn't really needed so it has been removed and replaced
by an InterlockedDecrement(). nSerial has been removed.
iStep is now dual-purpose. The process shared attribute
is now stored in the barrier struct.
* implement.h (pthread_barrier_t_): Lost some/gained one
elements.
* private.c (ptw32_threadStart): Removed some comments.
2001-07-10 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* barrier.c: Revamped to fix the race condition. Two alternating
semaphores are used instead of the PulseEvent. Also improved
overall throughput by returning PTHREAD_BARRIER_SERIAL_THREAD
to the first waking thread.
* implement.h (pthread_barrier_t_): Revamped.
2001-07-09 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* barrier.c: Fix several bugs in all routines. Now passes
tests/barrier5.c which is fairly rigorous. There is still
a non-optimal work-around for a race condition between
the barrier breeched event signal and event wait. Basically
the last (signalling) thread to hit the barrier yields
to allow any other threads, which may have lost the race,
to complete.
2001-07-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* barrier.c: Changed synchronisation mechanism to a
Win32 manual reset Event and use PulseEvent to signal
waiting threads. If the implementation continued to use
a semaphore it would require a second semaphore and
some management to use them alternately as barriers. A
single semaphore allows threads to cascade from one barrier
through the next, leaving some threads blocked at the first.
* implement.h (pthread_barrier_t_): As per above.
* general: Made a number of other routines inlinable.
2001-07-07 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* spin.c: Revamped and working; included static initialiser.
Now beta level.
* barrier.c: Likewise.
* condvar.c: Macro constant change; inline auto init routine.
* mutex.c: Likewise.
* rwlock.c: Likewise.
* private.c: Add support for spinlock initialiser.
* global.c: Likewise.
* implement.h: Likewise.
* pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo.
2001-07-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* barrier.c: Remove static initialisation - irrelevent
for this object.
* pthread.h (PTHREAD_BARRIER_INITIALIZER): Removed.
* rwlock.c (pthread_rwlock_wrlock): This routine is
not a cancelation point - disable deferred
cancelation around call to pthread_cond_wait().
2001-07-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* spin.c: New module implementing spin locks.
* barrier.c: New module implementing barriers.
* pthread.h (_POSIX_SPIN_LOCKS): defined.
(_POSIX_BARRIERS): Defined.
(pthread_spin_*): Defined.
(pthread_barrier*): Defined.
(PTHREAD_BARRIER_SERIAL_THREAD): Defined.
* implement.h (pthread_spinlock_t_): Defined.
(pthread_barrier_t_): Defined.
(pthread_barrierattr_t_): Defined.
* mutex.c (pthread_mutex_lock): Return with the error
if an auto-initialiser initialisation fails.
* nonportable.c (pthread_getprocessors_np): New; gets the
number of available processors for the current process.
2001-07-03 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* pthread.h (_POSIX_READER_WRITER_LOCKS): Define it
if not already defined.
2001-07-01 Alexander Terekhov <TEREKHOV at de.ibm.com>
* condvar.c: Fixed lost signal bug reported by Timur Aydin
(taydin@snet.net).
[RPJ (me) didn't translate the original algorithm
correctly.]
* semaphore.c: Added sem_post_multiple; this is a useful
routine, but it doesn't appear to be standard. For now it's
not an exported function.
2001-06-25 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* create.c (pthread_create): Add priority inheritance
attributes.
* mutex.c (pthread_mutex_lock): Remove some overhead for
PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid
calling pthread_self() and pthread_equal() to check/set
the mutex owner. Introduce a new pseudo owner for this
type. Test results suggest increases in speed of up to
90% for non-blocking locks.
This is the default type of mutex used internally by other
synchronising objects, ie. condition variables and
read-write locks. The test rwlock7.c shows about a
30-35% speed increase over snapshot 2001-06-06. The
price of this is that the application developer
must ensure correct behaviour, or explicitly set the
mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK.
For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT)
type mutexes will not return an error if a thread which is not
the owner calls pthread_mutex_unlock. The call will succeed
in unlocking the mutex if it is currently locked, but a
subsequent unlock by the true owner will then fail with EPERM.
This is however consistent with some other implementations.
(pthread_mutex_unlock): Likewise.
(pthread_mutex_trylock): Likewise.
(pthread_mutex_destroy): Likewise.
* attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the
default inheritance attribute; THREAD_PRIORITY_NORMAL is
the default priority for new threads.
* sched.c (pthread_attr_setschedpolicy): Added routine.
(pthread_attr_getschedpolicy): Added routine.
(pthread_attr_setinheritsched): Added routine.
(pthread_attr_getinheritsched): Added routine.
* pthread.h (sched_rr_set_interval): Added as a macro;
returns -1 with errno set to ENOSYS.
2001-06-23 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
*sched.c (pthread_attr_setschedparam): Add priority range
check.
(sched_setscheduler): New function; checks for a valid
pid and policy; checks for permission to set information
in the target process; expects pid to be a Win32 process ID,
not a process handle; the only scheduler policy allowed is
SCHED_OTHER.
(sched_getscheduler): Likewise, but checks for permission
to query.
* pthread.h (SCHED_*): Moved to sched.h as defined in the
POSIX standard.
* sched.h (SCHED_*): Moved from pthread.h.
(pid_t): Defined if necessary.
(sched_setscheduler): Defined.
(sched_getscheduler): Defined.
* pthread.def (sched_setscheduler): Exported.
(sched_getscheduler): Likewise.
2001-06-23 Ralf Brese <Ralf.Brese at pdb4.siemens.de>
* create.c (pthread_create): Set thread priority from
thread attributes.
2001-06-18 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* Made organisational-only changes to UWIN additions.
* dll.c (dllMain): Moved UWIN process attach code
to pthread_win32_process_attach_np(); moved
instance of pthread_count to global.c.
* global.c (pthread_count): Moved from dll.c.
* nonportable.c (pthread_win32_process_attach_np):
Moved _UWIN code to here from dll.c.
* implement.h (pthread_count): Define extern int.
* create.c (pthread_count): Remove extern int.
* private.c (pthread_count): Likewise.
* exit.c (pthread_count): Likewise.
2001-06-18 David Korn <dgk at research.att.com>
* dll.c: Added changes necessary to work with UWIN.
* create.c: Likewise.
* pthread.h: Likewise.
* misc.c: Likewise.
* exit.c: Likewise.
* private.c: Likewise.
* implement.h: Likewise.
There is some room at the start of struct pthread_t_
to implement the signal semantics in UWIN's posix.dll
although this is not yet complete.
* Nmakefile: Compatible with UWIN's Nmake utility.
* Nmakefile.tests: Likewise - for running the tests.
2001-06-08 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* semaphore.h (sem_t): Fixed for compile and test.
* implement.h (sem_t_): Likewise.
* semaphore.c: Likewise.
* private.c (ptw32_sem_timedwait): Updated to use new
opaque sem_t.
2001-06-06 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* semaphore.h (sem_t): Is now an opaque pointer;
moved actual definition to implement.h.
* implement.h (sem_t_): Move here from semaphore.h;
was the definition of sem_t.
* semaphore.c: Wherever necessary, changed use of sem
from that of a pointer to a pointer-pointer; added
extra checks for a valid sem_t; NULL sem_t when
it is destroyed; added extra checks when creating
and destroying sem_t elements in the NEED_SEM
code branches; changed from using a pthread_mutex_t
((*sem)->mutex) to CRITICAL_SECTION ((*sem)->sem_lock_cs)
in NEED_SEM branches for access serialisation.
2001-06-06 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* mutex.c (pthread_mutexattr_init): Remove
ptw32_mutex_default_kind.
2001-06-05 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* nonportable.c (pthread_mutex_setdefaultkind_np):
Remove - should not have been included in the first place.
(pthread_mutex_getdefaultkind_np): Likewise.
* global.c (ptw32_mutex_default_kind): Likewise.
* mutex.c (pthread_mutex_init): Remove use of
ptw32_mutex_default_kind.
* pthread.h (pthread_mutex_setdefaultkind_np): Likewise.
(pthread_mutex_getdefaultkind_np): Likewise.
* pthread.def (pthread_mutexattr_setkind_np): Added.
(pthread_mutexattr_getkind_np): Likewise.
* README: Many changes that should have gone in before
the last snapshot.
* README.NONPORTABLE: New - referred to by ANNOUNCE
but never created; documents the non-portable routines
included in the library - moved from README with new
routines added.
* ANNOUNCE (pthread_mutexattr_setkind_np): Added to
compliance list.
(pthread_mutexattr_getkind_np): Likewise.
2001-06-04 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* condvar.c: Add original description of the algorithm as
developed by Terekhov and Thomas, plus reference to
README.CV.
2001-06-03 Alexander Terekhov <TEREKHOV at de.ibm.com>, Louis Thomas <lthomas at arbitrade.com>
* condvar.c (pthread_cond_init): Completely revamped.
(pthread_cond_destroy): Likewise.
(ptw32_cond_wait_cleanup): Likewise.
(ptw32_cond_timedwait): Likewise.
(ptw32_cond_unblock): New general signaling routine.
(pthread_cond_signal): Now calls ptw32_cond_unblock.
(pthread_cond_broadcast): Likewise.
* implement.h (pthread_cond_t_): Revamped.
* README.CV: New; explanation of the above changes.
2001-05-30 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* pthread.h (rand_r): Fake using _seed argument to quell
compiler warning (compiler should optimise this away later).
* GNUmakefile (OPT): Leave symbolic information out of the library
and increase optimisation level - for smaller faster prebuilt
dlls.
2001-05-29 Milan Gardian <Milan.Gardian at LEIBINGER.com>
* Makefile: fix typo.
* pthreads.h: Fix problems with stdcall/cdecl conventions, in particular
remove the need for PT_STDCALL everywhere; remove warning supression.
* (errno): Fix the longstanding "inconsistent dll linkage" problem
with errno; now also works with /MD debugging libs -
warnings emerged when compiling pthreads library with /MD (or /MDd)
compiler switch, instead of /MT (or /MTd) (i.e. when compiling pthreads
using Multithreaded DLL CRT instead of Multithreaded statically linked
CRT).
* create.c (pthread_create): Likewise; fix typo.
* private.c (ptw32_threadStart): Eliminate use of terminate() which doesn't
throw exceptions.
* Remove unnecessary #includes from a number of modules -
[I had to #include malloc.h in implement.h for gcc - rpj].
2001-05-29 Thomas Pfaff <tpfaff at gmx.net>
* pthread.h (PTHREAD_MUTEX_DEFAULT): New; equivalent to
PTHREAD_MUTEX_DEFAULT_NP.
* (PTHREAD_MUTEX_NORMAL): Similarly.
* (PTHREAD_MUTEX_ERRORCHECK): Similarly.
* (PTHREAD_MUTEX_RECURSIVE): Similarly.
* (pthread_mutex_setdefaultkind_np): New; Linux compatibility stub
for pthread_mutexattr_settype.
* (pthread_mutexattr_getkind_np): New; Linux compatibility stub
for pthread_mutexattr_gettype.
* mutex.c (pthread_mutexattr_settype): New; allow
the following types of mutex:
PTHREAD_MUTEX_DEFAULT_NP
PTHREAD_MUTEX_NORMAL_NP
PTHREAD_MUTEX_ERRORCHECK_NP
PTHREAD_MUTEX_RECURSIVE_NP
* Note that PTHREAD_MUTEX_DEFAULT is equivalent to
PTHREAD_MUTEX_NORMAL - ie. mutexes should no longer
be recursive by default, and a thread will deadlock if it
tries to relock a mutex it already owns. This is inline with
other pthreads implementations.
* (pthread_mutex_lock): Process the lock request
according to the mutex type.
* (pthread_mutex_init): Eliminate use of Win32 mutexes as the
basis of POSIX mutexes - instead, a combination of one critical section
and one semaphore are used in conjunction with Win32 Interlocked* routines.
* (pthread_mutex_destroy): Likewise.
* (pthread_mutex_lock): Likewise.
* (pthread_mutex_trylock): Likewise.
* (pthread_mutex_unlock): Likewise.
* Use longjmp/setjmp to implement cancelation when building the library
using a C compiler which doesn't support exceptions, e.g. gcc -x c (note
that gcc -x c++ uses exceptions).
* Also fixed some of the same typos and eliminated PT_STDCALL as
Milan Gardian's patches above.
2001-02-07 Alexander Terekhov <TEREKHOV at de.ibm.com>
* rwlock.c: Revamped.
* implement.h (pthread_rwlock_t_): Redefined.
This implementation does not have reader/writer starvation problem.
Rwlock attempts to behave more like a normal mutex with
races and scheduling policy determining who is more important;
It also supports recursive locking,
has less synchronization overhead (no broadcasts at all,
readers are not blocked on any condition variable) and seem to
be faster than the current implementation [W98 appears to be
approximately 15 percent faster at least - on top of speed increase
from Thomas Pfaff's changes to mutex.c - rpj].
2000-12-29 Ross Johnson <rpj at special.ise.canberra.edu.au>
* Makefile: Back-out "for" loops which don't work.
* GNUmakefile: Remove the fake.a target; add the "realclean"
target; don't remove built libs under the "clean" target.
* config.h: Add a guard against multiple inclusion.
* semaphore.h: Add some defines from config.h to make
semaphore.h independent of config.h when building apps.
* pthread.h (_errno): Back-out previous fix until we know how to
fix it properly.
* implement.h (lockCount): Add missing element to pthread_mutex_t_.
* sync.c (pthread_join): Spelling fix in comment.
* private.c (ptw32_threadStart): Reset original termination
function (C++).
(ptw32_threadStart): Cleanup detached threads early in case
the library is statically linked.
(ptw32_callUserDestroyRoutines): Remove [SEH] __try block from
destructor call so that unhandled exceptions will be passed through
to the system; call terminate() from [C++] try block for the same
reason.
* tsd.c (pthread_getspecific): Add comment.
* mutex.c (pthread_mutex_init): Initialise new elements in
pthread_mutex_t.
(pthread_mutex_unlock): Invert "pthread_equal()" test.
2000-12-28 Ross Johnson <rpj at special.ise.canberra.edu.au>
* semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition.
* config.h.in (HAVE_MODE_T): Added.
(_UWIN): Start adding defines for the UWIN package.
* private.c (ptw32_threadStart): Unhandled exceptions are
now passed through to the system to deal with. This is consistent
with normal Windows behaviour. C++ applications may use
set_terminate() to override the default behaviour which is
to call ptw32_terminate(). Ptw32_terminate() cleans up some
POSIX thread stuff before calling the system default function
which calls abort(). The users termination function should conform
to standard C++ semantics which is to not return. It should
exit the thread (call pthread_exit()) or exit the application.
* private.c (ptw32_terminate): Added as the default set_terminate()
function. It calls the system default function after cleaning up
some POSIX thread stuff.
* implement.h (ptw32_try_enter_critical_section): Move
declaration.
* global.c (ptw32_try_enter_critical_section): Moved
from dll.c.
* dll.c: Move process and thread attach/detach code into
functions in nonportable.c.
* nonportable.c (pthread_win32_process_attach_np): Process
attach code from dll.c is now available to static linked
applications.
* nonportable.c (pthread_win32_process_detach_np): Likewise.
* nonportable.c (pthread_win32_thread_attach_np): Likewise.
* nonportable.c (pthread_win32_thread_detach_np): Likewise.
* pthread.h: Add new non-portable prototypes for static
linked applications.
* GNUmakefile (OPT): Increase optimisation flag and remove
debug info flag.
* pthread.def: Add new non-portable exports for static
linked applications.
2000-12-11 Ross Johnson <rpj at special.ise.canberra.edu.au>
* FAQ: Update Answer 6 re getting a fully working
Mingw32 built library.
2000-10-10 Steven Reddie <smr at essemer.com.au>
* misc.c (pthread_self): Restore Win32 "last error"
cleared by TlsGetValue() call in
pthread_getspecific()
2000-09-20 Arthur Kantor <akantor at bexusa.com>
* mutex.c (pthread_mutex_lock): Record the owner
of the mutex. This requires also keeping count of
recursive locks ourselves rather than leaving it
to Win32 since we need to know when to NULL the
thread owner when the mutex is unlocked.
(pthread_mutex_trylock): Likewise.
(pthread_mutex_unlock): Check that the calling
thread owns the mutex, decrement the recursive
lock count, and NULL the owner if zero. Return
EPERM if the mutex is owned by another thread.
* implement.h (pthread_mutex_t_): Add ownerThread
and lockCount members.
2000-09-13 Jef Gearhart <jgearhart at tpssys.com>
* mutex.c (pthread_mutex_init): Call
TryEnterCriticalSection through the pointer
rather than directly so that the dll can load
on Windows versions that can't resolve the
function, eg. Windows 95
2000-09-09 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.h (ctime_r): Fix arg.
2000-09-08 Ross Johnson <rpj at special.ise.canberra.edu.au>
* GNUmakefile(_WIN32_WINNT=0x400): Define in CFLAGS;
doesn't seem to be needed though.
* cancel.c (pthread_cancel): Must get "self" through
calling pthread_self() which will ensure a POSIX thread
struct is built for non-POSIX threads; return an error
if this fails
- Ollie Leahy <ollie at mpt.ie>
(pthread_setcancelstate): Likewise.
(pthread_setcanceltype): Likewise.
* misc.c (ptw32_cancelable_wait): Likewise.
* private.c (ptw32_tkAssocCreate): Remove unused #if 0
wrapped code.
* pthread.h (ptw32_get_exception_services_code):
Needed to be forward declared unconditionally.
2000-09-06 Ross Johnson <rpj at special.ise.canberra.edu.au>
* cancel.c (pthread_cancel): If called from the main
thread "self" would be NULL; get "self" via pthread_self()
instead of directly from TLS so that an implicit
pthread object is created.
* misc.c (pthread_equal): Strengthen test for NULLs.
2000-09-02 Ross Johnson <rpj at special.ise.canberra.edu.au>
* condvar.c (ptw32_cond_wait_cleanup): Ensure that all
waking threads check if they are the last, and notify
the broadcaster if so - even if an error occurs in the
waiter.
* semaphore.c (_decrease_semaphore): Should be
a call to ptw32_decrease_semaphore.
(_increase_semaphore): Should be a call to
ptw32_increase_semaphore.
* misc.c (ptw32_cancelable_wait): Renamed from
CancelableWait.
* rwlock.c (_rwlock_check*): Renamed to
ptw32_rwlock_check*.
* mutex.c (_mutex_check*): Renamed to ptw32_mutex_check*.
* condvar.c (cond_timed*): Renamed to ptw32_cond_timed*.
(_cond_check*): Renamed to ptw32_cond_check*.
(cond_wait_cleanup*): Rename to ptw32_cond_wait_cleanup*.
(ptw32_cond_timedwait): Add comments.
2000-08-22 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* private.c (ptw32_throw): Fix exception test;
move exceptionInformation declaration.
* tsd.c (pthread_key_create): newkey wrongly declared.
* pthread.h: Fix comment block.
2000-08-18 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* mutex.c (pthread_mutex_destroy): Check that the mutex isn't
held; invalidate the mutex as early as possible to avoid
contention; not perfect - FIXME!
* rwlock.c (pthread_rwlock_init): Remove redundant assignment
to "rw".
(pthread_rwlock_destroy): Invalidate the rwlock before
freeing up any of it's resources - to avoid contention.
* private.c (ptw32_tkAssocCreate): Change assoc->lock
to use a dynamically initialised mutex - only consumes
a W32 mutex or critical section when first used,
not before.
* mutex.c (pthread_mutex_init): Remove redundant assignment
to "mx".
(pthread_mutexattr_destroy): Set attribute to NULL
before freeing it's memory - to avoid contention.
* implement.h (PTW32_EPS_CANCEL/PTW32_EPS_EXIT):
Must be defined for all compilers - used as generic
exception selectors by ptw32_throw().
* Several: Fix typos from scripted edit session
yesterday.
* nonportable.c (pthread_mutexattr_setforcecs_np):
Moved this function from mutex.c.
(pthread_getw32threadhandle_np): New function to
return the win32 thread handle that the POSIX
thread is using.
* mutex.c (pthread_mutexattr_setforcecs_np):
Moved to new file "nonportable.c".
* pthread.h (PTW32_BUILD): Only redefine __except
and catch compiler keywords if we aren't building
the library (ie. PTW32_BUILD is not defined) -
this is safer than defining and then undefining
if not building the library.
* implement.h: Remove __except and catch undefines.
* Makefile (CFLAGS): Define PTW32_BUILD.
* GNUmakefile (CFLAGS): Define PTW32_BUILD.
* All appropriate: Change Pthread_exception* to
ptw32_exception* to be consistent with internal
identifier naming.
* private.c (ptw32_throw): New function to provide
a generic exception throw for all internal
exceptions and EH schemes.
(ptw32_threadStart): pthread_exit() value is now
returned via the thread structure exitStatus
element.
* exit.c (pthread_exit): pthread_exit() value is now
returned via the thread structure exitStatus
element.
* cancel.c (ptw32_cancel_self): Now uses ptw32_throw.
(pthread_setcancelstate): Ditto.
(pthread_setcanceltype): Ditto.
(pthread_testcancel): Ditto.
(pthread_cancel): Ditto.
* misc.c (CancelableWait): Ditto.
* exit.c (pthread_exit): Ditto.
* All applicable: Change PTW32_ prefix to
PTW32_ prefix to remove leading underscores
from private library identifiers.
2000-08-17 Ross Johnson <rpj at special.ise.canberra.edu.au>
* All applicable: Change _pthread_ prefix to
ptw32_ prefix to remove leading underscores
from private library identifiers (single
and double leading underscores are reserved in the
ANSI C standard for compiler implementations).
* tsd.c (pthread_create_key): Initialise temporary
key before returning it's address to avoid race
conditions.
2000-08-13 Ross Johnson <rpj at special.ise.canberra.edu.au>
* errno.c: Add _MD precompile condition; thus far
had no effect when using /MD compile option but I
thnk it should be there.
* exit.c: Add __cplusplus to various #if lines;
was compiling SEH code even when VC++ had
C++ compile options.
* private.c: ditto.
* create.c (pthread_create): Add PT_STDCALL macro to
function pointer arg in _beginthread().
* pthread.h: PT_STDCALL really does need to be defined
in both this and impliment.h; don't set it to __cdecl
- this macro is only used to extend function pointer
casting for functions that will be passed as parameters.
(~PThreadCleanup): add cast and group expression.
(_errno): Add _MD compile conditional.
(PtW32NoCatchWarn): Change pragma message.
* implement.h: Move and change PT_STDCALL define.
* need_errno.h: Add _MD to compilation conditional.
* GNUmakefile: Substantial rewrite for new naming
convention; set for nil optimisation (turn it up
when we have a working library build; add target
"fake.a" to build a libpthreadw32.a from the VC++
built DLL pthreadVCE.dll.
* pthread.def (LIBRARY): Don't specify in the .def
file - it is specified on the linker command line
since we now use the same .def file for variously
named .dlls.
* Makefile: Substantial rewrite for new naming
convention; default nmake target only issues a
help message; run nmake with specific target
corresponding to the EH scheme being used.
* README: Update information; add naming convention
explanation.
* ANNOUNCE: Update information.
2000-08-12 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.h: Add compile-time message when using
MSC_VER compiler and C++ EH to warn application
programmers to use PtW32Catch instead of catch(...)
if they want cancelation and pthread_exit to work.
* implement.h: Remove #include <semaphore.h>; we
use our own local semaphore.h.
2000-08-10 Ross Johnson <rpj at special.ise.canberra.edu.au>
* cleanup.c (pthread_pop_cleanup): Remove _pthread
prefix from __except and catch keywords; implement.h
now simply undefines ptw32__except and
ptw32_catch if defined; VC++ was not textually
substituting ptw32_catch etc back to catch as
it was redefined; the reason for using the prefixed
version was to make it clear that it was not using
the pthread.h redefined catch keyword.
* private.c (ptw32_threadStart): Ditto.
(ptw32_callUserDestroyRoutines): Ditto.
* implement.h (ptw32__except): Remove #define.
(ptw32_catch): Remove #define.
* GNUmakefile (pthread.a): New target to build
libpthread32.a from pthread.dll using dlltool.
* buildlib.bat: Duplicate cl commands with args to
build C++ EH version of pthread.dll; use of .bat
files is redundant now that nmake compatible
Makefile is included; used as a kludge only now.
* Makefile: Localise some macros and fix up the clean:
target to extend it and work properly.
* CONTRIBUTORS: Add contributors.
* ANNOUNCE: Updated.
* README: Updated.
2000-08-06 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.h: Remove #warning - VC++ doesn't accept it.
2000-08-05 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.h (PtW32CatchAll): Add macro. When compiling
applications using VC++ with C++ EH rather than SEH
'PtW32CatchAll' must be used in place of any 'catch( ... )'
if the application wants pthread cancelation or
pthread_exit() to work.
2000-08-03 Ross Johnson <rpj at special.ise.canberra.edu.au>
* pthread.h: Add a base class ptw32_exception for
library internal exceptions and change the "catch"
re-define macro to use it.
2000-08-02 Ross Johnson <rpj at special.ise.canberra.edu.au>
* GNUmakefile (CFLAGS): Add -mthreads.
Add new targets to generate cpp and asm output.
* sync.c (pthread_join): Remove dead code.
2000-07-25 Tristan Savatier <tristan at mpegtv.com>
* sched.c (sched_get_priority_max): Handle different WinCE and
Win32 priority values together.
(sched_get_priority_min): Ditto.
2000-07-25 Ross Johnson <rpj at special.ise.canberra.edu.au>
* create.c (pthread_create): Force new threads to wait until
pthread_create has the new thread's handle; we also retain
a local copy of the handle for internal use until
pthread_create returns.
* private.c (ptw32_threadStart): Initialise ei[].
(ptw32_threadStart): When beginthread is used to start the
thread, force waiting until the creator thread had the
thread handle.
* cancel.c (ptw32_cancel_thread): Include context switch
code for defined(_X86_) environments in addition to _M_IX86.
* rwlock.c (pthread_rwlock_destroy): Assignment changed
to avoid compiler warning.
* private.c (ptw32_get_exception_services_code): Cast
NULL return value to avoid compiler warning.
* cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable
to avoid compiler warnings.
* misc.c (ptw32_new): Change "new" variable to "t" to avoid
confusion with the C++ keyword of the same name.
* condvar.c (cond_wait_cleanup): Initialise lastWaiter variable.
(cond_timedwait): Remove unused local variables. to avoid
compiler warnings.
* dll.c (dllMain): Remove 2000-07-21 change - problem
appears to be in pthread_create().
2000-07-22 Ross Johnson <rpj at special.ise.canberra.edu.au>
* tsd.c (pthread_key_create): If a destructor was given
and the pthread_mutex_init failed, then would try to
reference a NULL pointer (*key); eliminate this section of
code by using a dynamically initialised mutex
(PTHREAD_MUTEX_INITIALIZER).
* tsd.c (pthread_setspecific): Return an error if
unable to set the value; simplify cryptic conditional.
* tsd.c (pthread_key_delete): Locking threadsLock relied
on mutex_lock returning an error if the key has no destructor.
ThreadsLock is only initialised if the key has a destructor.
Making this mutex a static could reduce the number of mutexes
used by an application since it is actually created only at
first use and it's often destroyed soon after.
2000-07-22 Ross Johnson <rpj at special.ise.canberra.edu.au>
* FAQ: Added Q5 and Q6.
2000-07-21 David Baggett <dmb at itasoftware.com>
* dll.c: Include resource leakage work-around. This is a
partial FIXME which doesn't stop all leakage. The real
problem needs to be found and fixed.
2000-07-21 Ross Johnson <rpj at setup1.ise.canberra.edu.au>
* create.c (pthread_create): Set threadH to 0 (zero)
everywhere. Some assignments were using NULL. Maybe
it should be NULL everywhere - need to check. (I know
they are nearly always the same thing - but not by
definition.)
* misc.c (pthread_self): Try to catch NULL thread handles
at the point where they might be generated, even though
they should always be valid at this point.
* tsd.c (pthread_setspecific): return an error value if
pthread_self() returns NULL.
* sync.c (pthread_join): return an error value if
pthread_self() returns NULL.
* signal.c (pthread_sigmask): return an error value if
pthread_self() returns NULL.
2000-03-02 Ross Johnson <rpj at special.ise.canberra.edu.au>
* attr.c (pthread_attr_init): Set default stacksize to zero (0)
rather than PTHREAD_STACK_MIN even though these are now the same.
* pthread.h (PTHREAD_STACK_MIN): Lowered to 0.
2000-01-28 Ross Johnson <rpj at special.ise.canberra.edu.au>
* mutex.c (pthread_mutex_init): Free mutex if it has been alloced;
if critical sections can be used instead of Win32 mutexes, test
that the critical section works and return an error if not.
2000-01-07 Ross Johnson <rpj at special.ise.canberra.edu.au>
* cleanup.c (pthread_pop_cleanup): Include SEH code only if MSC is not
compiling as C++.
(pthread_push_cleanup): Include SEH code only if MSC is not
compiling as C++.
* pthread.h: Include SEH code only if MSC is not
compiling as C++.
* implement.h: Include SEH code only if MSC is not
compiling as C++.
* cancel.c (ptw32_cancel_thread): Add _M_IX86 check.
(pthread_testcancel): Include SEH code only if MSC is not
compiling as C++.
(ptw32_cancel_self): Include SEH code only if MSC is not
compiling as C++.
2000-01-06 Erik Hensema <erik.hensema at group2000.nl>
* Makefile: Remove inconsistencies in 'cl' args
2000-01-04 Ross Johnson <rpj at special.ise.canberra.edu.au>
* private.c (ptw32_get_exception_services_code): New; returns
value of EXCEPTION_PTW32_SERVICES.
(ptw32_processInitialize): Remove initialisation of
ptw32_exception_services which is no longer needed.
* pthread.h (ptw32_exception_services): Remove extern.
(ptw32_get_exception_services_code): Add function prototype;
use this to return EXCEPTION_PTW32_SERVICES value instead of
using the ptw32_exception_services variable which I had
trouble exporting through pthread.def.
* global.c (ptw32_exception_services): Remove declaration.
1999-11-22 Ross Johnson <rpj at special.ise.canberra.edu.au>
* implement.h: Forward declare ptw32_new();
* misc.c (ptw32_new): New; alloc and initialise a new pthread_t.
(pthread_self): New thread struct is generated by new routine
ptw32_new().
* create.c (pthread_create): New thread struct is generated
by new routine ptw32_new().
1999-11-21 Ross Johnson <rpj at special.ise.canberra.edu.au>
* global.c (ptw32_exception_services): Declare new variable.
* private.c (ptw32_threadStart): Destroy thread's
cancelLock mutex; make 'catch' and '__except' usageimmune to
redfinitions in pthread.h.
(ptw32_processInitialize): Init new constant ptw32_exception_services.
* create.c (pthread_create): Initialise thread's cancelLock
mutex.
* cleanup.c (pthread_pop_cleanup): Make 'catch' and '__except'
usage immune to redfinition s in pthread.h.
* private.c: Ditto.
* pthread.h (catch): Redefine 'catch' so that C++ applications
won't catch our internal exceptions.
(__except): ditto for __except.
* implement.h (ptw32_catch): Define internal version
of 'catch' because 'catch' is redefined by pthread.h.
(__except): ditto for __except.
(struct pthread_t_): Add cancelLock mutex for async cancel
safety.
1999-11-21 Jason Nye <jnye at nbnet.nb.ca>, Erik Hensema <erik.hensema at group2000.nl>
* cancel.c (ptw32_cancel_self): New; part of the async
cancellation implementation.
(ptw32_cancel_thread): Ditto; this function is X86
processor specific.
(pthread_setcancelstate): Add check for pending async
cancel request and cancel the calling thread if
required; add async-cancel safety lock.
(pthread_setcanceltype): Ditto.
1999-11-13 Erik Hensema <erik.hensema at group2000.nl>
* configure.in (AC_OUTPUT): Put generated output into GNUmakefile
rather than Makefile. Makefile will become the MSC nmake compatible
version
1999-11-13 John Bossom (John.Bossom@cognos.com>
* misc.c (pthread_self): Add a note about GetCurrentThread
returning a pseudo-handle
1999-11-10 Todd Owen <towen at lucidcalm.dropbear.id.au>
* dll.c (dllMain): Free kernel32 ASAP.
If TryEnterCriticalSection is not being used, then free
the kernel32.dll handle now, rather than leaving it until
DLL_PROCESS_DETACH.
Note: this is not a pedantic exercise in freeing unused
resources! It is a work-around for a bug in Windows 95
(see microsoft knowledge base article, Q187684) which
does Bad Things when FreeLibrary is called within
the DLL_PROCESS_DETACH code, in certain situations.
Since w95 just happens to be a platform which does not
provide TryEnterCriticalSection, the bug will be
effortlessly avoided.
1999-11-10 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sync.c (pthread_join): Make it a deferred cancelation point.
* misc.c (pthread_self): Explicitly initialise implicitly
created thread state to default values.
1999-11-05 Tristan Savatier <tristan at mpegtv.com>
* pthread.h (winsock.h): Include unconditionally.
(ETIMEDOUT): Change fallback value to that defined by winsock.h.
* general: Patched for portability to WinCE. The details are
described in the file WinCE-PORT. Follow the instructions
in README.WinCE to make the appropriate changes in config.h.
1999-10-30 Erik Hensema <erik.hensema at group2000.nl>
* create.c (pthread_create): Explicitly initialise thread state to
default values.
* cancel.c (pthread_setcancelstate): Check for NULL 'oldstate'
for compatibility with Solaris pthreads;
(pthread_setcanceltype): ditto:
1999-10-23 Erik Hensema <erik.hensema at group2000.nl>
* pthread.h (ctime_r): Fix incorrect argument "_tm"
1999-10-21 Aurelio Medina <aureliom at crt.com>
* pthread.h (_POSIX_THREADS): Only define it if it isn't
already defined. Projects may need to define this on
the CC command line under Win32 as it doesn't have unistd.h
1999-10-17 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* rwlock.c (pthread_rwlock_destroy): Add cast to remove compile
warning.
* condvar.c (pthread_cond_broadcast): Only release semaphores
if there are waiting threads.
1999-10-15 Lorin Hochstein <lmh at xiphos.ca>, Peter Slacik <Peter.Slacik at tatramed.sk>
* condvar.c (cond_wait_cleanup): New static cleanup handler for
cond_timedwait;
(cond_timedwait): pthread_cleanup_push args changed;
canceling a thread while it's in pthread_cond_wait
will now decrement the waiters count and cleanup if it's the
last waiter.
1999-10-15 Graham Dumpleton <Graham.Dumpleton at ra.pad.otc.telstra.com.au>
* condvar.c (cond_wait_cleanup): the last waiter will now reset the CV's
wasBroadcast flag
Thu Sep 16 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* rwlock.c (pthread_rwlock_destroy): Add serialisation.
(_rwlock_check_need_init): Check for detroyed rwlock.
* rwlock.c: Check return codes from _rwlock_check_need_init();
modify comments; serialise access to rwlock objects during
operations; rename rw_mutex to rw_lock.
* implement.h: Rename rw_mutex to rw_lock.
* mutex.c (pthread_mutex_destroy): Add serialisation.
(_mutex_check_need_init): Check for detroyed mutex.
* condvar.c (pthread_cond_destroy): Add serialisation.
(_cond_check_need_init): Check for detroyed condvar.
* mutex.c: Modify comments.
* condvar.c: Modify comments.
1999-08-10 Aurelio Medina <aureliom at crt.com>
* implement.h (pthread_rwlock_t_): Add.
* pthread.h (pthread_rwlock_t): Add.
(PTHREAD_RWLOCK_INITIALIZER): Add.
Add rwlock function prototypes.
* rwlock.c: New module.
* pthread.def: Add new rwlock functions.
* private.c (ptw32_processInitialize): initialise
ptw32_rwlock_test_init_lock critical section.
* global.c (ptw32_rwlock_test_init_lock): Add.
* mutex.c (pthread_mutex_destroy): Don't free mutex memory
if mutex is PTHREAD_MUTEX_INITIALIZER and has not been
initialised yet.
1999-08-08 Milan Gardian <mg at tatramed.sk>
* mutex.c (pthread_mutex_destroy): Free mutex memory.
1999-08-22 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* exit.c (pthread_exit): Fix reference to potentially
uninitialised pointer.
1999-08-21 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_threadStart): Apply fix of 1999-08-19
this time to C++ and non-trapped C versions. Ommitted to
do this the first time through.
1999-08-19 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_threadStart): Return exit status from
the application thread startup routine.
- Milan Gardian <mg at tatramed.sk>
1999-08-18 John Bossom <john.Bossom at cognos.com>
* exit.c (pthread_exit): Put status into pthread_t->exitStatus
* private.c (ptw32_threadStart): Set pthread->exitStatus
on exit of try{} block.
* sync.c (pthread_join): use pthread_exitStatus value if the
thread exit doesn't return a value (for Mingw32 CRTDLL
which uses endthread instead of _endthreadex).
Tue Aug 17 20:17:58 CDT 1999 Mumit Khan <khan at xraylith.wisc.edu>
* create.c (pthread_create): Add CRTDLL suppport.
* exit.c (pthread_exit): Likewise.
* private.c (ptw32_threadStart): Likewise.
(ptw32_threadDestroy): Likewise.
* sync.c (pthread_join): Likewise.
* tests/join1.c (main): Warn about partial support for CRTDLL.
Tue Aug 17 20:00:08 1999 Mumit Khan <khan at xraylith.wisc.edu>
* Makefile.in (LD): Delete entry point.
* acconfig.h (STDCALL): Delete unused macro.
* configure.in: Remove test for STDCALL.
* config.h.in: Regenerate.
* errno.c (_errno): Fix self type.
* pthread.h (PT_STDCALL): Move from here to
* implement.h (PT_STDCALL): here.
(ptw32_threadStart): Fix prototype.
* private.c (ptw32_threadStart): Likewise.
1999-08-14 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* exit.c (pthread_exit): Don't call pthread_self() but
get thread handle directly from TSD for efficiency.
1999-08-12 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_threadStart): ei[] only declared if _MSC_VER.
* exit.c (pthread_exit): Check for implicitly created threads
to avoid raising an unhandled exception.
1999-07-12 Peter Slacik <Peter.Slacik at tatramed.sk>
* condvar.c (pthread_cond_destroy): Add critical section.
(cond_timedwait): Add critical section; check for timeout
waiting on semaphore.
(pthread_cond_broadcast): Add critical section.
1999-07-09 Lorin Hochstein <lmh at xiphos.ca>, John Bossom <John.Bossom at Cognos.COM>
The problem was that cleanup handlers were not executed when
pthread_exit() was called.
* implement.h (pthread_t_): Add exceptionInformation element for
C++ per-thread exception information.
(general): Define and rename exceptions.
1999-07-09 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* misc.c (CancelableWait): PTW32_EPS_CANCEL (SEH) and
ptw32_exception_cancel (C++) used to identify the exception.
* cancel.c (pthread_testcancel): PTW32_EPS_CANCEL (SEH) and
ptw32_exception_cancel (C++) used to identify the exception.
* exit.c (pthread_exit): throw/raise an exception to return to
ptw32_threadStart() to exit the thread. PTW32_EPS_EXIT (SEH)
and ptw32_exception_exit (C++) used to identify the exception.
* private.c (ptw32_threadStart): Add pthread_exit exception trap;
clean up and exit the thread directly rather than via pthread_exit().
Sun May 30 00:25:02 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* semaphore.h (mode_t): Conditionally typedef it.
Fri May 28 13:33:05 1999 Mark E. Armstrong <avail at pacbell.net>
* condvar.c (pthread_cond_broadcast): Fix possible memory fault
Thu May 27 13:08:46 1999 Peter Slacik <Peter.Slacik at tatramed.sk>
* condvar.c (pthread_cond_broadcast): Fix logic bug
Thu May 27 13:08:46 1999 Bossom, John <John.Bossom at Cognos.COM>
* condvar.c (pthread_cond_broadcast): optimise sem_post loop
Fri May 14 12:13:18 1999 Mike Russo <miker at eai.com>
* attr.c (pthread_attr_setdetachstate): Fix logic bug
Sat May 8 09:42:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.def (sem_open): Add.
(sem_close): Add.
(sem_unlink): Add.
(sem_getvalue): Add.
* FAQ (Question 3): Add.
Thu Apr 8 01:16:23 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* semaphore.c (sem_open): New function; returns an error (ENOSYS).
(sem_close): ditto.
(sem_unlink): ditto.
(sem_getvalue): ditto.
* semaphore.h (_POSIX_SEMAPHORES): define.
Wed Apr 7 14:09:52 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* errno.c (_REENTRANT || _MT): Invert condition.
* pthread.h (_errno): Conditionally include prototype.
Wed Apr 7 09:37:00 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* *.c (comments): Remove individual attributions - these are
documented sufficiently elsewhere.
* implement.h (pthread.h): Remove extraneous include.
Sun Apr 4 11:05:57 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sched.c (sched.h): Include.
* sched.h: New file for POSIX 1b scheduling.
* pthread.h: Move opaque structures to implement.h; move sched_*
prototypes out and into sched.h.
* implement.h: Add opaque structures from pthread.h.
* sched.c (sched_yield): New function.
* condvar.c (ptw32_sem_*): Rename to sem_*; except for
ptw32_sem_timedwait which is an private function.
Sat Apr 3 23:28:00 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* Makefile.in (OBJS): Add errno.o.
Fri Apr 2 11:08:50 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h (ptw32_sem_*): Remove prototypes now defined in
semaphore.h.
* pthread.h (sempahore.h): Include.
* semaphore.h: New file for POSIX 1b semaphores.
* semaphore.c (ptw32_sem_timedwait): Moved to private.c.
* pthread.h (ptw32_sem_t): Change to sem_t.
* private.c (ptw32_sem_timedwait): Moved from semaphore.c;
set errno on error.
* pthread.h (pthread_t_): Add per-thread errno element.
Fri Apr 2 11:08:50 1999 John Bossom <jebossom at cognos.com>
* semaphore.c (ptw32_sem_*): Change to sem_*; these functions
will be exported from the library; set errno on error.
* errno.c (_errno): New file. New function.
Fri Mar 26 14:11:45 1999 Tor Lillqvist <tml at iki.fi>
* semaphore.c (ptw32_sem_timedwait): Check for negative
milliseconds.
Wed Mar 24 11:32:07 1999 John Bossom <jebossom at cognos.com>
* misc.c (CancelableWait): Initialise exceptionInformation[2].
(pthread_self): Get a real Win32 thread handle for implicit threads.
* cancel.c (pthread_testcancel): Initialise exceptionInformation[2].
* implement.h (SE_INFORMATION): Fix values.
* private.c (ptw32_threadDestroy): Close the thread handle.
Fri Mar 19 12:57:27 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* cancel.c (comments): Update and cleanup.
Fri Mar 19 09:12:59 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_threadStart): status returns PTHREAD_CANCELED.
* pthread.h (PTHREAD_CANCELED): defined.
Tue Mar 16 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* all: Add GNU LGPL and Copyright and Warranty.
Mon Mar 15 00:20:13 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* condvar.c (pthread_cond_init): fix possible uninitialised use
of cv.
Sun Mar 14 21:01:59 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* condvar.c (pthread_cond_destroy): don't do full cleanup if
static initialised cv has never been used.
(cond_timedwait): check result of auto-initialisation.
Thu Mar 11 09:01:48 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (pthread_mutex_t): revert to (pthread_mutex_t *);
define a value to serve as PTHREAD_MUTEX_INITIALIZER.
(pthread_mutex_t_): remove staticinit and valid elements.
(pthread_cond_t): revert to (pthread_cond_t_ *);
define a value to serve as PTHREAD_COND_INITIALIZER.
(pthread_cond_t_): remove staticinit and valid elements.
* mutex.c (pthread_mutex_t args): adjust indirection of references.
(all functions): check for PTHREAD_MUTEX_INITIALIZER value;
check for NULL (invalid).
* condvar.c (pthread_cond_t args): adjust indirection of references.
(all functions): check for PTHREAD_COND_INITIALIZER value;
check for NULL (invalid).
Wed Mar 10 17:18:12 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* misc.c (CancelableWait): Undo changes from Mar 8 and 7.
Mon Mar 8 11:18:59 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* misc.c (CancelableWait): Ensure cancelEvent handle is the lowest
indexed element in the handles array. Enhance test for abandoned
objects.
* pthread.h (PTHREAD_MUTEX_INITIALIZER): Trailing elements not
initialised are set to zero by the compiler. This avoids the
problem of initialising the opaque critical section element in it.
(PTHREAD_COND_INITIALIZER): Ditto.
* semaphore.c (ptw32_sem_timedwait): Check sem == NULL earlier.
Sun Mar 7 12:31:14 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* condvar.c (pthread_cond_init): set semaphore initial value
to 0, not 1. cond_timedwait was returning signaled immediately.
* misc.c (CancelableWait): Place the cancel event handle first
in the handle table for WaitForMultipleObjects. This ensures that
the cancel event is recognised and acted apon if both objects
happen to be signaled together.
* private.c (ptw32_cond_test_init_lock): Initialise and destroy.
* implement.h (ptw32_cond_test_init_lock): Add extern.
* global.c (ptw32_cond_test_init_lock): Add declaration.
* condvar.c (pthread_cond_destroy): check for valid initialised CV;
flag destroyed CVs as invalid.
(pthread_cond_init): pthread_cond_t is no longer just a pointer.
This is because PTHREAD_COND_INITIALIZER needs state info to reside
in pthread_cond_t so that it can initialise on first use. Will work on
making pthread_cond_t (and other objects like it) opaque again, if
possible, later.
(cond_timedwait): add check for statically initialisation of
CV; initialise on first use.
(pthread_cond_signal): check for valid CV.
(pthread_cond_broadcast): check for valid CV.
(_cond_check_need_init): Add.
* pthread.h (PTHREAD_COND_INITIALIZER): Fix.
(pthread_cond_t): no longer a pointer to pthread_cond_t_.
(pthread_cond_t_): add 'staticinit' and 'valid' elements.
Sat Mar 6 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Undate comments.
Sun Feb 21 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around
cs element initialiser.
1999-02-21 Ben Elliston <bje at cygnus.com>
* pthread.h (pthread_exit): The return type of this function is
void, not int.
* exit.c (pthread_exit): Do not return 0.
Sat Feb 20 16:03:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* dll.c (DLLMain): Expand TryEnterCriticalSection support test.
* mutex.c (pthread_mutex_trylock): The check for
ptw32_try_enter_critical_section == NULL should have been
removed long ago.
Fri Feb 19 16:03:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sync.c (pthread_join): Fix pthread_equal() test.
* mutex.c (pthread_mutex_trylock): Check mutex != NULL before
using it.
Thu Feb 18 16:17:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* misc.c (pthread_equal): Fix inverted result.
* Makefile.in: Use libpthread32.a as the name of the DLL export
library instead of pthread.lib.
* condvar.c (pthread_cond_init): cv could have been used unitialised;
initialise.
* create.c (pthread_create): parms could have been used unitialised;
initialise.
* pthread.h (struct pthread_once_t_): Remove redefinition.
Sat Feb 13 03:03:30 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (struct pthread_once_t_): Replaced.
* misc.c (pthread_once): Replace with John Bossom's version;
has lighter weight serialisation; fixes problem of not holding
competing threads until after the init_routine completes.
Thu Feb 11 13:34:14 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* misc.c (CancelableWait): Change C++ exception throw.
* sync.c (pthread_join): Change FIXME comment - issue resolved.
Wed Feb 10 12:49:11 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* configure: Various temporary changes.
- Kevin Ruland <Kevin.Ruland at anheuser-busch.com>
* README: Update.
* pthread.def (pthread_attr_getstackaddr): uncomment
(pthread_attr_setstackaddr): uncomment
Fri Feb 5 13:42:30 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* semaphore.c: Comment format changes.
Thu Feb 4 10:07:28 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* global.c: Remove ptw32_exception instantiation.
* cancel.c (pthread_testcancel): Change C++ exception throw.
* implement.h: Remove extern declaration.
Wed Feb 3 13:04:44 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* cleanup.c: Rename ptw32_*_cleanup() to pthread_*_cleanup().
* pthread.def: Ditto.
* pthread.h: Ditto.
* pthread.def (pthread_cleanup_push): Remove from export list;
the function is defined as a macro under all compilers.
(pthread_cleanup_pop): Ditto.
* pthread.h: Remove #if defined().
Wed Feb 3 10:13:48 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sync.c (pthread_join): Check for NULL value_ptr arg;
check for detached threads.
Tue Feb 2 18:07:43 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* implement.h: Add #include <pthread.h>.
Change sem_t to ptw32_sem_t.
Tue Feb 2 18:07:43 1999 Kevin Ruland <Kevin.Ruland at anheuser-busch.com>
* signal.c (pthread_sigmask): Add and modify casts.
Reverse LHS/RHS bitwise assignments.
* pthread.h: Remove #include <semaphore.h>.
(PTW32_ATTR_VALID): Add cast.
(struct pthread_t_): Add sigmask element.
* dll.c: Add "extern C" for DLLMain.
(DllMain): Add cast.
* create.c (pthread_create): Set sigmask in thread.
* condvar.c: Remove #include. Change sem_* to ptw32_sem_*.
* attr.c: Changed #include.
* Makefile.in: Additional targets and changes to build the library
as a DLL.
Fri Jan 29 11:56:28 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* Makefile.in (OBJS): Add semaphore.o to list.
* semaphore.c (ptw32_sem_timedwait): Move from private.c.
Rename sem_* to ptw32_sem_*.
* pthread.h (pthread_cond_t): Change type of sem_t.
_POSIX_SEMAPHORES no longer defined.
* semaphore.h: Contents moved to implement.h.
Removed from source tree.
* implement.h: Add semaphore function prototypes and rename all
functions to prepend 'ptw32_'. They are
now private to the pthreads-win32 implementation.
* private.c: Change #warning.
Move ptw32_sem_timedwait() to semaphore.c.
* cleanup.c: Change #warning.
* misc.c: Remove #include <errno.h>
* pthread.def: Cleanup CVS merge conflicts.
* global.c: Ditto.
* ChangeLog: Ditto.
* cleanup.c: Ditto.
Sun Jan 24 01:34:52 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* semaphore.c (sem_wait): Remove second arg to
pthreadCancelableWait() call.
Sat Jan 23 17:36:40 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.def: Add new functions to export list.
* pthread.h (PTHREAD_MUTEX_AUTO_CS_NP): New.
(PTHREAD_MUTEX_FORCE_CS_NP): New.
* README: Updated.
Fri Jan 22 14:31:59 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed
with egcs. Add -g for debugging.
* create.c (pthread_create): Replace __stdcall with PT_STDCALL
macro. This is a hack and must be fixed.
* misc.c (CancelableWait): Remove redundant statement.
* mutex.c (pthread_mutexattr_init): Cast calloc return value.
* misc.c (CancelableWait): Add cast.
(pthread_self): Add cast.
* exit.c (pthread_exit): Add cast.
* condvar.c (pthread_condattr_init): Cast calloc return value.
* cleanup.c: Reorganise conditional compilation.
* attr.c (pthread_attr_init): Remove unused 'result'.
Cast malloc return value.
* private.c (ptw32_callUserDestroyRoutines): Redo conditional
compilation.
* misc.c (CancelableWait): C++ version uses 'throw'.
* cancel.c (pthread_testcancel): Ditto.
* implement.h (class ptw32_exception): Define for C++.
* pthread.h: Fix C, C++, and Win32 SEH condition compilation
mayhem around pthread_cleanup_* defines. C++ version now uses John
Bossom's cleanup handlers.
(pthread_attr_t): Make 'valid' unsigned.
Define '_timeb' as 'timeb' for Ming32.
Define PT_STDCALL as nothing for Mingw32. May be temporary.
* cancel.c (pthread_testcancel): Cast return value.
Wed Jan 20 09:31:28 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (pthread_mutexattr_t): Changed to a pointer.
* mutex.c (pthread_mutex_init): Conditionally create Win32 mutex
- from John Bossom's implementation.
(pthread_mutex_destroy): Conditionally close Win32 mutex
- from John Bossom's implementation.
(pthread_mutexattr_init): Replaced by John Bossom's version.
(pthread_mutexattr_destroy): Ditto.
(pthread_mutexattr_getpshared): New function from John Bossom's
implementation.
(pthread_mutexattr_setpshared): New function from John Bossom's
implementation.
Tue Jan 19 18:27:42 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* pthread.h (pthreadCancelableTimedWait): New prototype.
(pthreadCancelableWait): Remove second argument.
* misc.c (CancelableWait): New static function is
pthreadCancelableWait() renamed.
(pthreadCancelableWait): Now just calls CancelableWait() with
INFINITE timeout.
(pthreadCancelableTimedWait): Just calls CancelableWait()
with passed in timeout.
Tue Jan 19 18:27:42 1999 Scott Lightner <scott at curriculum.com>
* private.c (ptw32_sem_timedwait): 'abstime' arg really is
absolute time. Calculate relative time to wait from current
time before passing timeout to new routine
pthreadCancelableTimedWait().
Tue Jan 19 10:27:39 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (pthread_mutexattr_setforcecs_np): New prototype.
* mutex.c (pthread_mutexattr_init): Init 'pshared' and 'forcecs'
attributes to 0.
(pthread_mutexattr_setforcecs_np): New function (not portable).
* pthread.h (pthread_mutex_t):
Add 'mutex' element. Set to NULL in PTHREAD_MUTEX_INITIALIZER.
The pthread_mutex_*() routines will try to optimise performance
by choosing either mutexes or critical sections as the basis
for pthread mutexes for each indevidual mutex.
(pthread_mutexattr_t_): Add 'forcecs' element.
Some applications may choose to force use of critical sections
if they know that:-
the mutex is PROCESS_PRIVATE and,
either the OS supports TryEnterCriticalSection() or
pthread_mutex_trylock() will never be called on the mutex.
This attribute will be setable via a non-portable routine.
Note: We don't yet support PROCESS_SHARED mutexes, so the
implementation as it stands will default to Win32 mutexes only if
the OS doesn't support TryEnterCriticalSection. On Win9x, and early
versions of NT 'forcecs' will need to be set in order to get
critical section based mutexes.
Sun Jan 17 12:01:26 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit'
value to '1' and existing 'valid' value to '1'.
* global.c (ptw32_mutex_test_init_lock): Add.
* implement.h (ptw32_mutex_test_init_lock.): Add extern.
* private.c (ptw32_processInitialize): Init critical section for
global lock used by _mutex_check_need_init().
(ptw32_processTerminate): Ditto (:s/Init/Destroy/).
* dll.c (dllMain): Move call to FreeLibrary() so that it is only
called once when the process detaches.
* mutex.c (_mutex_check_need_init): New static function to test
and init PTHREAD_MUTEX_INITIALIZER mutexes. Provides serialised
access to the internal state of the uninitialised static mutex.
Called from pthread_mutex_trylock() and pthread_mutex_lock() which
do a quick unguarded test to check if _mutex_check_need_init()
needs to be called. This is safe as the test is conservative
and is repeated inside the guarded section of
_mutex_check_need_init(). Thus in all calls except the first
calls to lock static mutexes, the additional overhead to lock any
mutex is a single memory fetch and test for zero.
* pthread.h (pthread_mutex_t_): Add 'staticinit' member. Mutexes
initialised by PTHREAD_MUTEX_INITIALIZER aren't really initialised
until the first attempt to lock it. Using the 'valid'
flag (which flags the mutex as destroyed or not) to record this
information would be messy. It is possible for a statically
initialised mutex such as this to be destroyed before ever being
used.
* mutex.c (pthread_mutex_trylock): Call _mutex_check_need_init()
to test/init PTHREAD_MUTEX_INITIALIZER mutexes.
(pthread_mutex_lock): Ditto.
(pthread_mutex_unlock): Add check to ensure we don't try to unlock
an unitialised static mutex.
(pthread_mutex_destroy): Add check to ensure we don't try to delete
a critical section that we never created. Allows us to destroy
a static mutex that has never been locked (and hence initialised).
(pthread_mutex_init): Set 'staticinit' flag to 0 for the new mutex.
Sun Jan 17 12:01:26 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_sem_timedwait): Move from semaphore.c.
* semaphore.c : Remove redundant #includes.
(ptw32_sem_timedwait): Move to private.c.
(sem_wait): Add missing abstime arg to pthreadCancelableWait() call.
Fri Jan 15 23:38:05 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* condvar.c (cond_timedwait): Remove comment.
Fri Jan 15 15:41:28 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* pthread.h: Add new 'abstime' arg to pthreadCancelableWait()
prototype.
* condvar.c (cond_timedwait): New generalised function called by
both pthread_cond_wait() and pthread_cond_timedwait(). This is
essentially pthread_cond_wait() renamed and modified to add the
'abstime' arg and call the new ptw32_sem_timedwait() instead of
sem_wait().
(pthread_cond_wait): Now just calls the internal static
function cond_timedwait() with an INFINITE wait.
(pthread_cond_timedwait): Now implemented. Calls the internal
static function cond_timedwait().
* implement.h (ptw32_sem_timedwait): New internal function
prototype.
* misc.c (pthreadCancelableWait): Added new 'abstime' argument
to allow shorter than INFINITE wait.
* semaphore.c (ptw32_sem_timedwait): New function for internal
use. This is essentially sem_wait() modified to add the
'abstime' arg and call the modified (see above)
pthreadCancelableWait().
Thu Jan 14 14:27:13 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* cleanup.c: Correct _cplusplus to __cplusplus wherever used.
* Makefile.in: Add CC=g++ and add -fhandle-exceptions to CFLAGS.
The derived Makefile will compile all units of the package as C++
so that those which include try/catch exception handling should work
properly. The package should compile ok if CC=gcc, however, exception
handling will not be included and thus thread cancellation, for
example, will not work.
* cleanup.c (ptw32_pop_cleanup): Add #warning to compile this
file as C++ if using a cygwin32 environment. Perhaps the whole package
should be compiled using g++ under cygwin.
* private.c (ptw32_threadStart): Change #error directive
into #warning and bracket for __CYGWIN__ and derivative compilers.
Wed Jan 13 09:34:52 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* build.bat: Delete old binaries before compiling/linking.
Tue Jan 12 09:58:38 1999 Tor Lillqvist <tml at iki.fi>
* dll.c: The Microsoft compiler pragmas probably are more
appropriately protected by _MSC_VER than by _WIN32.
* pthread.h: Define ETIMEDOUT. This should be returned by
pthread_cond_timedwait which is not implemented yet as of
snapshot-1999-01-04-1305. It was implemented in the older version.
The Microsoft compiler pragmas probably are more appropriately
protected by _MSC_VER than by _WIN32.
* pthread.def: pthread_mutex_destroy was missing from the def file
* condvar.c (pthread_cond_broadcast): Ensure we only wait on threads
if there were any waiting on the condition.
I think pthread_cond_broadcast should do the WaitForSingleObject
only if cv->waiters > 0? Otherwise it seems to hang, at least in the
testg thread program from glib.
Tue Jan 12 09:58:38 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* condvar.c (pthread_cond_timedwait): Fix function description
comments.
* semaphore.c (sem_post): Correct typo in comment.
Mon Jan 11 20:33:19 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h: Re-arrange conditional compile of pthread_cleanup-*
macros.
* cleanup.c (ptw32_push_cleanup): Provide conditional
compile of cleanup->prev.
1999-01-11 Tor Lillqvist <tml at iki.fi>
* condvar.c (pthread_cond_init): Invert logic when testing the
return value from calloc().
Sat Jan 9 14:32:08 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Compile-time switch for CYGWIN derived environments
to use CreateThread instead of _beginthreadex. Ditto for ExitThread.
Patch provided by Anders Norlander <anorland at hem2.passagen.se>.
Tue Jan 5 16:33:04 1999 Ross Johnson <rpj at swan.canberra.edu.au>
* cleanup.c (ptw32_pop_cleanup): Add C++ version of __try/__except
block. Move trailing "}" out of #ifdef _WIN32 block left there by
(rpj's) mistake.
* private.c: Remove #include <errno.h> which is included by pthread.h.
1998-12-11 Ben Elliston <bje at toilet.to.cygnus.com>
* README: Update info about subscribing to the mailing list.
Mon Jan 4 11:23:40 1999 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* all: No code changes, just cleanup.
- remove #if 0 /* Pre Bossom */ enclosed code.
- Remove some redundant #includes.
* pthread.h: Update implemented/unimplemented routines list.
* Tag the bossom merge branch getting ready to merge back to main
trunk.
Tue Dec 29 13:11:16 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Move the following struct definitions to pthread.h:
pthread_t_, pthread_attr_t_, pthread_mutex_t_, pthread_mutex_t_,
pthread_mutexattr_t_, pthread_key_t_, pthread_cond_t_,
pthread_condattr_t_, pthread_once_t_.
* pthread.h: Add "_" prefix to pthread_push_cleanup and
pthread_pop_cleanup internal routines, and associated struct and
typedefs.
* buildlib.bat: Add compile command for semaphore.c
* pthread.def: Comment out pthread_atfork routine name.
Now unimplemented.
* tsd.c (pthread_setspecific): Rename tkAssocCreate to
ptw32_tkAssocCreate.
(pthread_key_delete): Rename tkAssocDestroy to
ptw32_tkAssocDestroy.
* sync.c (pthread_join): Rename threadDestroy to ptw32_threadDestroy
* sched.c (is_attr): attr is now **attr (was *attr), so add extra
NULL pointer test.
(pthread_attr_setschedparam): Increase redirection for attr which is
now a **.
(pthread_attr_getschedparam): Ditto.
(pthread_setschedparam): Change thread validation and rename "thread"
Win32 thread Handle element name to match John Bossom's version.
(pthread_getschedparam): Ditto.
* private.c (ptw32_threadDestroy): Rename call to
callUserDestroyRoutines() as ptw32_callUserDestroyRoutines()
* misc.c: Add #include "implement.h".
* dll.c: Remove defined(KLUDGE) wrapped code.
* fork.c: Remove redefinition of ENOMEM.
Remove pthread_atfork() and fork() with #if 0/#endif.
* create.c (pthread_create): Rename threadStart and threadDestroy calls
to ptw32_threadStart and ptw32_threadDestroy.
* implement.h: Rename "detachedstate" to "detachstate".
* attr.c: Rename "detachedstate" to "detachstate".
Mon Dec 28 09:54:39 1998 John Bossom
* semaphore.c: Initial version.
* semaphore.h: Initial version.
Mon Dec 28 09:54:39 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.h (pthread_attr_t_): Change to *pthread_attr_t.
Mon Dec 28 09:54:39 1998 John Bossom, Ben Elliston
* attr.c (pthread_attr_setstacksize): Merge with John's version.
(pthread_attr_getstacksize): Merge with John's version.
(pthread_attr_setstackaddr): Merge with John's version.
(pthread_attr_getstackaddr): Merge with John's version.
(pthread_attr_init): Merge with John's version.
(pthread_attr_destroy): Merge with John's version.
(pthread_attr_getdetachstate): Merge with John's version.
(pthread_attr_setdetachstate): Merge with John's version.
(is_attr): attr is now **attr (was *attr), so add extra NULL pointer
test.
Mon Dec 28 09:54:39 1998 Ross Johnson
* implement.h (pthread_attr_t_): Add and rename elements in JEB's
version to correspond to original, so that it can be used with
original attr routines.
* pthread.h: Add #endif at end which was truncated in merging.
Sun Dec 20 14:51:58 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* misc.c (pthreadCancelableWait): New function by John Bossom. Non-standard
but provides a hook that can be used to implement cancellation points in
applications that use this library.
* pthread.h (pthread_cleanup_pop): C++ (non-WIN32) version uses
try/catch to emulate John Bossom's WIN32 __try/__finally behaviour.
In the WIN32 version __finally block, add a test for AbnormalTermination otherwise
cleanup is only run if the cleanup_pop execute arg is non-zero. Cancellation
should cause the cleanup to run irrespective of the execute arg.
* condvar.c (pthread_condattr_init): Replaced by John Bossom's version.
(pthread_condattr_destroy): Replaced by John Bossom's version.
(pthread_condattr_getpshared): Replaced by John Bossom's version.
(pthread_condattr_setpshared): Replaced by John Bossom's version.
(pthread_cond_init): Replaced by John Bossom's version.
Fix comment (refered to mutex rather than condition variable).
(pthread_cond_destroy): Replaced by John Bossom's version.
(pthread_cond_wait): Replaced by John Bossom's version.
(pthread_cond_timedwait): Replaced by John Bossom's version.
(pthread_cond_signal): Replaced by John Bossom's version.
(pthread_cond_broadcast): Replaced by John Bossom's version.
Thu Dec 17 19:10:46 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* tsd.c (pthread_key_create): Replaced by John Bossom's version.
(pthread_key_delete): Replaced by John Bossom's version.
(pthread_setspecific): Replaced by John Bossom's version.
(pthread_getspecific): Replaced by John Bossom's version.
Mon Dec 7 09:44:40 1998 John Bossom
* cancel.c (pthread_setcancelstate): Replaced.
(pthread_setcanceltype): Replaced.
(pthread_testcancel): Replaced.
(pthread_cancel): Replaced.
* exit.c (pthread_exit): Replaced.
* misc.c (pthread_self): Replaced.
(pthread_equal): Replaced.
* sync.c (pthread_detach): Replaced.
(pthread_join): Replaced.
* create.c (pthread_create): Replaced.
* private.c (ptw32_processInitialize): New.
(ptw32_processTerminate): New.
(ptw32_threadStart): New.
(ptw32_threadDestroy): New.
(ptw32_cleanupStack): New.
(ptw32_tkAssocCreate): New.
(ptw32_tkAssocDestroy): New.
(ptw32_callUserDestroyRoutines): New.
* implement.h: Added non-API structures and declarations.
* dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress
to resolve compile warning from MSVC.
* dll.c (DLLmain): Replaced.
* dll.c (PthreadsEntryPoint):
Re-applied Anders Norlander's patch:-
Initialize ptw32_try_enter_critical_section at startup
and release kernel32 handle when DLL is being unloaded.
Sun Dec 6 21:54:35 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* buildlib.bat: Fix args to CL when building the .DLL
* cleanup.c (ptw32_destructor_run_all): Fix TSD key management.
This is a tidy-up before TSD and Thread management is completely
replaced by John Bossom's code.
* tsd.c (pthread_key_create): Fix TSD key management.
* global.c (ptw32_key_virgin_next): Initialise.
* build.bat: New DOS script to compile and link a pthreads app
using Microsoft's CL compiler linker.
* buildlib.bat: New DOS script to compile all the object files
and create pthread.lib and pthread.dll using Microsoft's CL
compiler linker.
1998-12-05 Anders Norlander <anorland at hem2.passagen.se>
* implement.h (ptw32_try_enter_critical_section): New extern
* dll.c (ptw32_try_enter_critical_section): New pointer to
TryEnterCriticalSection if it exists; otherwise NULL.
* dll.c (PthreadsEntryPoint):
Initialize ptw32_try_enter_critical_section at startup
and release kernel32 handle when DLL is being unloaded.
* mutex.c (pthread_mutex_trylock): Replaced check for NT with
a check if ptw32_try_enter_critical_section is valid
pointer to a function. Call ptw32_try_enter_critical_section
instead of TryEnterCriticalSection to avoid errors on Win95.
Thu Dec 3 13:32:00 1998 Ross Johnson <rpj at ise.canberra.edu.au>
* README: Correct cygwin32 compatibility statement.
Sun Nov 15 21:24:06 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* cleanup.c (ptw32_destructor_run_all): Declare missing void * arg.
Fixup CVS merge conflicts.
1998-10-30 Ben Elliston <bje at cygnus.com>
* condvar.c (cond_wait): Fix semantic error. Test for equality
instead of making an assignment.
Fri Oct 30 15:15:50 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* cleanup.c (ptw32_handler_push): Fixed bug appending new
handler to list reported by Peter Slacik
<Peter.Slacik at leibinger.freinet.de>.
(new_thread): Rename poorly named local variable to
"new_handler".
Sat Oct 24 18:34:59 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* global.c: Add TSD key management array and index declarations.
* implement.h: Ditto for externs.
Fri Oct 23 00:08:09 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h (PTW32_TSD_KEY_REUSE): Add enum.
* private.c (ptw32_delete_thread): Add call to
ptw32_destructor_run_all() to clean up the threads keys.
* cleanup.c (ptw32_destructor_run_all): Check for no more dirty
keys to run destructors on. Assume that the destructor call always
succeeds and set the key value to NULL.
Thu Oct 22 21:44:44 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* tsd.c (pthread_setspecific): Add key management code.
(pthread_key_create): Ditto.
(pthread_key_delete): Ditto.
* implement.h (struct ptw32_tsd_key): Add status member.
* tsd.c: Add description of pthread_key_delete() from the
standard as a comment.
Fri Oct 16 17:38:47 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* cleanup.c (ptw32_destructor_run_all): Fix and improve
stepping through the key table.
Thu Oct 15 14:05:01 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* private.c (ptw32_new_thread): Remove init of destructorstack.
No longer an element of pthread_t.
* tsd.c (pthread_setspecific): Fix type declaration and cast.
(pthread_getspecific): Ditto.
(pthread_getspecific): Change error return value to NULL if key
is not in use.
Thu Oct 15 11:53:21 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* global.c (ptw32_tsd_key_table): Fix declaration.
* implement.h(ptw32_TSD_keys_TlsIndex): Add missing extern.
(ptw32_tsd_mutex): Ditto.
* create.c (ptw32_start_call): Fix "keys" array declaration.
Add comment.
* tsd.c (pthread_setspecific): Fix type declaration and cast.
(pthread_getspecific): Ditto.
* cleanup.c (ptw32_destructor_run_all): Declare missing loop
counter.
Wed Oct 14 21:09:24 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_new_thread): Increment ptw32_threads_count.
(ptw32_delete_thread): Decrement ptw32_threads_count.
Remove some comments.
* exit.c (ptw32_exit): : Fix two pthread_mutex_lock() calls that
should have been pthread_mutex_unlock() calls.
(ptw32_vacuum): Remove call to ptw32_destructor_pop_all().
* create.c (pthread_create): Fix two pthread_mutex_lock() calls that
should have been pthread_mutex_unlock() calls.
* global.c (ptw32_tsd_mutex): Add mutex for TSD operations.
* tsd.c (pthread_key_create): Add critical section.
(pthread_setspecific): Ditto.
(pthread_getspecific): Ditto.
(pthread_key_delete): Ditto.
* sync.c (pthread_join): Fix two pthread_mutex_lock() calls that
should have been pthread_mutex_unlock() calls.
Mon Oct 12 00:00:44 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h (ptw32_tsd_key_table): New.
* create.c (ptw32_start_call): Initialise per-thread TSD keys
to NULL.
* misc.c (pthread_once): Correct typo in comment.
* implement.h (ptw32_destructor_push): Remove.
(ptw32_destructor_pop): Remove.
(ptw32_destructor_run_all): Rename from ptw32_destructor_pop_all.
(PTW32_TSD_KEY_DELETED): Add enum.
(PTW32_TSD_KEY_INUSE): Add enum.
* cleanup.c (ptw32_destructor_push): Remove.
(ptw32_destructor_pop): Remove.
(ptw32_destructor_run_all): Totally revamped TSD.
* dll.c (ptw32_TSD_keys_TlsIndex): Initialise.
* tsd.c (pthread_setspecific): Totally revamped TSD.
(pthread_getspecific): Ditto.
(pthread_create): Ditto.
(pthread_delete): Ditto.
Sun Oct 11 22:44:55 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* global.c (ptw32_tsd_key_table): Add new global.
* implement.h (ptw32_tsd_key_t and struct ptw32_tsd_key):
Add.
(struct _pthread): Remove destructorstack.
* cleanup.c (ptw32_destructor_run_all): Rename from
ptw32_destructor_pop_all. The key destructor stack was made
global rather than per-thread. No longer removes destructor nodes
from the stack. Comments updated.
1998-10-06 Ben Elliston <bje at cygnus.com>
* condvar.c (cond_wait): Use POSIX, not Win32 mutex calls.
(pthread_cond_broadcast): Likewise.
(pthread_cond_signal): Likewise.
1998-10-05 Ben Elliston <bje at cygnus.com>
* pthread.def: Update. Some functions aren't available yet, others
are macros in <pthread.h>.
* tests/join.c: Remove; useless.
Mon Oct 5 14:25:08 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* pthread.def: New file for building the DLL.
1998-10-05 Ben Elliston <bje at cygnus.com>
* misc.c (pthread_equal): Correct inverted logic bug.
(pthread_once): Use the POSIX mutex primitives, not Win32. Remove
irrelevant FIXME comment.
* global.c (PTHREAD_MUTEX_INITIALIZER): Move to pthread.h.
* pthread.h (PTHREAD_MUTEX_INITIALIZER): Define.
(pthread_mutex_t): Reimplement as a struct containing a valid
flag. If the flag is ever down upon entry to a mutex operation,
we call pthread_mutex_create() to initialise the object. This
fixes the problem of how to handle statically initialised objects
that can't call InitializeCriticalSection() due to their context.
(PTHREAD_ONCE_INIT): Define.
* mutex.c (pthread_mutex_init): Set valid flag.
(pthread_mutex_destroy): Clear valid flag.
(pthread_mutex_lock): Check and handle the valid flag.
(pthread_mutex_unlock): Likewise.
(pthread_mutex_trylock): Likewise.
* tests/mutex3.c: New file; test for the static initialisation
macro. Passes.
* tests/create1.c: New file; test pthread_create(). Passes.
* tests/equal.c: Poor test; remove.
* tests/equal1.c New file; test pthread_equal(). Passes.
* tests/once1.c: New file; test for pthread_once(). Passes.
* tests/self.c: Remove; rename to self1.c.
* tests/self1.c: This is the old self.c.
* tests/self2.c: New file. Test pthread_self() with a single
thread. Passes.
* tests/self3.c: New file. Test pthread_self() with a couple of
threads to ensure their thread IDs differ. Passes.
1998-10-04 Ben Elliston <bje at cygnus.com>
* tests/mutex2.c: Test pthread_mutex_trylock(). Passes.
* tests/mutex1.c: New basic test for mutex functions (it passes).
(main): Eliminate warning.
* configure.in: Test for __stdcall, not _stdcall. Typo.
* configure: Regenerate.
* attr.c (pthread_attr_setstackaddr): Remove FIXME comment. Win32
does know about ENOSYS after all.
(pthread_attr_setstackaddr): Likewise.
1998-10-03 Ben Elliston <bje at cygnus.com>
* configure.in: Test for the `_stdcall' keyword. Define `STDCALL'
to `_stdcall' if we have it, null otherwise.
* configure: Regenerate.
* acconfig.h (STDCALL): New define.
* config.h.in: Regenerate.
* create.c (ptw32_start_call): Add STDCALL prefix.
* mutex.c (pthread_mutex_init): Correct function signature.
* attr.c (pthread_attr_init): Only zero out the `sigmask' member
if we have the sigset_t type.
* pthread.h: No need to include <unistd.h>. It doesn't even exist
on Win32! Again, an artifact of cross-compilation.
(pthread_sigmask): Only provide if we have the sigset_t type.
* process.h: Remove. This was a stand-in before we started doing
native compilation under Win32.
* pthread.h (pthread_mutex_init): Make `attr' argument const.
1998-10-02 Ben Elliston <bje at cygnus.com>
* COPYING: Remove.
* COPYING.LIB: Add. This library is under the LGPL.
1998-09-13 Ben Elliston <bje at cygnus.com>
* configure.in: Test for required system features.
* configure: Generate.
* acconfig.h: New file.
* config.h.in: Generate.
* Makefile.in: Renamed from Makefile.
* COPYING: Import from a recent GNU package.
* config.guess: Likewise.
* config.sub: Likewise.
* install-sh: Likewise.
* config.h: Remove.
* Makefile: Likewise.
1998-09-12 Ben Elliston <bje at cygnus.com>
* windows.h: No longer needed; remove.
* windows.c: Likewise.
Sat Sep 12 20:09:24 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* windows.h: Remove error number definitions. These are in <errno.h>
* tsd.c: Add comment explaining rationale for not building
POSIX TSD on top of Win32 TLS.
1998-09-12 Ben Elliston <bje at cygnus.com>
* {most}.c: Include <errno.h> to get POSIX error values.
* signal.c (pthread_sigmask): Only provide if HAVE_SIGSET_T is
defined.
* config.h: #undef features, don't #define them. This will be
generated by autoconf very soon.
1998-08-11 Ben Elliston <bje at cygnus.com>
* Makefile (LIB): Define.
(clean): Define target.
(all): Build a library not just the object files.
* pthread.h: Provide a definition for struct timespec if we don't
already have one.
* windows.c (TlsGetValue): Bug fix.
Thu Aug 6 15:19:22 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* misc.c (pthread_once): Fix arg 1 of EnterCriticalSection()
and LeaveCriticalSection() calls to pass address-of lock.
* fork.c (pthread_atfork): Typecast (void (*)(void *)) funcptr
in each ptw32_handler_push() call.
* exit.c (ptw32_exit): Fix attr arg in
pthread_attr_getdetachstate() call.
* private.c (ptw32_new_thread): Typecast (HANDLE) NULL.
(ptw32_delete_thread): Ditto.
* implement.h: (PTW32_MAX_THREADS): Add define. This keeps
changing in an attempt to make thread administration data types
opaque and cleanup DLL startup.
* dll.c (PthreadsEntryPoint):
(ptw32_virgins): Remove malloc() and free() calls.
(ptw32_reuse): Ditto.
(ptw32_win32handle_map): Ditto.
(ptw32_threads_mutex_table): Ditto.
* global.c (_POSIX_THREAD_THREADS_MAX): Initialise with
PTW32_MAX_THREADS.
(ptw32_virgins): Ditto.
(ptw32_reuse): Ditto.
(ptw32_win32handle_map): Ditto.
(ptw32_threads_mutex_table): Ditto.
* create.c (pthread_create): Typecast (HANDLE) NULL.
Typecast (unsigned (*)(void *)) start_routine.
* condvar.c (pthread_cond_init): Add address-of operator & to
arg 1 of pthread_mutex_init() call.
(pthread_cond_destroy): Add address-of operator & to
arg 1 of pthread_mutex_destroy() call.
* cleanup.c (ptw32_destructor_pop_all): Add (int) cast to
pthread_getspecific() arg.
(ptw32_destructor_pop): Add (void *) cast to "if" conditional.
(ptw32_destructor_push): Add (void *) cast to
ptw32_handler_push() "key" arg.
(malloc.h): Add include.
* implement.h (ptw32_destructor_pop): Add prototype.
* tsd.c (implement.h): Add include.
* sync.c (pthread_join): Remove target_thread_mutex and it's
initialisation. Rename getdetachedstate to getdetachstate.
Remove unused variable "exitcode".
(pthread_detach): Remove target_thread_mutex and it's
initialisation. Rename getdetachedstate to getdetachstate.
Rename setdetachedstate to setdetachstate.
* signal.c (pthread_sigmask): Rename SIG_SET to SIG_SETMASK.
Cast "set" to (long *) in assignment to passify compiler warning.
Add address-of operator & to thread->attr.sigmask in memcpy() call
and assignment.
(pthread_sigmask): Add address-of operator & to thread->attr.sigmask
in memcpy() call and assignment.
* windows.h (THREAD_PRIORITY_ERROR_RETURN): Add.
(THREAD_PRIORITY_LOWEST): Add.
(THREAD_PRIORITY_HIGHEST): Add.
* sched.c (is_attr): Add function.
(implement.h): Add include.
(pthread_setschedparam): Rename all instances of "sched_policy"
to "sched_priority".
(pthread_getschedparam): Ditto.
Tue Aug 4 16:57:58 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* private.c (ptw32_delete_thread): Fix typo. Add missing ';'.
* global.c (ptw32_virgins): Change types from pointer to
array pointer.
(ptw32_reuse): Ditto.
(ptw32_win32handle_map): Ditto.
(ptw32_threads_mutex_table): Ditto.
* implement.h(ptw32_virgins): Change types from pointer to
array pointer.
(ptw32_reuse): Ditto.
(ptw32_win32handle_map): Ditto.
(ptw32_threads_mutex_table): Ditto.
* private.c (ptw32_delete_thread): Fix "entry" should be "thread".
* misc.c (pthread_self): Add extern for ptw32_threadID_TlsIndex.
* global.c: Add comment.
* misc.c (pthread_once): Fix member -> dereferences.
Change ptw32_once_flag to once_control->flag in "if" test.
Tue Aug 4 00:09:30 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h(ptw32_virgins): Add extern.
(ptw32_virgin_next): Ditto.
(ptw32_reuse): Ditto.
(ptw32_reuse_top): Ditto.
(ptw32_win32handle_map): Ditto.
(ptw32_threads_mutex_table): Ditto.
* global.c (ptw32_virgins): Changed from array to pointer.
Storage allocation for the array moved into dll.c.
(ptw32_reuse): Ditto.
(ptw32_win32handle_map): Ditto.
(ptw32_threads_mutex_table): Ditto.
* dll.c (PthreadsEntryPoint): Set up thread admin storage when
DLL is loaded.
* fork.c (pthread_atfork): Fix function pointer arg to all
ptw32_handler_push() calls. Change "arg" arg to NULL in child push.
* exit.c: Add windows.h and process.h includes.
(ptw32_exit): Add local detachstate declaration.
(ptw32_exit): Fix incorrect name for pthread_attr_getdetachstate().
* pthread.h (_POSIX_THREAD_ATTR_STACKSIZE): Move from global.c
(_POSIX_THREAD_ATTR_STACKADDR): Ditto.
* create.c (pthread_create): Fix #if should be #ifdef.
(ptw32_start_call): Remove usused variables.
* process.h: Create.
* windows.h: Move _beginthreadex and _endthreadex into
process.h
Mon Aug 3 21:19:57 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* condvar.c (pthread_cond_init): Add NULL attr to
pthread_mutex_init() call - default attributes will be used.
(cond_wait): Fix typo.
(cond_wait): Fix typo - cv was ev.
(pthread_cond_broadcast): Fix two identical typos.
* cleanup.c (ptw32_destructor_pop_all): Remove _ prefix from
PTHREAD_DESTRUCTOR_ITERATIONS.
* pthread.h: Move _POSIX_* values into posix.h
* pthread.h: Fix typo in pthread_mutex_init() prototype.
* attr.c (pthread_attr_init): Fix error in priority member init.
* windows.h (THREAD_PRIORITY_NORMAL): Add.
* pthread.h (sched_param): Add missing ';' to struct definition.
* attr.c (pthread_attr_init): Remove obsolete pthread_attr_t
member initialisation - cancelstate, canceltype, cancel_pending.
(is_attr): Make arg "attr" a const.
* implement.h (PTW32_HANDLER_POP_LIFO): Remove definition.
(PTW32_HANDLER_POP_FIFO): Ditto.
(PTW32_VALID): Add missing newline escape (\).
(ptw32_handler_node): Make element "next" a pointer.
1998-08-02 Ben Elliston <bje at cygnus.com>
* windows.h: Remove duplicate TlsSetValue() prototype. Add
TlsGetValue() prototype.
(FALSE): Define.
(TRUE): Likewise.
Add forgotten errno values. Guard against multiple #includes.
* windows.c: New file. Implement stubs for Win32 functions.
* Makefile (SRCS): Remove. Not explicitly needed.
(CFLAGS): Add -Wall for all warnings with GCC.
Sun Aug 2 19:03:42 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* config.h: Create. This is a temporary stand-in for autoconf yet
to be done.
(HAVE_SIGNAL_H): Add.
* pthread.h: Minor rearrangement for temporary config.h.
Fri Jul 31 14:00:29 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* cleanup.c (ptw32_destructor_pop): Implement. Removes
destructors associated with a key without executing them.
(ptw32_destructor_pop_all): Add FIXME comment.
* tsd.c (pthread_key_delete): Add call to ptw32_destructor_pop().
Fri Jul 31 00:05:45 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* tsd.c (pthread_key_create): Update to properly associate
the destructor routine with the key.
(pthread_key_delete): Add FIXME comment.
* exit.c (ptw32_vacuum): Add call to
ptw32_destructor_pop_all().
* implement.h (ptw32_handler_pop_all): Add prototype.
(ptw32_destructor_pop_all): Ditto.
* cleanup.c (ptw32_destructor_push): Implement. This is just a
call to ptw32_handler_push().
(ptw32_destructor_pop_all): Implement. This is significantly
different to ptw32_handler_pop_all().
* Makefile (SRCS): Create. Preliminary.
* windows.h: Create. Contains Win32 definitions for compile
testing. This is just a standin for the real one.
* pthread.h (SIG_UNBLOCK): Fix typo. Was SIG_BLOCK.
(windows.h): Add include. Required for CRITICAL_SECTION.
(pthread_cond_t): Move enum declaration outside of struct
definition.
(unistd.h): Add include - may be temporary.
* condvar.c (windows.h): Add include.
* implement.h (PTW32_THIS): Remove - no longer required.
(PTW32_STACK): Use pthread_self() instead of PTW32_THIS.
Thu Jul 30 23:12:45 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Remove ptw32_find_entry() prototype.
* private.c: Extend comments.
Remove ptw32_find_entry() - no longer needed.
* create.c (ptw32_start_call): Add call to TlsSetValue() to
store the thread ID.
* dll.c (PthreadsEntryPoint): Implement. This is called
whenever a process loads the DLL. Used to initialise thread
local storage.
* implement.h: Add ptw32_threadID_TlsIndex.
Add ()s around PTW32_VALID expression.
* misc.c (pthread_self): Re-implement using Win32 TLS to store
the threads own ID.
Wed Jul 29 11:39:03 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c: Corrections in comments.
(ptw32_new_thread): Alter "if" flow to be more natural.
* cleanup.c (ptw32_handler_push): Same as below.
* create.c (pthread_create): Same as below.
* private.c (ptw32_new_thread): Rename "new" to "new_thread".
Since when has a C programmer been required to know C++?
Tue Jul 28 14:04:29 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* implement.h: Add PTW32_VALID macro.
* sync.c (pthread_join): Modify to use the new thread
type and ptw32_delete_thread(). Rename "target" to "thread".
Remove extra local variable "target".
(pthread_detach): Ditto.
* signal.c (pthread_sigmask): Move init of "us" out of inner block.
Fix instance of "this" should have been "us". Rename "us" to "thread".
* sched.c (pthread_setschedparam): Modify to use the new thread
type.
(pthread_getschedparam): Ditto.
* private.c (ptw32_find_thread): Fix return type and arg.
* implement.h: Remove PTW32_YES and PTW32_NO.
(ptw32_new_thread): Add prototype.
(ptw32_find_thread): Ditto.
(ptw32_delete_thread): Ditto.
(ptw32_new_thread_entry): Remove prototype.
(ptw32_find_thread_entry): Ditto.
(ptw32_delete_thread_entry): Ditto.
( PTW32_NEW, PTW32_INUSE, PTW32_EXITED, PTW32_REUSE):
Add.
* create.c (pthread_create): Minor rename "us" to "new" (I need
these cues but it doesn't stop me coming out with some major bugs
at times).
Load start_routine and arg into the thread so the wrapper can
call it.
* exit.c (pthread_exit): Fix pthread_this should be pthread_self.
* cancel.c (pthread_setcancelstate): Change
ptw32_threads_thread_t * to pthread_t and init with
pthread_this().
(pthread_setcanceltype): Ditto.
* exit.c (ptw32_exit): Add new pthread_t arg.
Rename ptw32_delete_thread_entry to ptw32_delete_thread.
Rename "us" to "thread".
(pthread_exit): Call ptw32_exit with added thread arg.
* create.c (ptw32_start_call): Insert missing ")".
Add "us" arg to ptw32_exit() call.
(pthread_create): Modify to use new thread allocation scheme.
* private.c: Added detailed explanation of the new thread
allocation scheme.
(ptw32_new_thread): Totally rewritten to use
new thread allocation scheme.
(ptw32_delete_thread): Ditto.
(ptw32_find_thread): Obsolete.
Mon Jul 27 17:46:37 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* create.c (pthread_create): Start of rewrite. Not completed yet.
* private.c (ptw32_new_thread_entry): Start of rewrite. Not
complete.
* implement.h (ptw32_threads_thread): Rename, remove thread
member, add win32handle and ptstatus members.
(ptw32_t): Add.
* pthread.h: pthread_t is no longer mapped directly to a Win32
HANDLE type. This is so we can let the Win32 thread terminate and
reuse the HANDLE while pthreads holds it's own thread ID until
the last waiting join exits.
Mon Jul 27 00:20:37 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_delete_thread_entry): Destroy the thread
entry attribute object before deleting the thread entry itself.
* attr.c (pthread_attr_init): Initialise cancel_pending = FALSE.
(pthread_attr_setdetachstate): Rename "detached" to "detachedstate".
(pthread_attr_getdetachstate): Ditto.
* exit.c (ptw32_exit): Fix incorrect check for detachedstate.
* implement.h (ptw32_call_t): Remove env member.
Sun Jul 26 13:06:12 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h (ptw32_new_thread_entry): Fix prototype.
(ptw32_find_thread_entry): Ditto.
(ptw32_delete_thread_entry): Ditto.
(ptw32_exit): Add prototype.
* exit.c (ptw32_exit): New function. Called from pthread_exit()
and ptw32_start_call() to exit the thread. It allows an extra
argument which is the return code passed to _endthreadex().
(ptw32_exit): Move thread entry delete call from ptw32_vacuum()
into here. Add more explanation of thread entry deletion.
(ptw32_exit): Clarify comment.
* create.c (ptw32_start_call): Change pthread_exit() call to
ptw32_exit() call.
* exit.c (ptw32_vacuum): Add thread entry deletion code
moved from ptw32_start_call(). See next item.
(pthread_exit): Remove longjmp(). Add mutex lock around thread table
manipulation code. This routine now calls _enthreadex().
* create.c (ptw32_start_call): Remove setjmp() call and move
cleanup code out. Call pthread_exit(NULL) to terminate the thread.
1998-07-26 Ben Elliston <bje at cygnus.com>
* tsd.c (pthread_getspecific): Update comments.
* mutex.c (pthread_mutexattr_setpshared): Not supported; remove.
(pthread_mutexattr_getpshared): Likewise.
* pthread.h (pthread_mutexattr_setpshared): Remove prototype.
(pthread_mutexattr_getpshared): Likewise.
Sun Jul 26 00:09:59 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sync.c: Rename all instances of ptw32_count_mutex to
ptw32_table_mutex.
* implement.h: Rename ptw32_count_mutex to
ptw32_table_mutex.
* global.c: Rename ptw32_count_mutex to
ptw32_table_mutex.
* create.c (pthread_create): Add critical sections.
(ptw32_start_call): Rename ptw32_count_mutex to
ptw32_table_mutex.
* cancel.c (pthread_setcancelstate): Fix indirection bug and rename
"this" to "us".
* signal.c (pthread_sigmask): Rename "this" to "us" and fix some
minor syntax errors. Declare "us" and initialise it.
* sync.c (pthread_detach): Rename "this" to "target".
* pthread.h: Converting PTHREAD_* defines to alias the (const int)
values in global.c.
* global.c: Started converting PTHREAD_* defines to (const int) as
a part of making the eventual pthreads DLL binary compatible
through version changes.
* condvar.c (cond_wait): Add cancelation point. This applies the
point to both pthread_cond_wait() and pthread_cond_timedwait().
* exit.c (pthread_exit): Rename "this" to "us".
* implement.h: Add comment.
* sync.c (pthread_join): I've satisfied myself that pthread_detach()
does set the detached attribute in the thread entry attributes
to PTHREAD_CREATE_DETACHED. "if" conditions were changed to test
that attribute instead of a separate flag.
* create.c (pthread_create): Rename "this" to "us".
(pthread_create): cancelstate and canceltype are not attributes
so the copy to thread entry attribute storage was removed.
Only the thread itself can change it's cancelstate or canceltype,
ie. the thread must exist already.
* private.c (ptw32_delete_thread_entry): Mutex locks removed.
Mutexes must be applied at the caller level.
(ptw32_new_thread_entry): Ditto.
(ptw32_new_thread_entry): Init cancelstate, canceltype, and
cancel_pending to default values.
(ptw32_new_thread_entry): Rename "this" to "new".
(ptw32_find_thread_entry): Rename "this" to "entry".
(ptw32_delete_thread_entry): Rename "thread_entry" to "entry".
* create.c (ptw32_start_call): Mutexes changed to
ptw32_count_mutex. All access to the threads table entries is
under the one mutex. Otherwise chaos reigns.
Sat Jul 25 23:16:51 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h (ptw32_threads_thread): Move cancelstate and
canceltype members out of pthread_attr_t into here.
* fork.c (fork): Add comment.
1998-07-25 Ben Elliston <bje at cygnus.com>
* fork.c (fork): Autoconfiscate.
Sat Jul 25 00:00:13 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* create.c (ptw32_start_call): Set thread priority. Ensure our
thread entry is removed from the thread table but only if
pthread_detach() was called and there are no waiting joins.
(pthread_create): Set detach flag in thread entry if the
thread is created PTHREAD_CREATE_DETACHED.
* pthread.h (pthread_attr_t): Rename member "detachedstate".
* attr.c (pthread_attr_init): Rename attr members.
* exit.c (pthread_exit): Fix indirection mistake.
* implement.h (PTW32_THREADS_TABLE_INDEX): Add.
* exit.c (ptw32_vacuum): Fix incorrect args to
ptw32_handler_pop_all() calls.
Make thread entry removal conditional.
* sync.c (pthread_join): Add multiple join and async detach handling.
* implement.h (PTW32_THREADS_TABLE_INDEX): Add.
* global.c (ptw32_threads_mutex_table): Add.
* implement.h (ptw32_once_flag): Remove.
(ptw32_once_lock): Ditto.
(ptw32_threads_mutex_table): Add.
* global.c (ptw32_once_flag): Remove.
(ptw32_once_lock): Ditto.
* sync.c (pthread_join): Fix tests involving new return value
from ptw32_find_thread_entry().
(pthread_detach): Ditto.
* private.c (ptw32_find_thread_entry): Failure return code
changed from -1 to NULL.
Fri Jul 24 23:09:33 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* create.c (pthread_create): Change . to -> in sigmask memcpy() args.
* pthread.h: (pthread_cancel): Add function prototype.
(pthread_testcancel): Ditto.
1998-07-24 Ben Elliston <bje at cygnus.com>
* pthread.h (pthread_condattr_t): Rename dummy structure member.
(pthread_mutexattr_t): Likewise.
Fri Jul 24 21:13:55 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* cancel.c (pthread_cancel): Implement.
(pthread_testcancel): Implement.
* exit.c (pthread_exit): Add comment explaining the longjmp().
* implement.h (ptw32_threads_thread_t): New member cancelthread.
(PTW32_YES): Define.
(PTW32_NO): Define.
(RND_SIZEOF): Remove.
* create.c (pthread_create): Rename cancelability to cancelstate.
* pthread.h (pthread_attr_t): Rename cancelability to cancelstate.
(PTHREAD_CANCELED): Define.
1998-07-24 Ben Elliston <bje at cygnus.com>
* pthread.h (SIG_BLOCK): Define if not already defined.
(SIG_UNBLOCK): Likewise.
(SIG_SETMASK): Likewise.
(pthread_attr_t): Add signal mask member.
(pthread_sigmask): Add function prototype.
* signal.c (pthread_sigmask): Implement.
* create.c: #include <string.h> to get a prototype for memcpy().
(pthread_create): New threads inherit their creator's signal
mask. Copy the signal mask to the new thread structure if we know
about signals.
Fri Jul 24 16:33:17 1998 Ross Johnson <rpj at swan.canberra.edu.au>
* fork.c (pthread_atfork): Add all the necessary push calls.
Local implementation semantics:
If we get an ENOMEM at any time then ALL handlers
(including those from previous pthread_atfork() calls) will be
popped off each of the three atfork stacks before we return.
(fork): Add all the necessary pop calls. Add the thread cancellation
and join calls to the child fork.
Add #includes.
* implement.h: (ptw32_handler_push): Fix return type and stack arg
type in prototype.
(ptw32_handler_pop): Fix stack arg type in prototype.
(ptw32_handler_pop_all): Fix stack arg type in prototype.
* cleanup.c (ptw32_handler_push): Change return type to int and
return ENOMEM if malloc() fails.
* sync.c (pthread_detach): Use equality test, not assignment.
* create.c (ptw32_start_call): Add call to Win32 CloseHandle()
if thread is detached.
1998-07-24 Ben Elliston <bje at cygnus.com>
* sync.c (pthread_detach): Close the Win32 thread handle to
emulate detached (or daemon) threads.
Fri Jul 24 03:00:25 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sync.c (pthread_join): Save valueptr arg in joinvalueptr for
pthread_exit() to use.
* private.c (ptw32_new_thread_entry): Initialise joinvalueptr to
NULL.
* create.c (ptw32_start_call): Rewrite to facilitate joins.
pthread_exit() will do a longjmp() back to here. Does appropriate
cleanup and exit/return from the thread.
(pthread_create): _beginthreadex() now passes a pointer to our
thread table entry instead of just the call member of that entry.
* implement.h (ptw32_threads_thread): New member
void ** joinvalueptr.
(ptw32_call_t): New member jmpbuf env.
* exit.c (pthread_exit): Major rewrite to handle joins and handing
value pointer to joining thread. Uses longjmp() back to
ptw32_start_call().
* create.c (pthread_create): Ensure values of new attribute members
are copied to the thread attribute object.
* attr.c (pthread_attr_destroy): Fix merge conflicts.
(pthread_attr_getdetachstate): Fix merge conflicts.
(pthread_attr_setdetachstate): Fix merge conflicts.
* pthread.h: Fix merge conflicts.
* sync.c (pthread_join): Fix merge conflicts.
Fri Jul 24 00:21:21 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* sync.c (pthread_join): Add check for valid and joinable
thread.
(pthread_detach): Implement. After checking for a valid and joinable
thread, it's still a no-op.
* private.c (ptw32_find_thread_entry): Bug prevented returning
an error value in some cases.
* attr.c (pthread_attr_setdetachedstate): Implement.
(pthread_attr_getdetachedstate): Implement.
* implement.h: Move more hidden definitions into here from
pthread.h.
1998-07-24 Ben Elliston <bje at cygnus.com>
* pthread.h (PTHREAD_CREATE_JOINABLE): Define.
(PTHREAD_CREATE_DETACHED): Likewise.
(pthread_attr_t): Add new structure member `detached'.
(pthread_attr_getdetachstate): Add function prototype.
(pthread_attr_setdetachstate): Likewise.
* sync.c (pthread_join): Return if the target thread is detached.
* attr.c (pthread_attr_init): Initialise cancelability and
canceltype structure members.
(pthread_attr_getdetachstate): Implement.
(pthread_attr_setdetachstate): Likewise.
* implement.h (PTW32_CANCEL_DEFAULTS): Remove. Bit fields
proved to be too cumbersome. Set the defaults in attr.c using the
public PTHREAD_CANCEL_* constants.
* cancel.c: New file.
* pthread.h (sched_param): Define this type.
(pthread_attr_getschedparam): Add function prototype.
(pthread_attr_setschedparam): Likewise.
(pthread_setcancelstate): Likewise.
(pthread_setcanceltype): Likewise.
(sched_get_priority_min): Likewise.
(sched_get_priority_max): Likewise.
(pthread_mutexattr_setprotocol): Remove; not supported.
(pthread_mutexattr_getprotocol): Likewise.
(pthread_mutexattr_setprioceiling): Likewise.
(pthread_mutexattr_getprioceiling): Likewise.
(pthread_attr_t): Add canceltype member. Update comments.
(SCHED_OTHER): Define this scheduling policy constant.
(SCHED_FIFO): Likewise.
(SCHED_RR): Likewise.
(SCHED_MIN): Define the lowest possible value for this constant.
(SCHED_MAX): Likewise, the maximum possible value.
(PTHREAD_CANCEL_ASYNCHRONOUS): Redefine.
(PTHREAD_CANCEL_DEFERRED): Likewise.
* sched.c: New file.
(pthread_setschedparam): Implement.
(pthread_getschedparam): Implement.
(sched_get_priority_max): Validate policy argument.
(sched_get_priority_min): Likewise.
* mutex.c (pthread_mutexattr_setprotocol): Remove; not supported.
(pthread_mutexattr_getprotocol): Likewise.
(pthread_mutexattr_setprioceiling): Likewise.
(pthread_mutexattr_getprioceiling): Likewise.
Fri Jul 24 00:21:21 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* create.c (pthread_create): Arg to ptw32_new_thread_entry()
changed. See next entry. Move mutex locks out. Changes made yesterday
and today allow us to start the new thread running rather than
temporarily suspended.
* private.c (ptw32_new_thread_entry): ptw32_thread_table
was changed back to a table of thread structures rather than pointers.
As such we're trading storage for increaded speed. This routine
was modified to work with the new table. Mutex lock put in around
global data accesses.
(ptw32_find_thread_entry): Ditto
(ptw32_delete_thread_entry): Ditto
Thu Jul 23 23:25:30 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* global.c: New. Global data objects declared here. These moved from
pthread.h.
* pthread.h: Move implementation hidden definitions into
implement.h.
* implement.h: Move implementation hidden definitions from
pthread.h. Add constants to index into the different handler stacks.
* cleanup.c (ptw32_handler_push): Simplify args. Restructure.
(ptw32_handler_pop): Simplify args. Restructure.
(ptw32_handler_pop_all): Simplify args. Restructure.
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge
conflicts.
* private.c (ptw32_find_thread_entry): Changes to return type
to support leaner ptw32_threads_table[] which now only stores
ptw32_thread_thread_t *.
(ptw32_new_thread_entry): Internal changes.
(ptw32_delete_thread_entry): Internal changes to avoid contention.
Calling routines changed accordingly.
* pthread.h: Modified cleanup macros to use new generic push and pop.
Added destructor and atfork stacks to ptw32_threads_thread_t.
* cleanup.c (ptw32_handler_push, ptw32_handler_pop,
ptw32_handler_pop_all): Renamed cleanup push and pop routines
and made generic to handle destructors and atfork handlers as
well.
* create.c (ptw32_start_call): New function is a wrapper for
all new threads. It allows us to do some cleanup when the thread
returns, ie. that is otherwise only done if the thread is cancelled.
* exit.c (ptw32_vacuum): New function contains code from
pthread_exit() that we need in the new ptw32_start_call()
as well.
* implement.h: Various additions and minor changes.
* pthread.h: Various additions and minor changes.
Change cleanup handler macros to use generic handler push and pop
functions.
* attr.c: Minor mods to all functions.
(is_attr): Implemented missing function.
* create.c (pthread_create): More clean up.
* private.c (ptw32_find_thread_entry): Implement.
(ptw32_delete_thread_entry): Implement.
(ptw32_new_thread_entry): Implement.
These functions manipulate the implementations internal thread
table and are part of general code cleanup and modularisation.
They replace ptw32_getthreadindex() which was removed.
* exit.c (pthread_exit): Changed to use the new code above.
* pthread.h: Add cancelability constants. Update comments.
1998-07-22 Ben Elliston <bje at cygnus.com>
* attr.c (pthread_setstacksize): Update test of attr argument.
(pthread_getstacksize): Likewise.
(pthread_setstackaddr): Likewise.
(pthread_getstackaddr): Likewise.
(pthread_attr_init): No need to allocate any storage.
(pthread_attr_destroy): No need to free any storage.
* mutex.c (is_attr): Not likely to be needed; remove.
(remove_attr): Likewise.
(insert_attr): Likewise.
* implement.h (ptw32_mutexattr_t): Moved to a public definition
in pthread.h. There was little gain in hiding these details.
(ptw32_condattr_t): Likewise.
(ptw32_attr_t): Likewise.
* pthread.h (pthread_atfork): Add function prototype.
(pthread_attr_t): Moved here from implement.h.
* fork.c (pthread_atfork): Preliminary implementation.
(ptw32_fork): Likewise.
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* cleanup.c (ptw32_cleanup_push): Implement.
(ptw32_cleanup_pop): Implement.
(ptw32_do_cancellation): Implement.
These are private to the implementation. The real cleanup functions
are macros. See below.
* pthread.h (pthread_cleanup_push): Implement as a macro.
(pthread_cleanup_pop): Implement as a macro.
Because these are macros which start and end a block, the POSIX scoping
requirement is observed. See the comment in the file.
* exit.c (pthread_exit): Refine the code.
* create.c (pthread_create): Code cleanup.
* implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T)
up to multiple of DWORD.
Add function prototypes.
* private.c (ptw32_getthreadindex): "*thread" should have been
"thread". Detect empty slot fail condition.
1998-07-20 Ben Elliston <bje at cygnus.com>
* misc.c (pthread_once): Implement. Don't use a per-application
flag and mutex--make `pthread_once_t' contain these elements in
their structure. The earlier version had incorrect semantics.
* pthread.h (ptw32_once_flag): Add new variable. Remove.
(ptw32_once_lock): Add new mutex lock to ensure integrity of
access to ptw32_once_flag. Remove.
(pthread_once): Add function prototype.
(pthread_once_t): Define this type.
Mon Jul 20 02:31:05 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* private.c (ptw32_getthreadindex): Implement.
* pthread.h: Add application static data dependent on
_PTHREADS_BUILD_DLL define. This is needed to avoid allocating
non-sharable static data within the pthread DLL.
* implement.h: Add ptw32_cleanup_stack_t, ptw32_cleanup_node_t
and PTW32_HASH_INDEX.
* exit.c (pthread_exit): Begin work on cleanup and de-allocate
thread-private storage.
* create.c (pthread_create): Add thread to thread table.
Keep a thread-private copy of the attributes with default values
filled in when necessary. Same for the cleanup stack. Make
pthread_create C run-time library friendly by using _beginthreadex()
instead of CreateThread(). Fix error returns.
Sun Jul 19 16:26:23 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Rename pthreads_thread_count to ptw32_threads_count.
Create ptw32_threads_thread_t struct to keep thread specific data.
* create.c: Rename pthreads_thread_count to ptw32_threads_count.
(pthread_create): Handle errors from CreateThread().
1998-07-19 Ben Elliston <bje at cygnus.com>
* condvar.c (pthread_cond_wait): Generalise. Moved from here ..
(cond_wait): To here.
(pthread_cond_timedwait): Implement; use generalised cond_wait().
* pthread.h (pthread_key_t): Define this type.
(pthread_key_create): Add function prototype.
(pthread_setspecific): Likewise.
(pthread_getspecific): Likwise.
(pthread_key_delete): Likewise.
* tsd.c (pthread_key_create): Implement.
(pthread_setspecific): Likewise.
(pthread_getspecific): Likewise.
(pthread_key_delete): Likewise.
* mutex.c (pthread_mutex_trylock): Return ENOSYS if this function
is called on a Win32 platform which is not Windows NT.
1998-07-18 Ben Elliston <bje at cygnus.com>
* condvar.c (pthread_condattr_init): Do not attempt to malloc any
storage; none is needed now that condattr_t is an empty struct.
(pthread_condattr_destory): Likewise; do not free storage.
(pthread_condattr_setpshared): No longer supported; return ENOSYS.
(pthread_condattr_getpshared): Likewise.
(pthread_cond_init): Implement with help from Douglas Schmidt.
Remember to initialise the cv's internal mutex.
(pthread_cond_wait): Likewise.
(pthread_cond_signal): Likewise.
(pthread_cond_broadcast): Likewise.
(pthread_cond_timedwait): Preliminary implementation, but I need
to see some API documentation for `WaitForMultipleObject'.
(pthread_destory): Implement.
* pthread.h (pthread_cond_init): Add function protoype.
(pthread_cond_broadcast): Likewise.
(pthread_cond_signal): Likewise.
(pthread_cond_timedwait): Likewise.
(pthread_cond_wait): Likewise.
(pthread_cond_destroy): Likewise.
(pthread_cond_t): Define this type. Fix for u_int. Do not assume
that the mutex contained withing the pthread_cond_t structure will
be a critical section. Use our new POSIX type!
* implement.h (ptw32_condattr_t): Remove shared attribute.
1998-07-17 Ben Elliston <bje at cygnus.com>
* pthread.h (PTHREADS_PROCESS_PRIVATE): Remove.
(PTHREAD_PROCESS_SHARED): Likewise. No support for mutexes shared
across processes for now.
(pthread_mutex_t): Use a Win32 CRITICAL_SECTION type for better
performance.
* implement.h (ptw32_mutexattr_t): Remove shared attribute.
* mutex.c (pthread_mutexattr_setpshared): This optional function
is no longer supported, since we want to implement POSIX mutex
variables using the much more efficient Win32 critical section
primitives. Critical section objects in Win32 cannot be shared
between processes.
(pthread_mutexattr_getpshared): Likewise.
(pthread_mutexattr_init): No need to malloc any storage; the
attributes structure is now empty.
(pthread_mutexattr_destroy): This is now a nop.
(pthread_mutex_init): Use InitializeCriticalSection().
(pthread_mutex_destroy): Use DeleteCriticalSection().
(pthread_mutex_lock): Use EnterCriticalSection().
(pthread_mutex_trylock): Use TryEnterCriticalSection(). This is
not supported by Windows 9x, but trylock is a hack anyway, IMHO.
(pthread_mutex_unlock): Use LeaveCriticalSection().
1998-07-14 Ben Elliston <bje at cygnus.com>
* attr.c (pthread_attr_setstacksize): Implement.
(pthread_attr_getstacksize): Likewise.
(pthread_attr_setstackaddr): Likewise.
(pthread_attr_getstackaddr): Likewise.
(pthread_attr_init): Likewise.
(pthread_attr_destroy): Likewise.
* condvar.c (pthread_condattr_init): Add `_cond' to function name.
* mutex.c (pthread_mutex_lock): Add `_mutex' to function name.
(pthread_mutex_trylock): Likewise.
(pthread_mutex_unlock): Likewise.
* pthread.h (pthread_condattr_setpshared): Fix typo.
(pthread_attr_init): Add function prototype.
(pthread_attr_destroy): Likewise.
(pthread_attr_setstacksize): Likewise.
(pthread_attr_getstacksize): Likewise.
(pthread_attr_setstackaddr): Likewise.
(pthread_attr_getstackaddr): Likewise.
Mon Jul 13 01:09:55 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Wrap in #ifndef _IMPLEMENT_H
* create.c (pthread_create): Map stacksize attr to Win32.
* mutex.c: Include implement.h
1998-07-13 Ben Elliston <bje at cygnus.com>
* condvar.c (pthread_condattr_init): Implement.
(pthread_condattr_destroy): Likewise.
(pthread_condattr_setpshared): Likewise.
(pthread_condattr_getpshared): Likewise.
* implement.h (PTHREAD_THREADS_MAX): Remove trailing semicolon.
(PTHREAD_STACK_MIN): Specify; needs confirming.
(ptw32_attr_t): Define this type.
(ptw32_condattr_t): Likewise.
* pthread.h (pthread_mutex_t): Define this type.
(pthread_condattr_t): Likewise.
(pthread_mutex_destroy): Add function prototype.
(pthread_lock): Likewise.
(pthread_trylock): Likewise.
(pthread_unlock): Likewise.
(pthread_condattr_init): Likewise.
(pthread_condattr_destroy): Likewise.
(pthread_condattr_setpshared): Likewise.
(pthread_condattr_getpshared): Likewise.
* mutex.c (pthread_mutex_init): Implement.
(pthread_mutex_destroy): Likewise.
(pthread_lock): Likewise.
(pthread_trylock): Likewise.
(pthread_unlock): Likewise.
1998-07-12 Ben Elliston <bje at cygnus.com>
* implement.h (ptw32_mutexattr_t): Define this implementation
internal type. Application programmers only see a mutex attribute
object as a void pointer.
* pthread.h (pthread_mutexattr_t): Define this type.
(pthread_mutexattr_init): Add function prototype.
(pthread_mutexattr_destroy): Likewise.
(pthread_mutexattr_setpshared): Likewise.
(pthread_mutexattr_getpshared): Likewise.
(pthread_mutexattr_setprotocol): Likewise.
(pthread_mutexattr_getprotocol): Likewise.
(pthread_mutexattr_setprioceiling): Likewise.
(pthread_mutexattr_getprioceiling): Likewise.
(PTHREAD_PROCESS_PRIVATE): Define.
(PTHREAD_PROCESS_SHARED): Define.
* mutex.c (pthread_mutexattr_init): Implement.
(pthread_mutexattr_destroy): Implement.
(pthread_mutexattr_setprotocol): Implement.
(pthread_mutexattr_getprotocol): Likewise.
(pthread_mutexattr_setprioceiling): Likewise.
(pthread_mutexattr_getprioceiling): Likewise.
(pthread_mutexattr_setpshared): Likewise.
(pthread_mutexattr_getpshared): Likewise.
(insert_attr): New function; very preliminary implementation!
(is_attr): Likewise.
(remove_attr): Likewise.
Sat Jul 11 14:48:54 1998 Ross Johnson <rpj at ixobrychus.canberra.edu.au>
* implement.h: Preliminary implementation specific defines.
* create.c (pthread_create): Preliminary implementation.
1998-07-11 Ben Elliston <bje at cygnus.com>
* sync.c (pthread_join): Implement.
* misc.c (pthread_equal): Likewise.
* pthread.h (pthread_join): Add function prototype.
(pthread_equal): Likewise.
1998-07-10 Ben Elliston <bje at cygnus.com>
* misc.c (pthread_self): Implement.
* exit.c (pthread_exit): Implement.
* pthread.h (pthread_exit): Add function prototype.
(pthread_self): Likewise.
(pthread_t): Define this type.
1998-07-09 Ben Elliston <bje at cygnus.com>
* create.c (pthread_create): A dummy stub right now.
* pthread.h (pthread_create): Add function prototype.
|