902-darwin_scripts_include.patch 2.7 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. @@ -147,6 +147,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. -DLOCALE
  63. +ifeq ($(shell uname -s),Darwin)
  64. +HOST_LOADLIBES += -lncurses
  65. +endif
  66. # ===========================================================================
  67. # Shared Makefile for the various kconfig executables:
  68. --- a/scripts/mod/mk_elfconfig.c
  69. +++ b/scripts/mod/mk_elfconfig.c
  70. @@ -1,7 +1,11 @@
  71. #include <stdio.h>
  72. #include <stdlib.h>
  73. #include <string.h>
  74. +#ifndef __APPLE__
  75. #include <elf.h>
  76. +#else
  77. +#include "../../../../../tools/sstrip/include/elf.h"
  78. +#endif
  79. int
  80. main(int argc, char **argv)
  81. --- a/scripts/mod/modpost.h
  82. +++ b/scripts/mod/modpost.h
  83. @@ -7,7 +7,11 @@
  84. #include <sys/mman.h>
  85. #include <fcntl.h>
  86. #include <unistd.h>
  87. +#if !(defined(__APPLE__) || defined(__CYGWIN__))
  88. #include <elf.h>
  89. +#else
  90. +#include "../../../../../tools/sstrip/include/elf.h"
  91. +#endif
  92. #include "elfconfig.h"