prepare for the transition to linux 2.6.22 - make it possible to override the kernel...
[openwrt/openwrt.git] / target / linux / generic-2.6 / patches-2.6.22 / 902-darwin_scripts_include.patch
1 diff -urN linux-2.6.21.1.old/scripts/genksyms/parse.c_shipped linux-2.6.21.1.dev/scripts/genksyms/parse.c_shipped
2 --- linux-2.6.21.1.old/scripts/genksyms/parse.c_shipped 2007-04-27 23:49:26.000000000 +0200
3 +++ linux-2.6.21.1.dev/scripts/genksyms/parse.c_shipped 2007-05-26 21:26:23.565690112 +0200
4 @@ -144,7 +144,9 @@
5
6
7 #include <assert.h>
8 +#ifndef __APPLE__
9 #include <malloc.h>
10 +#endif
11 #include "genksyms.h"
12
13 static int is_typedef;
14 diff -urN linux-2.6.21.1.old/scripts/genksyms/parse.y linux-2.6.21.1.dev/scripts/genksyms/parse.y
15 --- linux-2.6.21.1.old/scripts/genksyms/parse.y 2007-04-27 23:49:26.000000000 +0200
16 +++ linux-2.6.21.1.dev/scripts/genksyms/parse.y 2007-05-26 21:26:23.563690416 +0200
17 @@ -24,7 +24,9 @@
18 %{
19
20 #include <assert.h>
21 +#ifndef __APPLE__
22 #include <malloc.h>
23 +#endif
24 #include "genksyms.h"
25
26 static int is_typedef;
27 diff -urN linux-2.6.21.1.old/scripts/kallsyms.c linux-2.6.21.1.dev/scripts/kallsyms.c
28 --- linux-2.6.21.1.old/scripts/kallsyms.c 2007-04-27 23:49:26.000000000 +0200
29 +++ linux-2.6.21.1.dev/scripts/kallsyms.c 2007-05-26 21:26:23.579687984 +0200
30 @@ -30,6 +30,35 @@
31 #include <stdlib.h>
32 #include <string.h>
33 #include <ctype.h>
34 +#ifdef __APPLE__
35 +/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */
36 +void *memmem (const void *haystack, size_t haystack_len,
37 + const void *needle, size_t needle_len)
38 +{
39 + const char *begin;
40 + const char *const last_possible
41 + = (const char *) haystack + haystack_len - needle_len;
42 +
43 + if (needle_len == 0)
44 + /* The first occurrence of the empty string is deemed to occur at
45 + the beginning of the string. */
46 + return (void *) haystack;
47 +
48 + /* Sanity check, otherwise the loop might search through the whole
49 + memory. */
50 + if (__builtin_expect (haystack_len < needle_len, 0))
51 + return NULL;
52 +
53 + for (begin = (const char *) haystack; begin <= last_possible; ++begin)
54 + if (begin[0] == ((const char *) needle)[0] &&
55 + !memcmp ((const void *) &begin[1],
56 + (const void *) ((const char *) needle + 1),
57 + needle_len - 1))
58 + return (void *) begin;
59 +
60 + return NULL;
61 +}
62 +#endif
63
64 #define KSYM_NAME_LEN 127
65
66 diff -urN linux-2.6.21.1.old/scripts/kconfig/Makefile linux-2.6.21.1.dev/scripts/kconfig/Makefile
67 --- linux-2.6.21.1.old/scripts/kconfig/Makefile 2007-04-27 23:49:26.000000000 +0200
68 +++ linux-2.6.21.1.dev/scripts/kconfig/Makefile 2007-05-26 21:26:23.553691936 +0200
69 @@ -87,6 +87,9 @@
70 # we really need to do so. (Do not call gcc as part of make mrproper)
71 HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
72 HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
73 +ifeq ($(shell uname -s),Darwin)
74 +HOST_LOADLIBES += -lncurses
75 +endif
76
77 HOST_EXTRACFLAGS += -DLOCALE
78
79 diff -urN linux-2.6.21.1.old/scripts/mod/mk_elfconfig.c linux-2.6.21.1.dev/scripts/mod/mk_elfconfig.c
80 --- linux-2.6.21.1.old/scripts/mod/mk_elfconfig.c 2007-04-27 23:49:26.000000000 +0200
81 +++ linux-2.6.21.1.dev/scripts/mod/mk_elfconfig.c 2007-05-26 21:26:23.553691936 +0200
82 @@ -1,7 +1,11 @@
83 #include <stdio.h>
84 #include <stdlib.h>
85 #include <string.h>
86 +#ifndef __APPLE__
87 #include <elf.h>
88 +#else
89 +#include "../../../../../tools/sstrip/include/elf.h"
90 +#endif
91
92 int
93 main(int argc, char **argv)
94 diff -urN linux-2.6.21.1.old/scripts/mod/modpost.h linux-2.6.21.1.dev/scripts/mod/modpost.h
95 --- linux-2.6.21.1.old/scripts/mod/modpost.h 2007-04-27 23:49:26.000000000 +0200
96 +++ linux-2.6.21.1.dev/scripts/mod/modpost.h 2007-05-26 21:26:23.553691936 +0200
97 @@ -7,7 +7,11 @@
98 #include <sys/mman.h>
99 #include <fcntl.h>
100 #include <unistd.h>
101 +#ifndef __APPLE__
102 #include <elf.h>
103 +#else
104 +#include "../../../../../tools/sstrip/include/elf.h"
105 +#endif
106
107 #include "elfconfig.h"
108