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
|
Fri Mar 26 14:11:45 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* semaphore.c (_pthread_sem_timedwait): Check for negative
milliseconds.
- Tor Lillqvist <tml@iki.fi>
Wed Mar 24 11:32:07 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* misc.c (CancelableWait): Initialise exceptionInformation[2].
(pthread_self): Get a real Win32 thread handle for implicit threads.
- John Bossom <jebossom@cognos.com>
* cancel.c (pthread_testcancel): Initialise exceptionInformation[2].
- John Bossom <jebossom@cognos.com>
* implement.h (SE_INFORMATION): Fix values.
- John Bossom <jebossom@cognos.com>
* private.c (_pthread_threadDestroy): Close the thread handle.
- John Bossom <jebossom@cognos.com>
Fri Mar 19 12:57:27 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* cancel.c (comments): Update and cleanup.
Fri Mar 19 09:12:59 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* private.c (_pthread_threadStart): status returns PTHREAD_CANCELED.
* pthread.h (PTHREAD_CANCELED): defined.
Tue Mar 16 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* all: Add GNU LGPL and Copyright and Warranty.
Mon Mar 15 00:20:13 1999 Ross Johnson <rpj@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@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@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@ixobrychus.canberra.edu.au>
* misc.c (CancelableWait): Undo changes from Mar 8 and 7.
Mon Mar 8 11:18:59 1999 Ross Johnson <rpj@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 (_pthread_sem_timedwait): Check sem == NULL earlier.
Sun Mar 7 12:31:14 1999 Ross Johnson <rpj@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 (_pthread_cond_test_init_lock): Initialise and destroy.
* implement.h (_pthread_cond_test_init_lock): Add extern.
* global.c (_pthread_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@ixobrychus.canberra.edu.au>
* implement.h: Undate comments.
Sun Feb 21 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around
cs element initialiser.
1999-02-21 Ben Elliston <bje@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@ixobrychus.canberra.edu.au>
* dll.c (DLLMain): Expand TryEnterCriticalSection support test.
* mutex.c (pthread_mutex_trylock): The check for
_pthread_try_enter_critical_section == NULL should have been
removed long ago.
Fri Feb 19 16:03:30 1999 Ross Johnson <rpj@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@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@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@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@ixobrychus.canberra.edu.au>
* configure: Various temporary changes.
- Kevin Ruland <Kevin.Ruland@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@swan.canberra.edu.au>
* semaphore.c: Comment format changes.
Thu Feb 4 10:07:28 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* global.c: Remove Pthread_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@swan.canberra.edu.au>
* cleanup.c: Rename _pthread_*_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@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@swan.canberra.edu.au>
* implement.h: Add #include <pthread.h>.
Change sem_t to _pthread_sem_t.
Various patches by Kevin Ruland <Kevin.Ruland@anheuser-busch.com>
* signal.c (pthread_sigmask): Add and modify casts.
Reverse LHS/RHS bitwise assignments.
* pthread.h: Remove #include <semaphore.h>.
(_PTHREAD_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 _pthread_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@swan.canberra.edu.au>
* Makefile.in (OBJS): Add semaphore.o to list.
* semaphore.c (_pthread_sem_timedwait): Move from private.c.
Rename sem_* to _pthread_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 ename all
functions to prepend '_pthread_'. They are
now private to the pthreads-win32 implementation.
* private.c: Change #warning.
Move _pthread_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@ixobrychus.canberra.edu.au>
* semaphore.c (sem_wait): Remove second arg to
pthreadCancelableWait() call.
Sat Jan 23 17:36:40 1999 Ross Johnson <rpj@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@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 (_pthread_callUserDestroyRoutines): Redo conditional
compilation.
* misc.c (CancelableWait): C++ version uses 'throw'.
* cancel.c (pthread_testcancel): Ditto.
* implement.h (class pthread_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@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@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.
* private.c (_pthread_sem_timedwait): 'abstime' arg really is
absolute time. Calculate relative time to wait from current
time before passing timeout to new routine
pthreadCancelableTimedWait().
- Scott Lightner <scott@curriculum.com>
Tue Jan 19 10:27:39 1999 Ross Johnson <rpj@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@ixobrychus.canberra.edu.au>
* pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit'
value to '1' and existing 'valid' value to '1'.
* global.c (_pthread_mutex_test_init_lock): Add.
* implement.h (_pthread_mutex_test_init_lock.): Add extern.
* private.c (_pthread_processInitialize): Init critical section for
global lock used by _mutex_check_need_init().
(_pthread_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@ixobrychus.canberra.edu.au>
* private.c (_pthread_sem_timedwait): Move from semaphore.c.
* semaphore.c : Remove redundant #includes.
(_pthread_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@ixobrychus.canberra.edu.au>
* condvar.c (cond_timedwait): Remove comment.
Fri Jan 15 15:41:28 1999 Ross Johnson <rpj@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 _pthread_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 (_pthread_sem_timedwait): New internal function
prototype.
* misc.c (pthreadCancelableWait): Added new 'abstime' argument
to allow shorter than INFINITE wait.
* semaphore.c (_pthread_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@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 (_pthread_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 (_pthread_threadStart): Change #error directive
into #warning and bracket for __CYGWIN__ and derivative compilers.
Wed Jan 13 09:34:52 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* build.bat: Delete old binaries before compiling/linking.
Tue Jan 12 09:58:38 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* dll.c: The Microsoft compiler pragmas probably are more
appropriately protected by _MSC_VER than by _WIN32.
- Tor Lillqvist <tml@iki.fi>.
* condvar.c (pthread_cond_timedwait): Fix function description
comments.
* 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.
- Tor Lillqvist <tml@iki.fi>.
* pthread.def: pthread_mutex_destroy was missing from the def file
- Tor Lillqvist <tml@iki.fi>.
* 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.
- Tor Lillqvist <tml@iki.fi>.
* semaphore.c (sem_post): Correct typo in comment.
Mon Jan 11 20:33:19 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* pthread.h: Re-arrange conditional compile of pthread_cleanup-*
macros.
* cleanup.c (_pthread_push_cleanup): Provide conditional
compile of cleanup->prev.
1999-01-11 Ben Elliston <bje@cygnus.com>
* condvar.c (pthread_cond_init): Invert logic when testing the
return value from calloc().
- Tor Lillqvist <tml@iki.fi>.
Sat Jan 9 14:32:08 1999 Ross Johnson <rpj@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@hem2.passagen.se>.
Tue Jan 5 16:33:04 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* cleanup.c (_pthread_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@toilet.to.cygnus.com>
* README: Update info about subscribing to the mailing list.
Mon Jan 4 11:23:40 1999 Ross Johnson <rpj@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@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
_pthread_tkAssocCreate.
(pthread_key_delete): Rename tkAssocDestroy to
_pthread_tkAssocDestroy.
* sync.c (pthread_join): Rename threadDestroy to _pthread_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 (_pthread_threadDestroy): Rename call to
callUserDestroyRoutines() as _pthread_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 _pthread_threadStart and _pthread_threadDestroy.
* implement.h: Rename "detachedstate" to "detachstate".
* attr.c: Rename "detachedstate" to "detachstate".
Mon Dec 28 09:54:39 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* semaphore.c: Initial version. From John Bossom's implementation.
* semaphore.h: Initial version. From John Bossom's implementation.
Mon Dec 28 09:54:39 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* pthread.h (pthread_attr_t_): Change to *pthread_attr_t.
* attr.c (pthread_attr_setstacksize): Merge with John Bossom's version.
(pthread_attr_getstacksize): Merge with John Bossom's version.
(pthread_attr_setstackaddr): Merge with John Bossom's version.
(pthread_attr_getstackaddr): Merge with John Bossom's version.
(pthread_attr_init): Merge with John Bossom's version.
(pthread_attr_destroy): Merge with John Bossom's version.
(pthread_attr_getdetachstate): Merge with John Bossom's version.
(pthread_attr_setdetachstate): Merge with John Bossom's version.
(is_attr): attr is now **attr (was *attr), so add extra NULL pointer
test.
* 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@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@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 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* cancel.c (pthread_setcancelstate): Replaced by John Bossom's version.
(pthread_setcanceltype): Replaced by John Bossom's version.
(pthread_testcancel): Replaced by John Bossom's version.
(pthread_cancel): Replaced by John Bossom's version.
* exit.c (pthread_exit): Replaced by John Bossom's version.
* misc.c (pthread_self): Replaced by John Bossom's version.
(pthread_equal): Replaced by John Bossom's version.
* sync.c (pthread_detach): Replaced by John Bossom's version.
(pthread_join): Replaced by John Bossom's version.
* create.c (pthread_create): Replaced by John Bossom's version.
* private.c (_pthread_processInitialize): New by John Bossom.
(_pthread_processTerminate): Non-public function by John Bossom.
(_pthread_threadStart): Non-public function by John Bossom.
(_pthread_threadDestroy): Non-public function by John Bossom.
(_pthread_cleanupStack): Non-public function by John Bossom.
(_pthread_tkAssocCreate): Non-public function by John Bossom.
(_pthread_tkAssocDestroy): Non-public function by John Bossom.
(_pthread_callUserDestroyRoutines): Non-public function by John Bossom.
* implement.h: Added John Bossom's non-API structures and
declarations.
* dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress
to resolve compile warning from MSVC.
* dll.c (DLLmain): Replaced by John Bossom's version.
* dll.c (PthreadsEntryPoint):
Re-applied Anders Norlander's patch:-
Initialize _pthread_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@ixobrychus.canberra.edu.au>
* buildlib.bat: Fix args to CL when building the .DLL
* cleanup.c (_pthread_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 (_pthread_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@hem2.passagen.se>
* implement.h (_pthread_try_enter_critical_section): New extern
* dll.c (_pthread_try_enter_critical_section): New pointer to
TryEnterCriticalSection if it exists; otherwise NULL.
* dll.c (PthreadsEntryPoint):
Initialize _pthread_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 _pthread_try_enter_critical_section is valid
pointer to a function. Call _pthread_try_enter_critical_section
instead of TryEnterCriticalSection to avoid errors on Win95.
Thu Dec 3 13:32:00 1998 Ross Johnson <rpj@ise.canberra.edu.au>
* README: Correct cygwin32 compatibility statement.
Sun Nov 15 21:24:06 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* cleanup.c (_pthread_destructor_run_all): Declare missing void * arg.
Fixup CVS merge conflicts.
1998-10-30 Ben Elliston <bje@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@swan.canberra.edu.au>
* cleanup.c (_pthread_handler_push): Fixed bug appending new
handler to list reported by Peter Slacik
<Peter.Slacik@leibinger.freinet.de>.
(new_thread): Rename poorly named local variable to
"new_handler".
Sat Oct 24 18:34:59 1998 Ross Johnson <rpj@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@ixobrychus.canberra.edu.au>
* implement.h (_PTHREAD_TSD_KEY_REUSE): Add enum.
* private.c (_pthread_delete_thread): Add call to
_pthread_destructor_run_all() to clean up the threads keys.
* cleanup.c (_pthread_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@ixobrychus.canberra.edu.au>
* tsd.c (pthread_setspecific): Add key management code.
(pthread_key_create): Ditto.
(pthread_key_delete): Ditto.
* implement.h (struct _pthread_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@swan.canberra.edu.au>
* cleanup.c (_pthread_destructor_run_all): Fix and improve
stepping through the key table.
Thu Oct 15 14:05:01 1998 Ross Johnson <rpj@swan.canberra.edu.au>
* private.c (_pthread_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@ixobrychus.canberra.edu.au>
* global.c (_pthread_tsd_key_table): Fix declaration.
* implement.h(_pthread_TSD_keys_TlsIndex): Add missing extern.
(_pthread_tsd_mutex): Ditto.
* create.c (_pthread_start_call): Fix "keys" array declaration.
Add comment.
* tsd.c (pthread_setspecific): Fix type declaration and cast.
(pthread_getspecific): Ditto.
* cleanup.c (_pthread_destructor_run_all): Declare missing loop
counter.
Wed Oct 14 21:09:24 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* private.c (_pthread_new_thread): Increment _pthread_threads_count.
(_pthread_delete_thread): Decrement _pthread_threads_count.
Remove some comments.
* exit.c (_pthread_exit): : Fix two pthread_mutex_lock() calls that
should have been pthread_mutex_unlock() calls.
(_pthread_vacuum): Remove call to _pthread_destructor_pop_all().
* create.c (pthread_create): Fix two pthread_mutex_lock() calls that
should have been pthread_mutex_unlock() calls.
* global.c (_pthread_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@ixobrychus.canberra.edu.au>
* implement.h (_pthread_tsd_key_table): New.
* create.c (_pthread_start_call): Initialise per-thread TSD keys
to NULL.
* misc.c (pthread_once): Correct typo in comment.
* implement.h (_pthread_destructor_push): Remove.
(_pthread_destructor_pop): Remove.
(_pthread_destructor_run_all): Rename from _pthread_destructor_pop_all.
(_PTHREAD_TSD_KEY_DELETED): Add enum.
(_PTHREAD_TSD_KEY_INUSE): Add enum.
* cleanup.c (_pthread_destructor_push): Remove.
(_pthread_destructor_pop): Remove.
(_pthread_destructor_run_all): Totally revamped TSD.
* dll.c (_pthread_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@ixobrychus.canberra.edu.au>
* global.c (_pthread_tsd_key_table): Add new global.
* implement.h (_pthread_tsd_key_t and struct _pthread_tsd_key):
Add.
(struct _pthread): Remove destructorstack.
* cleanup.c (_pthread_destructor_run_all): Rename from
_pthread_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@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@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@ixobrychus.canberra.edu.au>
* pthread.def: New file for building the DLL.
1998-10-05 Ben Elliston <bje@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@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@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 (_pthread_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@cygnus.com>
* COPYING: Remove.
* COPYING.LIB: Add. This library is under the LGPL.
1998-09-13 Ben Elliston <bje@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@cygnus.com>
* windows.h: No longer needed; remove.
* windows.c: Likewise.
Sat Sep 12 20:09:24 1998 Ross Johnson <rpj@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@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@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@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 _pthread_handler_push() call.
* exit.c (_pthread_exit): Fix attr arg in
pthread_attr_getdetachstate() call.
* private.c (_pthread_new_thread): Typecast (HANDLE) NULL.
(_pthread_delete_thread): Ditto.
* implement.h: (_PTHREAD_MAX_THREADS): Add define. This keeps
changing in an attempt to make thread administration data types
opaque and cleanup DLL startup.
* dll.c (PthreadsEntryPoint):
(_pthread_virgins): Remove malloc() and free() calls.
(_pthread_reuse): Ditto.
(_pthread_win32handle_map): Ditto.
(_pthread_threads_mutex_table): Ditto.
* global.c (_POSIX_THREAD_THREADS_MAX): Initialise with
_PTHREAD_MAX_THREADS.
(_pthread_virgins): Ditto.
(_pthread_reuse): Ditto.
(_pthread_win32handle_map): Ditto.
(_pthread_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 (_pthread_destructor_pop_all): Add (int) cast to
pthread_getspecific() arg.
(_pthread_destructor_pop): Add (void *) cast to "if" conditional.
(_pthread_destructor_push): Add (void *) cast to
_pthread_handler_push() "key" arg.
(malloc.h): Add include.
* implement.h (_pthread_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@swan.canberra.edu.au>
* private.c (_pthread_delete_thread): Fix typo. Add missing ';'.
* global.c (_pthread_virgins): Change types from pointer to
array pointer.
(_pthread_reuse): Ditto.
(_pthread_win32handle_map): Ditto.
(_pthread_threads_mutex_table): Ditto.
* implement.h(_pthread_virgins): Change types from pointer to
array pointer.
(_pthread_reuse): Ditto.
(_pthread_win32handle_map): Ditto.
(_pthread_threads_mutex_table): Ditto.
* private.c (_pthread_delete_thread): Fix "entry" should be "thread".
* misc.c (pthread_self): Add extern for _pthread_threadID_TlsIndex.
* global.c: Add comment.
* misc.c (pthread_once): Fix member -> dereferences.
Change _pthread_once_flag to once_control->flag in "if" test.
Tue Aug 4 00:09:30 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* implement.h(_pthread_virgins): Add extern.
(_pthread_virgin_next): Ditto.
(_pthread_reuse): Ditto.
(_pthread_reuse_top): Ditto.
(_pthread_win32handle_map): Ditto.
(_pthread_threads_mutex_table): Ditto.
* global.c (_pthread_virgins): Changed from array to pointer.
Storage allocation for the array moved into dll.c.
(_pthread_reuse): Ditto.
(_pthread_win32handle_map): Ditto.
(_pthread_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
_pthread_handler_push() calls. Change "arg" arg to NULL in child push.
* exit.c: Add windows.h and process.h includes.
(_pthread_exit): Add local detachstate declaration.
(_pthread_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.
(_pthread_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@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 (_pthread_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 (_PTHREAD_HANDLER_POP_LIFO): Remove definition.
(_PTHREAD_HANDLER_POP_FIFO): Ditto.
(_PTHREAD_VALID): Add missing newline escape (\).
(_pthread_handler_node): Make element "next" a pointer.
1998-08-02 Ben Elliston <bje@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@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@swan.canberra.edu.au>
* cleanup.c (_pthread_destructor_pop): Implement. Removes
destructors associated with a key without executing them.
(_pthread_destructor_pop_all): Add FIXME comment.
* tsd.c (pthread_key_delete): Add call to _pthread_destructor_pop().
Fri Jul 31 00:05:45 1998 Ross Johnson <rpj@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 (_pthread_vacuum): Add call to
_pthread_destructor_pop_all().
* implement.h (_pthread_handler_pop_all): Add prototype.
(_pthread_destructor_pop_all): Ditto.
* cleanup.c (_pthread_destructor_push): Implement. This is just a
call to _pthread_handler_push().
(_pthread_destructor_pop_all): Implement. This is significantly
different to _pthread_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 (_PTHREAD_THIS): Remove - no longer required.
(_PTHREAD_STACK): Use pthread_self() instead of _PTHREAD_THIS.
Thu Jul 30 23:12:45 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* implement.h: Remove _pthread_find_entry() prototype.
* private.c: Extend comments.
Remove _pthread_find_entry() - no longer needed.
* create.c (_pthread_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 _pthread_threadID_TlsIndex.
Add ()s around _PTHREAD_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@ixobrychus.canberra.edu.au>
* private.c: Corrections in comments.
(_pthread_new_thread): Alter "if" flow to be more natural.
* cleanup.c (_pthread_handler_push): Same as below.
* create.c (pthread_create): Same as below.
* private.c (_pthread_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@swan.canberra.edu.au>
* implement.h: Add _PTHREAD_VALID macro.
* sync.c (pthread_join): Modify to use the new thread
type and _pthread_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 (_pthread_find_thread): Fix return type and arg.
* implement.h: Remove _PTHREAD_YES and _PTHREAD_NO.
(_pthread_new_thread): Add prototype.
(_pthread_find_thread): Ditto.
(_pthread_delete_thread): Ditto.
(_pthread_new_thread_entry): Remove prototype.
(_pthread_find_thread_entry): Ditto.
(_pthread_delete_thread_entry): Ditto.
( _PTHREAD_NEW, _PTHREAD_INUSE, _PTHREAD_EXITED, _PTHREAD_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
_pthread_threads_thread_t * to pthread_t and init with
pthread_this().
(pthread_setcanceltype): Ditto.
* exit.c (_pthread_exit): Add new pthread_t arg.
Rename _pthread_delete_thread_entry to _pthread_delete_thread.
Rename "us" to "thread".
(pthread_exit): Call _pthread_exit with added thread arg.
* create.c (_pthread_start_call): Insert missing ")".
Add "us" arg to _pthread_exit() call.
(pthread_create): Modify to use new thread allocation scheme.
* private.c: Added detailed explanation of the new thread
allocation scheme.
(_pthread_new_thread): Totally rewritten to use
new thread allocation scheme.
(_pthread_delete_thread): Ditto.
(_pthread_find_thread): Obsolete.
Mon Jul 27 17:46:37 1998 Ross Johnson <rpj@swan.canberra.edu.au>
* create.c (pthread_create): Start of rewrite. Not completed yet.
* private.c (_pthread_new_thread_entry): Start of rewrite. Not
complete.
* implement.h (_pthread_threads_thread): Rename, remove thread
member, add win32handle and ptstatus members.
(_pthread_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@ixobrychus.canberra.edu.au>
* private.c (_pthread_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 (_pthread_exit): Fix incorrect check for detachedstate.
* implement.h (_pthread_call_t): Remove env member.
Sun Jul 26 13:06:12 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* implement.h (_pthread_new_thread_entry): Fix prototype.
(_pthread_find_thread_entry): Ditto.
(_pthread_delete_thread_entry): Ditto.
(_pthread_exit): Add prototype.
* exit.c (_pthread_exit): New function. Called from pthread_exit()
and _pthread_start_call() to exit the thread. It allows an extra
argument which is the return code passed to _endthreadex().
(_pthread_exit): Move thread entry delete call from _pthread_vacuum()
into here. Add more explanation of thread entry deletion.
(_pthread_exit): Clarify comment.
* create.c (_pthread_start_call): Change pthread_exit() call to
_pthread_exit() call.
* exit.c (_pthread_vacuum): Add thread entry deletion code
moved from _pthread_start_call(). See next item.
(pthread_exit): Remove longjmp(). Add mutex lock around thread table
manipulation code. This routine now calls _enthreadex().
* create.c (_pthread_start_call): Remove setjmp() call and move
cleanup code out. Call pthread_exit(NULL) to terminate the thread.
1998-07-26 Ben Elliston <bje@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@ixobrychus.canberra.edu.au>
* sync.c: Rename all instances of _pthread_count_mutex to
_pthread_table_mutex.
* implement.h: Rename _pthread_count_mutex to
_pthread_table_mutex.
* global.c: Rename _pthread_count_mutex to
_pthread_table_mutex.
* create.c (pthread_create): Add critical sections.
(_pthread_start_call): Rename _pthread_count_mutex to
_pthread_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 (_pthread_delete_thread_entry): Mutex locks removed.
Mutexes must be applied at the caller level.
(_pthread_new_thread_entry): Ditto.
(_pthread_new_thread_entry): Init cancelstate, canceltype, and
cancel_pending to default values.
(_pthread_new_thread_entry): Rename "this" to "new".
(_pthread_find_thread_entry): Rename "this" to "entry".
(_pthread_delete_thread_entry): Rename "thread_entry" to "entry".
* create.c (_pthread_start_call): Mutexes changed to
_pthread_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@ixobrychus.canberra.edu.au>
* implement.h (_pthread_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@cygnus.com>
* fork.c (fork): Autoconfiscate.
Sat Jul 25 00:00:13 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* create.c (_pthread_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 (_PTHREAD_THREADS_TABLE_INDEX): Add.
* exit.c (_pthread_vacuum): Fix incorrect args to
_pthread_handler_pop_all() calls.
Make thread entry removal conditional.
* sync.c (pthread_join): Add multiple join and async detach handling.
* implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add.
* global.c (_pthread_threads_mutex_table): Add.
* implement.h (_pthread_once_flag): Remove.
(_pthread_once_lock): Ditto.
(_pthread_threads_mutex_table): Add.
* global.c (_pthread_once_flag): Remove.
(_pthread_once_lock): Ditto.
* sync.c (pthread_join): Fix tests involving new return value
from _pthread_find_thread_entry().
(pthread_detach): Ditto.
* private.c (_pthread_find_thread_entry): Failure return code
changed from -1 to NULL.
Fri Jul 24 23:09:33 1998 Ross Johnson <rpj@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@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@ixobrychus.canberra.edu.au>
* cancel.c (pthread_cancel): Implement.
(pthread_testcancel): Implement.
* exit.c (pthread_exit): Add comment explaining the longjmp().
* implement.h (_pthread_threads_thread_t): New member cancelthread.
(_PTHREAD_YES): Define.
(_PTHREAD_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@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@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: (_pthread_handler_push): Fix return type and stack arg
type in prototype.
(_pthread_handler_pop): Fix stack arg type in prototype.
(_pthread_handler_pop_all): Fix stack arg type in prototype.
* cleanup.c (_pthread_handler_push): Change return type to int and
return ENOMEM if malloc() fails.
* sync.c (pthread_detach): Use equality test, not assignment.
* create.c (_pthread_start_call): Add call to Win32 CloseHandle()
if thread is detached.
1998-07-24 Ben Elliston <bje@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@ixobrychus.canberra.edu.au>
* sync.c (pthread_join): Save valueptr arg in joinvalueptr for
pthread_exit() to use.
* private.c (_pthread_new_thread_entry): Initialise joinvalueptr to
NULL.
* create.c (_pthread_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 (_pthread_threads_thread): New member
void ** joinvalueptr.
(_pthread_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
_pthread_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@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 (_pthread_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@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 (_PTHREAD_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@ixobrychus.canberra.edu.au>
* create.c (pthread_create): Arg to _pthread_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 (_pthread_new_thread_entry): _pthread_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.
(_pthread_find_thread_entry): Ditto
(_pthread_delete_thread_entry): Ditto
Thu Jul 23 23:25:30 1998 Ross Johnson <rpj@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 (_pthread_handler_push): Simplify args. Restructure.
(_pthread_handler_pop): Simplify args. Restructure.
(_pthread_handler_pop_all): Simplify args. Restructure.
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge
conflicts.
* private.c (_pthread_find_thread_entry): Changes to return type
to support leaner _pthread_threads_table[] which now only stores
_pthread_thread_thread_t *.
(_pthread_new_thread_entry): Internal changes.
(_pthread_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 _pthread_threads_thread_t.
* cleanup.c (_pthread_handler_push, _pthread_handler_pop,
_pthread_handler_pop_all): Renamed cleanup push and pop routines
and made generic to handle destructors and atfork handlers as
well.
* create.c (_pthread_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 (_pthread_vacuum): New function contains code from
pthread_exit() that we need in the new _pthread_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 (_pthread_find_thread_entry): Implement.
(_pthread_delete_thread_entry): Implement.
(_pthread_new_thread_entry): Implement.
These functions manipulate the implementations internal thread
table and are part of general code cleanup and modularisation.
They replace _pthread_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@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 (_pthread_mutexattr_t): Moved to a public definition
in pthread.h. There was little gain in hiding these details.
(_pthread_condattr_t): Likewise.
(_pthread_attr_t): Likewise.
* pthread.h (pthread_atfork): Add function prototype.
(pthread_attr_t): Moved here from implement.h.
* fork.c (pthread_atfork): Preliminary implementation.
(_pthread_fork): Likewise.
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* cleanup.c (_pthread_cleanup_push): Implement.
(_pthread_cleanup_pop): Implement.
(_pthread_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 (_pthread_getthreadindex): "*thread" should have been
"thread". Detect empty slot fail condition.
1998-07-20 Ben Elliston <bje@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 (_pthread_once_flag): Add new variable. Remove.
(_pthread_once_lock): Add new mutex lock to ensure integrity of
access to _pthread_once_flag. Remove.
(pthread_once): Add function prototype.
(pthread_once_t): Define this type.
Mon Jul 20 02:31:05 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* private.c (_pthread_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 _pthread_cleanup_stack_t, _pthread_cleanup_node_t
and _PTHREAD_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@ixobrychus.canberra.edu.au>
* implement.h: Rename pthreads_thread_count to _pthread_threads_count.
Create _pthread_threads_thread_t struct to keep thread specific data.
* create.c: Rename pthreads_thread_count to _pthread_threads_count.
(pthread_create): Handle errors from CreateThread().
1998-07-19 Ben Elliston <bje@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@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 (_pthread_condattr_t): Remove shared attribute.
1998-07-17 Ben Elliston <bje@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 (_pthread_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@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@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@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.
(_pthread_attr_t): Define this type.
(_pthread_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@cygnus.com>
* implement.h (_pthread_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@ixobrychus.canberra.edu.au>
* implement.h: Preliminary implementation specific defines.
* create.c (pthread_create): Preliminary implementation.
1998-07-11 Ben Elliston <bje@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@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@cygnus.com>
* create.c (pthread_create): A dummy stub right now.
* pthread.h (pthread_create): Add function prototype.
|