summaryrefslogtreecommitdiff
blob: 09527d0ead5668f5c8370a606da293b8654b0cf3 (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
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
Authors: Tim Yamin <plasmaroo@gentoo.org>
         Mike Frysinger <vapier@gentoo.org>
         Martin Schlemmer <azarah@gentoo.org>
         Jeremy Huddleston <eradicator@gentoo.org>

This patch neatens up the 2.6 headers for user-space usage and allows backward
compatibility on a variety of applications which are designed for 2.4 headers.

diff -ur linux-2.6.0/include/linux/bitmap.h linux-2.6.0/include/linux.gentoo/bitmap.h
--- linux-2.6.0/include/linux/bitmap.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/bitmap.h	2003-12-27 19:19:31.000000000 +0000
@@ -1,6 +1,7 @@
 #ifndef __LINUX_BITMAP_H
 #define __LINUX_BITMAP_H
 
+#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 #include <linux/config.h>
@@ -155,5 +156,5 @@
 #endif
 
 #endif /* __ASSEMBLY__ */
-
+#endif /* __KERNEL__ */
 #endif /* __LINUX_BITMAP_H */
diff -ur linux-2.6.0/include/linux/buffer_head.h linux-2.6.0/include/linux.gentoo/buffer_head.h
--- linux-2.6.0/include/linux/buffer_head.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/buffer_head.h	2003-12-27 19:19:31.000000000 +0000
@@ -34,6 +34,8 @@
 
 #define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
 
+#ifdef __KERNEL__
+
 struct page;
 struct buffer_head;
 struct address_space;
@@ -283,6 +285,8 @@
 		__wait_on_buffer(bh);
 }
 
+#endif /* __KERNEL__ */
+
 static inline void lock_buffer(struct buffer_head *bh)
 {
 	while (test_set_buffer_locked(bh))
diff -ur linux-2.6.0/include/linux/compiler-gcc2.h linux-2.6.0/include/linux.gentoo/compiler-gcc2.h
--- linux-2.6.0/include/linux/compiler-gcc2.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/compiler-gcc2.h	2003-12-27 19:19:31.000000000 +0000
@@ -12,7 +12,9 @@
 # define __builtin_expect(x, expected_value) (x)
 #endif
 
+#ifndef __attribute_used__
 #define __attribute_used__	__attribute__((__unused__))
+#endif
 
 /*
  * The attribute `pure' is not implemented in GCC versions earlier
diff -ur linux-2.6.1/include/linux/cpumask.h linux-2.6.1/include/linux.gentoo/cpumask.h
--- linux-2.6.1/include/linux/cpumask.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.1/include/linux.gentoo/cpumask.h	2003-12-27 19:19:31.000000000 +0000
@@ -1,6 +1,8 @@
 #ifndef __LINUX_CPUMASK_H
 #define __LINUX_CPUMASK_H
 
+#ifdef __KERNEL__
+
 /*
  * Cpumasks provide a bitmap suitable for representing the
  * set of CPU's in a system, one bit position per CPU number.
@@ -68,4 +70,5 @@
 		cpu < NR_CPUS;						\
 		cpu = next_online_cpu(cpu,map))
 
+#endif /* __KERNEL__ */
 #endif /* __LINUX_CPUMASK_H */
diff -ur linux-2.6.0/include/linux/ext2_fs_sb.h linux-2.6.0/include/linux.gentoo/ext2_fs_sb.h
--- linux-2.6.0/include/linux/ext2_fs_sb.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/ext2_fs_sb.h	2003-12-27 19:19:31.000000000 +0000
@@ -46,9 +46,9 @@
 	int s_inode_size;
 	int s_first_ino;
 	spinlock_t s_next_gen_lock;
-	u32 s_next_generation;
+	__u32 s_next_generation;
 	unsigned long s_dir_count;
-	u8 *s_debts;
+	__u8 *s_debts;
 	struct percpu_counter s_freeblocks_counter;
 	struct percpu_counter s_freeinodes_counter;
 	struct percpu_counter s_dirs_counter;
diff -ur linux-2.6.7/include/linux/mod_devicetable.h linux-2.6.7/include/linux.gentoo/mod_devicetable.h
--- linux-2.6.7/include/linux/mod_devicetable.h.orig	2004-06-16 01:20:19.000000000 -0400
+++ linux-2.6.7/include/linux/mod_devicetable.h	2004-07-22 14:12:34.707621864 -0400
@@ -8,6 +8,7 @@
 #define LINUX_MOD_DEVICETABLE_H
 
 #ifdef __KERNEL__
+#ifndef __KERNEL_ULONG_T__
 #include <linux/types.h>
 typedef unsigned long kernel_ulong_t;
 #endif
@@ -164,5 +165,5 @@
 	} devs[PNP_MAX_DEVICES];
 };
 
-
+#endif /* __KERNEL__ */
 #endif /* LINUX_MOD_DEVICETABLE_H */
diff -ur linux-2.6.6/include/linux/radix-tree.h linux-2.6.6/include/linux.gentoo/radix-tree.h
--- linux-2.6.6/include/linux/radix-tree.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.6/include/linux.gentoo/radix-tree.h	2003-12-27 19:19:31.000000000 +0000
@@ -44,6 +44,8 @@
 	(root)->rnode = NULL;						\
 } while (0)
 
+#ifdef __KERNEL__
+
 int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
 void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
 void *radix_tree_delete(struct radix_tree_root *, unsigned long);
@@ -68,4 +70,5 @@
 	preempt_enable();
 }
 
+#endif /* __KERNEL__ */
 #endif /* _LINUX_RADIX_TREE_H */
diff -ur linux-2.6.0/include/linux/smp.h linux-2.6.0/include/linux.gentoo/smp.h
--- linux-2.6.0/include/linux/smp.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/smp.h	2003-12-27 19:19:31.000000000 +0000
@@ -6,6 +6,8 @@
  *		Alan Cox. <alan@redhat.com>
  */
 
+
+#ifdef __KERNEL__
 #include <linux/config.h>
 
 #ifdef CONFIG_SMP
@@ -112,4 +114,5 @@
 #define put_cpu()		preempt_enable()
 #define put_cpu_no_resched()	preempt_enable_no_resched()
 
+#endif /* __KERNEL__ */
 #endif /* __LINUX_SMP_H */
diff -ur linux-2.6.0/include/linux/spinlock.h linux-2.6.0/include/linux.gentoo/spinlock.h
--- linux-2.6.0/include/linux/spinlock.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/spinlock.h	2003-12-27 19:19:31.000000000 +0000
@@ -183,6 +183,7 @@
 #define _raw_write_trylock(lock) ({ (void)(lock); (1); })
 
 #endif /* !SMP */
+#ifdef __KERNEL__
 
 /*
  * Define the various spin_lock and rw_lock methods.  Note we define these
@@ -465,4 +466,5 @@
 #endif
 }
 
+#endif /* __KERNEL__ */
 #endif /* __LINUX_SPINLOCK_H */
diff -ur linux-2.6.0/include/linux/time.h linux-2.6.0/include/linux.gentoo/time.h
--- linux-2.6.0/include/linux/time.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/time.h	2003-12-27 19:19:31.000000000 +0000
@@ -4,24 +4,31 @@
 #include <asm/param.h>
 #include <linux/types.h>
 
+#ifndef _SYS_TIME_H
 #ifndef _STRUCT_TIMESPEC
+#ifndef __timespec_defined
 #define _STRUCT_TIMESPEC
 struct timespec {
 	time_t	tv_sec;		/* seconds */
 	long	tv_nsec;	/* nanoseconds */
 };
+#endif /* __timespec_defined */
 #endif /* _STRUCT_TIMESPEC */
 
+#ifndef _STRUCT_TIMEVAL
 struct timeval {
 	time_t		tv_sec;		/* seconds */
 	suseconds_t	tv_usec;	/* microseconds */
 };
+#endif /* _STRUCT_TIMEVAL */
 
 struct timezone {
 	int	tz_minuteswest;	/* minutes west of Greenwich */
 	int	tz_dsttime;	/* type of dst correction */
 };
 
+#endif /* _SYS_TIME_H */
+
 #ifdef __KERNEL__
 
 #include <linux/spinlock.h>
@@ -281,6 +281,8 @@
  * machines were long is 32-bit! (However, as time_t is signed, we
  * will already get problems at other places on 2038-01-19 03:14:08)
  */
+
+#ifndef _TIME_H
 static inline unsigned long
 mktime (unsigned int year, unsigned int mon,
 	unsigned int day, unsigned int hour,
@@ -298,6 +300,7 @@
 	  )*60 + min /* now have minutes */
 	)*60 + sec; /* finally seconds */
 }
+#endif
 
 extern struct timespec xtime;
 extern struct timespec wall_to_monotonic;
@@ -351,15 +358,19 @@
 #define	ITIMER_VIRTUAL	1
 #define	ITIMER_PROF	2
 
+#ifndef _TIME_H
 struct  itimerspec {
         struct  timespec it_interval;    /* timer period */
         struct  timespec it_value;       /* timer expiration */
 };
+#endif /* _TIME_H */
 
+#ifndef _SYS_TIME_H
 struct	itimerval {
 	struct	timeval it_interval;	/* timer interval */
 	struct	timeval it_value;	/* current value */
 };
+#endif /* _SYS_TIME_H */
 
 
 /*
diff -ur linux-2.6.0/include/linux/workqueue.h linux-2.6.0/include/linux.gentoo/workqueue.h
--- linux-2.6.0/include/linux/workqueue.h	2003-12-27 19:22:38.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/workqueue.h	2003-12-27 19:19:31.000000000 +0000
@@ -5,6 +5,8 @@
 #ifndef _LINUX_WORKQUEUE_H
 #define _LINUX_WORKQUEUE_H
 
+#ifdef __KERNEL__
+
 #include <linux/timer.h>
 #include <linux/linkage.h>
 
@@ -73,5 +75,7 @@
 	return del_timer_sync(&work->timer);
 }
 
+#endif /* __KERNEL__ */
+
 #endif
 
diff -ur linux-2.6.0/include/asm-i386/mpspec.h linux-2.6.0/include/asm-i386/mpspec.h
--- linux-2.6.0/include/asm-i386/mpspec.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.0/include/asm-i386/mpspec.h	2004-01-19 20:01:11.000000000 +0000
@@ -3,7 +3,7 @@
 
 #include <linux/cpumask.h>
 #include <asm/mpspec_def.h>
-#include <mach_mpspec.h>
+#include <asm/mach-generic/mach_mpspec.h>
 
 extern int mp_bus_id_to_type [MAX_MP_BUSSES];
 extern int mp_bus_id_to_node [MAX_MP_BUSSES];
diff -ur linux-2.6.0/include/asm-i386/processor.h linux-2.6.0/include/asm-i386/processor.h
--- linux-2.6.0/include/asm-i386/processor.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.0/include/asm-i386/processor.h	2004-01-19 20:01:11.000000000 +0000
@@ -8,7 +8,9 @@
 #define __ASM_I386_PROCESSOR_H
 
 #include <asm/vm86.h>
+#ifdef __KERNEL__
 #include <asm/math_emu.h>
+#endif
 #include <asm/segment.h>
 #include <asm/page.h>
 #include <asm/types.h>
diff -ur linux-2.6.0/include/asm-i386/semaphore.h linux-2.6.0/include/asm-i386/semaphore.h
--- linux-2.6.0/include/asm-i386/semaphore.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.0/include/asm-i386/semaphore.h	2004-01-19 20:01:11.000000000 +0000
@@ -3,8 +3,6 @@
 
 #include <linux/linkage.h>
 
-#ifdef __KERNEL__
-
 /*
  * SMP- and interrupt-safe semaphores..
  *
@@ -214,4 +212,3 @@
 }
 
 #endif
-#endif
diff -ur linux-2.6.8.1/include/asm-i386/signal.h linux-2.6.8.1/include/asm-i386/signal.h
--- linux-2.6.8.1/include/asm-i386/signal.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.8.1/include/asm-i386/signal.h	2004-01-19 20:01:11.000000000 +0000
@@ -26,7 +26,9 @@
 /* Here we must cater to libcs that poke about in kernel headers.  */
 
 #define NSIG		32
+#ifndef __sigset_t_defined
 typedef unsigned long sigset_t;
+#endif
 
 #endif /* __KERNEL__ */
 
@@ -155,6 +157,7 @@
 #else
 /* Here we must cater to libcs that poke about in kernel headers.  */
 
+#ifndef _SIGNAL_H
 struct sigaction {
 	union {
 	  __sighandler_t _sa_handler;
@@ -164,17 +167,20 @@
 	unsigned long sa_flags;
 	void (*sa_restorer)(void);
 };
+#endif
 
 #define sa_handler	_u._sa_handler
 #define sa_sigaction	_u._sa_sigaction
 
 #endif /* __KERNEL__ */
 
+#ifndef _SIGNAL_H
 typedef struct sigaltstack {
 	void __user *ss_sp;
 	int ss_flags;
 	size_t ss_size;
 } stack_t;
+#endif
 
 #ifdef __KERNEL__
 #include <asm/sigcontext.h>
diff -ur linux-2.6.0/include/asm-i386/smp.h linux-2.6.0/include/asm-i386/smp.h
--- linux-2.6.0/include/asm-i386/smp.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.0/include/asm-i386/smp.h	2004-01-19 20:01:11.000000000 +0000
@@ -70,7 +70,7 @@
 #ifdef APIC_DEFINITION
 extern int hard_smp_processor_id(void);
 #else
-#include <mach_apicdef.h>
+#include <asm/mach-generic/mach_apicdef.h>
 static inline int hard_smp_processor_id(void)
 {
 	/* we don't want to mark this access volatile - bad code generation */
diff -ur linux-2.6.0/include/linux/types.h linux-2.6.0/include/linux.gentoo/types.h
--- linux-2.6.0/include/linux/types.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.0/include/linux.gentoo/types.h	2004-01-19 20:01:11.000000000 +0000
@@ -19,12 +19,24 @@
 
 typedef __u32 __kernel_dev_t;
 
+#ifndef _SYS_SELECT_H
 typedef __kernel_fd_set		fd_set;
+#endif
+#ifndef __dev_t_defined
 typedef __kernel_dev_t		dev_t;
+#endif
+#ifndef __ino_t_defined
 typedef __kernel_ino_t		ino_t;
+#endif
+#ifndef __mode_t_defined
 typedef __kernel_mode_t		mode_t;
+#endif
+#ifndef __nlink_t_defined
 typedef __kernel_nlink_t	nlink_t;
+#endif
+#ifndef __off_t_defined
 typedef __kernel_off_t		off_t;
+#endif
 typedef __kernel_pid_t		pid_t;
 typedef __kernel_daddr_t	daddr_t;
 typedef __kernel_key_t		key_t;
@@ -34,7 +46,9 @@
 
 #ifdef __KERNEL__
 typedef __kernel_uid32_t	uid_t;
+#define __uid_t_defined
 typedef __kernel_gid32_t	gid_t;
+#define __gid_t_defined
 typedef __kernel_uid16_t        uid16_t;
 typedef __kernel_gid16_t        gid16_t;
 
@@ -49,7 +63,9 @@
  */
 #else
 typedef __kernel_uid_t		uid_t;
+#define __uid_t_defined
 typedef __kernel_gid_t		gid_t;
+#define __gid_t_defined
 #endif /* __KERNEL__ */
 
 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
@@ -176,16 +157,22 @@
 typedef __u16 __bitwise __be16;
 typedef __u32 __bitwise __le32;
 typedef __u32 __bitwise __be32;
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
 typedef __u64 __bitwise __le64;
 typedef __u64 __bitwise __be64;
-#endif
 
+#ifndef _SYS_TYPES_H
 struct ustat {
 	__kernel_daddr_t	f_tfree;
 	__kernel_ino_t		f_tinode;
 	char			f_fname[6];
 	char			f_fpack[6];
 };
+#endif
+
+/* Fix bad upstream jojo in XEmacs; bug #82690. Temporary fix only warning until upstream fixes
+   things... */
+#ifdef register
+#undef register
+#endif
 
 #endif /* _LINUX_TYPES_H */
diff -ur linux-2.6.8.1/include/asm-generic/siginfo.h linux-2.6.8.1-gentoo/include/asm-generic/siginfo.h
--- linux-2.6.8.1/include/asm-generic/siginfo.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.8.1-gentoo/include/asm-generic/siginfo.h	2004-01-19 20:01:11.000000000 +0000
@@ -4,10 +4,12 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 
+#ifndef _SIGNAL_H
 typedef union sigval {
 	int sival_int;
 	void __user *sival_ptr;
 } sigval_t;
+#endif
 
 /*
  * This is the size (including padding) of the part of the
@@ -31,7 +33,7 @@
 #endif
 
 #ifndef HAVE_ARCH_SIGINFO_T
-
+#ifndef _SIGNAL_H
 typedef struct siginfo {
 	int si_signo;
 	int si_errno;
@@ -86,7 +88,7 @@
 		} _sigpoll;
 	} _sifields;
 } siginfo_t;
-
+#endif
 #endif
 
 /*
@@ -242,6 +244,7 @@
 #define SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE/sizeof(int)) - 3)
 #endif
 
+#ifndef _SIGNAL_H
 typedef struct sigevent {
 	sigval_t sigev_value;
 	int sigev_signo;
@@ -256,7 +259,7 @@
 		} _sigev_thread;
 	} _sigev_un;
 } sigevent_t;
-
+#endif
 #define sigev_notify_function	_sigev_un._sigev_thread._function
 #define sigev_notify_attributes	_sigev_un._sigev_thread._attribute
 #define sigev_notify_thread_id	 _sigev_un._tid
diff -ur linux-2.6.11/include/linux/jiffies.h linux-2.6.11/include/linux.gentoo/jiffies.h
--- linux-2.6.11/include/linux/jiffies.h	2004-01-19 20:18:36.000000000 +0000
+++ linux-2.6.11/include/linux.gentoo/jiffies.h	2004-01-19 20:01:11.000000000 +0000
@@ -13,15 +13,15 @@
  * without holding read_lock_irq(&xtime_lock).
  * get_jiffies_64() will do this for you as appropriate.
  */
-extern u64 __jiffy_data jiffies_64;
+extern __u64 __jiffy_data jiffies_64;
 extern unsigned long volatile __jiffy_data jiffies;
 
 #if (BITS_PER_LONG < 64)
-u64 get_jiffies_64(void);
+__u64 get_jiffies_64(void);
 #else
-static inline u64 get_jiffies_64(void)
+static inline __u64 get_jiffies_64(void)
 {
-	return (u64)jiffies;
+	return (__u64)jiffies;
 }
 #endif
 
diff -ur linux-2.6.7/include/linux/i2c.h linux-2.6.7-gentoo/include/linux/i2c.h
--- linux-2.6.7/include/linux/i2c.h	2004-02-07 13:29:15.099504640 -0500
+++ linux-2.6.7-gentoo/include/linux/i2c.h	2004-02-07 13:35:53.956869104 -0500
@@ -28,10 +28,18 @@
 #ifndef _LINUX_I2C_H
 #define _LINUX_I2C_H
 
-#include <linux/module.h>
-#include <linux/types.h>
+#ifdef __KERNEL__
+#	include <linux/module.h>
+#	include <linux/types.h>
+#else
+#	define __KERNEL__
+#	include <linux/types.h>
+#	undef __KERNEL__
+#endif
 #include <linux/i2c-id.h>
+#ifdef __KERNEL__
 #include <linux/device.h>	/* for struct device */
 #include <asm/semaphore.h>
+#endif
 
 /* --- General options ------------------------------------------------	*/
@@ -109,6 +117,7 @@
  * events.
  */
 
+#ifdef __KERNEL__
 struct i2c_driver {
 	struct module *owner;
 	char name[32];
@@ -268,6 +277,7 @@
 {
 	dev_set_drvdata (&dev->dev, data);
 }
+#endif
 
 /*flags for the driver struct: */
 #define I2C_DF_NOTIFY	0x01		/* notify on bus (de/a)ttaches 	*/
diff -ur linux-2.6.3/include/linux/usbdevice_fs.h linux-2.6.3/include/linux/usbdevice_fs.h
--- linux-2.6.3/include/linux/usbdevice_fs.h	2004-02-22 16:52:07.000000000 +0000
+++ linux-2.6.3/include/linux/usbdevice_fs.h	2004-02-22 22:10:45.000000000 +0000
@@ -31,6 +31,7 @@
 #ifndef _LINUX_USBDEVICE_FS_H
 #define _LINUX_USBDEVICE_FS_H
 
+#include <linux/compiler.h>
 #include <linux/types.h>
 
 /* --------------------------------------------------------------------- */

diff -ur linux-2.6.4/include/asm-i386/ipc.h linux-2.6.4-gentoo/include/asm-i386/ipc.h
--- linux-2.6.4/include/asm-i386/ipc.h	2004-03-13 13:05:04.000026816 +0000
+++ linux-2.6.4-gentoo/include/asm-i386/ipc.h	2004-03-13 13:11:56.486319368 +0000
@@ -6,6 +6,8 @@
  *
  * See arch/i386/kernel/sys_i386.c for ugly details..
  */
+
+#include <linux/compiler.h>
 struct ipc_kludge {
 	struct msgbuf __user *msgp;
 	long msgtyp;
diff -ur linux-2.6.4/include/linux/mroute.h linux-2.6.4-gentoo/include/linux/mroute.h
--- linux-2.6.4/include/linux/mroute.h	2004-03-13 13:04:54.084534200 +0000
+++ linux-2.6.4-gentoo/include/linux/mroute.h	2004-03-13 13:14:04.356880088 +0000
@@ -1,6 +1,7 @@
 #ifndef __LINUX_MROUTE_H
 #define __LINUX_MROUTE_H
 
+#include <linux/types.h>
 #include <linux/sockios.h>
 #include <linux/in.h>
 
diff -ur linux-2.6.6/include/asm-ppc/signal.h linux-2.6.6-gentoo/include/asm-ppc/signal.h
--- linux-2.6.6/include/asm-ppc/signal.h	2004-06-02 18:30:17.329072696 +0100
+++ linux-2.6.6-gentoo/include/asm-ppc/signal.h	2004-06-02 18:35:04.093477880 +0100
@@ -17,9 +17,11 @@
 
 typedef unsigned long old_sigset_t;		/* at least 32 bits */
 
+#ifndef __sigset_t_defined
 typedef struct {
 	unsigned long sig[_NSIG_WORDS];
 } sigset_t;
+#endif
 
 #define SIGHUP		 1
 #define SIGINT		 2
@@ -125,28 +127,51 @@
 #define SIG_ERR	((__sighandler_t)-1)	/* error return from signal */
 
 struct old_sigaction {
+#ifdef __USE_POSIX199309
+#	ifdef sa_handler
+#		undef sa_handler
+#	endif
+#	ifdef sa_sigaction
+#		undef sa_sigaction
+#	endif
+	union
+	{
+		/* Used if SA_SIGINFO is not set.  */
+			__sighandler_t sa_handler;
+		/* Used if SA_SIGINFO is set.  */
+			void (*sa_sigaction) (int, siginfo_t *, void *);
+	}
+	__sigaction_handler;
+#	define sa_handler	__sigaction_handler.sa_handler
+#	define sa_sigaction	__sigaction_handler.sa_sigaction
+#else
 	__sighandler_t sa_handler;
+#endif
 	old_sigset_t sa_mask;
 	unsigned long sa_flags;
 	__sigrestore_t sa_restorer;
 };
 
+#ifndef _SIGNAL_H
 struct sigaction {
 	__sighandler_t sa_handler;
 	unsigned long sa_flags;
 	__sigrestore_t sa_restorer;
 	sigset_t sa_mask;		/* mask last for extensibility */
 };
+#endif
 
 struct k_sigaction {
 	struct sigaction sa;
 };
 
+#ifndef _SIGNAL_H
 typedef struct sigaltstack {
 	void __user *ss_sp;
 	int ss_flags;
 	size_t ss_size;
 } stack_t;
+#endif
 
 #ifdef __KERNEL__
 #include <asm/sigcontext.h>
diff -ur linux-2.6.6/include/asm-x86_64/processor.h linux-2.6.6-gentoo/include/asm-x86_64/processor.h
--- linux-2.6.6/include/asm-x86_64/processor.h	2004-06-02 19:25:24.000000000 +0100
+++ linux-2.6.6-gentoo/include/asm-x86_64/processor.h	2004-06-02 19:24:31.000000000 +0100
@@ -136,7 +136,11 @@
  * enable), so that any CPU's that boot up
  * after us can get the correct flags.
  */
+#ifndef __BOUNDS_CHECKING_ON
 extern unsigned long mmu_cr4_features;
+#else
+unsigned long mmu_cr4_features;
+#endif
 
 static inline void set_in_cr4 (unsigned long mask)
 {
@@ -189,17 +189,17 @@
 #define INVALID_IO_BITMAP_OFFSET 0x8000
 
 struct i387_fxsave_struct {
-	u16	cwd;
-	u16	swd;
-	u16	twd;
-	u16	fop;
-	u64	rip;
-	u64	rdp; 
-	u32	mxcsr;
-	u32	mxcsr_mask;
-	u32	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
-	u32	xmm_space[64];	/* 16*16 bytes for each XMM-reg = 128 bytes */
-	u32	padding[24];
+	__u16	cwd;
+	__u16	swd;
+	__u16	twd;
+	__u16	fop;
+	__u64	rip;
+	__u64	rdp; 
+	__u32	mxcsr;
+	__u32	mxcsr_mask;
+	__u32	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
+	__u32	xmm_space[64];	/* 16*16 bytes for each XMM-reg = 128 bytes */
+	__u32	padding[24];
 } __attribute__ ((aligned (16)));
 
 union i387_union {
@@ -207,16 +207,16 @@
 };
 
 struct tss_struct {
-	u32 reserved1;
-	u64 rsp0;	
-	u64 rsp1;
-	u64 rsp2;
-	u64 reserved2;
-	u64 ist[7];
-	u32 reserved3;
-	u32 reserved4;
-	u16 reserved5;
-	u16 io_bitmap_base;
+	__u32 reserved1;
+	__u64 rsp0;	
+	__u64 rsp1;
+	__u64 rsp2;
+	__u64 reserved2;
+	__u64 ist[7];
+	__u32 reserved3;
+	__u32 reserved4;
+	__u16 reserved5;
+	__u16 io_bitmap_base;
 	/*
 	 * The extra 1 is there because the CPU will access an
 	 * additional byte beyond the end of the IO permission
@@ -252,7 +252,7 @@
 	int		ioperm;
 	unsigned long	*io_bitmap_ptr;
 /* cached TLS descriptors. */
-	u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
+	__u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
 } __attribute__((aligned(16)));
 
 #define INIT_THREAD  {}
diff -ur linux-2.6.10/include/asm-x86_64/system.h linux-2.6.10-gentoo/include/asm-x86_64/system.h
--- linux-2.6.10/include/asm-x86_64/system.h	2004-06-02 19:25:27.000000000 +0100
+++ linux-2.6.10-gentoo/include/asm-x86_64/system.h	2004-06-02 19:25:17.000000000 +0100
@@ -4,6 +4,32 @@
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <asm/segment.h>
+#include <linux/bitops.h> /* for LOCK_PREFIX... */
+
+/*
+ * Alternative inline assembly with input.
+ * 
+ * Pecularities:
+ * No memory clobber here. 
+ * Argument numbers start with 1.
+ * Best is to use constraints that are fixed size (like (%1) ... "r")
+ * If you use variable sized constraints like "m" or "g" in the 
+ * replacement maake sure to pad to the worst case length.
+ */
+
+#define alternative_input(oldinstr, newinstr, feature, input...)	\
+	asm volatile ("661:\n\t" oldinstr "\n662:\n"			\
+		      ".section .altinstructions,\"a\"\n"		\
+		      "  .align 8\n"					\
+		      "  .quad 661b\n"            /* label */		\
+		      "  .quad 663f\n"		  /* new instruction */	\
+		      "  .byte %c0\n"             /* feature bit */	\
+		      "  .byte 662b-661b\n"       /* sourcelen */	\
+		      "  .byte 664f-663f\n"       /* replacementlen */	\
+		      ".previous\n"					\
+		      ".section .altinstr_replacement,\"ax\"\n"		\
+		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ \
+		      ".previous" :: "i" (feature), ##input)
 
 #ifdef __KERNEL__
 
@@ -114,30 +140,6 @@
 		      ".previous" :: "i" (feature) : "memory")  
 
 /*
- * Alternative inline assembly with input.
- * 
- * Pecularities:
- * No memory clobber here. 
- * Argument numbers start with 1.
- * Best is to use constraints that are fixed size (like (%1) ... "r")
- * If you use variable sized constraints like "m" or "g" in the 
- * replacement maake sure to pad to the worst case length.
- */
-#define alternative_input(oldinstr, newinstr, feature, input...)	\
-	asm volatile ("661:\n\t" oldinstr "\n662:\n"			\
-		      ".section .altinstructions,\"a\"\n"		\
-		      "  .align 8\n"					\
-		      "  .quad 661b\n"            /* label */		\
-		      "  .quad 663f\n"		  /* new instruction */	\
-		      "  .byte %c0\n"             /* feature bit */	\
-		      "  .byte 662b-661b\n"       /* sourcelen */	\
-		      "  .byte 664f-663f\n"       /* replacementlen */	\
-		      ".previous\n"					\
-		      ".section .altinstr_replacement,\"ax\"\n"		\
-		      "663:\n\t" newinstr "\n664:\n"   /* replacement */ \
-		      ".previous" :: "i" (feature), ##input)
-
-/*
  * Clear and set 'TS' bit respectively
  */
 #define clts() __asm__ __volatile__ ("clts")
@@ -240,32 +240,32 @@
 #define __HAVE_ARCH_CMPXCHG 1
 
 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-				      unsigned long new, int size)
+				      unsigned long __new, int size)
 {
 	unsigned long prev;
 	switch (size) {
 	case 1:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(__new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	case 2:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(__new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	case 4:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %k1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(__new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	case 8:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgq %1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(__new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	}
diff -ur linux-2.6.6/include/linux/socket.h linux-2.6.6-gentoo/include/linux/socket.h
--- linux-2.6.6/include/linux/socket.h	2004-05-25 17:47:07.000000000 +0100
+++ linux-2.6.6-gentoo/include/linux/socket.h	2004-06-02 21:19:49.000000000 +0100
@@ -16,6 +16,10 @@
 				/* _SS_MAXSIZE value minus size of ss_family */
 } __attribute__ ((aligned(_K_SS_ALIGNSIZE)));	/* force desired alignment */
 
+#ifndef _SYS_SOCKET_H
+typedef unsigned short	sa_family_t;
+#endif
+
 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
 
 #include <linux/config.h>		/* for CONFIG_COMPAT */
@@ -26,8 +30,6 @@
 #include <linux/types.h>		/* pid_t			*/
 #include <linux/compiler.h>		/* __user			*/
 
-typedef unsigned short	sa_family_t;
-
 /*
  *	1003.1g requires sa_family_t and that sa_data is char.
  */
diff -ur linux-2.6.6/include/linux/audit.h linux-2.6.6-gentoo/include/linux/audit.h
--- linux-2.6.6/include/linux/audit.h	2004-05-25 17:47:07.000000000 +0100
+++ linux-2.6.6-gentoo/include/linux/audit.h	2004-06-02 21:19:21.000000000 +0100
@@ -97,6 +97,7 @@
 #define AUDIT_FAIL_PANIC	2
 
 #ifndef __KERNEL__
+#include <linux/netlink.h>
 struct audit_message {
 	struct nlmsghdr nlh;
 	char		data[1200];
diff -ur linux-2.6.7/include/asm-x86_64/sigcontext.h linux-2.6.7-gentoo/include/asm-x86_64/sigcontext.h
--- linux-2.6.7/include/asm-x86_64/sigcontext.h	2004-05-25 17:47:07.000000000 +0100
+++ linux-2.6.7-gentoo/include/asm-x86_64/sigcontext.h	2004-06-02 22:04:52.000000000 +0100
@@ -7,6 +7,12 @@
 /* FXSAVE frame */
 /* Note: reserved1/2 may someday contain valuable data. Always save/restore
    them when you change signal frames. */
+
+#if ! defined(__KERNEL__) && ! defined(__UCLIBC__)
+#include <signal.h> /* Pulls in <bits/sigcontext.h> which contains both /*
+                    /* of these structures ... except on uClibc ... */
+#else
+#if ! defined(_SIGNAL_H) || defined(__UCLIBC__)
 struct _fpstate {
 	__u16	cwd;
 	__u16	swd;
@@ -53,3 +59,5 @@
 };
 
 #endif
+#endif
+#endif
diff -ur linux-2.6.6/include/linux/gfp.h linux-2.6.6-gentoo/include/linux/gfp.h
--- linux-2.6.6/include/linux/gfp.h	2004-04-04 04:36:52.000000000 +0100
+++ linux-2.6.6-gentoo/include/linux/gfp.h	2004-05-11 19:51:06.412779200 +0100
@@ -48,6 +48,7 @@
 
 #define GFP_DMA		__GFP_DMA
 
+#ifdef __KERNEL__
 
 /*
  * There is only one page-allocator function, and two main namespaces to
@@ -96,4 +97,5 @@
 
 void page_alloc_init(void);
 
+#endif /* __KERNEL__ */
 #endif /* __LINUX_GFP_H */
diff -ur linux-2.6.6/include/linux/percpu.h linux-2.6.6-gentoo/include/linux/percpu.h
--- linux-2.6.6/include/linux/percpu.h	2004-04-04 04:38:14.000000000 +0100
+++ linux-2.6.6-gentoo/include/linux/percpu.h	2004-05-11 19:33:00.987788880 +0100
@@ -1,5 +1,6 @@
 #ifndef __LINUX_PERCPU_H
 #define __LINUX_PERCPU_H
+#include <linux/gfp.h>
 #include <linux/spinlock.h> /* For preempt_disable() */
 #include <linux/slab.h> /* For kmalloc() */
 #include <linux/smp.h>
diff -ur linux-2.6.6/include/linux/percpu_counter.h linux-2.6.6-gentoo/include/linux/percpu_counter.h
--- linux-2.6.6/include/linux/percpu_counter.h	2004-04-04 04:37:23.000000000 +0100
+++ linux-2.6.6-gentoo/include/linux/percpu_counter.h	2004-05-11 19:46:31.423583912 +0100
@@ -4,6 +4,7 @@
  * WARNING: these things are HUGE.  4 kbytes per counter on 32-way P4.
  */
 
+#include <linux/preempt.h>
 #include <linux/config.h>
 #include <linux/spinlock.h>
 #include <linux/smp.h>

diff -ur linux-2.6.7/include/linux/pid.h linux-2.6.7-gentoo/include/linux/pid.h
--- linux-2.6.7/include/linux/pid.h	2004-06-16 06:19:02.000000000 +0100
+++ linux-2.6.7-gentoo/pid.h	2004-06-18 18:38:37.252859416 +0100
@@ -1,6 +1,10 @@
 #ifndef _LINUX_PID_H
 #define _LINUX_PID_H
 
+#include <linux/wait.h>
+#include <linux/types.h>
+#include <asm/atomic.h>
+
 enum pid_type
 {
 	PIDTYPE_PID,
@@ -29,6 +31,8 @@
 #define pid_task(elem, type) \
 	list_entry(elem, struct task_struct, pids[type].pid_chain)
 
+#ifdef __KERNEL__
+
 /*
  * attach_pid() and link_pid() must be called with the tasklist_lock
  * write-held.
@@ -61,4 +64,5 @@
 			elem = elem->next, prefetch(elem->next), 	\
 			task = pid_task(elem, type))
 
+#endif /* __KERNEL__ */
 #endif /* _LINUX_PID_H */
diff -ur linux-2.6.8.1/include/linux/wait.h linux-2.6.8.1-gentoo/include/linux/wait.h
--- linux-2.6.8.1/include/linux/wait.h	2004-06-16 06:19:31.000000000 +0100
+++ linux-2.6.8.1-gentoo/wait.h	2004-06-18 18:35:03.760315216 +0100
@@ -17,8 +17,6 @@
 #define P_PID		1
 #define P_PGID		2
 
-#ifdef __KERNEL__
-
 #include <linux/config.h>
 #include <linux/list.h>
 #include <linux/stddef.h>
@@ -54,6 +52,7 @@
 };
 typedef struct __wait_queue_head wait_queue_head_t;
 
+#include <linux/pid.h>
 
 /*
  * Macros for declaration and initialisaton of the datatypes
@@ -116,6 +115,8 @@
 extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
 extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
 
+#ifdef __KERNEL__
+
 static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
 {
 	list_add(&new->task_list, &head->task_list);
@@ -136,6 +137,8 @@
 	list_del(&old->task_list);
 }
 
+#endif /* __KERNEL__ */
+
 void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key));
 extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
 extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
@@ -280,6 +283,8 @@
 	__ret;								\
 })
 
+#ifdef __KERNEL__
+
 /*
  * Must be called with the spinlock in the wait_queue_head_t held.
  */
@@ -299,6 +304,8 @@
 	__remove_wait_queue(q,  wait);
 }
 
+#endif /* __KERNEL__ */
+
 /*
  * These are the old interfaces to sleep waiting for an event.
  * They are racy.  DO NOT use them, use the wait_event* interfaces above.  
@@ -349,6 +356,7 @@
 		INIT_LIST_HEAD(&(wait)->task_list);			\
 	} while (0)
 
+#ifndef __cplusplus
 /**
  * wait_on_bit - wait for a bit to be cleared
  * @word: the word being waited on, a kernel virtual address
@@ -394,7 +402,6 @@
 		return 0;
 	return out_of_line_wait_on_bit_lock(word, bit, action, mode);
 }
-	
-#endif /* __KERNEL__ */
 
+#endif	
 #endif
diff -ur linux-2.6.8.1/include/linux/compiler.h linux-2.6.8.1-gentoo/include/linux/compiler.h
--- linux-2.6.8.1/include/linux/compiler.h	2004-06-12 12:11:54.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/linux/compiler.h	2004-06-24 09:48:32.478502752 +0100
@@ -15,8 +15,20 @@
 # define __chk_user_ptr(x) (void)0
 #endif
 
-#ifdef __KERNEL__
+#ifndef __KERNEL__
+#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#define inline          __inline__
+#define __inline__      __inline__
+#define __inline        __inline__
+#ifndef asm
+#  define asm           __asm__
+#endif
+#ifndef volatile
+#  define volatile      __volatile__
+#endif
+#endif
 
+#else
 #if __GNUC__ > 3
 # include <linux/compiler-gcc+.h>	/* catch-all for GCC 4, 5, etc. */
 #elif __GNUC__ == 3
@@ -28,6 +39,7 @@
 # error Sorry, your compiler is too old/not recognized.
 #endif
 #endif
+#endif
 
 /* Intel compiler defines __GNUC__. So we will overwrite implementations
  * coming from above header files here
@@ -47,7 +59,11 @@
 
 /* Optimization barrier */
 #ifndef barrier
-# define barrier() __memory_barrier()
+# ifdef mb
+#   define barrier() mb()
+# else
+#   define barrier() __asm__ __volatile__ ("" : : : "memory")
+# endif
 #endif
 
 #ifndef RELOC_HIDE
@@ -57,8 +74,6 @@
     (typeof(ptr)) (__ptr + (off)); })
 #endif
 
-#endif /* __KERNEL__ */
-
 /*
  * Allow us to mark functions as 'deprecated' and have gcc emit a nice
  * warning for each use, in hopes of speeding the functions removal.
@@ -137,12 +134,14 @@
 # define __attribute_const__	/* unimplemented */
 #endif
 
-#ifndef noinline
-#define noinline
-#endif
-
 #ifndef __always_inline
 #define __always_inline inline
 #endif
 
+#ifdef __cplusplus
+#define __cast__(_to) (_to)
+#else
+#define __cast__(_to)
+#endif
+
 #endif /* __LINUX_COMPILER_H */
diff -ur linux-2.6.6/include/linux/hiddev.h linux-2.6.6-gentoo/include/linux/hiddev.h
--- linux-2.6.6/include/linux/hiddev.h	2004-06-12 12:11:54.000000000 +0100
+++ linux-2.6.6-gentoo/include/linux/hiddev.h	2004-07-10 00:13:36.584448824 +0100
@@ -33,6 +33,8 @@
  * The event structure itself
  */
 
+#define HID_MAX_USAGES 1024 /* From: drivers/usb/input/hid.h */
+
 struct hiddev_event {
 	unsigned hid;
 	signed int value;
diff -ur linux-2.6.7/include/asm-i386/cache.h linux-2.6.7-gentoo/include/asm-i386/cache.h
--- linux-2.6.7/include/asm-i386/cache.h	2004-07-13 16:33:15.000000000 +0200
+++ linux-2.6.7-gentoo/include/asm-i386/cache.h	2004-07-13 16:50:38.384364344 +0200
@@ -7,7 +7,11 @@
 #include <linux/config.h>
 
 /* L1 cache line size */
+#ifndef CONFIG_X86_L1_CACHE_SHIFT
+#define L1_CACHE_SHIFT 7  /* 7 is given with X86_GENERIC kernel config */
+#else
 #define L1_CACHE_SHIFT	(CONFIG_X86_L1_CACHE_SHIFT)
+#endif
 #define L1_CACHE_BYTES	(1 << L1_CACHE_SHIFT)
 
 #define L1_CACHE_SHIFT_MAX 7	/* largest L1 which this arch supports */
diff -ur linux-2.6.7/include/asm-i386/system.h linux-2.6.7-gentoo/include/asm-i386/system.h
--- linux-2.6.7/include/asm-i386/system.h	2004-06-16 07:18:38.000000000 +0200
+++ linux-2.6.7-gentoo/include/asm-i386/system.h	2004-07-13 16:34:50.632444536 +0200
@@ -244,26 +244,26 @@
 #endif
 
 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-				      unsigned long new, int size)
+				      unsigned long _new, int size)
 {
 	unsigned long prev;
 	switch (size) {
 	case 1:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(_new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	case 2:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(_new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	case 4:
 		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
 				     : "=a"(prev)
-				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
+				     : "q"(_new), "m"(*__xg(ptr)), "0"(old)
 				     : "memory");
 		return prev;
 	}
diff -ur linux-2.6.7/include/asm-i386/processor.h linux-2.6.7-gentoo/include/asm-i386/processor.h
--- linux-2.6.7/include/asm-i386/processor.h	2004-07-18 13:09:36.191824280 +0100
+++ linux-2.6.7-gentoo/include/asm-i386/processor.h	2004-07-18 13:14:01.627471928 +0100
@@ -403,8 +403,10 @@
 	/*
 	 * .. and then another 0x100 bytes for emergency kernel stack
 	 */
-	unsigned long stack[64];
-} __attribute__((packed));
+	#ifndef stack /* LVM2-Userspace defines this as a function... */
+		unsigned long stack[64];
+	#endif
+}  __attribute__((packed));
 
 #define ARCH_MIN_TASKALIGN	16
 
@@ -491,7 +493,9 @@
 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
 
 extern unsigned long thread_saved_pc(struct task_struct *tsk);
+#ifdef __KERNEL__
 void show_trace(struct task_struct *task, unsigned long *stack);
+#endif
 
 unsigned long get_wchan(struct task_struct *p);
 
diff -ur linux-2.6.8.1/scripts/mod/file2alias.c linux-2.6.8.1-gentoo/scripts/mod/file2alias.c
--- linux-2.6.8.1/scripts/mod/file2alias.c.orig	2004-07-22 14:10:33.644026328 -0400
+++ linux-2.6.8.1/scripts/mod/file2alias.c	2004-07-22 14:10:53.613990432 -0400
@@ -10,6 +10,8 @@
  * of the GNU General Public License, incorporated herein by reference.
  */
 
+#define __KERNEL__
+#define __KERNEL_ULONG_T__
 #include "modpost.h"
 
 /* We use the ELF typedefs, since we can't rely on stdint.h being present. */
diff -ur linux-2.6.7/include/asm-x86_64/pda.h linux-2.6.7-gentoo/include/asm-x86_64/pda.h
--- linux-2.6.7/include/asm-x86_64/pda.h	2004-07-24 21:30:43.213205064 +0100
+++ linux-2.6.7-gentoo/include/asm-x86_64/pda.h	2004-07-24 21:31:24.238968200 +0100
@@ -36,7 +36,7 @@
  * have to mention %fs/%gs.  So it needs to be done this Torvaldian way.
  */ 
 #define sizeof_field(type,field)  (sizeof(((type *)0)->field))
-#define typeof_field(type,field)  typeof(((type *)0)->field)
+#define typeof_field(type,field)  __typeof__(((type *)0)->field)
 
 extern void __bad_pda_field(void);
 
diff -ur linux-2.6.10/include/linux/compiler-gcc3.h linux-2.6.10-gentoo/include/linux/compiler-gcc3.h
--- linux-2.6.10/include/linux/compiler-gcc3.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.10-gentoo/include/linux/compiler-gcc3.h	2004-07-27 13:09:20.420468272 +0100
@@ -3,12 +3,6 @@
 /* These definitions are for GCC v3.x.  */
 #include <linux/compiler-gcc.h>
 
-#if __GNUC_MINOR__ >= 1
-# define inline		inline		__attribute__((always_inline))
-# define __inline__	__inline__	__attribute__((always_inline))
-# define __inline	__inline	__attribute__((always_inline))
-#endif
-
 #if __GNUC_MINOR__ > 0
 # define __deprecated	__attribute__((deprecated))
 #endif
diff -ur linux-2.6.7/include/linux/sem.h linux-2.6.7-gentoo/include/linux/sem.h
--- linux-2.6.7/include/linux/sem.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.7-gentoo/include/linux/sem.h	2004-07-27 11:48:07.440273000 +0100
@@ -1,6 +1,7 @@
 #ifndef _LINUX_SEM_H
 #define _LINUX_SEM_H
 
+#include <linux/compiler.h>
 #include <linux/ipc.h>
 #include <asm/atomic.h>
 
diff -ur linux-2.6.7/include/asm-x86_64/bitops.h linux-2.6.7-gentoo/include/asm-x86_64/bitops.h
--- linux-2.6.7/include/asm-x86_64/bitops.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.7-gentoo/include/asm-x86_64/bitops.h	2004-07-28 16:08:37.650740208 +0100
@@ -262,7 +262,7 @@
 /* return index of first bet set in val or max when no bit is set */
 static inline unsigned long __scanbit(unsigned long val, unsigned long max)
 {
-	asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max));
+	__asm__("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max));
 	return val;
 }
 
@@ -475,8 +475,6 @@
 
 #endif /* __KERNEL__ */
 
-#ifdef __KERNEL__
-
 #define ext2_set_bit(nr,addr) \
 	__test_and_set_bit((nr),(unsigned long*)addr)
 #define ext2_set_bit_atomic(lock,nr,addr) \
@@ -504,6 +502,4 @@
 
 #define ARCH_HAS_ATOMIC_UNSIGNED 1
 
-#endif /* __KERNEL__ */
-
 #endif /* _X86_64_BITOPS_H */
diff -urp linux-2.6.7/include/asm-parisc/bitops.h linux-2.6.7-gentoo/include/asm-parisc/bitops.h
--- linux-2.6.7/include/asm-parisc/bitops.h	2004-08-24 12:09:23.000000000 -0400
+++ linux-2.6.7-gentoo/include/asm-parisc/bitops.h	2004-08-24 11:59:41.952667176 -0400
@@ -203,8 +203,6 @@ static __inline__ int test_bit(int nr, c
 	return !!(*addr & mask);
 }
 
-#ifdef __KERNEL__
-
 /**
  * __ffs - find first bit in word. returns 0 to "BITS_PER_LONG-1".
  * @word: The word to search
@@ -261,10 +261,12 @@
  * This is defined the same way as the libc and compiler builtin
  * ffs routines, therefore differs in spirit from the above ffz (man ffs).
  */
+#ifndef _STRING_H
 static __inline__ int ffs(int x)
 {
 	return x ? (__ffs((unsigned long)x) + 1) : 0;
 }
+#endif
 
 /*
  * fls: find last (most significant) bit set.
@@ -345,8 +345,6 @@ static inline int sched_find_first_bit(c
 #endif
 }
 
-#endif /* __KERNEL__ */
-
 /*
  * This implementation of find_{first,next}_zero_bit was stolen from
  * Linus' asm-alpha/bitops.h.
@@ -486,7 +484,7 @@ extern __inline__ unsigned long ext2_fin
 	size -= result;
 	offset &= 31UL;
 	if (offset) {
-		tmp = cpu_to_le32p(p++);
+		tmp = __cpu_to_le32p(p++);
 		tmp |= ~0UL >> (32-offset);
 		if (size < 32)
 			goto found_first;
@@ -496,14 +494,14 @@ extern __inline__ unsigned long ext2_fin
 		result += 32;
 	}
 	while (size >= 32) {
-		if ((tmp = cpu_to_le32p(p++)) != ~0U)
+		if ((tmp = __cpu_to_le32p(p++)) != ~0U)
 			goto found_middle;
 		result += 32;
 		size -= 32;
 	}
 	if (!size)
 		return result;
-	tmp = cpu_to_le32p(p);
+	tmp = __cpu_to_le32p(p);
 found_first:
 	tmp |= ~0U << size;
 found_middle:
diff -urp linux-2.6.7/include/asm-parisc/hardware.h linux-2.6.7-gentoo/include/asm-parisc/hardware.h
--- linux-2.6.7/include/asm-parisc/hardware.h	2004-08-24 12:09:23.000000000 -0400
+++ linux-2.6.7-gentoo/include/asm-parisc/hardware.h	2004-08-24 11:59:41.978663224 -0400
@@ -45,41 +46,41 @@ extern char *cpu_name_version[][2]; /* m
 struct parisc_driver;
 
 struct io_module {
-        volatile uint32_t nothing;		/* reg 0 */
-        volatile uint32_t io_eim;
-        volatile uint32_t io_dc_adata;
-        volatile uint32_t io_ii_cdata;
-        volatile uint32_t io_dma_link;		/* reg 4 */
-        volatile uint32_t io_dma_command;
-        volatile uint32_t io_dma_address;
-        volatile uint32_t io_dma_count;
-        volatile uint32_t io_flex;		/* reg 8 */
-        volatile uint32_t io_spa_address;
-        volatile uint32_t reserved1[2];
-        volatile uint32_t io_command;		/* reg 12 */
-        volatile uint32_t io_status;
-        volatile uint32_t io_control;
-        volatile uint32_t io_data;
-        volatile uint32_t reserved2;		/* reg 16 */
-        volatile uint32_t chain_addr;
-        volatile uint32_t sub_mask_clr;
-        volatile uint32_t reserved3[13];
-        volatile uint32_t undefined[480];
-        volatile uint32_t unpriv[512];
+        volatile __u32 nothing;		/* reg 0 */
+        volatile __u32 io_eim;
+        volatile __u32 io_dc_adata;
+        volatile __u32 io_ii_cdata;
+        volatile __u32 io_dma_link;		/* reg 4 */
+        volatile __u32 io_dma_command;
+        volatile __u32 io_dma_address;
+        volatile __u32 io_dma_count;
+        volatile __u32 io_flex;		/* reg 8 */
+        volatile __u32 io_spa_address;
+        volatile __u32 reserved1[2];
+        volatile __u32 io_command;		/* reg 12 */
+        volatile __u32 io_status;
+        volatile __u32 io_control;
+        volatile __u32 io_data;
+        volatile __u32 reserved2;		/* reg 16 */
+        volatile __u32 chain_addr;
+        volatile __u32 sub_mask_clr;
+        volatile __u32 reserved3[13];
+        volatile __u32 undefined[480];
+        volatile __u32 unpriv[512];
 };
 
 struct bc_module {
-        volatile uint32_t unused1[12];
-        volatile uint32_t io_command;
-        volatile uint32_t io_status;
-        volatile uint32_t io_control;
-        volatile uint32_t unused2[1];
-        volatile uint32_t io_err_resp;
-        volatile uint32_t io_err_info;
-        volatile uint32_t io_err_req;
-        volatile uint32_t unused3[11];
-        volatile uint32_t io_io_low;
-        volatile uint32_t io_io_high;
+        volatile __u32 unused1[12];
+        volatile __u32 io_command;
+        volatile __u32 io_status;
+        volatile __u32 io_control;
+        volatile __u32 unused2[1];
+        volatile __u32 io_err_resp;
+        volatile __u32 io_err_info;
+        volatile __u32 io_err_req;
+        volatile __u32 unused3[11];
+        volatile __u32 io_io_low;
+        volatile __u32 io_io_high;
 };
 
 #define HPHW_NPROC     0 
diff -urp linux-2.6.7/include/asm-parisc/processor.h linux-2.6.7-gentoo/include/asm-parisc/processor.h
--- linux-2.6.7/include/asm-parisc/processor.h	2004-08-24 12:09:23.000000000 -0400
+++ linux-2.6.7-gentoo/include/asm-parisc/processor.h	2004-08-24 11:59:41.950667480 -0400
@@ -12,11 +12,11 @@
 #include <linux/config.h>
 #include <linux/threads.h>
 
+#include <asm/types.h>
 #include <asm/hardware.h>
 #include <asm/page.h>
 #include <asm/pdc.h>
 #include <asm/ptrace.h>
-#include <asm/types.h>
 #include <asm/system.h>
 #endif /* __ASSEMBLY__ */
 
diff -up linux-2.6.11/include/linux/list.h linux-2.6.11-gentoo/include/linux/list.h
--- linux-2.6.11/include/linux/list.h	2004-08-20 19:54:37.000000000 +0100
+++ linux-2.6.11-gentoo/linux/list.h	2004-08-24 17:52:07.416139368 +0100
@@ -1,8 +1,6 @@
 #ifndef _LINUX_LIST_H
 #define _LINUX_LIST_H
 
-#ifdef __KERNEL__
-
 #include <linux/stddef.h>
 #include <linux/prefetch.h>
 #include <asm/system.h>
@@ -38,20 +36,39 @@ struct list_head {
 	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)
 
+struct hlist_head {
+	struct hlist_node *first;
+};
+
+struct hlist_node {
+	struct hlist_node *next, **pprev;
+};
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+       return head->next == head;
+}
+
+#if defined(__KERNEL__) || defined(__LINUX_KEYBOARD_H)
+
 /*
  * Insert a new entry between two known consecutive entries.
  *
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static inline void __list_add(struct list_head *new,
+static inline void __list_add(struct list_head *_new,
 			      struct list_head *prev,
 			      struct list_head *next)
 {
-	next->prev = new;
-	new->next = next;
-	new->prev = prev;
-	prev->next = new;
+	next->prev = _new;
+	_new->next = next;
+	_new->prev = prev;
+	prev->next = _new;
 }
 
 /**
@@ -62,9 +62,9 @@ static inline void __list_add(struct lis
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-static inline void list_add(struct list_head *new, struct list_head *head)
+static inline void list_add(struct list_head *_new, struct list_head *head)
 {
-	__list_add(new, head, head->next);
+	__list_add(_new, head, head->next);
 }
 
 /**
@@ -75,9 +75,9 @@ static inline void list_add(struct list_
  * Insert a new entry before the specified head.
  * This is useful for implementing queues.
  */
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
+static inline void list_add_tail(struct list_head *_new, struct list_head *head)
 {
-	__list_add(new, head->prev, head);
+	__list_add(_new, head->prev, head);
 }
 
 /*
@@ -86,14 +86,14 @@ static inline void list_add_tail(struct 
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static inline void __list_add_rcu(struct list_head * new,
+static inline void __list_add_rcu(struct list_head * _new,
 		struct list_head * prev, struct list_head * next)
 {
-	new->next = next;
-	new->prev = prev;
+	_new->next = next;
+	_new->prev = prev;
 	smp_wmb();
-	next->prev = new;
-	prev->next = new;
+	next->prev = _new;
+	prev->next = _new;
 }
 
 /**
@@ -112,9 +112,9 @@ static inline void __list_add_rcu(struct
  * the _rcu list-traversal primitives, such as
  * list_for_each_entry_rcu().
  */
-static inline void list_add_rcu(struct list_head *new, struct list_head *head)
+static inline void list_add_rcu(struct list_head *_new, struct list_head *head)
 {
-	__list_add_rcu(new, head, head->next);
+	__list_add_rcu(_new, head, head->next);
 }
 
 /**
@@ -133,10 +133,10 @@ static inline void list_add_rcu(struct l
  * the _rcu list-traversal primitives, such as
  * list_for_each_entry_rcu().
  */
-static inline void list_add_tail_rcu(struct list_head *new,
+static inline void list_add_tail_rcu(struct list_head *_new,
 					struct list_head *head)
 {
-	__list_add_rcu(new, head->prev, head);
+	__list_add_rcu(_new, head->prev, head);
 }
 
 /*
@@ -161,8 +161,8 @@ static inline void __list_del(struct lis
 static inline void list_del(struct list_head *entry)
 {
 	__list_del(entry->prev, entry->next);
-	entry->next = LIST_POISON1;
-	entry->prev = LIST_POISON2;
+	entry->next = __cast__(list_head*) LIST_POISON1;
+	entry->prev = __cast__(list_head*) LIST_POISON2;
 }
 
 /**
@@ -192,7 +192,7 @@ static inline void list_del(struct list_
 static inline void list_del_rcu(struct list_head *entry)
 {
 	__list_del(entry->prev, entry->next);
-	entry->prev = LIST_POISON2;
+	entry->prev = __cast__(list_head*) LIST_POISON2;
 }
 
 /**
@@ -219,12 +219,12 @@
  *
  * The old entry will be replaced with the new entry atomically.
  */
-static inline void list_replace_rcu(struct list_head *old, struct list_head *new){
-	new->next = old->next;
-	new->prev = old->prev;
+static inline void list_replace_rcu(struct list_head *old, struct list_head *_new){
+	_new->next = old->next;
+	_new->prev = old->prev;
 	smp_wmb();
-	new->next->prev = new;
-	new->prev->next = new;
+	_new->next->prev = _new;
+	_new->prev->next = _new;
 }
 
 /**
@@ -244,15 +244,6 @@
 }
 
 /**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static inline int list_empty(const struct list_head *head)
-{
-	return head->next == head;
-}
-
-/**
  * list_empty_careful - tests whether a list is
  * empty _and_ checks that no other CPU might be
  * in the process of still modifying either member
@@ -496,14 +504,6 @@ static inline void list_splice_init(stru
  * You lose the ability to access the tail in O(1).
  */
 
-struct hlist_head {
-	struct hlist_node *first;
-};
-
-struct hlist_node {
-	struct hlist_node *next, **pprev;
-};
-
 #define HLIST_HEAD_INIT { .first = NULL }
 #define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
@@ -506,8 +506,8 @@ static inline int hlist_empty(const stru
 
 static inline void __hlist_del(struct hlist_node *n)
 {
-	struct hlist_node *next = n->next;
-	struct hlist_node **pprev = n->pprev;
+	struct hlist_node *next = __cast__(hlist_node*) n->next;
+	struct hlist_node **pprev = __cast__(hlist_node**) n->pprev;
 	*pprev = next;
 	if (next)
 		next->pprev = pprev;
@@ -516,8 +516,8 @@ static inline void __hlist_del(struct hl
 static inline void hlist_del(struct hlist_node *n)
 {
 	__hlist_del(n);
-	n->next = LIST_POISON1;
-	n->pprev = LIST_POISON2;
+	n->next = __cast__(hlist_node*) LIST_POISON1;
+	n->pprev = __cast__(hlist_node**) LIST_POISON2;
 }
 
 /**
@@ -542,7 +542,7 @@ static inline void hlist_del(struct hlis
 static inline void hlist_del_rcu(struct hlist_node *n)
 {
 	__hlist_del(n);
-	n->pprev = LIST_POISON2;
+	n->pprev = __cast__(hlist_node**) LIST_POISON2;
 }
 
 static inline void hlist_del_init(struct hlist_node *n)
@@ -694,8 +694,5 @@ static inline void hlist_add_after(struc
 	     pos && ({ prefetch(pos->next); 1;}) &&			 \
 		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
 	     pos = rcu_dereference(pos->next))
-
-#else
-#warning "don't include kernel headers in userspace"
-#endif /* __KERNEL__ */
+#endif
 #endif
diff -ur linux-2.6.8.1/include/linux/prefetch.h linux-2.6.8.1-gentoo/include/linux/prefetch.h
--- linux-2.6.8.1/include/linux/prefetch.h	2004-07-13 19:00:02.450665496 +0100
+++ linux-2.6.8.1-gentoo/include/linux/prefetch.h	2004-07-13 18:44:43.000000000 +0100
@@ -10,6 +10,7 @@
 #ifndef _LINUX_PREFETCH_H
 #define _LINUX_PREFETCH_H
 
+#include <linux/compiler.h>
 #include <linux/types.h>
 #include <asm/processor.h>
 #include <asm/cache.h>
@@ -59,9 +59,9 @@
 {
 #ifdef ARCH_HAS_PREFETCH
 	char *cp;
-	char *end = addr + len;
+	char *end = __cast__(char *) addr + len;
 
-	for (cp = addr; cp < end; cp += PREFETCH_STRIDE)
+	for (cp = __cast__(char *) addr; cp < end; cp += PREFETCH_STRIDE)
 		prefetch(cp);
 #endif
 }
diff -ur linux-2.6.8.1/include/linux/videodev2.h linux-2.6.8.1-gentoo/include/linux/videodev2.h
--- linux-2.6.8.1/include/linux/videodev2.h	2004-08-20 19:54:37.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/linux/videodev2.h	2004-08-24 21:20:48.468650056 +0100
@@ -13,6 +13,8 @@
  *		Justin Schoeman
  *		et al.
  */
+
+#include <linux/compiler.h>
 #ifdef __KERNEL__
 #include <linux/time.h> /* need struct timeval */
 #endif
diff -ur linux-2.6.8.1/include/linux/crc-ccitt.h linux-2.6.8.1-gentoo/include/linux/crc-ccitt.h
--- linux-2.6.8.1/include/linux/crc-ccitt.h	2004-08-20 19:54:37.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/linux/crc-ccitt.h	2004-08-25 18:49:57.048297800 +0100
@@ -3,11 +3,11 @@
 
 #include <linux/types.h>
 
-extern u16 const crc_ccitt_table[256];
+extern __u16 const crc_ccitt_table[256];
 
-extern u16 crc_ccitt(u16 crc, const u8 *buffer, size_t len);
+extern __u16 crc_ccitt(__u16 crc, const __u8 *buffer, size_t len);
 
-static inline u16 crc_ccitt_byte(u16 crc, const u8 c)
+static inline __u16 crc_ccitt_byte(__u16 crc, const __u8 c)
 {
 	return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
 }
diff -ur linux-2.6.8.1/include/linux/capi.h linux-2.6.8.1-gentoo/include/linux/capi.h
--- linux-2.6.8.1/include/linux/capi.h	2004-08-20 19:54:37.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/linux/capi.h	2004-08-25 18:49:57.048297800 +0100
@@ -17,6 +17,7 @@
 #ifndef __KERNEL__
 #include <linux/kernelcapi.h>
 #endif
+#include <linux/compiler.h>
 
 /*
  * CAPI_REGISTER
diff -ur linux-2.6.8.1/include/asm-parisc/types.h linux-2.6.8.1-gentoo/include/asm-parisc/types.h
--- linux-2.6.8.1/include/asm-parisc/types.h	2004-08-20 19:54:37.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-parisc/types.h	2004-08-25 18:49:57.048297800 +0100
@@ -19,7 +19,7 @@
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
 
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if defined(__GNUC__)
 typedef __signed__ long long __s64;
 typedef unsigned long long __u64;
 #endif
diff -ur linux-2.6.8.1/include/asm-ppc/unaligned.h linux-2.6.8.1-gentoo/include/asm-ppc/unaligned.h
--- linux-2.6.8.1/include/asm-ppc/unaligned.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-ppc/unaligned.h	2004-09-25 19:07:46.956434136 +0100
@@ -1,4 +1,3 @@
-#ifdef __KERNEL__
 #ifndef __PPC_UNALIGNED_H
 #define __PPC_UNALIGNED_H
 
@@ -15,4 +14,3 @@
 #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
 
 #endif
-#endif /* __KERNEL__ */
diff -ur linux-2.6.8.1/include/asm-ppc64/processor.h linux-2.6.8.1-gentoo/include/asm-ppc64/processor.h
--- linux-2.6.8.1/include/asm-ppc64/processor.h	2004-09-28 16:56:15.966475184 +0100
+++ linux-2.6.8.1-gentoo/include/asm-ppc64/processor.h	2004-09-28 16:54:55.359729000 +0100
@@ -547,9 +547,9 @@
 	unsigned long	saved_softe;	/* Ditto for Soft Enable/Disable */
 #ifdef CONFIG_ALTIVEC
 	/* Complete AltiVec register set */
-	vector128	vr[32] __attribute((aligned(16)));
+	__vector128	vr[32] __attribute((aligned(16)));
 	/* AltiVec status */
-	vector128	vscr __attribute((aligned(16)));
+	__vector128	vscr __attribute((aligned(16)));
 	unsigned long	vrsave;
 	int		used_vr;	/* set if process has used altivec */
 #endif /* CONFIG_ALTIVEC */
diff -ur linux-2.6.11/include/asm-ppc64/spinlock.h linux-2.6.11-gentoo/include/asm-ppc64/spinlock.h
--- linux-2.6.11/include/asm-ppc64/spinlock.h	2004-09-28 16:56:15.948477920 +0100
+++ linux-2.6.11-gentoo/include/asm-ppc64/spinlock.h	2004-09-28 16:55:30.463392000 +0100
@@ -20,9 +20,10 @@
 	volatile unsigned int lock;
 } spinlock_t;
 
-#ifdef __KERNEL__
 #define SPIN_LOCK_UNLOCKED	(spinlock_t) { 0 }
 
+#ifdef __KERNEL__
+
 #define spin_is_locked(x)	((x)->lock != 0)
 #define spin_lock_init(x)	do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
 
diff -ur linux-2.6.8.1/include/asm-ppc64/page.h linux-2.6.8.1-gentoo/include/asm-ppc64/page.h
--- linux-2.6.8.1/include/asm-ppc64/page.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-ppc64/page.h	2004-10-03 14:09:31.434460808 +0100
@@ -91,6 +91,14 @@
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)	_ALIGN(addr, PAGE_SIZE)
 
+#ifdef STRICT_MM_TYPECHECKS
+typedef struct { unsigned long pte; } pte_t;
+typedef struct { unsigned int  pgd; } pgd_t;
+#else
+typedef unsigned long pte_t;
+typedef unsigned long pgd_t;
+#endif
+
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 #include <asm/naca.h>
@@ -129,10 +135,8 @@
  * These are used to make use of C type-checking.  
  * Entries in the pte table are 64b, while entries in the pgd & pmd are 32b.
  */
-typedef struct { unsigned long pte; } pte_t;
 typedef struct { unsigned int  pmd; } pmd_t;
-typedef struct { unsigned int  pgd; } pgd_t;
 typedef struct { unsigned long pgprot; } pgprot_t;
 
 #define pte_val(x)	((x).pte)
 #define pmd_val(x)	((x).pmd)
@@ -148,10 +153,8 @@
 /*
  * .. while these make it easier on the compiler
  */
-typedef unsigned long pte_t;
 typedef unsigned int  pmd_t;
-typedef unsigned int  pgd_t;
 typedef unsigned long pgprot_t;
 
 #define pte_val(x)	(x)
 #define pmd_val(x)	(x)
diff -ur linux-2.6.8.1/include/asm-sparc64/signal.h linux-2.6.8.1-gentoo/include/asm-sparc64/signal.h
--- linux-2.6.8.1/include/asm-sparc64/signal.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-sparc64/signal.h	2004-10-03 14:09:31.434460808 +0100
@@ -110,7 +110,9 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef __sigset_t_defined
 typedef unsigned long __old_sigset_t;            /* at least 32 bits */
+#endif
 
 typedef struct {
        unsigned long sig[_NSIG_WORDS];
diff -ur linux-2.6.8.1/include/asm-sparc/signal.h linux-2.6.8.1-gentoo/include/asm-sparc/signal.h
--- linux-2.6.8.1/include/asm-sparc/signal.h	2004-07-10 01:47:34.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-sparc/signal.h	2004-10-03 14:09:31.434460808 +0100
@@ -105,7 +105,9 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef __sigset_t_defined
 typedef unsigned long __old_sigset_t;
+#endif
 
 typedef struct {
 	unsigned long	sig[_NSIG_WORDS];
diff -ur linux-2.6.8.1/include/asm-ia64/fpu.h linux-2.6.8.1-gentoo/include/asm-ia64/fpu.h
--- linux-2.6.8.1/include/asm-ia64/fpu.h	2004-10-31 14:20:01.000000000 -0700
+++ linux-2.6.8.1-gentoo/include/asm-ia64/fpu.h	2004-11-01 12:04:54.202369190 -0700
@@ -53,13 +53,24 @@
 			 | FPSR_S3 (FPSF_DEFAULT | FPSF_TD))
 
 # ifndef __ASSEMBLY__
+#   ifndef __KERNEL__
+#     include <bits/posix1_lim.h>
+      /* Versioning, newer glibc's declare ia64_fpreg without telling us
+           -- plasmaroo */
+#   endif
 
+#   ifdef _FCNTL_H /* Userspace */
+#     include <signal.h>
+#   else
+#     if !defined(_POSIX_HOST_NAME_MAX) || !defined(_BITS_SIGCONTEXT_H) || defined(__KERNEL__)
 struct ia64_fpreg {
 	union {
 		unsigned long bits[2];
 		long double __dummy;	/* force 16-byte alignment */
 	} u;
 };
+#     endif
+#   endif
 
 # endif /* __ASSEMBLY__ */
 
diff -ur linux-2.6.8.1/include/asm-ppc/bitops.h linux-2.6.8.1-gentoo/include/asm-ppc/bitops.h
--- linux-2.6.8.1/include/asm-ppc/bitops.h	2004-08-14 11:55:32.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-ppc/bitops.h	2004-12-26 19:58:15.881705760 +0000
@@ -2,9 +2,8 @@
  * bitops.h: Bit string operations on the ppc
  */
 
-#ifdef __KERNEL__
 #ifndef _PPC_BITOPS_H
 #define _PPC_BITOPS_H
 
 #include <linux/config.h>
 #include <linux/compiler.h>
@@ -241,6 +240,7 @@
 	return __ilog2(x & -x);
 }
 
+#ifdef __KERNEL__
 /*
  * ffs: find first bit set. This is defined the same way as
  * the libc and compiler builtin ffs routines, therefore
@@ -250,6 +250,7 @@
 {
 	return __ilog2(x & -x) + 1;
 }
+#endif __KERNEL__
 
 /*
  * fls: find last (most-significant) bit set.
@@ -263,6 +265,8 @@
 	return 32 - lz;
 }
 
+#ifdef __KERNEL__
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
@@ -456,5 +460,6 @@
 #define minix_test_bit(nr,addr) ext2_test_bit(nr,addr)
 #define minix_find_first_zero_bit(addr,size) ext2_find_first_zero_bit(addr,size)
 
-#endif /* _PPC_BITOPS_H */
 #endif /* __KERNEL__ */
+#endif /* _PPC_BITOPS_H */
+
diff -ur linux-2.6.8.1/include/asm-alpha/signal.h linux-2.6.8.1-gentoo/include/asm-alpha/signal.h
--- linux-2.6.8.1/include/asm-alpha/signal.h	2004-08-14 11:55:32.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/asm-alpha/signal.h	2004-12-26 19:58:15.881705760 +0000
@@ -24,7 +24,9 @@
 /* Here we must cater to libcs that poke about in kernel headers.  */
 
 #define NSIG		32
+#ifndef __sigset_t_defined
 typedef unsigned long sigset_t;
+#endif
 
 #endif /* __KERNEL__ */
 
@@ -158,6 +160,7 @@
 #else
 /* Here we must cater to libcs that poke about in kernel headers.  */
 
+#ifndef _SIGNAL_H
 struct sigaction {
 	union {
 	  __sighandler_t	_sa_handler;
@@ -166,26 +169,31 @@
 	sigset_t	sa_mask;
 	int		sa_flags;
 };
+#endif
 
 #define sa_handler	_u._sa_handler
 #define sa_sigaction	_u._sa_sigaction
 
 #endif /* __KERNEL__ */
 
+#ifndef _SIGNAL_H
 typedef struct sigaltstack {
 	void __user *ss_sp;
 	int ss_flags;
 	size_t ss_size;
 } stack_t;
+#endif
 
 /* sigstack(2) is deprecated, and will be withdrawn in a future version
    of the X/Open CAE Specification.  Use sigaltstack instead.  It is only
    implemented here for OSF/1 compatibility.  */
 
+#ifndef _SIGNAL_H
 struct sigstack {
 	void __user *ss_sp;
 	int ss_onstack;
 };
+#endif
 
 #ifdef __KERNEL__
 #include <asm/sigcontext.h>
diff -ur linux-2.6.8.1/include/linux/preempt.h linux-2.6.8.1-gentoo/include/linux/preempt.h
--- linux-2.6.8.1/include/linux/preempt.h      2004-08-14 11:55:32.000000000 +0100
+++ linux-2.6.8.1-gentoo/include/linux/preempt.h	  2004-12-26 19:58:15.881705760 +0000
@@ -8,6 +8,7 @@
 
 #include <linux/config.h>
 #include <linux/linkage.h>
+#include <asm/system.h> /* barrier() <--> mb() */
 
 #define preempt_count()        (current_thread_info()->preempt_count)
 
diff -ur linux-2.6.8.1/include/linux/blkpg.h linux-2.6.8.1-gentoo/include/linux/blkpg.h
--- linux-2.6.8.1/include/linux/blkpg.h.orig	2005-01-12 23:15:25.000000000 -0800
+++ linux-2.6.8.1-gentoo/include/linux/blkpg.h	2005-01-12 23:16:05.000000000 -0800
@@ -25,6 +25,7 @@
  * For today, only the partition stuff - aeb, 990515
  */
 #include <linux/ioctl.h>
+#include <linux/compiler.h>
 
 #define BLKPG      _IO(0x12,105)
 
diff -urp linux-2.6.10/include/asm-i386/param.h linux-2.6.10-gentoo/include/asm-i386/param.h
--- linux-2.6.10/include/asm-i386/param.h	2005-02-08 21:01:47.000000000 +0000
+++ linux-2.6.10-gentoo/include/asm-i386/param.h	2005-02-08 20:28:36.000000000 +0000
@@ -11,6 +11,10 @@
 #define HZ 100
 #endif
 
+#ifndef USER_HZ
+#define USER_HZ 100
+#endif
+
 #define EXEC_PAGESIZE	4096
 
 #ifndef NOGROUP
diff -urp linux-2.6.10/include/asm-i386/semaphore.h linux-2.6.10-gentoo/include/asm-i386/semaphore.h
--- linux-2.6.10/include/asm-i386/semaphore.h	2005-02-08 21:01:47.000000000 +0000
+++ linux-2.6.10-gentoo/include/asm-i386/semaphore.h	2005-02-08 20:46:02.000000000 +0000
@@ -1,6 +1,7 @@
 #ifndef _I386_SEMAPHORE_H
 #define _I386_SEMAPHORE_H
 
+#include <linux/wait.h>
 #include <linux/linkage.h>
 
 /*
diff -urp linux-2.6.10/include/linux/prio_tree.h linux-2.6.10-gentoo/include/linux/prio_tree.h
--- linux-2.6.10/include/linux/prio_tree.h	2005-02-08 21:01:47.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/prio_tree.h	2005-02-08 20:15:28.000000000 +0000
@@ -1,6 +1,8 @@
 #ifndef _LINUX_PRIO_TREE_H
 #define _LINUX_PRIO_TREE_H
 
+#include <linux/types.h>
+
 struct prio_tree_node {
 	struct prio_tree_node	*left;
 	struct prio_tree_node	*right;
diff -urp linux-2.6.10/include/linux/time.h linux-2.6.10-gentoo/include/linux/time.h
--- linux-2.6.10/include/linux/time.h	2005-02-08 21:01:47.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/time.h	2005-02-08 20:26:11.000000000 +0000
@@ -32,8 +32,6 @@ struct timezone {
 
 #endif /* _SYS_TIME_H */
 
-#ifdef __KERNEL__
-
 /* Parameters used to convert the timespec values */
 #ifndef USEC_PER_SEC
 #define USEC_PER_SEC (1000000L)
@@ -47,6 +45,8 @@ struct timezone {
 #define NSEC_PER_USEC (1000L)
 #endif
 
+#ifdef __KERNEL__
+
 static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) 
 { 
 	return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
diff -urp linux-2.6.10/include/topology.h linux-2.6.10-gentoo/include/linux/topology.h
--- linux-2.6.10/include/linux/topology.h	2005-02-08 21:01:47.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/topology.h	2005-02-08 20:48:27.000000000 +0000
@@ -27,6 +27,8 @@
 #ifndef _LINUX_TOPOLOGY_H
 #define _LINUX_TOPOLOGY_H
 
+#ifdef __KERNEL__
+
 #include <linux/cpumask.h>
 #include <linux/bitops.h>
 #include <linux/mmzone.h>
@@ -133,4 +135,5 @@ static inline int __next_node_with_cpus(
 #endif
 #endif /* CONFIG_NUMA */
 
+#endif /* __KERNEL__ */
 #endif /* _LINUX_TOPOLOGY_H */
diff -urp linux-2.6.10/include/linux/types.h linux-2.6.10-gentoo/include/linux/types.h
--- linux-2.6.10/include/linux/types.h	2005-02-08 21:01:47.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/types.h	2005-02-08 20:40:22.000000000 +0000
@@ -11,6 +11,7 @@
 #endif
 
 #include <linux/posix_types.h>
+#include <asm/posix_types.h>
 #include <asm/types.h>
 
 #ifndef __KERNEL_STRICT_NAMES
@@ -148,6 +149,10 @@ typedef		__s64		int64_t;
 typedef unsigned long sector_t;
 #endif
 
+#else /* Userspace ... */
+#include <time.h>
+#endif /* __KERNEL_STRICT_NAMES */
+
 /*
  * The type of an index into the pagecache.  Use a #define so asm/types.h
  * can override it.
@@ -156,8 +161,6 @@ typedef unsigned long sector_t;
 #define pgoff_t unsigned long
 #endif
 
-#endif /* __KERNEL_STRICT_NAMES */
-
 /*
  * Below are truly Linux-specific types that should never collide with
  * any application/library that wants linux/types.h.
diff -urp linux-2.6.10/include/asm-i386/thread_info.h linux-2.6.10-gentoo/include/asm-i386/thread_info.h
--- linux-2.6.10/include/asm-i386/thread_info.h	2005-02-08 21:30:49.000000000 +0000
+++ linux-2.6.10-gentoo/asm-i386/thread_info.h	2005-02-08 21:27:03.000000000 +0000
@@ -7,8 +7,7 @@
 #ifndef _ASM_THREAD_INFO_H
 #define _ASM_THREAD_INFO_H
 
-#ifdef __KERNEL__
 
 #include <linux/config.h>
 #include <linux/compiler.h>
 #include <asm/page.h>
@@ -165,6 +163,4 @@ register unsigned long current_stack_poi
  */
 #define TS_USEDFPU		0x0001	/* FPU was used by this task this quantum (SMP) */
 
-#endif /* __KERNEL__ */
-
 #endif /* _ASM_THREAD_INFO_H */
diff -urp linux-2.6.10/include/linux/telephony.h linux-2.6.10-gentoo/include/linux/telephony.h
--- linux-2.6.10/include/linux/telephony.h	2004-11-20 16:54:35.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/telephony.h	2005-02-08 22:03:49.468357464 +0000
@@ -37,6 +37,8 @@
 #ifndef TELEPHONY_H
 #define TELEPHONY_H
 
+#include <linux/compiler.h>
+
 #define TELEPHONY_VERSION 3013
 
 #define PHONE_VENDOR_IXJ          1
diff -urp linux-2.6.10/include/asm-i386/unistd.h linux-2.6.10-gentoo/include/asm-i386/unistd.h
--- linux-2.6.10/include/asm-i386/unistd.h	2005-02-08 21:30:49.000000000 +0000
+++ linux-2.6.10-gentoo/asm-i386/unistd.h	2005-02-08 21:27:03.000000000 +0000
@@ -314,6 +314,21 @@
 __syscall_return(type,__res); \
 }
 
+#ifdef __PIC__
+#define _syscall1(type,name,type1,arg1) \
+type name(type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile (\
+	"pushl %%ebx\n\t" \
+	"movl %2,%%ebx\n\t" \
+	"int $0x80\n\t" \
+	"popl %%ebx\n\t" \
+	: "=a" (__res) \
+	: "0" (__NR_##name),"r" ((long)(arg1))); \
+__syscall_return(type,__res); \
+}
+#else
 #define _syscall1(type,name,type1,arg1) \
 type name(type1 arg1) \
 { \
@@ -323,7 +338,23 @@
 	: "0" (__NR_##name),"b" ((long)(arg1))); \
 __syscall_return(type,__res); \
 }
+#endif
 
+#ifdef __PIC__
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name(type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile (\
+	"pushl %%ebx\n\t" \
+	"movl %2,%%ebx\n\t" \
+	"int $0x80\n\t" \
+	"popl %%ebx\n\t" \
+	: "=a" (__res) \
+	: "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
+__syscall_return(type,__res); \
+}
+#else
 #define _syscall2(type,name,type1,arg1,type2,arg2) \
 type name(type1 arg1,type2 arg2) \
 { \
@@ -333,7 +364,24 @@
 	: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
 __syscall_return(type,__res); \
 }
+#endif
 
+#ifdef __PIC__
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name(type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile (\
+	"pushl %%ebx\n\t" \
+	"movl %2,%%ebx\n\t" \
+	"int $0x80\n\t" \
+	"popl %%ebx\n\t" \
+	: "=a" (__res) \
+	: "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+		  "d" ((long)(arg3))); \
+__syscall_return(type,__res); \
+}
+#else
 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
 type name(type1 arg1,type2 arg2,type3 arg3) \
 { \
@@ -344,7 +392,24 @@
 		  "d" ((long)(arg3))); \
 __syscall_return(type,__res); \
 }
+#endif
 
+#ifdef __PIC__
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+long __res; \
+__asm__ volatile (\
+	"pushl %%ebx\n\t" \
+	"movl %2,%%ebx\n\t" \
+	"int $0x80\n\t" \
+	"popl %%ebx\n\t" \
+	: "=a" (__res) \
+	: "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
+	  "d" ((long)(arg3)),"S" ((long)(arg4))); \
+__syscall_return(type,__res); \
+} 
+#else
 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
 { \
@@ -355,7 +420,25 @@
 	  "d" ((long)(arg3)),"S" ((long)(arg4))); \
 __syscall_return(type,__res); \
 } 
+#endif
 
+#ifdef __PIC__
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+	  type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+__asm__ volatile (\
+	"pushl %%ebx\n\t" \
+	"movl %2,%%ebx\n\t" \
+	"int $0x80\n\t" \
+	"popl %%ebx\n\t" \
+	: "=a" (__res) \
+	: "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
+	  "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
+__syscall_return(type,__res); \
+}
+#else
 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
 	  type5,arg5) \
 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
@@ -367,7 +450,30 @@
 	  "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
 __syscall_return(type,__res); \
 }
+#endif
 
+#ifdef __PIC__
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+	  type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+long __res; \
+__asm__ volatile (\
+	"pushl %%ebp\n\t" \
+	"pushl %%ebx\n\t" \
+	"movl %2,%%ebx\n\t" \
+	"movl %%eax,%%ebp\n\t" \
+	"movl %1,%%eax\n\t" \
+	"int $0x80\n\t" \
+	"popl %%ebx\n\t" \
+	"popl %%ebp\n\t" \
+	: "=a" (__res) \
+	: "i" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
+	  "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
+	  "0" ((long)(arg6))); \
+__syscall_return(type,__res); \
+}
+#else
 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
 	  type5,arg5,type6,arg6) \
 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
@@ -380,6 +486,7 @@
 	  "0" ((long)(arg6))); \
 __syscall_return(type,__res); \
 }
+#endif
 
 #ifdef __KERNEL__
 #define __ARCH_WANT_IPC_PARSE_VERSION
diff -urp linux-2.6.10/include/linux/if_fddi.h linux-2.6.10-gentoo/include/linux/if_fddi.h
--- linux-2.6.10/include/linux/if_fddi.h	2004-11-20 16:54:35.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/if_fddi.h	2005-02-12 19:19:51.244852928 +0000
@@ -24,6 +24,8 @@
 #ifndef _LINUX_IF_FDDI_H
 #define _LINUX_IF_FDDI_H
 
+#include <linux/netdevice.h>
+
 /*
  *  Define max and min legal sizes.  The frame sizes do not include
  *  4 byte FCS/CRC (frame check sequence).
diff -urp linux-2.6.11/include/linux/keyboard.h linux-2.6.11-gentoo/include/linux/keyboard.h
--- linux-2.6.11/include/linux/keyboard.h	2004-11-20 16:54:35.000000000 +0000
+++ linux-2.6.11-gentoo/include/linux/keyboard.h	2005-02-12 19:19:51.244852928 +0000
@@ -1,6 +1,22 @@
 #ifndef __LINUX_KEYBOARD_H
 #define __LINUX_KEYBOARD_H
 
+#ifdef __hppa__ /* Add more affected archs as needed */
+/* Currently this only seems to be applicable to HPPA and eradicator
+   has fixed this locally in 2.3.5 anyway, but we still need this here
+   for HPPA as 2.3.5 doesn't work for them just yet. -- plasmaroo */
+#ifndef __le64
+#ifdef _LINUX_TYPES_H
+#undef _LINUX_TYPES_H
+#warning Gentoo Linux Headers Warning: GNU Libc Linux Headers Override Detected.
+#warning Gentoo Linux Headers Warning: This is bad. Removing override and continuing.
+#warning Gentoo Linux Headers Warning: If your compilation dies here, mention this when
+#warning Gentoo Linux Headers Warning: filing a bug!
+#include <linux/types.h>
+#endif /* #ifdef _LINUX_TYPES_H */
+#endif /* #ifndef __le64 */
+#endif /* #if (arch) */
+
 #include <linux/wait.h>
 
 #define KG_SHIFT	0
diff -urp linux-2.6.11/include/asm-parisc/thread_info.h linux-2.6.11-gentoo/include/asm-parisc/thread_info.h
--- linux-2.6.11/include/asm-parisc/thread_info.h	2004-11-20 16:54:35.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-parisc/thread_info.h	2005-02-12 19:19:51.244852928 +0000
@@ -1,8 +1,6 @@
 #ifndef _ASM_PARISC_THREAD_INFO_H
 #define _ASM_PARISC_THREAD_INFO_H
 
-#ifdef __KERNEL__
-
 #ifndef __ASSEMBLY__
 #include <asm/processor.h>
 
@@ -75,6 +73,4 @@
 #define _TIF_USER_WORK_MASK     (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
                                  _TIF_NEED_RESCHED)
 
-#endif /* __KERNEL__ */
-
 #endif /* _ASM_PARISC_THREAD_INFO_H */
--- linux-2.6.10/include/asm-sparc/processor.h	2004-12-11 15:49:24.522603912 -0800
+++ linux-2.6.10-gentoo/include/asm-sparc/processor.h	2004-12-11 15:49:18.865463928 -0800
@@ -44,11 +44,13 @@
 struct task_struct;
 
 #ifdef __KERNEL__
-struct fpq {
+#define __fpq fpq
+#endif
+
+struct __fpq {
 	unsigned long *insn_addr;
 	unsigned long insn;
 };
-#endif
 
 typedef struct {
 	int seg;
@@ -67,13 +69,17 @@ struct thread_struct {
 	unsigned long   float_regs[32] __attribute__ ((aligned (8)));
 	unsigned long   fsr;
 	unsigned long   fpqdepth;
-	struct fpq	fpqueue[16];
+	struct __fpq	fpqueue[16];
 	unsigned long flags;
 	mm_segment_t current_ds;
 	struct exec core_exec;     /* just what it says. */
 	int new_signal;
 };
 
+#ifdef __KERNEL__
+#undef __fpq
+#endif
+
 #define SPARC_FLAG_KTHREAD      0x1    /* task is a kernel thread */
 #define SPARC_FLAG_UNALIGNED    0x2    /* is allowed to do unaligned accesses */
 
diff -urp linux-2.6.10/include/linux/usb_ch9.h linux-2.6.10-gentoo/include/linux/usb_ch9.h
--- linux-2.6.10/include/linux/usb_ch9.h	2004-11-20 16:54:35.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/usb_ch9.h	2005-02-13 23:42:55.629530192 +0000
@@ -17,6 +17,7 @@
 #define __LINUX_USB_CH9_H
 
 #include <asm/types.h>		/* __u8 etc */
+#include <linux/types.h>	/* __le16 */
 
 /*-------------------------------------------------------------------------*/
 
diff -urp linux-2.6.10/include/linux/if_ppp.h linux-2.6.10-gentoo/include/linux/if_ppp.h
--- linux-2.6.10/include/linux/if_ppp.h	2005-02-25 00:19:05.000000000 +0000
+++ linux-2.6.10-gentoo/include/linux/if_ppp.h	2005-03-06 18:22:18.483422888 +0000
@@ -34,6 +34,13 @@
 
 #ifndef _IF_PPP_H_
 #define _IF_PPP_H_
+#include <linux/types.h>
+
+/* For NPmode */
+#include <linux/ppp_defs.h>
+
+/* For ifreq */
+#include <linux/if.h>
 
 /*
  * Packet sizes
--- linux-2.6.10/include/asm-sparc/thread_info.h.orig	2004-12-23 21:38:32.000000000 -0800
+++ linux-2.6.10/include/asm-sparc/thread_info.h	2005-03-07 15:24:52.954659122 -0800
@@ -11,8 +11,6 @@
 #ifndef _ASM_THREAD_INFO_H
 #define _ASM_THREAD_INFO_H
 
-#ifdef __KERNEL__
-
 #ifndef __ASSEMBLY__
 
 #include <asm/btfixup.h>
@@ -147,6 +145,4 @@ BTFIXUPDEF_CALL(void, free_thread_info, 
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 
-#endif /* __KERNEL__ */
-
 #endif /* _ASM_THREAD_INFO_H */
--- linux-2.6.10/include/asm-sparc64/thread_info.h.orig	2004-12-23 21:38:32.000000000 -0800
+++ linux-2.6.10/include/asm-sparc64/thread_info.h	2005-03-07 15:24:43.765013779 -0800
@@ -7,8 +7,6 @@
 #ifndef _ASM_THREAD_INFO_H
 #define _ASM_THREAD_INFO_H
 
-#ifdef __KERNEL__
-
 #define NSWINS		7
 
 #define TI_FLAG_BYTE_FAULT_CODE		0
@@ -246,6 +244,4 @@ register struct thread_info *current_thr
 				 (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
 				  _TIF_NEED_RESCHED | _TIF_PERFCTR))
 
-#endif /* __KERNEL__ */
-
 #endif /* _ASM_THREAD_INFO_H */
--- linux-2.6.10/include/asm-sparc/fbio.h.orig	2005-03-07 18:29:59.719149292 -0800
+++ linux-2.6.10/include/asm-sparc/fbio.h	2005-03-07 18:30:39.958067643 -0800
@@ -1,6 +1,8 @@
 #ifndef __LINUX_FBIO_H
 #define __LINUX_FBIO_H
 
+#include <linux/compiler.h>
+
 /* Constants used for fbio SunOS compatibility */
 /* (C) 1996 Miguel de Icaza */
 
--- linux-2.6.11/include/linux/byteorder/little_endian.h.84353	2005-03-07 01:19:49.000000000 +0100
+++ linux-2.6.11-gentoo/include/linux/byteorder/little_endian.h	2005-03-07 01:20:22.000000000 +0100
@@ -40,6 +40,7 @@
 #define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
 #define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
 
+#ifndef __STRICT_ANSI__
 static inline __le64 __cpu_to_le64p(const __u64 *p)
 {
 	return (__force __le64)*p;
@@ -48,6 +49,7 @@
 {
 	return (__force __u64)*p;
 }
+#endif /* !__STRICT_ANSI__ */
 static inline __le32 __cpu_to_le32p(const __u32 *p)
 {
 	return (__force __le32)*p;
@@ -64,6 +66,7 @@
 {
 	return (__force __u16)*p;
 }
+#ifndef __STRICT_ANSI__
 static inline __be64 __cpu_to_be64p(const __u64 *p)
 {
 	return (__force __be64)__swab64p(p);
@@ -72,6 +75,7 @@
 {
 	return __swab64p((__u64 *)p);
 }
+#endif /* !__STRICT_ANSI__ */
 static inline __be32 __cpu_to_be32p(const __u32 *p)
 {
 	return (__force __be32)__swab32p(p);
--- linux-2.6.8.1/include/linux/ethtool.h	2005-04-13 13:39:08.000000000 -0700
+++ linux-2.6.8.1-gentoo/include/linux/ethtool.h	2005-04-13 13:35:31.000000000 -0700
@@ -12,6 +12,8 @@
 #ifndef _LINUX_ETHTOOL_H
 #define _LINUX_ETHTOOL_H
 
+#include <linux/types.h>
+
 /* This should work for both 32 and 64 bit userland. */
 struct ethtool_cmd {
 	__u32	    cmd;
diff -ur linux-2.6.11/include/asm-ia64/bitops.h linux-2.6.11-gentoo/include/asm-ia64/bitops.h
--- linux-2.6.11/include/asm-ia64/bitops.h	2005-04-24 13:56:27.000000000 -0500
+++ linux-2.6.11-gentoo/include/asm-ia64/bitops.h	2005-04-24 13:48:38.120189000 -0500
@@ -311,8 +311,6 @@
 	return result;
 }
 
-#ifdef __KERNEL__
-
 /*
  * find_last_zero_bit - find the last zero bit in a 64 bit quantity
  * @x: The value to search
@@ -341,6 +339,8 @@
  */
 #define ffs(x)	__builtin_ffs(x)
 
+#ifdef __KERNEL__
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
diff -ur linux-2.6.11/include/asm-ia64/page.h linux-2.6.11-gentoo/include/asm-ia64/page.h
--- linux-2.6.11/include/asm-ia64/page.h	2005-04-24 13:56:27.000000000 -0500
+++ linux-2.6.11-gentoo/include/asm-ia64/page.h	2005-04-24 13:46:03.891675000 -0500
@@ -109,6 +109,8 @@
 #define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
 #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 
+#endif /* __KERNEL__ */
+
 typedef union ia64_va {
 	struct {
 		unsigned long off : 61;		/* intra-region offset */
@@ -130,6 +132,8 @@
 #define REGION_NUMBER(x)	({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
 #define REGION_OFFSET(x)	({ia64_va _v; _v.l = (long) (x); _v.f.off;})
 
+#ifdef __KERNEL__
+
 #define REGION_SIZE		REGION_NUMBER(1)
 #define REGION_KERNEL		7
 
diff -ur linux-2.6.11/include/asm-ia64/processor.h linux-2.6.11-gentoo/include/asm-ia64/processor.h
--- linux-2.6.11/include/asm-ia64/processor.h	2005-04-24 13:56:27.000000000 -0500
+++ linux-2.6.11-gentoo/include/asm-ia64/processor.h	2005-04-24 13:53:40.383857000 -0500
@@ -351,7 +353,7 @@
  * do_basic_setup() and the timing is such that free_initmem() has
  * been called already.
  */
-extern pid_t kernel_thread (int (*fn)(void *), void *arg, unsigned long flags);
+extern __kernel_pid_t kernel_thread (int (*fn)(void *), void *arg, unsigned long flags);
 
 /* Get wait channel for task P.  */
 extern unsigned long get_wchan (struct task_struct *p);
diff -ur linux-2.6.11/include/asm-ia64/thread_info.h linux-2.6.11-gentoo/include/asm-ia64/thread_info.h
--- linux-2.6.11/include/asm-ia64/thread_info.h	2005-04-24 13:56:27.000000000 -0500
+++ linux-2.6.11-gentoo/include/asm-ia64/thread_info.h	2005-04-24 13:54:00.893623000 -0500
@@ -32,7 +32,7 @@
 		int code;
 		void __user *addr;
 		unsigned long start_time;
-		pid_t pid;
+		__kernel_pid_t pid;
 	} sigdelayed;			/* Saved information for TIF_SIGDELAYED */
 };
 
--- linux-2.6/include/asm-arm/elf.h
+++ linux-2.6/include/asm-arm/elf.h
@@ -38,9 +38,9 @@
  */
 #define ELF_CLASS	ELFCLASS32
 #ifdef __ARMEB__
-#define ELF_DATA	ELFDATA2MSB;
+#define ELF_DATA	ELFDATA2MSB
 #else
-#define ELF_DATA	ELFDATA2LSB;
+#define ELF_DATA	ELFDATA2LSB
 #endif
 #define ELF_ARCH	EM_ARM
 
--- linux-2.6/include/asm-arm26/elf.h
+++ linux-2.6/include/asm-arm26/elf.h
@@ -36,7 +36,7 @@
  * These are used to set parameters in the core dumps.
  */
 #define ELF_CLASS	ELFCLASS32
-#define ELF_DATA	ELFDATA2LSB;
+#define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_ARM
 
 #define USE_ELF_CORE_DUMP
--- linux-2.6/include/asm-cris/elf.h
+++ linux-2.6/include/asm-cris/elf.h
@@ -27,7 +27,7 @@
  * These are used to set parameters in the core dumps.
  */
 #define ELF_CLASS	ELFCLASS32
-#define ELF_DATA	ELFDATA2LSB;
+#define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_CRIS
 
 #define USE_ELF_CORE_DUMP
--- linux-2.6.11/include/linux/i2c-dev.h	2005-04-28 22:30:29.000000000 +0100
+++ linux-2.6.11-gentoo/include/linux/i2c-dev.h	2005-05-24 14:48:01.000000000 +0100
@@ -24,6 +24,8 @@
 #ifndef _LINUX_I2C_DEV_H
 #define _LINUX_I2C_DEV_H
 
+#include <linux/compiler.h>
+#include <linux/i2c.h>
 #include <linux/types.h>
 
 /* Some IOCTL commands are defined in <linux/i2c.h> */
--- linux-2.6.11/include/asm-arm/thread_info.h	2005-03-02 07:38:08.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-arm/thread_info.h	2005-05-29 23:42:31.000000000 +0100
@@ -10,8 +10,6 @@
 #ifndef __ASM_ARM_THREAD_INFO_H
 #define __ASM_ARM_THREAD_INFO_H
 
-#ifdef __KERNEL__
-
 #include <asm/fpstate.h>
 
 #ifndef __ASSEMBLY__
@@ -143,5 +141,4 @@
  */
 #define _TIF_WORK_MASK		0x000000ff
 
-#endif /* __KERNEL__ */
 #endif /* __ASM_ARM_THREAD_INFO_H */
--- linux-2.6.11/include/asm-arm/types.h	2005-03-02 07:37:31.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-arm/types.h	2005-05-29 23:42:46.000000000 +0100
@@ -19,7 +19,7 @@
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
 
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if defined(__GNUC__)
 typedef __signed__ long long __s64;
 typedef unsigned long long __u64;
 #endif
--- linux-2.6.11/include/asm-ppc/types.h	2005-03-02 07:37:31.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-ppc/types.h	2005-05-29 23:42:46.000000000 +0100
@@ -19,7 +19,7 @@
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
 
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if defined(__GNUC__)
 typedef __signed__ long long __s64;
 typedef unsigned long long __u64;
 #endif
--- linux-2.6.11/include/linux/unistd.h	2005-05-24 14:58:11.000000000 +0100
+++ linux-2.6.11-gentoo/include/linux/unistd.h	2005-05-29 23:45:34.000000000 +0100
@@ -1,7 +1,7 @@
 #ifndef _LINUX_UNISTD_H_
 #define _LINUX_UNISTD_H_
 
-extern int errno;
+#include <errno.h>
 
 /*
  * Include machine specific syscallX macros
--- linux-2.6.8.1/include/asm-ppc/spinlock.h	2005-07-01 18:56:58.000000000 +0100
+++ linux-2.6.8.1/include/asm-ppc/spinlock.h	2005-07-01 18:57:56.000000000 +0100
@@ -18,6 +18,10 @@
 #endif
 } spinlock_t;
 
+#ifndef __KERNEL__
+#define SPIN_LOCK_UNLOCKED	(spinlock_t) { 0 }
+#endif
+
 #ifdef __KERNEL__
 #ifdef CONFIG_DEBUG_SPINLOCK
 #define SPINLOCK_DEBUG_INIT     , 0, 0
--- linux-2.6.11/include/asm-ppc64/paca.h.orig	2005-04-04 03:39:48.576951465 +0200
+++ linux-2.6.11-gentoo/include/asm-ppc64/paca.h	2005-04-04 03:42:17.970090549 +0200
@@ -22,7 +22,6 @@
 #include	<asm/iSeries/ItLpRegSave.h>
 #include	<asm/mmu.h>
 
-extern struct paca_struct paca[];
 register struct paca_struct *local_paca asm("r13");
 #define get_paca()	local_paca
 
@@ -115,4 +114,6 @@
 #endif
 };
 
+extern struct paca_struct paca[];
+
 #endif /* _PPC64_PACA_H */
--- linux-2.6.11/include/linux/byteorder/big_endian.h	2005-03-02 07:38:26.000000000 +0000
+++ linux-2.6.11-gentoo/include/linux/byteorder/big_endian.h	2005-07-18 19:01:53.000000000 +0100
@@ -40,6 +40,7 @@
 #define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
 #define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
 
+#ifndef __STRICT_ANSI__
 static inline __le64 __cpu_to_le64p(const __u64 *p)
 {
 	return (__force __le64)__swab64p(p);
@@ -48,6 +49,7 @@
 {
 	return __swab64p((__u64 *)p);
 }
+#endif
 static inline __le32 __cpu_to_le32p(const __u32 *p)
 {
 	return (__force __le32)__swab32p(p);
@@ -64,6 +66,7 @@
 {
 	return __swab16p((__u16 *)p);
 }
+#ifndef __STRICT_ANSI__
 static inline __be64 __cpu_to_be64p(const __u64 *p)
 {
 	return (__force __be64)*p;
@@ -72,6 +75,7 @@
 {
 	return (__force __u64)*p;
 }
+#endif
 static inline __be32 __cpu_to_be32p(const __u32 *p)
 {
 	return (__force __be32)*p;
--- linux-2.6.11/include/asm-s390/types.h	2005-03-02 07:38:09.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-s390/types.h	2005-07-18 20:45:45.000000000 +0100
@@ -28,7 +28,7 @@
 typedef unsigned int __u32;
 
 #ifndef __s390x__
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if defined(__GNUC__)
 typedef __signed__ long long __s64;
 typedef unsigned long long __u64;
 #endif
--- linux-2.6.11/include/asm-s390/elf.h	2005-03-02 07:38:26.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-s390/elf.h	2005-07-18 20:45:37.000000000 +0100
@@ -150,6 +150,7 @@
 /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
    now struct_user_regs, they are different) */
 
+#ifdef __KERNEL__
 static inline int dump_regs(struct pt_regs *ptregs, elf_gregset_t *regs)
 {
 	memcpy(&regs->psw, &ptregs->psw, sizeof(regs->psw)+sizeof(regs->gprs));
@@ -181,7 +182,7 @@
 }
 
 #define ELF_CORE_COPY_FPREGS(tsk, fpregs) dump_task_fpu(tsk, fpregs)
-
+#endif
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports. */
--- linux-2.6.11/include/asm-ppc/bitops.h	2005-03-02 07:38:09.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-ppc/bitops.h	2005-07-18 20:55:20.000000000 +0100
@@ -23,6 +23,7 @@
 #define SMP_MB
 #endif /* CONFIG_SMP */
 
+#define PPC405_ERR77(ra,rb)   "dcbt	ra, rb;\n"
 static __inline__ void set_bit(int nr, volatile unsigned long * addr)
 {
 	unsigned long old;
diff -Naur linux-2.6.11.orig/include/asm-sh/thread_info.h linux-2.6.11/include/asm-sh/thread_info.h
--- linux-2.6.11.orig/include/asm-sh/thread_info.h	2005-03-02 16:38:13.000000000 +0900
+++ linux-2.6.11/include/asm-sh/thread_info.h	2005-07-24 10:18:10.000000000 +0900
@@ -10,8 +10,6 @@
  *  - Incorporating suggestions made by Linus Torvalds and Dave Miller
  */
 
-#ifdef __KERNEL__
-
 #ifndef __ASSEMBLY__
 #include <asm/processor.h>
 
@@ -97,6 +95,4 @@
 #define _TIF_WORK_MASK		0x000000FE	/* work to do on interrupt/exception return */
 #define _TIF_ALLWORK_MASK	0x000000FF	/* work to do on any return to u-space */
 
-#endif /* __KERNEL__ */
-
 #endif /* __ASM_SH_THREAD_INFO_H */
--- linux-2.6.11.orig/include/asm-sh/types.h	2005-03-02 07:38:26.000000000 +0000
+++ linux-2.6.11/include/asm-sh/types.h	2005-07-28 22:54:52.000000000 +0100
@@ -19,7 +19,7 @@
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
 
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if defined(__GNUC__)
 typedef __signed__ long long __s64;
 typedef unsigned long long __u64;
 #endif
diff -ur linux-2.6.11.orig/include/asm-ia64/siginfo.h linux-2.6.11/include/asm-ia64/siginfo.h
--- linux-2.6.11.orig/include/asm-ia64/siginfo.h	2005-11-18 21:07:42.000000000 +0000
+++ linux-2.6.11/include/asm-ia64/siginfo.h	2005-11-18 21:03:17.000000000 +0000
@@ -18,6 +18,7 @@
 
 #include <asm-generic/siginfo.h>
 
+#ifndef _SIGNAL_H
 typedef struct siginfo {
 	int si_signo;
 	int si_errno;
@@ -73,6 +74,7 @@
 		} _sigpoll;
 	} _sifields;
 } siginfo_t;
+#endif
 
 #define si_imm		_sifields._sigfault._imm	/* as per UNIX SysV ABI spec */
 #define si_flags	_sifields._sigfault._flags
diff -ur linux-2.6.11.orig/include/asm-ia64/signal.h linux-2.6.11/include/asm-ia64/signal.h
--- linux-2.6.11.orig/include/asm-ia64/signal.h	2005-11-18 21:07:42.000000000 +0000
+++ linux-2.6.11/include/asm-ia64/signal.h	2005-11-18 21:02:36.000000000 +0000
@@ -146,11 +146,13 @@
 /* Type of a signal handler.  */
 typedef void __user (*__sighandler_t)(int);
 
+#ifndef _SIGNAL_H
 typedef struct sigaltstack {
 	void __user *ss_sp;
 	int ss_flags;
 	size_t ss_size;
 } stack_t;
+#endif
 
 #ifdef __KERNEL__ 
 
--- linux-2.6.11.orig/include/asm-ppc64/signal.h	2005-09-10 14:27:15.000000000 +0000
+++ linux-2.6.11/include/asm-ppc64/signal.h	2005-09-11 08:47:06.000000000 +0000
@@ -8,6 +8,7 @@
 /* Avoid too many header ordering problems.  */
 struct siginfo;
 
+#ifdef __KERNEL__
 #define _NSIG		64
 #define _NSIG_BPW	64
 #define _NSIG_WORDS	(_NSIG / _NSIG_BPW)
@@ -18,6 +19,16 @@
 	unsigned long sig[_NSIG_WORDS];
 } sigset_t;
 
+#else
+
+#define NSIG            32
+#ifndef __sigset_t_defined
+typedef unsigned long sigset_t;
+
+#endif
+
+#endif /* __KERNEL__ */
+
 #define SIGHUP		 1
 #define SIGINT		 2
 #define SIGQUIT		 3
@@ -96,6 +107,8 @@
 
 #define MINSIGSTKSZ	2048
 #define SIGSTKSZ	8192
+
+
 #ifdef __KERNEL__
 
 /*
@@ -126,6 +139,8 @@
 #define SIG_IGN	((__sighandler_t)1)	/* ignore signal */
 #define SIG_ERR	((__sighandler_t)-1)	/* error return from signal */
 
+
+#ifdef __KERNEL__
 struct old_sigaction {
 	__sighandler_t sa_handler;
 	old_sigset_t sa_mask;
@@ -144,16 +159,40 @@
 	struct sigaction sa;
 };
 
+#else
+
+#ifndef _SIGNAL_H
+struct sigaction {
+        union {
+          __sighandler_t _sa_handler;
+          void (*_sa_sigaction)(int, struct siginfo *, void *);
+        } _u;
+	sigset_t sa_mask;
+	unsigned long sa_flags;
+	void (*sa_restorer)(void);
+};
+#endif
+
+#define sa_handler      _u._sa_handler
+#define sa_sigaction    _u._sa_sigaction
+
+#endif /* __KERNEL */
+
+#ifndef _SIGNAL_H
 typedef struct sigaltstack {
 	void __user *ss_sp;
 	int ss_flags;
 	size_t ss_size;
 } stack_t;
+#endif
 
+#ifdef __KERNEL__
 struct pt_regs;
 struct timespec;
 extern int do_signal(sigset_t *oldset, struct pt_regs *regs);
 extern int do_signal32(sigset_t *oldset, struct pt_regs *regs);
 #define ptrace_signal_deliver(regs, cookie) do { } while (0)
 
+#endif /* __KERNEL__ */
+
 #endif /* _ASMPPC64_SIGNAL_H */
--- linux-2.6.11/include/linux/joystick.h	2005-10-18 01:02:08.000000000 +0100
+++ linux-2.6.14/include/linux/joystick.h	2005-10-18 01:02:08.000000000 +0100
@@ -66,10 +66,10 @@
 #define JSIOCSCORR		_IOW('j', 0x21, struct js_corr)			/* set correction values */
 #define JSIOCGCORR		_IOR('j', 0x22, struct js_corr)			/* get correction values */
 
-#define JSIOCSAXMAP		_IOW('j', 0x31, __u8[ABS_MAX])			/* set axis mapping */
-#define JSIOCGAXMAP		_IOR('j', 0x32, __u8[ABS_MAX])			/* get axis mapping */
-#define JSIOCSBTNMAP		_IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC])	/* set button mapping */
-#define JSIOCGBTNMAP		_IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC])	/* get button mapping */
+#define JSIOCSAXMAP		_IOW('j', 0x31, __u8[ABS_MAX + 1])		/* set axis mapping */
+#define JSIOCGAXMAP		_IOR('j', 0x32, __u8[ABS_MAX + 1])		/* get axis mapping */
+#define JSIOCSBTNMAP		_IOW('j', 0x33, __u16[KEY_MAX - BTN_MISC + 1])	/* set button mapping */
+#define JSIOCGBTNMAP		_IOR('j', 0x34, __u16[KEY_MAX - BTN_MISC + 1])	/* get button mapping */
 
 /*
  * Types and constants for get/set correction
@@ -111,18 +111,37 @@
 #define JS_SET_ALL		8
 
 struct JS_DATA_TYPE {
-	int buttons;
-	int x;
-	int y;
+	__u32 buttons;
+	__u32 x;
+	__u32 y;
 };
 
-struct JS_DATA_SAVE_TYPE {
-	int JS_TIMEOUT;
-	int BUSY;
-	long JS_EXPIRETIME;
-	long JS_TIMELIMIT;
+struct JS_DATA_SAVE_TYPE_32 {
+	__u32 JS_TIMEOUT;
+	__u32 BUSY;
+	__u32 JS_EXPIRETIME;
+	__u32 JS_TIMELIMIT;
 	struct JS_DATA_TYPE JS_SAVE;
 	struct JS_DATA_TYPE JS_CORR;
 };
 
+struct JS_DATA_SAVE_TYPE_64 {
+	__u32 JS_TIMEOUT;
+	__u32 BUSY;
+	__u64 JS_EXPIRETIME;
+	__u64 JS_TIMELIMIT;
+	struct JS_DATA_TYPE JS_SAVE;
+	struct JS_DATA_TYPE JS_CORR;
+};
+
+#ifdef __KERNEL__
+#if BITS_PER_LONG == 64
+#define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_64
+#elif BITS_PER_LONG == 32
+#define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_32
+#else
+#error Unexpected BITS_PER_LONG
+#endif
+#endif
+
 #endif /* _LINUX_JOYSTICK_H */
--- linux-2.6.11/include/asm-sparc/signal.h	2005-03-02 07:38:10.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-sparc/signal.h	2005-12-22 13:35:16.000000000 +0000
@@ -108,10 +108,12 @@
 
 typedef unsigned long __old_sigset_t;
 
+#ifndef __sigset_t_defined
+#define __sigset_t_defined
 typedef struct {
 	unsigned long	sig[_NSIG_WORDS];
 } __new_sigset_t;
-
+#endif
 
 #ifdef __KERNEL__
 /* A SunOS sigstack */
--- linux-2.6.11/include/asm-sparc/processor.h	2005-12-22 23:01:10.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-sparc/processor.h	2005-12-22 23:01:03.000000000 +0000
@@ -108,7 +108,7 @@
 
 /* Free all resources held by a thread. */
 #define release_thread(tsk)		do { } while(0)
-extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+extern __kernel_pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
 
 /* Prepare to copy thread state - unlazy all lazy status */
 #define prepare_to_copy(tsk)	do { } while (0)
--- linux-2.6.11/include/asm-ppc64/bitops.h	2005-03-02 07:38:38.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-ppc64/bitops.h	2005-12-22 13:25:21.000000000 +0000
@@ -40,8 +40,6 @@
 #ifndef _PPC64_BITOPS_H
 #define _PPC64_BITOPS_H
 
-#ifdef __KERNEL__
-
 #include <asm/memory.h>
 
 /*
@@ -271,6 +269,8 @@
 	return __ilog2(x & -x);
 }
 
+#ifdef __KERNEL__
+
 /*
  * ffs: find first bit set. This is defined the same way as
  * the libc and compiler builtin ffs routines, therefore
@@ -282,12 +282,16 @@
 	return __ilog2(i & -i) + 1;
 }
 
+#endif
+
 /*
  * fls: find last (most-significant) bit set.
  * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
  */
 #define fls(x) generic_fls(x)
 
+#ifdef __KERNEL__
+
 /*
  * hweightN: returns the hamming weight (i.e. the number
  * of bits set) of a N-bit word
--- linux-2.6.11/include/asm-ppc64/types.h	2006-04-18 16:43:24.000000000 +0100
+++ linux-2.6.11-gentoo/include/asm-ppc64/types.h	2006-04-19 22:58:27.000000000 +0100
@@ -16,6 +16,10 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#ifdef umode_t /* Fix userspace definitions, we do it properly here... */
+#undef umode_t
+#endif
+
 typedef unsigned int umode_t;
 
 /*
--- linux-2.6.11/include/asm-alpha/bitops.h	2005-03-02 07:38:09.000000000 +0000
+++ linux-2.6.11-gentoo/include/asm-alpha/bitops.h	2006-02-21 01:05:38.000000000 +0000
@@ -310,6 +310,8 @@
 	return word ? result : 0;
 }
 
+#endif /* __KERNEL__ */
+
 /*
  * fls: find last bit set.
  */
@@ -322,6 +324,8 @@
 #define fls	generic_fls
 #endif
 
+#ifdef __KERNEL__
+
 /* Compute powers of two for the given integer.  */
 static inline long floor_log2(unsigned long word)
 {