summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2018-02-20 12:34:17 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2018-02-20 12:34:17 -0800
commit99d45c850e3962e4c89839dd8531de1c080b3ee7 (patch)
treed86561a75bb0e24cac70ac1c0704cd03ee05dff7
parent53371ddd17b685f8880c22b8b698e494e0f1059b (diff)
downloadnasm-99d45c850e3962e4c89839dd8531de1c080b3ee7.tar.gz
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>
-rw-r--r--aclocal.m427
-rw-r--r--configure.ac7
-rw-r--r--include/compiler.h24
-rw-r--r--include/iflag.h1
4 files changed, 49 insertions, 10 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index bd93193a..36d36cf8 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -172,3 +172,30 @@ AC_DEFUN(_PA_ADD_HEADER,
AC_DEFUN(PA_ADD_HEADERS,
[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])])])
diff --git a/configure.ac b/configure.ac
index 1f492103..7f1e1ce6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -287,6 +287,13 @@ PA_ARG_ENABLED([werror],
)
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 support ccache
dnl
PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
diff --git a/include/compiler.h b/include/compiler.h
index 6e919d3d..95fd5ec4 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -214,15 +214,20 @@ size_t strnlen(const char *s, size_t maxlen);
/*
* Hack to support external-linkage inline functions
*/
-#ifdef __GNUC__
-# ifdef __GNUC_STDC_INLINE__
-# define HAVE_STDC_INLINE
-# else
-# define HAVE_GNU_INLINE
-# endif
-#elif defined(__STDC_VERSION__)
-# if __STDC_VERSION__ >= 199901L
-# define HAVE_STDC_INLINE
+#ifndef HAVE_STDC_INLINE
+# ifdef __GNUC__
+# ifdef __GNUC_STDC_INLINE__
+# define HAVE_STDC_INLINE
+# else
+# define HAVE_GNU_INLINE
+# endif
+# 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
+# define HAVE_STDC_INLINE
+# endif
# endif
#endif
@@ -230,6 +235,7 @@ size_t strnlen(const char *s, size_t maxlen);
# define extern_inline inline
#elif defined(HAVE_GNU_INLINE)
# define extern_inline extern inline
+# define inline_prototypes
#else
# define inline_prototypes
#endif
diff --git a/include/iflag.h b/include/iflag.h
index e8fa6036..5280703e 100644
--- a/include/iflag.h
+++ b/include/iflag.h
@@ -7,7 +7,6 @@
#include <string.h>
#include "iflaggen.h"
-#include "nasmlib.h" /* For ilog2_32() */
#define IF_GENBIT(bit) (UINT32_C(1) << (bit))