902-darwin_scripts_include.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. --- a/scripts/genksyms/parse.c_shipped
  2. +++ b/scripts/genksyms/parse.c_shipped
  3. @@ -160,7 +160,9 @@
  4. #include <assert.h>
  5. +#ifndef __APPLE__
  6. #include <malloc.h>
  7. +#endif
  8. #include "genksyms.h"
  9. static int is_typedef;
  10. --- a/scripts/genksyms/parse.y
  11. +++ b/scripts/genksyms/parse.y
  12. @@ -24,7 +24,9 @@
  13. %{
  14. #include <assert.h>
  15. +#ifndef __APPLE__
  16. #include <malloc.h>
  17. +#endif
  18. #include "genksyms.h"
  19. static int is_typedef;
  20. --- a/scripts/kallsyms.c
  21. +++ b/scripts/kallsyms.c
  22. @@ -22,6 +22,35 @@
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <ctype.h>
  26. +#ifdef __APPLE__
  27. +/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */
  28. +void *memmem (const void *haystack, size_t haystack_len,
  29. + const void *needle, size_t needle_len)
  30. +{
  31. + const char *begin;
  32. + const char *const last_possible
  33. + = (const char *) haystack + haystack_len - needle_len;
  34. +
  35. + if (needle_len == 0)
  36. + /* The first occurrence of the empty string is deemed to occur at
  37. + the beginning of the string. */
  38. + return (void *) haystack;
  39. +
  40. + /* Sanity check, otherwise the loop might search through the whole
  41. + memory. */
  42. + if (__builtin_expect (haystack_len < needle_len, 0))
  43. + return NULL;
  44. +
  45. + for (begin = (const char *) haystack; begin <= last_possible; ++begin)
  46. + if (begin[0] == ((const char *) needle)[0] &&
  47. + !memcmp ((const void *) &begin[1],
  48. + (const void *) ((const char *) needle + 1),
  49. + needle_len - 1))
  50. + return (void *) begin;
  51. +
  52. + return NULL;
  53. +}
  54. +#endif
  55. #ifndef ARRAY_SIZE
  56. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  57. --- a/scripts/kconfig/Makefile
  58. +++ b/scripts/kconfig/Makefile
  59. @@ -130,6 +130,9 @@ check-lxdialog := $(srctree)/$(src)/lxd
  60. # we really need to do so. (Do not call gcc as part of make mrproper)
  61. HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
  62. HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
  63. +ifeq ($(shell uname -s),Darwin)
  64. +HOST_LOADLIBES += -lncurses
  65. +endif
  66. HOST_EXTRACFLAGS += -DLOCALE
  67. --- a/scripts/mod/mk_elfconfig.c
  68. +++ b/scripts/mod/mk_elfconfig.c
  69. @@ -1,7 +1,11 @@
  70. #include <stdio.h>
  71. #include <stdlib.h>
  72. #include <string.h>
  73. +#ifndef __APPLE__
  74. #include <elf.h>
  75. +#else
  76. +#include "../../../../../tools/sstrip/include/elf.h"
  77. +#endif
  78. int
  79. main(int argc, char **argv)
  80. --- a/scripts/mod/modpost.h
  81. +++ b/scripts/mod/modpost.h
  82. @@ -7,7 +7,11 @@
  83. #include <sys/mman.h>
  84. #include <fcntl.h>
  85. #include <unistd.h>
  86. +#if !(defined(__APPLE__) || defined(__CYGWIN__))
  87. #include <elf.h>
  88. +#else
  89. +#include "../../../../../tools/sstrip/include/elf.h"
  90. +#endif
  91. #include "elfconfig.h"