210-darwin_scripts_include.patch 2.3 KB

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