[kernel] generic-2.6/2.6.21: refresh patches
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.21 / 902-darwin_scripts_include.patch
1 --- a/scripts/genksyms/parse.c_shipped
2 +++ b/scripts/genksyms/parse.c_shipped
3 @@ -144,7 +144,9 @@
4  
5  
6  #include <assert.h>
7 +#ifndef __APPLE__
8  #include <malloc.h>
9 +#endif
10  #include "genksyms.h"
11  
12  static int is_typedef;
13 --- a/scripts/genksyms/parse.y
14 +++ b/scripts/genksyms/parse.y
15 @@ -24,7 +24,9 @@
16  %{
17  
18  #include <assert.h>
19 +#ifndef __APPLE__
20  #include <malloc.h>
21 +#endif
22  #include "genksyms.h"
23  
24  static int is_typedef;
25 --- a/scripts/kallsyms.c
26 +++ b/scripts/kallsyms.c
27 @@ -30,6 +30,35 @@
28  #include <stdlib.h>
29  #include <string.h>
30  #include <ctype.h>
31 +#ifdef __APPLE__
32 +/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */
33 +void *memmem (const void *haystack, size_t haystack_len,
34 +                          const void *needle,  size_t needle_len)
35 +{
36 +  const char *begin;
37 +  const char *const last_possible
38 +    = (const char *) haystack + haystack_len - needle_len;
39 +
40 +  if (needle_len == 0)
41 +    /* The first occurrence of the empty string is deemed to occur at
42 +       the beginning of the string.  */
43 +    return (void *) haystack;
44 +
45 +  /* Sanity check, otherwise the loop might search through the whole
46 +     memory.  */
47 +  if (__builtin_expect (haystack_len < needle_len, 0))
48 +    return NULL;
49 +
50 +  for (begin = (const char *) haystack; begin <= last_possible; ++begin)
51 +    if (begin[0] == ((const char *) needle)[0] &&
52 +        !memcmp ((const void *) &begin[1],
53 +                 (const void *) ((const char *) needle + 1),
54 +                 needle_len - 1))
55 +      return (void *) begin;
56 +
57 +  return NULL;
58 +}
59 +#endif
60  
61  #define KSYM_NAME_LEN          127
62  
63 --- a/scripts/kconfig/Makefile
64 +++ b/scripts/kconfig/Makefile
65 @@ -87,6 +87,9 @@ check-lxdialog  := $(srctree)/$(src)/lxd
66  # we really need to do so. (Do not call gcc as part of make mrproper)
67  HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
68  HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
69 +ifeq ($(shell uname -s),Darwin)
70 +HOST_LOADLIBES  += -lncurses
71 +endif
72  
73  HOST_EXTRACFLAGS += -DLOCALE
74  
75 --- a/scripts/mod/file2alias.c
76 +++ b/scripts/mod/file2alias.c
77 @@ -37,7 +37,21 @@ typedef unsigned char        __u8;
78   * even potentially has different endianness and word sizes, since
79   * we handle those differences explicitly below */
80  #include "../../include/linux/mod_devicetable.h"
81 +#ifndef __APPLE__
82  #include "../../include/linux/input.h"
83 +#else
84 +#define EV_MAX                  0x1f
85 +#define KEY_MUTE                113
86 +#define KEY_MIN_INTERESTING     KEY_MUTE
87 +#define KEY_MAX                 0x1ff
88 +#define REL_MAX                 0x0f
89 +#define ABS_MAX                 0x3f
90 +#define MSC_MAX                 0x07
91 +#define LED_MAX                 0x0f
92 +#define SND_MAX                 0x07
93 +#define FF_MAX                 0x7f
94 +#define SW_MAX                  0x0f
95 +#endif
96  
97  #define ADD(str, sep, cond, field)                              \
98  do {                                                            \
99 --- a/scripts/mod/mk_elfconfig.c
100 +++ b/scripts/mod/mk_elfconfig.c
101 @@ -1,7 +1,11 @@
102  #include <stdio.h>
103  #include <stdlib.h>
104  #include <string.h>
105 +#ifndef __APPLE__
106  #include <elf.h>
107 +#else
108 +#include "../../../../../tools/sstrip/include/elf.h"
109 +#endif
110  
111  int
112  main(int argc, char **argv)
113 --- a/scripts/mod/modpost.h
114 +++ b/scripts/mod/modpost.h
115 @@ -7,7 +7,11 @@
116  #include <sys/mman.h>
117  #include <fcntl.h>
118  #include <unistd.h>
119 +#ifndef __APPLE__
120  #include <elf.h>
121 +#else
122 +#include "../../../../../tools/sstrip/include/elf.h"
123 +#endif
124  
125  #include "elfconfig.h"
126  
127 --- a/scripts/mod/sumversion.c
128 +++ b/scripts/mod/sumversion.c
129 @@ -8,6 +8,9 @@
130  #include <errno.h>
131  #include <string.h>
132  #include "modpost.h"
133 +#ifdef __APPLE__
134 +#include <limits.h>
135 +#endif
136  
137  /*
138   * Stolen form Cryptographic API.