|
|
- From b6b3cdc16eaa50b40623f1589ea51dd43ebb456d Mon Sep 17 00:00:00 2001
- From: Eneas U de Queiroz <cotequeiroz@gmail.com>
- Date: Fri, 8 Oct 2021 14:47:08 -0300
- Subject: [PATCH 2/2] Fix compilation with gcc11
-
- Currently, libbb.h counts on __THROW and __inline being defined. They
- are internal macros used by glibc not meant to be publicly used. This
- causes trouble, at least with a combination of gcc11 and musl, where
- nether have them defined.
-
- Use definitions from <sys/cdefs.h> in gcc 8.4.0 if they're missing.
-
- Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
-
- --- a/include/libbb.h
- +++ b/include/libbb.h
- @@ -120,6 +120,65 @@
- #ifdef DMALLOC
- # include <dmalloc.h>
- #endif
- +
- +/* Compatibility with musl & gcc 11. Taken from <sys/cdefs.h> in gcc 8.4.0 */
- +#ifndef __THROW
- +#ifdef __GNUC__
- +
- +/* All functions, except those with callbacks or those that
- + synchronize memory, are leaf functions. */
- +# if __GNUC_PREREQ (4, 6) && !defined _LIBC
- +# define __LEAF , __leaf__
- +# define __LEAF_ATTR __attribute__ ((__leaf__))
- +# else
- +# define __LEAF
- +# define __LEAF_ATTR
- +# endif
- +
- +/* GCC can always grok prototypes. For C++ programs we add throw()
- + to help it optimize the function calls. But this works only with
- + gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
- + as non-throwing using a function attribute since programs can use
- + the -fexceptions options for C code as well. */
- +# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
- +# define __THROW __attribute__ ((__nothrow__ __LEAF))
- +# define __THROWNL __attribute__ ((__nothrow__))
- +# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
- +# else
- +# if defined __cplusplus && __GNUC_PREREQ (2,8)
- +# define __THROW throw ()
- +# define __THROWNL throw ()
- +# define __NTH(fct) __LEAF_ATTR fct throw ()
- +# else
- +# define __THROW
- +# define __THROWNL
- +# define __NTH(fct) fct
- +# endif
- +# endif
- +
- +#else /* Not GCC. */
- +
- +# define __inline /* No inline functions. */
- +
- +# define __THROW
- +# define __THROWNL
- +# define __NTH(fct) fct
- +
- +#endif /* GCC. */
- +#endif /* __THROW */
- +
- +#ifndef __nonnull
- +/* The nonull function attribute allows to mark pointer parameters which
- + must not be NULL. */
- +#if __GNUC_PREREQ (3,3)
- +# define __nonnull(params) __attribute__ ((__nonnull__ params))
- +#else
- +# define __nonnull(params)
- +#endif
- +#endif /* __nonnull */
- +
- +/* End of compatibility with musl & gcc 11. */
- +
- /* Just in case libc doesn't define some of these... */
- #ifndef _PATH_PASSWD
- #define _PATH_PASSWD "/etc/passwd"
|