summaryrefslogtreecommitdiff
path: root/contrib/crossrpms/patches/newlib-1.18.0-rtems4.10-20110110.diff
blob: e8d737dc55f17a068b79de25b4dc452b2bea272b (plain)
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
diff -Naur newlib-1.18.0.orig/newlib/ChangeLog.rtems newlib-1.18.0/newlib/ChangeLog.rtems
--- newlib-1.18.0.orig/newlib/ChangeLog.rtems	1970-01-01 01:00:00.000000000 +0100
+++ newlib-1.18.0/newlib/ChangeLog.rtems	2011-01-10 07:59:24.719365293 +0100
@@ -0,0 +1,302 @@
+2011-01-09	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libm/math/w_tgamma.c: Only build ifndef _DOUBLE_IS_32BITS.
+	* libm/math/wf_tgamma.c: Only build ifdef _DOUBLE_IS_32BITS.
+
+2011-01-07	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libc/stdio/open_memstream.c: Replace 64 * 1024 with 0x10000 to 
+	avoid integer overflow on h8300.
+
+2011-01-05	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libm/common/s_llrint.c: Back-port from newlib-cvs.
+
+2011-01-05	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libc/stdio/tmpnam.c: Include <stdint.h>.
+	Use intptr_t instead of _POINTER_INT for improved portability.
+	* libc/misc/__dprintf.c: Include <stdint.h>
+	Use intptr_t instead of _POINTER_INT for improved portability.
+
+2011-01-05	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libm/common/s_round.c: Cast const int to __int32_t.
+
+2011-01-04	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* doc/makedoc.c: Add cludge to make makedoc 64bit compliant.
+
+2011-01-04	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libm/math/e_scalb.c: Include <limits.h>.
+	Don't rely on 65000 being a valid int.
+
+2011-01-04	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libc/posix/readdir.c:	Include <stdint.h>.
+	Cast to intptr_t instead of int.
+
+2011-01-04	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libc/string/memccpy.c, libc/string/memchr.c,
+	libc/string/memcmp.c, libc/string/memcpy.c,
+	libc/string/memmove.c, libc/string/mempcpy.c,
+	libc/string/memset.c, libc/string/stpcpy.c,
+	libc/string/stpncpy.c, libc/string/strcpy.c,
+	libc/string/strlen.c, libc/string/strncat.c,
+	libc/string/strncpy.c (UNALIGNED):
+	Include <stdint.h>.
+	Cast to intptr_t instead of long.
+
+2011-01-04	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/crt0.c: Fix free and calloc declarations.
+
+2011-01-04	Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* libc/stdio/open_memstream.c (internal_open_memstream_r):
+	Don't limit c->max to 64*1024 on targets with SIZE_MAX < 64*1024.
+
+2010-10-05  Eric Blake  <eblake@redhat.com>
+
+	memmem, strstr, strcasestr: fix bug with long periodic needle
+    	* lib/str-two-way.h (two_way_long_needle): Avoid bug with long
+	periodic needle having false positive.
+
+2010-08-24  Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+	* libc/posix/opendir.c: Added missing memory free.
+
+2010-08-10	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	PR 1475/newlib:
+	* libc/include/stdint.h: Fall back to compute SIZE_MAX based on
+	__SIZEOF_SIZE_T__ and __CHAR_BIT__ if available.
+
+2010-08-04	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/string/strcat.c: 
+	Include <stdint.h>. Use uintptr_t instead of long in ALIGNED.
+	* libc/string/strchr.c, libc/string/strcmp.c, libc/string/strncmp.c:
+	Include <stdint.h>. Use uintptr_t instead of long in UNALIGNED.
+	* libc/include/sys/unistd.h: Activate decls for 
+	getsid, setegid, seteuid.
+
+2010-07-08	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* configure.host: Add -D_COMPILING_NEWLIB to newlib_cflags.
+	* libc/string/index.c, libc/string/rindex.c: Include <string.h>.
+	* libc/stdlib/putenv_r.c: Include <strings.h>
+
+2010-07-06  Corinna Vinschen  <corinna@vinschen.de>
+
+	* libc/posix/rewinddir.c (rewinddir): Remove incorrect cast to off_t.
+	* libc/sys/rtems/sys/dirent.h (_seekdir): Add prototype.
+
+2010-06-17	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/_types.h: Special case for sparc64.
+
+2010-04-23	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/_types.h: Add _mode_t.
+	* libc/include/sys/types.h: Derive mode_t from  _mode_t.
+
+2010-04-02	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/sched.h, libc/include/sys/sched.h:
+	Adopt newlib-cvs's versions.
+
+2010-03-25	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/strings.h: New (split-out from string.h).
+	* libc/include/string.h: Remove bcmp, bcopy, bzero, ffs, index, rindex,
+	strcasecmp, strncasecmp (Moved to strings.h).
+	Remove strcmpi, stricmp, strncmpi, strnicmp.
+	* libc/misc/ffs.c: Use <strings.h> instead of <string.h>.
+	* libc/string/bcmp.c: Use <strings.h> instead of <string.h>.
+	* libc/string/bzero.c: Use <strings.h> instead of <string.h>.
+	* libc/string/rindex.c: Use <strings.h> instead of <string.h>.
+	* libc/string/strcasecmp.c: Use <strings.h> instead of <string.h>.
+	* libc/string/strcasecmp.c: Use <strings.h> instead of <string.h>.
+
+2010-03-23	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/_types.h: Add i386 to 64bit off_t targets.
+
+2010-03-10	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/posix/telldir.c: Adopt newlib-cvs's telldir.c
+
+2010-02-10	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/_types.h: Use __int64_t for _off_t, fpos_t for 
+	selected targets.
+
+2010-02-05	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/posix/telldir.c: Remove bogus nested prototype of lseek().
+
+2010-01-11  Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+	* libc/posix/telldir.c (_cleanupdir): Fixed usage of freed memory.
+
+2009-12-18	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/search/db_local.h:
+	Use __uint32_t instead of u_int (prototype mismatches).
+	* libc/search/extern.h (__buf_init): 
+	Use __uint32_t instead of int (16 bit target portability).
+	* libc/search/hash_buf.c: Use ptrdiff_t instead of __uint32_t,
+	use __uint32_t instead of int (16 bit target portability).
+	* libc/search/hash.h: Use __uint32_it instead of int
+	(16 bit target portability).
+	* libm/common/modfl.c: Add cast to (double*) to avoid GCC warning.
+	* libm/common/sf_llrint.c, libm/common/sf_round.c: Add explicit 
+	casts to __uint32_t to avoid overflows on implicit casts.
+
+2009-12-18	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	Merger with newlib-1.18.0.
+
+2009-10-29	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/_types.h: Rework.
+	* libc/sys/rtems/machine/stdint.h: Remove.
+	* libc/include/inttypes.h: 
+	Rework logic to determine PRI*PTR.
+	Prefer long64 over longlong64.
+	* libc/include/machine/_default_types.h: 
+	Sync logic for __int32 with stdint.h (Prefer long over int).
+	* libc/include/stdint.h:
+	Remove __SPU__ hack.
+	Prefer int for int16_t (sync with _default_types.h).
+	Rework intptr_t determination.
+
+2009-10-28	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/_types.h: New.
+	Add custom time for _ssize_t.
+	* libc/stdlib/assert.c: Sync with newlib-CVS.
+	* configure.host: Add -DHAVE_ASSERT_FUNC to newlib_cflags.
+
+2009-10-27	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/sys/pthread.h: 
+	Add pthread_atfork (Mandated by IEEE Std 1003.1-2008).
+	Add pthread_rwlock_unlock (Formerly missing)
+
+2009-10-26	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/sys/signal.h: Sync with newlib-CVS.
+
+2009-10-09	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/sys/signal.h: Use pid_t as 1st arg to kill()
+	(mandated by POSIX).
+
+2009-09-22	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/sys/queue.h: Update copyright (from FreeBSD).
+	Remove CIRCLEQ_*.
+	* libc/search/hcreate.c: Don't include sys/queue.h.
+
+2009-09-18  Christopher Faylor  <me+cygwin@cgf.cx>
+
+	* libc/include/sys/unistd.h: Declare getpagesize as returning
+	POSIX-mandated int.
+
+2009-09-16	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/crt0.c: Use while(1) in _exit stub to silence GCC "noreturn"
+	warning.
+
+2009-09-15	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/stdlib.h: Add posix_memalign.
+
+2009-09-11	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* configure.host (m32c): Remove -D_ABORT_PROVIDED.
+
+2009-09-10	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* configure.host: Add -D_NO_POPEN.
+	* libc/sys/rtems/crt0.c: Don't provide waitpid unless used.
+
+2009-09-09	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* configure.host: Add -D_NO_WORDEXP.
+
+2009-09-06	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/crt0.c: Add issetugid.
+
+2009-09-02	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/crt0.c: Rework. Introduce macro RTEMS_STUB.
+
+2009-07-27	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/crt0.c: Add _isatty_r.
+
+2009-07-06	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* libc/include/sys/features.h: Define _UNIX98_THREAD_MUTEX_ATTRIBUTES.
+
+2009-05-05	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* configure.host: Remove -DMISSING_SYSCALL_NAMES.
+
+2009-03-11	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/stdlib/assert.c: Don't build __assert_func.
+	* libc/sys/rtems/crt0.c: Add __assert_func.
+
+2009-03-09	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/machine/powerpc/times.c: Remove.
+	* libc/machine/powerpc/Makefile.am: Remove times.c.
+	* libc/machine/powerpc/Makefile.in: Regenerate.
+
+2009-02-24	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/unix/ttyname.c: Sync with newlib-cvs.
+	* configure.host: Add -DHAVE_BLKSIZE to newlib_cflags.
+
+2009-02-22	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/machine/stdint.h: Add __lm32__.
+	* libc/machine/lm32/configure.in: Set AC_CONFIG_SRC to setjmp.S.
+	* libc/machine/lm32/configure: Regenerate.
+
+2009-02-20	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/unix/Makefile.in: Regenerate.
+
+2009-02-20  Craig Howland <howland@LGSInnovations.com> on behalf of
+	Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+	* libc/unix/ttyname.c:  Remove ttyname_r() (to a new file to avoid
+	coupling ttyname_r() and ttyname() due to the latter's large buffer).
+	* libc/unix/ttyname_r.c:  New file to hold ttyname_r(), previously in
+	ttyname.c.
+	* libc/unix/ttyname.h:  New file (common size definition for the 2
+	ttyname*c files that are now split).
+	* libc/unix/Makefile.am (ELIX_2_SOURCES):  Add ttyname_r.c.
+
+2009-02-16	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/sys/rtems/sys/param.h:
+	Update copyright notice from FreeBSD.
+	Remove HZ.
+	Add #include <sys/priority.h>
+	Remove priority handling (moved to sys/priority.h).
+	Remove CLBYTES (Unused, abandoned in BSD).
+
+2009-02-06	Ralf Corsépius <ralf.corsepius@rtems.org>
+
+	* libc/include/sched.h:
+	Remove (collides with RTEMS's schedul.h).
+
diff -Naur newlib-1.18.0.orig/newlib/configure.host newlib-1.18.0/newlib/configure.host
--- newlib-1.18.0.orig/newlib/configure.host	2009-12-10 18:12:11.000000000 +0100
+++ newlib-1.18.0/newlib/configure.host	2011-01-10 07:59:24.720365335 +0100
@@ -556,6 +556,7 @@
   *-*-rtems*)
 	default_newlib_io_long_long="yes"
 	default_newlib_io_c99_formats="yes"
+	newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
 	newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
         # turn off unsupported items in posix directory 
 	newlib_cflags="${newlib_cflags} -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN"
diff -Naur newlib-1.18.0.orig/newlib/doc/makedoc.c newlib-1.18.0/newlib/doc/makedoc.c
--- newlib-1.18.0.orig/newlib/doc/makedoc.c	2009-03-25 22:16:04.000000000 +0100
+++ newlib-1.18.0/newlib/doc/makedoc.c	2011-01-10 07:59:24.721365381 +0100
@@ -57,7 +57,7 @@
 {
     char *ptr;
     unsigned int write_idx;
-    unsigned int size;
+    size_t size;
 } string_type;
 
 
@@ -68,7 +68,7 @@
 
 static void DEFUN(init_string_with_size,(buffer, size),
 	   string_type *buffer AND
-	   unsigned int size )
+	   size_t size )
 {
   buffer->write_idx = 0;
   buffer->size = size;
@@ -219,8 +219,8 @@
 stinst_type *pc;
 stinst_type sstack[STACK];
 stinst_type *ssp = &sstack[0];
-int istack[STACK];
-int *isp = &istack[0];
+long istack[STACK];
+long *isp = &istack[0];
 
 typedef int *word_type;
 
@@ -270,7 +270,7 @@
 {
     isp++;
     pc++;
-    *isp = (int)(*pc);
+    *isp = (long)(*pc);
     pc++;
     
 }
diff -Naur newlib-1.18.0.orig/newlib/libc/include/inttypes.h newlib-1.18.0/newlib/libc/include/inttypes.h
--- newlib-1.18.0.orig/newlib/libc/include/inttypes.h	2009-01-19 23:02:06.000000000 +0100
+++ newlib-1.18.0/newlib/libc/include/inttypes.h	2011-01-10 07:59:24.721365381 +0100
@@ -242,6 +242,20 @@
 #define SCNxMAX		__SCNMAX(x)
 
 /* ptr types */
+#if INTPTR_MAX == INT64_MAX
+#define __PRIPTR(x) __PRI64(x)
+#define __SCNPTR(x) __SCN64(x)
+#elif INTPTR_MAX == INT32_MAX
+#define __PRIPTR(x) __PRI32(x)
+#define __SCNPTR(x) __SCN32(x)
+#elif INTPTR_MAX == INT16_MAX
+#define __PRIPTR(x) __PRI16(x)
+#define __SCNPTR(x) __SCN16(x)
+#else
+#error cannot determine PRI*PTR
+#endif
+
+#if 0
 #if __have_long64
 #define __PRIPTR(x) __STRINGIFY(l##x)
 #define __SCNPTR(x) __STRINGIFY(l##x)
@@ -252,6 +266,7 @@
 #define __PRIPTR(x) __STRINGIFY(x)
 #define __SCNPTR(x) __STRINGIFY(x)
 #endif
+#endif
 
 #define PRIdPTR		__PRIPTR(d)
 #define PRIiPTR		__PRIPTR(i)
diff -Naur newlib-1.18.0.orig/newlib/libc/include/machine/_default_types.h newlib-1.18.0/newlib/libc/include/machine/_default_types.h
--- newlib-1.18.0.orig/newlib/libc/include/machine/_default_types.h	2008-06-12 00:14:54.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/machine/_default_types.h	2011-01-10 07:59:24.721365381 +0100
@@ -54,14 +54,14 @@
 #endif
 #endif
 
-#if __EXP(INT_MAX) == 0x7fffffffL
-typedef signed int __int32_t;
-typedef unsigned int __uint32_t;
-#define ___int32_t_defined 1
-#elif __EXP(LONG_MAX) == 0x7fffffffL
+#if __EXP(LONG_MAX) == 0x7fffffffL
 typedef signed long __int32_t;
 typedef unsigned long __uint32_t;
 #define ___int32_t_defined 1
+#elif __EXP(INT_MAX) == 0x7fffffffL
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#define ___int32_t_defined 1
 #elif __EXP(SHRT_MAX) == 0x7fffffffL
 typedef signed short __int32_t;
 typedef unsigned short __uint32_t;
diff -Naur newlib-1.18.0.orig/newlib/libc/include/sched.h newlib-1.18.0/newlib/libc/include/sched.h
--- newlib-1.18.0.orig/newlib/libc/include/sched.h	2007-09-21 23:02:15.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/sched.h	2011-01-10 07:59:24.722365427 +0100
@@ -1,11 +1,94 @@
+/*
+ *  Written by Joel Sherrill <joel@OARcorp.com>.
+ *
+ *  COPYRIGHT (c) 1989-2010.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  Permission to use, copy, modify, and distribute this software for any
+ *  purpose without fee is hereby granted, provided that this entire notice
+ *  is included in all copies of any software which is or includes a copy
+ *  or modification of this software.
+ *
+ *  THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ *  WARRANTY.  IN PARTICULAR,  THE AUTHOR MAKES NO REPRESENTATION
+ *  OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
+ *  SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ *  $Id$
+ */
+
 #ifndef _SCHED_H_
 #define _SCHED_H_
 
+#include <sys/types.h>
+#include <sys/sched.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <sys/sched.h>
+#if defined(_POSIX_PRIORITY_SCHEDULING)
+/*
+ *  XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1803
+ */
+int sched_setparam(
+  pid_t                     __pid,
+  const struct sched_param *__param
+);
+
+/*
+ *  XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1800
+ */
+int sched_getparam(
+  pid_t                     __pid,
+  struct sched_param       *__param
+);
+
+/*
+ *  XBD 13 - Set Scheduling Policy and Scheduling Parameters,
+ *         P1003.1b-2008, p. 1805
+ */
+int sched_setscheduler(
+  pid_t                     __pid,
+  int                       __policy,
+  const struct sched_param *__param
+);
+
+/*
+ *  XBD 13 - Get Scheduling Policy, P1003.1b-2008, p. 1801
+ */
+int sched_getscheduler(
+  pid_t                     __pid
+);
+
+/*
+ *  XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1799
+ */
+int sched_get_priority_max(
+  int __policy
+);
+
+int sched_get_priority_min(
+  int  __policy
+);
+
+/*
+ *  XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1802
+ */
+int sched_rr_get_interval(
+  pid_t             __pid,
+  struct timespec  *__interval
+);
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+
+#if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING)
+
+/*
+ *  XBD 13 - Yield Processor, P1003.1b-2008, p. 1807
+ */
+int sched_yield( void );
+
+#endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */
 
 #ifdef __cplusplus
 }
diff -Naur newlib-1.18.0.orig/newlib/libc/include/stdint.h newlib-1.18.0/newlib/libc/include/stdint.h
--- newlib-1.18.0.orig/newlib/libc/include/stdint.h	2009-04-24 23:55:07.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/stdint.h	2011-01-10 07:59:24.722365427 +0100
@@ -33,7 +33,7 @@
 /* Check if "long" is 64bit or 32bit wide */
 #if __STDINT_EXP(LONG_MAX) > 0x7fffffff
 #define __have_long64 1
-#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
+#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff
 #define __have_long32 1
 #endif
 
@@ -49,14 +49,14 @@
 #define __int_least8_t_defined 1
 #endif
 
-#if __STDINT_EXP(SHRT_MAX) == 0x7fff
-typedef signed short int16_t;
-typedef unsigned short uint16_t;
-#define __int16_t_defined 1
-#elif __STDINT_EXP(INT_MAX) == 0x7fff
+#if __STDINT_EXP(INT_MAX) == 0x7fff
 typedef signed int int16_t;
 typedef unsigned int uint16_t;
 #define __int16_t_defined 1
+#elif __STDINT_EXP(SHRT_MAX) == 0x7fff
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+#define __int16_t_defined 1
 #elif __STDINT_EXP(SCHAR_MAX) == 0x7fff
 typedef signed char int16_t;
 typedef unsigned char uint16_t;
@@ -239,6 +239,29 @@
  * GCC doesn't provide an appropriate macro for [u]intptr_t
  * For now, use __PTRDIFF_TYPE__
  */
+#if defined(__SIZEOF_POINTER__)
+#if __SIZEOF_POINTER__ == 8
+  typedef int64_t intptr_t;
+  typedef uint64_t uintptr_t;
+#define INTPTR_MAX INT64_MAX
+#define INTPTR_MIN INT64_MIN
+#define UINTPTR_MAX UINT64_MAX
+#elif __SIZEOF_POINTER__ == 4
+  typedef int32_t intptr_t;
+  typedef uint32_t uintptr_t;
+#define INTPTR_MAX INT32_MAX
+#define INTPTR_MIN INT32_MIN
+#define UINTPTR_MAX UINT32_MAX
+#elif __SIZEOF_POINTER__ == 2
+  typedef int16_t intptr_t;
+  typedef uint16_t uintptr_t;
+#define INTPTR_MAX INT16_MAX
+#define INTPTR_MIN INT16_MIN
+#define UINTPTR_MAX UINT16_MAX
+#else
+#error cannot determine intptr_t
+#endif
+#else
 #if defined(__PTRDIFF_TYPE__)
 typedef signed __PTRDIFF_TYPE__ intptr_t;
 typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
@@ -260,6 +283,7 @@
 #define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
 #define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
 #endif
+#endif
 
 /* Limits of Specified-Width Integer Types */
 
@@ -408,6 +432,8 @@
 /* This must match size_t in stddef.h, currently long unsigned int */
 #ifdef __SIZE_MAX__
 #define SIZE_MAX __SIZE_MAX__
+#elif defined(__SIZEOF_SIZE_T__) && defined(__CHAR_BIT__)
+#define SIZE_MAX (__SIZEOF_SIZE_T__ * __CHAR_BIT__)
 #else
 #define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
 #endif
diff -Naur newlib-1.18.0.orig/newlib/libc/include/string.h newlib-1.18.0/newlib/libc/include/string.h
--- newlib-1.18.0.orig/newlib/libc/include/string.h	2008-06-18 17:27:27.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/string.h	2011-01-10 07:59:24.722365427 +0100
@@ -49,18 +49,11 @@
 #ifndef __STRICT_ANSI__
 char 	*_EXFUN(strtok_r,(char *, const char *, char **));
 
-int	 _EXFUN(bcmp,(const void *, const void *, size_t));
-void	 _EXFUN(bcopy,(const void *, void *, size_t));
-void	 _EXFUN(bzero,(void *, size_t));
-int	 _EXFUN(ffs,(int));
-char 	*_EXFUN(index,(const char *, int));
 _PTR	 _EXFUN(memccpy,(_PTR, const _PTR, int, size_t));
 _PTR	 _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
 _PTR	 _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
-char 	*_EXFUN(rindex,(const char *, int));
 char 	*_EXFUN(stpcpy,(char *, const char *));
 char 	*_EXFUN(stpncpy,(char *, const char *, size_t));
-int	 _EXFUN(strcasecmp,(const char *, const char *));
 char	*_EXFUN(strcasestr,(const char *, const char *));
 char 	*_EXFUN(strdup,(const char *));
 char 	*_EXFUN(_strdup_r,(struct _reent *, const char *));
@@ -69,7 +62,6 @@
 char 	*_EXFUN(strerror_r,(int, char *, size_t));
 size_t	 _EXFUN(strlcat,(char *, const char *, size_t));
 size_t	 _EXFUN(strlcpy,(char *, const char *, size_t));
-int	 _EXFUN(strncasecmp,(const char *, const char *, size_t));
 size_t	 _EXFUN(strnlen,(const char *, size_t));
 char 	*_EXFUN(strsep,(char **, const char *));
 char	*_EXFUN(strlwr,(char *));
@@ -81,20 +73,6 @@
 int     _EXFUN(strtosigno, (const char *__name));
 #endif
 
-/* These function names are used on Windows and perhaps other systems.  */
-#ifndef strcmpi
-#define strcmpi strcasecmp
-#endif
-#ifndef stricmp
-#define stricmp strcasecmp
-#endif
-#ifndef strncmpi
-#define strncmpi strncasecmp
-#endif
-#ifndef strnicmp
-#define strnicmp strncasecmp
-#endif
-
 #endif /* ! __STRICT_ANSI__ */
 
 #include <sys/string.h>
diff -Naur newlib-1.18.0.orig/newlib/libc/include/strings.h newlib-1.18.0/newlib/libc/include/strings.h
--- newlib-1.18.0.orig/newlib/libc/include/strings.h	1970-01-01 01:00:00.000000000 +0100
+++ newlib-1.18.0/newlib/libc/include/strings.h	2011-01-10 07:59:24.722365427 +0100
@@ -0,0 +1,44 @@
+/*
+ * strings.h
+ *
+ * Definitions for string operations.
+ */
+
+#ifndef _STRINGS_H_
+#define _STRINGS_H_
+
+#include "_ansi.h"
+#include <sys/reent.h>
+
+#include <sys/types.h> /* for size_t */
+#include <locale.h> /* for locale_t */
+
+_BEGIN_STD_C
+
+#ifndef __STRICT_ANSI__
+/* 
+ * Marked LEGACY in Open Group Base Specifications Issue 6/IEEE Std 1003.1-2004
+ * Removed from Open Group Base Specifications Issue 7/IEEE Std 1003.1-2008
+ */
+int	 _EXFUN(bcmp,(const void *, const void *, size_t));
+void	 _EXFUN(bcopy,(const void *, void *, size_t));
+void	 _EXFUN(bzero,(void *, size_t));
+char 	*_EXFUN(index,(const char *, int));
+char 	*_EXFUN(rindex,(const char *, int));
+#endif /* ! __STRICT_ANSI__ */
+
+int	 _EXFUN(ffs,(int));
+int	 _EXFUN(strcasecmp,(const char *, const char *));
+#if 0
+/* Not implemented */
+int	 _EXFUN(strcasecmp_l,(const char *, const char *, locale_t));
+#endif
+int	 _EXFUN(strncasecmp,(const char *, const char *, size_t));
+#if 0
+/* Not implemented */
+int	 _EXFUN(strncasecmp_l,(const char *, const char *, size_t, locale_t));
+#endif
+
+_END_STD_C
+
+#endif /* _STRINGS_H_ */
diff -Naur newlib-1.18.0.orig/newlib/libc/include/sys/features.h newlib-1.18.0/newlib/libc/include/sys/features.h
--- newlib-1.18.0.orig/newlib/libc/include/sys/features.h	2009-07-06 20:59:04.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/sys/features.h	2011-01-10 07:59:24.723365480 +0100
@@ -33,7 +33,7 @@
 #define _POSIX_VERSION			199309L
 #define _POSIX_ASYNCHRONOUS_IO		1
 #define _POSIX_FSYNC			1
-#define _POSIX_MAPPED_FILES		1
+/* #define _POSIX_MAPPED_FILES		1 */
 #define _POSIX_MEMLOCK			1
 #define _POSIX_MEMLOCK_RANGE		1
 #define _POSIX_MEMORY_PROTECTION	1
diff -Naur newlib-1.18.0.orig/newlib/libc/include/sys/sched.h newlib-1.18.0/newlib/libc/include/sys/sched.h
--- newlib-1.18.0.orig/newlib/libc/include/sys/sched.h	2002-06-20 21:51:24.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/sys/sched.h	2011-01-10 07:59:24.723365480 +0100
@@ -1,7 +1,7 @@
 /*
  *  Written by Joel Sherrill <joel@OARcorp.com>.
  *
- *  COPYRIGHT (c) 1989-2000.
+ *  COPYRIGHT (c) 1989-2010.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  Permission to use, copy, modify, and distribute this software for any
@@ -14,51 +14,53 @@
  *  OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
  *  SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  *
- *  $Id$
+ *  $Id$
  */
 
 
-#ifndef __POSIX_SYS_SCHEDULING_h
-#define __POSIX_SYS_SCHEDULING_h
+#ifndef _SYS_SCHED_H_
+#define _SYS_SCHED_H_
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <sys/unistd.h>
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-/* Scheduling Policies, P1003.1b-1993, p. 250
-   NOTE:  SCHED_SPORADIC added by P1003.4b/D8, p. 34.  */
-
+/* Scheduling Policies */
+/* Open Group Specifications Issue 6 */
+#if defined(__CYGWIN__)
+#define SCHED_OTHER    3
+#else
 #define SCHED_OTHER    0
+#endif
+
 #define SCHED_FIFO     1
 #define SCHED_RR       2
 
 #if defined(_POSIX_SPORADIC_SERVER)
-#define SCHED_SPORADIC 3 
+#define SCHED_SPORADIC 4
 #endif
 
-/* Scheduling Parameters, P1003.1b-1993, p. 249
-   NOTE:  Fields whose name begins with "ss_" added by P1003.4b/D8, p. 33.  */
+/* Scheduling Parameters */
+/* Open Group Specifications Issue 6 */
 
 struct sched_param {
   int sched_priority;           /* Process execution scheduling priority */
 
-#if defined(_POSIX_SPORADIC_SERVER)
-  int ss_low_priority;          /* Low scheduling priority for sporadic */
+#if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER)
+  int sched_ss_low_priority;    /* Low scheduling priority for sporadic */
                                 /*   server */
-  struct timespec ss_replenish_period; 
+  struct timespec sched_ss_repl_period;
                                 /* Replenishment period for sporadic server */
-  struct timespec ss_initial_budget;   /* Initial budget for sporadic server */
+  struct timespec sched_ss_init_budget;
+                               /* Initial budget for sporadic server */
+  int sched_ss_max_repl;       /* Maximum pending replenishments for */
+                               /* sporadic server */
 #endif
 };
 
 #ifdef __cplusplus
 }
-#endif 
+#endif
 
 #endif
 /* end of include file */
diff -Naur newlib-1.18.0.orig/newlib/libc/include/sys/types.h newlib-1.18.0/newlib/libc/include/sys/types.h
--- newlib-1.18.0.orig/newlib/libc/include/sys/types.h	2009-09-28 18:42:21.000000000 +0200
+++ newlib-1.18.0/newlib/libc/include/sys/types.h	2011-01-10 07:59:24.723365480 +0100
@@ -176,7 +176,11 @@
 #endif
 typedef _ssize_t ssize_t;
 
-#ifndef __CYGWIN__
+#if defined(__rtems__)
+typedef _mode_t mode_t;
+#endif
+
+#if !defined(__CYGWIN__) && !defined(__rtems__)
 #ifdef __MS_types__
 typedef	char *	addr_t;
 typedef int mode_t;
diff -Naur newlib-1.18.0.orig/newlib/libc/machine/powerpc/Makefile.am newlib-1.18.0/newlib/libc/machine/powerpc/Makefile.am
--- newlib-1.18.0.orig/newlib/libc/machine/powerpc/Makefile.am	2007-05-24 19:33:35.000000000 +0200
+++ newlib-1.18.0/newlib/libc/machine/powerpc/Makefile.am	2011-01-10 07:59:24.723365480 +0100
@@ -10,7 +10,7 @@
 
 AM_CFLAGS = -I $(srcdir)/../../stdio -I $(srcdir)/../../stdlib
 
-lib_a_SOURCES = setjmp.S times.c
+lib_a_SOURCES = setjmp.S
 lib_a_CCASFLAGS=$(AM_CCASFLAGS)
 lib_a_CFLAGS=$(AM_CFLAGS)
 lib_a_LIBADD = @extra_objs@
diff -Naur newlib-1.18.0.orig/newlib/libc/machine/powerpc/Makefile.in newlib-1.18.0/newlib/libc/machine/powerpc/Makefile.in
--- newlib-1.18.0.orig/newlib/libc/machine/powerpc/Makefile.in	2009-10-21 00:44:03.000000000 +0200
+++ newlib-1.18.0/newlib/libc/machine/powerpc/Makefile.in	2011-01-10 07:59:24.724365530 +0100
@@ -51,7 +51,7 @@
 LIBRARIES = $(noinst_LIBRARIES)
 ARFLAGS = cru
 lib_a_AR = $(AR) $(ARFLAGS)
-am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-times.$(OBJEXT)
+am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
@@ -173,7 +173,7 @@
 AM_CCASFLAGS = $(INCLUDES)
 noinst_LIBRARIES = lib.a
 AM_CFLAGS = -I $(srcdir)/../../stdio -I $(srcdir)/../../stdlib
-lib_a_SOURCES = setjmp.S times.c
+lib_a_SOURCES = setjmp.S
 lib_a_CCASFLAGS = $(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
 lib_a_LIBADD = @extra_objs@
@@ -184,7 +184,7 @@
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .S .c .o .obj
+.SUFFIXES: .S .o .obj
 am--refresh:
 	@:
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
@@ -245,18 +245,6 @@
 lib_a-setjmp.obj: setjmp.S
 	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-setjmp.obj `if test -f 'setjmp.S'; then $(CYGPATH_W) 'setjmp.S'; else $(CYGPATH_W) '$(srcdir)/setjmp.S'; fi`
 
-.c.o:
-	$(COMPILE) -c $<
-
-.c.obj:
-	$(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-lib_a-times.o: times.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-times.o `test -f 'times.c' || echo '$(srcdir)/'`times.c
-
-lib_a-times.obj: times.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-times.obj `if test -f 'times.c'; then $(CYGPATH_W) 'times.c'; else $(CYGPATH_W) '$(srcdir)/times.c'; fi`
-
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
diff -Naur newlib-1.18.0.orig/newlib/libc/machine/powerpc/times.c newlib-1.18.0/newlib/libc/machine/powerpc/times.c
--- newlib-1.18.0.orig/newlib/libc/machine/powerpc/times.c	2002-07-22 22:26:51.000000000 +0200
+++ newlib-1.18.0/newlib/libc/machine/powerpc/times.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,36 +0,0 @@
-/* Time support routines for PowerPC.
- *
- * Written by Aldy Hernandez.
- */
-
-#include <_ansi.h>
-#include <reent.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/resource.h>
-
-clock_t
-times (struct tms *tp)
-{
-  struct rusage usage;
-  union {
-    struct rusage r;
-    /* Newlib's rusage has only 2 fields.  We need to make room for
-       when we call the system's rusage.  This should be enough.  */
-    int filler[32];
-  } host_ru;
-
-  getrusage (RUSAGE_SELF, (void *)&host_ru);
-
-  if (tp)
-    {
-      tp->tms_utime = host_ru.r.ru_utime.tv_sec * 1000
-	+ host_ru.r.ru_utime.tv_usec;
-      tp->tms_stime = host_ru.r.ru_stime.tv_sec * 1000
-	+ host_ru.r.ru_stime.tv_usec;
-      tp->tms_cutime = 0;	/* user time, children */
-      tp->tms_cstime = 0;	/* system time, children */
-    }
-
-  return tp->tms_utime;
-}
diff -Naur newlib-1.18.0.orig/newlib/libc/misc/__dprintf.c newlib-1.18.0/newlib/libc/misc/__dprintf.c
--- newlib-1.18.0.orig/newlib/libc/misc/__dprintf.c	2008-12-11 18:27:55.000000000 +0100
+++ newlib-1.18.0/newlib/libc/misc/__dprintf.c	2011-01-10 07:59:24.727365666 +0100
@@ -5,6 +5,7 @@
 */
 
 #include <_ansi.h>
+#include <stdint.h>
 #include "ctype.h"
 #include "reent.h"
 #include "string.h"
@@ -131,7 +132,7 @@
 	      write_string (unctrl (c));
 	      break;
 	    case 'p' :
-	      l = (_POINTER_INT) va_arg (args, char *);
+	      l = (intptr_t) va_arg (args, char *);
 	      print_number (16, 1, l);
 	      break;
 	    case 'd' :
diff -Naur newlib-1.18.0.orig/newlib/libc/misc/ffs.c newlib-1.18.0/newlib/libc/misc/ffs.c
--- newlib-1.18.0.orig/newlib/libc/misc/ffs.c	2003-06-06 21:57:51.000000000 +0200
+++ newlib-1.18.0/newlib/libc/misc/ffs.c	2011-01-10 07:59:24.727365666 +0100
@@ -24,7 +24,7 @@
 
 No supporting OS subroutines are required.  */
 
-#include <_ansi.h>
+#include <strings.h>
 
 int
 _DEFUN(ffs, (word),
diff -Naur newlib-1.18.0.orig/newlib/libc/posix/opendir.c newlib-1.18.0/newlib/libc/posix/opendir.c
--- newlib-1.18.0.orig/newlib/libc/posix/opendir.c	2003-06-06 21:57:51.000000000 +0200
+++ newlib-1.18.0/newlib/libc/posix/opendir.c	2011-01-10 07:59:24.727365666 +0100
@@ -74,6 +74,7 @@
 	dirp->dd_len = 512;
 
 	if (dirp->dd_buf == NULL) {
+		free(dirp);
 		close (fd);
 		return NULL;
 	}
diff -Naur newlib-1.18.0.orig/newlib/libc/posix/readdir.c newlib-1.18.0/newlib/libc/posix/readdir.c
--- newlib-1.18.0.orig/newlib/libc/posix/readdir.c	2003-06-06 21:57:51.000000000 +0200
+++ newlib-1.18.0/newlib/libc/posix/readdir.c	2011-01-10 07:59:24.727365666 +0100
@@ -37,6 +37,7 @@
 static char sccsid[] = "@(#)readdir.c	5.7 (Berkeley) 6/1/90";
 #endif /* LIBC_SCCS and not lint */
 
+#include <stdint.h>
 #include <dirent.h>
 
 extern int getdents (int fd, void *dp, int count);
@@ -75,7 +76,7 @@
       continue;
     }
     dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
-    if ((int)dp & 03) {	/* bogus pointer check */
+    if ((intptr_t)dp & 03) {	/* bogus pointer check */
 #ifdef HAVE_DD_LOCK
       __lock_release_recursive(dirp->dd_lock);
 #endif
diff -Naur newlib-1.18.0.orig/newlib/libc/posix/rewinddir.c newlib-1.18.0/newlib/libc/posix/rewinddir.c
--- newlib-1.18.0.orig/newlib/libc/posix/rewinddir.c	2003-06-06 21:57:51.000000000 +0200
+++ newlib-1.18.0/newlib/libc/posix/rewinddir.c	2011-01-10 07:59:24.728365709 +0100
@@ -48,7 +48,7 @@
 #ifdef HAVE_DD_LOCK
 	__lock_acquire_recursive(dirp->dd_lock);
 #endif
-	_seekdir((dirp), (off_t)0);
+	_seekdir((dirp), 0L);
 #ifdef HAVE_DD_LOCK
 	__lock_release_recursive(dirp->dd_lock);
 #endif
diff -Naur newlib-1.18.0.orig/newlib/libc/posix/telldir.c newlib-1.18.0/newlib/libc/posix/telldir.c
--- newlib-1.18.0.orig/newlib/libc/posix/telldir.c	2008-11-27 22:01:40.000000000 +0100
+++ newlib-1.18.0/newlib/libc/posix/telldir.c	2011-01-10 07:59:24.728365709 +0100
@@ -67,7 +67,7 @@
 #define	NDIRHASH	32	/* Num of hash lists, must be a power of 2 */
 #define	LOCHASH(i)	((i)&(NDIRHASH-1))
 
-static long	dd_loccnt;	/* Index of entry for sequential readdir's */
+static long	dd_loccnt = 1;	/* Index of entry for sequential readdir's */
 static struct	ddloc *dd_hash[NDIRHASH];   /* Hash list heads for ddlocs */
 __LOCK_INIT(static, dd_hash_lock);
 
@@ -119,40 +119,46 @@
 	register struct ddloc *lp;
 	register struct ddloc **prevlp;
 	struct dirent *dp;
-	extern long lseek();
 
 #ifdef HAVE_DD_LOCK
 	__lock_acquire(dd_hash_lock);
 #endif
-	prevlp = &dd_hash[LOCHASH(loc)];
-	lp = *prevlp;
-	while (lp != NULL) {
-		if (lp->loc_index == loc)
-			break;
-		prevlp = &lp->loc_next;
-		lp = lp->loc_next;
-	}
-	if (lp == NULL) {
+	if (loc != 0) {
+		prevlp = &dd_hash[LOCHASH(loc)];
+		lp = *prevlp;
+		while (lp != NULL) {
+			if (lp->loc_index == loc)
+				break;
+			prevlp = &lp->loc_next;
+			lp = lp->loc_next;
+		}
+		if (lp == NULL) {
 #ifdef HAVE_DD_LOCK
-		__lock_release(dd_hash_lock);
+			__lock_release(dd_hash_lock);
 #endif
-		return;
-	}
-	if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
-		goto found;
-	(void) lseek(dirp->dd_fd, lp->loc_seek, 0);
-	dirp->dd_seek = lp->loc_seek;
-	dirp->dd_loc = 0;
-	while (dirp->dd_loc < lp->loc_loc) {
-		dp = readdir(dirp);
-		if (dp == NULL)
-			break;
-	}
+			return;
+		}
+		if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
+			goto found;
+		(void) lseek(dirp->dd_fd, lp->loc_seek, 0);
+		dirp->dd_seek = lp->loc_seek;
+		dirp->dd_loc = 0;
+		while (dirp->dd_loc < lp->loc_loc) {
+			dp = readdir(dirp);
+			if (dp == NULL)
+				break;
+		}
 found:
 #ifdef SINGLEUSE
-	*prevlp = lp->loc_next;
-	free((caddr_t)lp);
+		*prevlp = lp->loc_next;
+		free((caddr_t)lp);
 #endif
+	} else {
+		// loc 0 means rewinding
+		(void) lseek(dirp->dd_fd, 0, 0);
+		dirp->dd_seek = 0;
+		dirp->dd_loc = 0;
+	}
 #ifdef HAVE_DD_LOCK
 	__lock_release(dd_hash_lock);
 #endif
@@ -169,26 +175,26 @@
 	__lock_acquire(dd_hash_lock);
 #endif
 	for (i = 0; i < NDIRHASH; ++i) {
+		struct ddloc head;
 		register struct ddloc *lp;
 		register struct ddloc *prevlp;
+
 		lp = dd_hash[i];
-		while (lp != NULL && lp->loc_dirp == dirp) {
-			dd_hash[i] = lp->loc_next;
-			prevlp = lp;
-			free((caddr_t)lp);
-			lp = prevlp->loc_next;
-		}
-		prevlp = lp;
+		head.loc_next = lp;
+		prevlp = &head;
 		while (lp != NULL) {
-			lp = lp->loc_next;
-			if (lp != NULL && lp->loc_dirp == dirp) {
-				prevlp->loc_next = lp->loc_next;
+			struct ddloc *nextlp;
+
+			nextlp = lp->loc_next;
+			if (lp->loc_dirp == dirp) {
+				prevlp->loc_next = nextlp;
 				free((caddr_t)lp);
-				lp = prevlp;
 			}
 			else
 				prevlp = lp;
+			lp = nextlp;
 		}
+		dd_hash[i] = head.loc_next;
 	}
 #ifdef HAVE_DD_LOCK
 	__lock_release(dd_hash_lock);
diff -Naur newlib-1.18.0.orig/newlib/libc/search/db_local.h newlib-1.18.0/newlib/libc/search/db_local.h
--- newlib-1.18.0.orig/newlib/libc/search/db_local.h	2002-06-25 01:05:08.000000000 +0200
+++ newlib-1.18.0/newlib/libc/search/db_local.h	2011-01-10 07:59:24.728365709 +0100
@@ -102,11 +102,11 @@
 typedef struct __db {
 	DBTYPE type;			/* Underlying db type. */
 	int (*close)(struct __db *);
-	int (*del)(const struct __db *, const DBT *, u_int);
-	int (*get)(const struct __db *, const DBT *, DBT *, u_int);
-	int (*put)(const struct __db *, DBT *, const DBT *, u_int);
-	int (*seq)(const struct __db *, DBT *, DBT *, u_int);
-	int (*sync)(const struct __db *, u_int);
+	int (*del)(const struct __db *, const DBT *, __uint32_t);
+	int (*get)(const struct __db *, const DBT *, DBT *, __uint32_t);
+	int (*put)(const struct __db *, DBT *, const DBT *, __uint32_t);
+	int (*seq)(const struct __db *, DBT *, DBT *, __uint32_t);
+	int (*sync)(const struct __db *, __uint32_t);
 	void *internal;			/* Access method private. */
 	int (*fd)(const struct __db *);
 } DB;
diff -Naur newlib-1.18.0.orig/newlib/libc/search/extern.h newlib-1.18.0/newlib/libc/search/extern.h
--- newlib-1.18.0.orig/newlib/libc/search/extern.h	2002-06-20 21:51:31.000000000 +0200
+++ newlib-1.18.0/newlib/libc/search/extern.h	2011-01-10 07:59:24.728365709 +0100
@@ -43,7 +43,7 @@
 int	 __big_split(HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
 		int, __uint32_t, SPLIT_RETURN *);
 int	 __buf_free(HTAB *, int, int);
-void	 __buf_init(HTAB *, int);
+void	 __buf_init(HTAB *, __uint32_t);
 __uint32_t	 __call_hash(HTAB *, char *, int);
 int	 __delpair(HTAB *, BUFHEAD *, int);
 int	 __expand_table(HTAB *);
diff -Naur newlib-1.18.0.orig/newlib/libc/search/hash_buf.c newlib-1.18.0/newlib/libc/search/hash_buf.c
--- newlib-1.18.0.orig/newlib/libc/search/hash_buf.c	2004-05-26 19:57:10.000000000 +0200
+++ newlib-1.18.0/newlib/libc/search/hash_buf.c	2011-01-10 07:59:24.730365799 +0100
@@ -118,7 +118,7 @@
 	int newpage;	/* If prev_bp set, indicates a new overflow page. */
 {
 	BUFHEAD *bp;
-	__uint32_t is_disk_mask;
+	ptrdiff_t is_disk_mask;
 	int is_disk, segment_ndx;
 	SEGMENT segp;
 
@@ -298,7 +298,7 @@
 extern void
 __buf_init(hashp, nbytes)
 	HTAB *hashp;
-	int nbytes;
+	__uint32_t nbytes;
 {
 	BUFHEAD *bfp;
 	int npages;
diff -Naur newlib-1.18.0.orig/newlib/libc/search/hash.h newlib-1.18.0/newlib/libc/search/hash.h
--- newlib-1.18.0.orig/newlib/libc/search/hash.h	2008-07-02 20:38:45.000000000 +0200
+++ newlib-1.18.0/newlib/libc/search/hash.h	2011-01-10 07:59:24.729365753 +0100
@@ -82,7 +82,7 @@
 
 /* Hash Table Information */
 typedef struct hashhdr {		/* Disk resident portion */
-	int		magic;		/* Magic NO for hash tables */
+	__uint32_t	magic;		/* Magic NO for hash tables */
 	int		version;	/* Version ID */
 	__uint32_t	lorder;		/* Byte Order */
 	int		bsize;		/* Bucket/Page Size */
@@ -97,7 +97,7 @@
 	int		high_mask;	/* Mask to modulo into entire table */
 	int		low_mask;	/* Mask to modulo into lower half of 
 					 * table */
-	int		ffactor;	/* Fill factor */
+	__uint32_t	ffactor;	/* Fill factor */
 	int		nkeys;		/* Number of keys in hash table */
 	int		hdrpages;	/* Size of table header */
 	int		h_charkey;	/* value of hash(CHARKEY) */
diff -Naur newlib-1.18.0.orig/newlib/libc/stdio/open_memstream.c newlib-1.18.0/newlib/libc/stdio/open_memstream.c
--- newlib-1.18.0.orig/newlib/libc/stdio/open_memstream.c	2009-02-25 05:00:05.000000000 +0100
+++ newlib-1.18.0/newlib/libc/stdio/open_memstream.c	2011-01-10 07:59:24.730365799 +0100
@@ -330,8 +330,10 @@
     c->max *= sizeof(wchar_t);
   if (c->max < 64)
     c->max = 64;
-  else if (c->max > 64 * 1024)
-    c->max = 64 * 1024;
+#if (SIZE_MAX >= 0x10000)
+  else if (c->max > 0x10000)
+    c->max = 0x10000;
+#endif
   *size = 0;
   *buf = _malloc_r (ptr, c->max);
   if (!*buf)
diff -Naur newlib-1.18.0.orig/newlib/libc/stdio/tmpnam.c newlib-1.18.0/newlib/libc/stdio/tmpnam.c
--- newlib-1.18.0.orig/newlib/libc/stdio/tmpnam.c	2004-04-23 22:01:55.000000000 +0200
+++ newlib-1.18.0/newlib/libc/stdio/tmpnam.c	2011-01-10 07:59:24.730365799 +0100
@@ -94,6 +94,7 @@
 #include <_ansi.h>
 #include <reent.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
@@ -109,7 +110,7 @@
        char *result       _AND
        _CONST char *part1 _AND
        _CONST char *part2 _AND
-       int part3          _AND
+       intptr_t part3     _AND
        int *part4)
 {
   /*  Generate the filename and make sure that there isn't one called
@@ -183,7 +184,7 @@
   if (filename)
     {
       if (! worker (p, filename, dir, prefix,
-		    _getpid_r (p) ^ (int) (_POINTER_INT) p, &p->_inc))
+		    _getpid_r (p) ^ (intptr_t) p, &p->_inc))
 	return NULL;
     }
   return filename;
diff -Naur newlib-1.18.0.orig/newlib/libc/stdlib/putenv_r.c newlib-1.18.0/newlib/libc/stdlib/putenv_r.c
--- newlib-1.18.0.orig/newlib/libc/stdlib/putenv_r.c	2004-11-24 23:34:14.000000000 +0100
+++ newlib-1.18.0/newlib/libc/stdlib/putenv_r.c	2011-01-10 07:59:24.730365799 +0100
@@ -24,6 +24,7 @@
 #include <reent.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 
 #include "envlock.h"
 
diff -Naur newlib-1.18.0.orig/newlib/libc/string/bcmp.c newlib-1.18.0/newlib/libc/string/bcmp.c
--- newlib-1.18.0.orig/newlib/libc/string/bcmp.c	2005-10-28 23:21:07.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/bcmp.c	2011-01-10 07:59:24.730365799 +0100
@@ -6,11 +6,11 @@
 	bcmp
 
 ANSI_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	int bcmp(const void *<[s1]>, const void *<[s2]>, size_t <[n]>);
 
 TRAD_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	int bcmp(<[s1]>, <[s2]>, <[n]>)
 	const void *<[s1]>;
 	const void *<[s2]>;
@@ -35,7 +35,7 @@
 	bcmp ansi pure
 */
 
-#include <string.h>
+#include <strings.h>
 
 int
 _DEFUN (bcmp, (m1, m2, n),
diff -Naur newlib-1.18.0.orig/newlib/libc/string/bcopy.c newlib-1.18.0/newlib/libc/string/bcopy.c
--- newlib-1.18.0.orig/newlib/libc/string/bcopy.c	2002-05-23 20:46:04.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/bcopy.c	2011-01-10 07:59:24.731365848 +0100
@@ -3,7 +3,7 @@
 	<<bcopy>>---copy memory regions
 
 ANSI_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	void bcopy(const void *<[in]>, void *<[out]>, size_t <[n]>);
 
 TRAD_SYNOPSIS
@@ -26,7 +26,7 @@
 	bcopy - pure
 */
 
-#include <string.h>
+#include <strings.h>
 
 void
 _DEFUN (bcopy, (b1, b2, length),
diff -Naur newlib-1.18.0.orig/newlib/libc/string/bzero.c newlib-1.18.0/newlib/libc/string/bzero.c
--- newlib-1.18.0.orig/newlib/libc/string/bzero.c	2002-05-23 20:46:04.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/bzero.c	2011-01-10 07:59:24.731365848 +0100
@@ -6,11 +6,11 @@
 	bzero
 
 ANSI_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	void bzero(void *<[b]>, size_t <[length]>);
 
 TRAD_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	void bzero(<[b]>, <[length]>)
 	void *<[b]>;
 	size_t <[length]>;
@@ -30,7 +30,7 @@
 <<bzero>> requires no supporting OS subroutines.
 */
 
-#include <string.h>
+#include <strings.h>
 
 _VOID
 _DEFUN (bzero, (b, length),
diff -Naur newlib-1.18.0.orig/newlib/libc/string/index.c newlib-1.18.0/newlib/libc/string/index.c
--- newlib-1.18.0.orig/newlib/libc/string/index.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/index.c	2011-01-10 07:59:24.731365848 +0100
@@ -10,7 +10,7 @@
 	char * index(const char *<[string]>, int <[c]>);
 
 TRAD_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	char * index(<[string]>, <[c]>);
 	char *<[string]>;
 	int *<[c]>;
@@ -33,7 +33,8 @@
 	index - pure
 */
 
-#include <string.h>
+#include <strings.h>
+#include <string.h> /* strchr */
 
 char *
 _DEFUN (index, (s, c),
diff -Naur newlib-1.18.0.orig/newlib/libc/string/memccpy.c newlib-1.18.0/newlib/libc/string/memccpy.c
--- newlib-1.18.0.orig/newlib/libc/string/memccpy.c	2002-07-23 23:38:00.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/memccpy.c	2011-01-10 07:59:24.731365848 +0100
@@ -35,13 +35,14 @@
 	*/
 
 #include <_ansi.h>
+#include <stdint.h>
 #include <stddef.h>
 #include <string.h>
 #include <limits.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 /* How many bytes are copied each iteration of the word copy loop.  */
 #define LITTLEBLOCKSIZE (sizeof (long))
diff -Naur newlib-1.18.0.orig/newlib/libc/string/memchr.c newlib-1.18.0/newlib/libc/string/memchr.c
--- newlib-1.18.0.orig/newlib/libc/string/memchr.c	2008-05-27 01:31:08.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/memchr.c	2011-01-10 07:59:24.731365848 +0100
@@ -38,10 +38,11 @@
 
 #include <_ansi.h>
 #include <string.h>
+#include <stdint.h>
 #include <limits.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
-#define UNALIGNED(X) ((long)X & (sizeof (long) - 1))
+#define UNALIGNED(X) ((intptr_t)X & (sizeof (long) - 1))
 
 /* How many bytes are loaded each iteration of the word copy loop.  */
 #define LBLOCKSIZE (sizeof (long))
diff -Naur newlib-1.18.0.orig/newlib/libc/string/memcmp.c newlib-1.18.0/newlib/libc/string/memcmp.c
--- newlib-1.18.0.orig/newlib/libc/string/memcmp.c	2005-03-06 21:40:05.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/memcmp.c	2011-01-10 07:59:24.731365848 +0100
@@ -37,11 +37,11 @@
 */
 
 #include <string.h>
-
+#include <stdint.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 /* How many bytes are copied each iteration of the word copy loop.  */
 #define LBLOCKSIZE (sizeof (long))
diff -Naur newlib-1.18.0.orig/newlib/libc/string/memcpy.c newlib-1.18.0/newlib/libc/string/memcpy.c
--- newlib-1.18.0.orig/newlib/libc/string/memcpy.c	2008-12-11 18:27:56.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/memcpy.c	2011-01-10 07:59:24.731365848 +0100
@@ -34,11 +34,12 @@
 	*/
 
 #include <_ansi.h>
+#include <stdint.h>
 #include <string.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 /* How many bytes are copied each iteration of the 4X unrolled loop.  */
 #define BIGBLOCKSIZE    (sizeof (long) << 2)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/memmove.c newlib-1.18.0/newlib/libc/string/memmove.c
--- newlib-1.18.0.orig/newlib/libc/string/memmove.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/memmove.c	2011-01-10 07:59:24.732365897 +0100
@@ -36,13 +36,14 @@
 */
 
 #include <string.h>
+#include <stdint.h>
 #include <_ansi.h>
 #include <stddef.h>
 #include <limits.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 /* How many bytes are copied each iteration of the 4X unrolled loop.  */
 #define BIGBLOCKSIZE    (sizeof (long) << 2)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/mempcpy.c newlib-1.18.0/newlib/libc/string/mempcpy.c
--- newlib-1.18.0.orig/newlib/libc/string/mempcpy.c	2002-07-23 23:38:00.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/mempcpy.c	2011-01-10 07:59:24.732365897 +0100
@@ -34,10 +34,11 @@
 #include <stddef.h>
 #include <limits.h>
 #include <string.h>
+#include <stdint.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((uintptr_t)Y & (sizeof (long) - 1)))
 
 /* How many bytes are copied each iteration of the 4X unrolled loop.  */
 #define BIGBLOCKSIZE    (sizeof (long) << 2)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/memset.c newlib-1.18.0/newlib/libc/string/memset.c
--- newlib-1.18.0.orig/newlib/libc/string/memset.c	2008-05-27 20:44:40.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/memset.c	2011-01-10 07:59:24.733365944 +0100
@@ -34,9 +34,10 @@
 */
 
 #include <string.h>
+#include <stdint.h>
 
 #define LBLOCKSIZE (sizeof(long))
-#define UNALIGNED(X)   ((long)X & (LBLOCKSIZE - 1))
+#define UNALIGNED(X)   ((intptr_t)X & (LBLOCKSIZE - 1))
 #define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
 
 _PTR
diff -Naur newlib-1.18.0.orig/newlib/libc/string/rindex.c newlib-1.18.0/newlib/libc/string/rindex.c
--- newlib-1.18.0.orig/newlib/libc/string/rindex.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/rindex.c	2011-01-10 07:59:24.733365944 +0100
@@ -10,7 +10,7 @@
 	char * rindex(const char *<[string]>, int <[c]>);
 
 TRAD_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	char * rindex(<[string]>, <[c]>);
 	char *<[string]>;
 	int *<[c]>;
@@ -33,7 +33,8 @@
 	rindex - pure
 */
 
-#include <string.h>
+#include <strings.h>
+#include <string.h> /* strchr */
 
 char *
 _DEFUN (rindex, (s, c),
diff -Naur newlib-1.18.0.orig/newlib/libc/string/stpcpy.c newlib-1.18.0/newlib/libc/string/stpcpy.c
--- newlib-1.18.0.orig/newlib/libc/string/stpcpy.c	2007-06-28 19:07:23.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/stpcpy.c	2011-01-10 07:59:24.733365944 +0100
@@ -34,6 +34,7 @@
 */
 
 #include <string.h>
+#include <stdint.h>
 #include <limits.h>
 
 /*SUPPRESS 560*/
@@ -41,7 +42,7 @@
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/stpncpy.c newlib-1.18.0/newlib/libc/string/stpncpy.c
--- newlib-1.18.0.orig/newlib/libc/string/stpncpy.c	2007-06-28 19:07:23.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/stpncpy.c	2011-01-10 07:59:24.733365944 +0100
@@ -40,6 +40,7 @@
 */
 
 #include <string.h>
+#include <stdint.h>
 #include <limits.h>
 
 /*SUPPRESS 560*/
@@ -47,7 +48,7 @@
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strcasecmp.c newlib-1.18.0/newlib/libc/string/strcasecmp.c
--- newlib-1.18.0.orig/newlib/libc/string/strcasecmp.c	2009-04-23 20:11:22.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/strcasecmp.c	2011-01-10 07:59:24.733365944 +0100
@@ -38,7 +38,7 @@
 	strcasecmp
 */
 
-#include <string.h>
+#include <strings.h>
 #include <ctype.h>
 
 int
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strcat.c newlib-1.18.0/newlib/libc/string/strcat.c
--- newlib-1.18.0.orig/newlib/libc/string/strcat.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/strcat.c	2011-01-10 07:59:24.733365944 +0100
@@ -33,12 +33,13 @@
 	strcat ansi pure
 */
 
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
 /* Nonzero if X is aligned on a "long" boundary.  */
 #define ALIGNED(X) \
-  (((long)X & (sizeof (long) - 1)) == 0)
+  (((uintptr_t)X & (sizeof (long) - 1)) == 0)
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strchr.c newlib-1.18.0/newlib/libc/string/strchr.c
--- newlib-1.18.0.orig/newlib/libc/string/strchr.c	2008-05-22 04:31:46.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/strchr.c	2011-01-10 07:59:24.734365990 +0100
@@ -33,11 +33,12 @@
 	strchr ansi pure
 */
 
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
 /* Nonzero if X is not aligned on a "long" boundary.  */
-#define UNALIGNED(X) ((long)X & (sizeof (long) - 1))
+#define UNALIGNED(X) ((uintptr_t)X & (sizeof (long) - 1))
 
 /* How many bytes are loaded each iteration of the word copy loop.  */
 #define LBLOCKSIZE (sizeof (long))
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strcmp.c newlib-1.18.0/newlib/libc/string/strcmp.c
--- newlib-1.18.0.orig/newlib/libc/string/strcmp.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/strcmp.c	2011-01-10 07:59:24.734365990 +0100
@@ -35,12 +35,13 @@
 	strcmp ansi pure
 */
 
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((uintptr_t)X & (sizeof (long) - 1)) | ((uintptr_t)Y & (sizeof (long) - 1)))
 
 /* DETECTNULL returns nonzero if (long)X contains a NULL byte. */
 #if LONG_MAX == 2147483647L
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strcpy.c newlib-1.18.0/newlib/libc/string/strcpy.c
--- newlib-1.18.0.orig/newlib/libc/string/strcpy.c	2007-05-29 23:26:59.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/strcpy.c	2011-01-10 07:59:24.734365990 +0100
@@ -32,6 +32,7 @@
 	strcpy ansi pure
 */
 
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
@@ -40,7 +41,7 @@
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strlen.c newlib-1.18.0/newlib/libc/string/strlen.c
--- newlib-1.18.0.orig/newlib/libc/string/strlen.c	2008-05-27 00:56:14.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/strlen.c	2011-01-10 07:59:24.734365990 +0100
@@ -32,11 +32,12 @@
 */
 
 #include <_ansi.h>
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
 #define LBLOCKSIZE   (sizeof (long))
-#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
+#define UNALIGNED(X) ((intptr_t)X & (LBLOCKSIZE - 1))
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strncasecmp.c newlib-1.18.0/newlib/libc/string/strncasecmp.c
--- newlib-1.18.0.orig/newlib/libc/string/strncasecmp.c	2009-04-23 20:11:22.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/strncasecmp.c	2011-01-10 07:59:24.734365990 +0100
@@ -6,11 +6,11 @@
 	strncasecmp
 
 ANSI_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	int strncasecmp(const char *<[a]>, const char * <[b]>, size_t <[length]>);
 
 TRAD_SYNOPSIS
-	#include <string.h>
+	#include <strings.h>
 	int strncasecmp(<[a]>, <[b]>, <[length]>)
 	char *<[a]>;
 	char *<[b]>;
@@ -40,7 +40,7 @@
 	strncasecmp
 */
 
-#include <string.h>
+#include <strings.h>
 #include <ctype.h>
 
 int 
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strncat.c newlib-1.18.0/newlib/libc/string/strncat.c
--- newlib-1.18.0.orig/newlib/libc/string/strncat.c	2005-10-28 23:21:07.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/strncat.c	2011-01-10 07:59:24.734365990 +0100
@@ -42,11 +42,12 @@
 */
 
 #include <string.h>
+#include <stdint.h>
 #include <limits.h>
 
 /* Nonzero if X is aligned on a "long" boundary.  */
 #define ALIGNED(X) \
-  (((long)X & (sizeof (long) - 1)) == 0)
+  (((intptr_t)X & (sizeof (long) - 1)) == 0)
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strncmp.c newlib-1.18.0/newlib/libc/string/strncmp.c
--- newlib-1.18.0.orig/newlib/libc/string/strncmp.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/strncmp.c	2011-01-10 07:59:24.734365990 +0100
@@ -36,12 +36,13 @@
 	strncmp ansi pure
 */
 
+#include <stdint.h>
 #include <string.h>
 #include <limits.h>
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((uintptr_t)X & (sizeof (long) - 1)) | ((uintptr_t)Y & (sizeof (long) - 1)))
 
 /* DETECTNULL returns nonzero if (long)X contains a NULL byte. */
 #if LONG_MAX == 2147483647L
diff -Naur newlib-1.18.0.orig/newlib/libc/string/strncpy.c newlib-1.18.0/newlib/libc/string/strncpy.c
--- newlib-1.18.0.orig/newlib/libc/string/strncpy.c	2000-02-17 20:39:48.000000000 +0100
+++ newlib-1.18.0/newlib/libc/string/strncpy.c	2011-01-10 07:59:24.735366036 +0100
@@ -38,6 +38,7 @@
 */
 
 #include <string.h>
+#include <stdint.h>
 #include <limits.h>
 
 /*SUPPRESS 560*/
@@ -45,7 +46,7 @@
 
 /* Nonzero if either X or Y is not aligned on a "long" boundary.  */
 #define UNALIGNED(X, Y) \
-  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
+  (((intptr_t)X & (sizeof (long) - 1)) | ((intptr_t)Y & (sizeof (long) - 1)))
 
 #if LONG_MAX == 2147483647L
 #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
diff -Naur newlib-1.18.0.orig/newlib/libc/string/str-two-way.h newlib-1.18.0/newlib/libc/string/str-two-way.h
--- newlib-1.18.0.orig/newlib/libc/string/str-two-way.h	2008-10-02 22:12:34.000000000 +0200
+++ newlib-1.18.0/newlib/libc/string/str-two-way.h	2011-01-10 07:59:24.733365944 +0100
@@ -1,5 +1,5 @@
 /* Byte-wise substring search, using the Two-Way algorithm.
- * Copyright (C) 2008 Eric Blake
+ * Copyright (C) 2008, 2010 Eric Blake
  * Permission to use, copy, modify, and distribute this software
  * is freely granted, provided that this notice is preserved.
  */
@@ -335,8 +335,8 @@
 		     a byte out of place, there can be no match until
 		     after the mismatch.  */
 		  shift = needle_len - period;
-		  memory = 0;
 		}
+		memory = 0;
 	      j += shift;
 	      continue;
 	    }
diff -Naur newlib-1.18.0.orig/newlib/libc/sys/rtems/crt0.c newlib-1.18.0/newlib/libc/sys/rtems/crt0.c
--- newlib-1.18.0.orig/newlib/libc/sys/rtems/crt0.c	2009-12-16 19:28:14.000000000 +0100
+++ newlib-1.18.0/newlib/libc/sys/rtems/crt0.c	2011-01-10 07:59:24.735366036 +0100
@@ -24,8 +24,8 @@
 /* RTEMS provides some of its own routines including a Malloc family */
 RTEMS_STUB(void *,malloc(size_t s)) { return 0; }
 RTEMS_STUB(void *,realloc(void* p, size_t s)) { return 0; }
-RTEMS_STUB(void, free(void)) { ; }
-RTEMS_STUB(_PTR, calloc(struct _reent *r, size_t s1, size_t s2)) {}
+RTEMS_STUB(void, free(void* ptr)) { ; }
+RTEMS_STUB(_PTR, calloc(size_t s1, size_t s2)) {}
 
 #if defined(__GNUC__)
 /*
diff -Naur newlib-1.18.0.orig/newlib/libc/sys/rtems/machine/_types.h newlib-1.18.0/newlib/libc/sys/rtems/machine/_types.h
--- newlib-1.18.0.orig/newlib/libc/sys/rtems/machine/_types.h	2009-12-17 17:10:41.000000000 +0100
+++ newlib-1.18.0/newlib/libc/sys/rtems/machine/_types.h	2011-01-10 07:59:24.735366036 +0100
@@ -31,4 +31,25 @@
 
 typedef __int32_t blksize_t;
 typedef __int32_t blkcnt_t;
+
+/* EXPERIMENTAL: Use 64bit types */
+#if defined(__arm__) || defined(__i386__) || defined(__m68k__) || defined(__mips__) || defined(__PPC__) || defined(__sparc__)
+/* Use 64bit types */
+typedef __int64_t _off_t;
+#define __off_t_defined 1
+
+typedef __int64_t _fpos_t;
+#define __fpos_t_defined 1
+#else
+/* Use 32bit types */
+typedef __int32_t _off_t;
+#define __off_t_defined 1
+
+typedef __int32_t _fpos_t;
+#define __fpos_t_defined 1
+#endif
+
+typedef __uint32_t _mode_t;
+#define __mode_t_defined 1
+
 #endif
diff -Naur newlib-1.18.0.orig/newlib/libc/sys/rtems/sys/dirent.h newlib-1.18.0/newlib/libc/sys/rtems/sys/dirent.h
--- newlib-1.18.0.orig/newlib/libc/sys/rtems/sys/dirent.h	2004-01-08 20:25:21.000000000 +0100
+++ newlib-1.18.0/newlib/libc/sys/rtems/sys/dirent.h	2011-01-10 07:59:24.735366036 +0100
@@ -31,6 +31,10 @@
 void seekdir(DIR *dir, long loc);
 long telldir(DIR *dir);
 
+#ifdef _COMPILING_NEWLIB
+void _seekdir(DIR *dir, long offset);
+#endif
+
 #include <sys/types.h>
 
 #include <limits.h>
diff -Naur newlib-1.18.0.orig/newlib/libm/common/modfl.c newlib-1.18.0/newlib/libm/common/modfl.c
--- newlib-1.18.0.orig/newlib/libm/common/modfl.c	2009-04-18 00:15:43.000000000 +0200
+++ newlib-1.18.0/newlib/libm/common/modfl.c	2011-01-10 07:59:24.735366036 +0100
@@ -36,7 +36,7 @@
 long double
 modfl (long double x, long double *iptr)
 {
-  return modf(x, iptr);
+  return modf(x, (double*) iptr);
 }
 #endif
 
diff -Naur newlib-1.18.0.orig/newlib/libm/common/sf_llrint.c newlib-1.18.0/newlib/libm/common/sf_llrint.c
--- newlib-1.18.0.orig/newlib/libm/common/sf_llrint.c	2009-04-03 19:39:24.000000000 +0200
+++ newlib-1.18.0/newlib/libm/common/sf_llrint.c	2011-01-10 07:59:24.736366080 +0100
@@ -71,7 +71,7 @@
           GET_FLOAT_WORD (i0, t);
           /* Detect the all-zeros representation of plus and
              minus zero, which fails the calculation below. */
-          if ((i0 & ~(1 << 31)) == 0)
+          if ((i0 & ~((__uint32_t)1 << 31)) == 0)
               return 0;
           j0 = ((i0 >> 23) & 0xff) - 0x7f;
           i0 &= 0x7fffff;
diff -Naur newlib-1.18.0.orig/newlib/libm/common/sf_round.c newlib-1.18.0/newlib/libm/common/sf_round.c
--- newlib-1.18.0.orig/newlib/libm/common/sf_round.c	2005-02-24 20:02:35.000000000 +0100
+++ newlib-1.18.0/newlib/libm/common/sf_round.c	2011-01-10 07:59:24.736366080 +0100
@@ -38,7 +38,7 @@
           w &= 0x80000000;
           if (exponent_less_127 == -1)
             /* Result is +1.0 or -1.0. */
-            w |= (127 << 23);
+            w |= ((__uint32_t)127 << 23);
         }
       else
         {
diff -Naur newlib-1.18.0.orig/newlib/libm/common/s_llrint.c newlib-1.18.0/newlib/libm/common/s_llrint.c
--- newlib-1.18.0.orig/newlib/libm/common/s_llrint.c	2009-04-03 19:39:24.000000000 +0200
+++ newlib-1.18.0/newlib/libm/common/s_llrint.c	2011-01-10 07:59:24.735366036 +0100
@@ -61,40 +61,56 @@
 
   /* Extract exponent field. */
   j0 = ((i0 & 0x7ff00000) >> 20) - 1023;
+  /* j0 in [-1023,1024] */
   
   if(j0 < 20)
     {
+      /* j0 in [-1023,19] */
       if(j0 < -1)
         return 0;
       else
         {
+          /* j0 in [0,19] */
+	  /* shift amt in [0,19] */
           w = TWO52[sx] + x;
           t = w - TWO52[sx];
           GET_HIGH_WORD(i0, t);
           /* Detect the all-zeros representation of plus and
              minus zero, which fails the calculation below. */
-          if ((i0 & ~(1 << 31)) == 0)
+          if ((i0 & ~((__int32_t)1 << 31)) == 0)
               return 0;
+          /* After round:  j0 in [0,20] */
           j0 = ((i0 & 0x7ff00000) >> 20) - 1023;
           i0 &= 0x000fffff;
           i0 |= 0x00100000;
+	  /* shift amt in [20,0] */
           result = i0 >> (20 - j0);
         }
     }
   else if (j0 < (int)(8 * sizeof (long long int)) - 1)
     {
+      /* 64bit return: j0 in [20,62] */
       if (j0 >= 52)
+	/* 64bit return: j0 in [52,62] */
+	/* 64bit return: left shift amt in [32,42] */
         result = ((long long int) ((i0 & 0x000fffff) | 0x0010000) << (j0 - 20)) | 
+		/* 64bit return: right shift amt in [0,10] */
                    (i1 << (j0 - 52));
       else
         {
+	  /* 64bit return: j0 in [20,51] */
           w = TWO52[sx] + x;
           t = w - TWO52[sx];
           EXTRACT_WORDS (i0, i1, t);
           j0 = ((i0 & 0x7ff00000) >> 20) - 1023;
           i0 &= 0x000fffff;
           i0 |= 0x00100000;
-          result = ((long long int) i0 << (j0 - 20)) | (i1 >> (52 - j0));
+          /* After round:
+	   * 64bit return: j0 in [20,52] */
+	  /* 64bit return: left shift amt in [0,32] */
+          /* ***64bit return: right shift amt in [32,0] */
+          result = ((long long int) i0 << (j0 - 20))
+			| SAFE_RIGHT_SHIFT (i1, (52 - j0));
         }
     }
   else
diff -Naur newlib-1.18.0.orig/newlib/libm/common/s_round.c newlib-1.18.0/newlib/libm/common/s_round.c
--- newlib-1.18.0.orig/newlib/libm/common/s_round.c	2009-03-25 20:13:01.000000000 +0100
+++ newlib-1.18.0/newlib/libm/common/s_round.c	2011-01-10 07:59:24.736366080 +0100
@@ -68,7 +68,7 @@
           msw &= 0x80000000;
           if (exponent_less_1023 == -1)
             /* Result is +1.0 or -1.0. */
-            msw |= (1023 << 20);
+            msw |= ((__int32_t)1023 << 20);
           lsw = 0;
         }
       else
diff -Naur newlib-1.18.0.orig/newlib/libm/math/e_scalb.c newlib-1.18.0/newlib/libm/math/e_scalb.c
--- newlib-1.18.0.orig/newlib/libm/math/e_scalb.c	2000-02-17 20:39:51.000000000 +0100
+++ newlib-1.18.0/newlib/libm/math/e_scalb.c	2011-01-10 07:59:24.736366080 +0100
@@ -17,6 +17,7 @@
  * should use scalbn() instead.
  */
 
+#include <limits.h>
 #include "fdlibm.h"
 
 #ifndef _DOUBLE_IS_32BITS
@@ -46,8 +47,17 @@
 	    else       return x/(-fn);
 	}
 	if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
+#if (INT_MAX < 65000)
+	if ( fn > (double) INT_MAX) return scalbn(x, INT_MAX);
+#else
 	if ( fn > 65000.0) return scalbn(x, 65000);
-	if (-fn > 65000.0) return scalbn(x,-65000);
+#endif
+
+#if (INT_MIN > -65000)
+        if (fn < (double) INT_MIN) return scalbn(x,INT_MIN);
+#else
+	if (fn < -65000.0) return scalbn(x,-65000);
+#endif
 	return scalbn(x,(int)fn);
 #endif
 }
diff -Naur newlib-1.18.0.orig/newlib/libm/math/wf_tgamma.c newlib-1.18.0/newlib/libm/math/wf_tgamma.c
--- newlib-1.18.0.orig/newlib/libm/math/wf_tgamma.c	2007-09-04 19:33:10.000000000 +0200
+++ newlib-1.18.0/newlib/libm/math/wf_tgamma.c	2011-01-10 07:59:24.736366080 +0100
@@ -43,3 +43,17 @@
 	return y;
 #endif
 }
+
+#ifdef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+	double tgamma(double x)
+#else
+	double tgamma(x)
+	double x;
+#endif
+{
+	return (double) tgammaf((float) x);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff -Naur newlib-1.18.0.orig/newlib/libm/math/w_tgamma.c newlib-1.18.0/newlib/libm/math/w_tgamma.c
--- newlib-1.18.0.orig/newlib/libm/math/w_tgamma.c	2002-06-07 23:59:56.000000000 +0200
+++ newlib-1.18.0/newlib/libm/math/w_tgamma.c	2011-01-10 07:59:24.736366080 +0100
@@ -17,6 +17,8 @@
 
 #include "fdlibm.h"
 
+#ifndef _DOUBLE_IS_32BITS
+
 #ifdef __STDC__
 	double tgamma(double x)
 #else
@@ -42,3 +44,5 @@
 	return y;
 #endif
 }
+
+#endif /* defined(_DOUBLE_IS_32BITS) */
diff -Naur newlib-1.18.0.orig/newlib/Makefile.am newlib-1.18.0/newlib/Makefile.am
--- newlib-1.18.0.orig/newlib/Makefile.am	2009-08-18 23:48:05.000000000 +0200
+++ newlib-1.18.0/newlib/Makefile.am	2011-01-10 07:59:24.720365335 +0100
@@ -81,7 +81,7 @@
 	libc.a
 endif
 
-noinst_DATA = stmp-targ-include
+BUILT_SOURCES = stmp-targ-include
 
 toollib_DATA = $(CRT0) $(CRT1)
 
diff -Naur newlib-1.18.0.orig/newlib/Makefile.in newlib-1.18.0/newlib/Makefile.in
--- newlib-1.18.0.orig/newlib/Makefile.in	2009-10-21 00:43:45.000000000 +0200
+++ newlib-1.18.0/newlib/Makefile.in	2011-01-10 07:59:24.720365335 +0100
@@ -122,7 +122,7 @@
 	install-pdf-recursive install-ps-recursive install-recursive \
 	installcheck-recursive installdirs-recursive pdf-recursive \
 	ps-recursive uninstall-recursive
-DATA = $(noinst_DATA) $(toollib_DATA)
+DATA = $(toollib_DATA)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
 AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
@@ -351,7 +351,7 @@
 @USE_LIBTOOL_FALSE@toollib_LIBRARIES = libm.a \
 @USE_LIBTOOL_FALSE@	libc.a
 
-noinst_DATA = stmp-targ-include
+BUILT_SOURCES = stmp-targ-include
 toollib_DATA = $(CRT0) $(CRT1)
 
 # The functions ldexp, frexp and modf are traditionally supplied in
@@ -411,7 +411,7 @@
 
 # dejagnu support
 RUNTESTFLAGS = 
-all: newlib.h
+all: $(BUILT_SOURCES) newlib.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
@@ -725,14 +725,16 @@
 	done
 check-am:
 	$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
-check: check-recursive
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-recursive
 all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) newlib.h
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(toollibdir)" "$(DESTDIR)$(toollibdir)" "$(DESTDIR)$(toollibdir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
-install: install-recursive
+install: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-recursive
 install-exec: install-exec-recursive
 install-data: install-data-recursive
 uninstall: uninstall-recursive
@@ -758,6 +760,7 @@
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 clean: clean-recursive
 
 clean-am: clean-generic clean-libtool clean-toollibLIBRARIES \
@@ -833,8 +836,9 @@
 uninstall-am: uninstall-toollibDATA uninstall-toollibLIBRARIES \
 	uninstall-toollibLTLIBRARIES
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check-am \
-	ctags-recursive install-am install-strip tags-recursive
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
+	check-am ctags-recursive install install-am install-strip \
+	tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 	all all-am am--refresh check check-DEJAGNU check-am clean \