0001-Fix-function-declaration-protection-for-glibc-alread.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 1f8a3f7bccfc84b195218ad0086ebd57049c3490 Mon Sep 17 00:00:00 2001
  2. From: Guillem Jover <guillem@hadrons.org>
  3. Date: Tue, 6 Mar 2018 01:39:45 +0100
  4. Subject: [PATCH] Fix function declaration protection for glibc already
  5. providing them
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. On non-glibc based systems we cannot unconditionally use the
  10. __GLIBC_PREREQ macro as it gets expanded before evaluation. Instead,
  11. if it is undefined, define it to 0.
  12. We should also always declare these functions on non-glibc based
  13. systems. And on systems with a new enough glibc, which provides these
  14. functions, we should still provide the declarations if _GNU_SOURCE
  15. is *not* defined.
  16. Backported from:
  17. https://cgit.freedesktop.org/libbsd/patch/?id=1f8a3f7bccfc84b195218ad0086ebd57049c3490
  18. Reported-by: Jörg Krause <joerg.krause@embedded.rocks>
  19. Signed-off-by: Guillem Jover <guillem@hadrons.org>
  20. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
  21. ---
  22. include/bsd/stdlib.h | 3 ++-
  23. include/bsd/string.h | 3 ++-
  24. include/bsd/sys/cdefs.h | 8 ++++++++
  25. 3 files changed, 12 insertions(+), 2 deletions(-)
  26. diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h
  27. index 8d33d1f..a5b063c 100644
  28. --- a/include/bsd/stdlib.h
  29. +++ b/include/bsd/stdlib.h
  30. @@ -71,7 +71,8 @@ int sradixsort(const unsigned char **base, int nmemb,
  31. const unsigned char *table, unsigned endbyte);
  32. void *reallocf(void *ptr, size_t size);
  33. -#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 26)
  34. +#if !defined(__GLIBC__) || \
  35. + (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 26) || !defined(_GNU_SOURCE)))
  36. void *reallocarray(void *ptr, size_t nmemb, size_t size);
  37. #endif
  38. diff --git a/include/bsd/string.h b/include/bsd/string.h
  39. index 29097f6..f987fee 100644
  40. --- a/include/bsd/string.h
  41. +++ b/include/bsd/string.h
  42. @@ -46,7 +46,8 @@ size_t strlcat(char *dst, const char *src, size_t siz);
  43. char *strnstr(const char *str, const char *find, size_t str_len);
  44. void strmode(mode_t mode, char *str);
  45. -#if defined(_GNU_SOURCE) && defined(__GLIBC__) && !__GLIBC_PREREQ(2, 25)
  46. +#if !defined(__GLIBC__) || \
  47. + (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE)))
  48. void explicit_bzero(void *buf, size_t len);
  49. #endif
  50. __END_DECLS
  51. diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
  52. index b4c8f30..d1cc419 100644
  53. --- a/include/bsd/sys/cdefs.h
  54. +++ b/include/bsd/sys/cdefs.h
  55. @@ -58,6 +58,14 @@
  56. #endif
  57. #endif
  58. +/*
  59. + * On non-glibc based systems, we cannot unconditionally use the
  60. + * __GLIBC_PREREQ macro as it gets expanded before evaluation.
  61. + */
  62. +#ifndef __GLIBC_PREREQ
  63. +#define __GLIBC_PREREQ(maj, min) 0
  64. +#endif
  65. +
  66. /*
  67. * Some kFreeBSD headers expect those macros to be set for sanity checks.
  68. */
  69. --
  70. 2.16.2