You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.5 KiB

  1. From b6b3cdc16eaa50b40623f1589ea51dd43ebb456d Mon Sep 17 00:00:00 2001
  2. From: Eneas U de Queiroz <cotequeiroz@gmail.com>
  3. Date: Fri, 8 Oct 2021 14:47:08 -0300
  4. Subject: [PATCH 2/2] Fix compilation with gcc11
  5. Currently, libbb.h counts on __THROW and __inline being defined. They
  6. are internal macros used by glibc not meant to be publicly used. This
  7. causes trouble, at least with a combination of gcc11 and musl, where
  8. nether have them defined.
  9. Use definitions from <sys/cdefs.h> in gcc 8.4.0 if they're missing.
  10. Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
  11. --- a/include/libbb.h
  12. +++ b/include/libbb.h
  13. @@ -120,6 +120,65 @@
  14. #ifdef DMALLOC
  15. # include <dmalloc.h>
  16. #endif
  17. +
  18. +/* Compatibility with musl & gcc 11. Taken from <sys/cdefs.h> in gcc 8.4.0 */
  19. +#ifndef __THROW
  20. +#ifdef __GNUC__
  21. +
  22. +/* All functions, except those with callbacks or those that
  23. + synchronize memory, are leaf functions. */
  24. +# if __GNUC_PREREQ (4, 6) && !defined _LIBC
  25. +# define __LEAF , __leaf__
  26. +# define __LEAF_ATTR __attribute__ ((__leaf__))
  27. +# else
  28. +# define __LEAF
  29. +# define __LEAF_ATTR
  30. +# endif
  31. +
  32. +/* GCC can always grok prototypes. For C++ programs we add throw()
  33. + to help it optimize the function calls. But this works only with
  34. + gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
  35. + as non-throwing using a function attribute since programs can use
  36. + the -fexceptions options for C code as well. */
  37. +# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
  38. +# define __THROW __attribute__ ((__nothrow__ __LEAF))
  39. +# define __THROWNL __attribute__ ((__nothrow__))
  40. +# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
  41. +# else
  42. +# if defined __cplusplus && __GNUC_PREREQ (2,8)
  43. +# define __THROW throw ()
  44. +# define __THROWNL throw ()
  45. +# define __NTH(fct) __LEAF_ATTR fct throw ()
  46. +# else
  47. +# define __THROW
  48. +# define __THROWNL
  49. +# define __NTH(fct) fct
  50. +# endif
  51. +# endif
  52. +
  53. +#else /* Not GCC. */
  54. +
  55. +# define __inline /* No inline functions. */
  56. +
  57. +# define __THROW
  58. +# define __THROWNL
  59. +# define __NTH(fct) fct
  60. +
  61. +#endif /* GCC. */
  62. +#endif /* __THROW */
  63. +
  64. +#ifndef __nonnull
  65. +/* The nonull function attribute allows to mark pointer parameters which
  66. + must not be NULL. */
  67. +#if __GNUC_PREREQ (3,3)
  68. +# define __nonnull(params) __attribute__ ((__nonnull__ params))
  69. +#else
  70. +# define __nonnull(params)
  71. +#endif
  72. +#endif /* __nonnull */
  73. +
  74. +/* End of compatibility with musl & gcc 11. */
  75. +
  76. /* Just in case libc doesn't define some of these... */
  77. #ifndef _PATH_PASSWD
  78. #define _PATH_PASSWD "/etc/passwd"