mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
Fix problem with C99 inlines and -Werror=missing-prototypes
Some older versions of gcc (gcc 4.2.1 at least) produce a warning, promoted to error, on C99 inlines. Do some work to figure out if we need to fall back to GNU inline syntax. Fix some issues with GNU inline syntax. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
27
aclocal.m4
vendored
27
aclocal.m4
vendored
@@ -172,3 +172,30 @@ AC_DEFUN(_PA_ADD_HEADER,
|
|||||||
|
|
||||||
AC_DEFUN(PA_ADD_HEADERS,
|
AC_DEFUN(PA_ADD_HEADERS,
|
||||||
[m4_map_args_w([$1],[_PA_ADD_HEADER(],[)])])
|
[m4_map_args_w([$1],[_PA_ADD_HEADER(],[)])])
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------
|
||||||
|
dnl PA_CHECK_BAD_STDC_INLINE
|
||||||
|
dnl
|
||||||
|
dnl Some versions of gcc seem to apply -Wmissing-prototypes to C99
|
||||||
|
dnl inline functions, which means we need to use GNU inline syntax
|
||||||
|
dnl --------------------------------------------------------------------------
|
||||||
|
AC_DEFUN(PA_CHECK_BAD_STDC_INLINE,
|
||||||
|
[AC_MSG_CHECKING([if $CC supports C99 external inlines])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||||
|
AC_INCLUDES_DEFAULT
|
||||||
|
|
||||||
|
/* Don't mistake GNU inlines for c99 */
|
||||||
|
#ifdef __GNUC_GNU_INLINE__
|
||||||
|
# error "Using gnu inline standard"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline int foo(int x)
|
||||||
|
{
|
||||||
|
return x+1;
|
||||||
|
}
|
||||||
|
])],
|
||||||
|
[AC_MSG_RESULT([yes])
|
||||||
|
AC_DEFINE(HAVE_STDC_INLINE, 1,
|
||||||
|
[Define to 1 if your compiler supports C99 extern inline])],
|
||||||
|
[AC_MSG_RESULT([no])
|
||||||
|
PA_ADD_CFLAGS([-fgnu89-inline])])])
|
||||||
|
@@ -286,6 +286,13 @@ PA_ARG_ENABLED([werror],
|
|||||||
PA_ADD_CFLAGS([-Werror=vla])]
|
PA_ADD_CFLAGS([-Werror=vla])]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl On some versions of gcc, -Werror=missing-prototypes causes problems
|
||||||
|
dnl with C99-style external inlines. Test this *after* adding the -Werror
|
||||||
|
dnl options.
|
||||||
|
dnl
|
||||||
|
PA_CHECK_BAD_STDC_INLINE
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl support ccache
|
dnl support ccache
|
||||||
dnl
|
dnl
|
||||||
|
@@ -214,22 +214,28 @@ size_t strnlen(const char *s, size_t maxlen);
|
|||||||
/*
|
/*
|
||||||
* Hack to support external-linkage inline functions
|
* Hack to support external-linkage inline functions
|
||||||
*/
|
*/
|
||||||
#ifdef __GNUC__
|
#ifndef HAVE_STDC_INLINE
|
||||||
|
# ifdef __GNUC__
|
||||||
# ifdef __GNUC_STDC_INLINE__
|
# ifdef __GNUC_STDC_INLINE__
|
||||||
# define HAVE_STDC_INLINE
|
# define HAVE_STDC_INLINE
|
||||||
# else
|
# else
|
||||||
# define HAVE_GNU_INLINE
|
# define HAVE_GNU_INLINE
|
||||||
# endif
|
# endif
|
||||||
#elif defined(__STDC_VERSION__)
|
# elif defined(__GNUC_GNU_INLINE__)
|
||||||
|
/* Some other compiler implementing only GNU inline semantics? */
|
||||||
|
# define HAVE_GNU_INLINE
|
||||||
|
# elif defined(__STDC_VERSION__)
|
||||||
# if __STDC_VERSION__ >= 199901L
|
# if __STDC_VERSION__ >= 199901L
|
||||||
# define HAVE_STDC_INLINE
|
# define HAVE_STDC_INLINE
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STDC_INLINE
|
#ifdef HAVE_STDC_INLINE
|
||||||
# define extern_inline inline
|
# define extern_inline inline
|
||||||
#elif defined(HAVE_GNU_INLINE)
|
#elif defined(HAVE_GNU_INLINE)
|
||||||
# define extern_inline extern inline
|
# define extern_inline extern inline
|
||||||
|
# define inline_prototypes
|
||||||
#else
|
#else
|
||||||
# define inline_prototypes
|
# define inline_prototypes
|
||||||
#endif
|
#endif
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "iflaggen.h"
|
#include "iflaggen.h"
|
||||||
#include "nasmlib.h" /* For ilog2_32() */
|
|
||||||
|
|
||||||
#define IF_GENBIT(bit) (UINT32_C(1) << (bit))
|
#define IF_GENBIT(bit) (UINT32_C(1) << (bit))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user