summaryrefslogtreecommitdiff
path: root/autoconf
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-16 00:08:27 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-16 00:08:27 -0700
commit8b6e6bf04f6f62a576ae818758d6d5a58ca69a5d (patch)
tree1aa4af4af6e7ce892da9aaf8d9834356be8c428e /autoconf
parent9fbd9fb8596af9fd4cdf6a962e53f9d5e18d7d87 (diff)
downloadnasm-8b6e6bf04f6f62a576ae818758d6d5a58ca69a5d.tar.gz
config.h: separate function and function pointer attributes; automate
Separate out function and function pointer attributes, as not all versions of all compilers support both. Have macros related to function attributes auto-generated by autoheader. As a result, rename config.h.in to unconfig.h, to make it more obvious that it is really intended to be included from some C programs. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'autoconf')
-rw-r--r--autoconf/gitignore10
-rw-r--r--autoconf/m4/pa_func_attribute.m470
-rw-r--r--autoconf/m4/pa_func_attribute_error.m43
-rw-r--r--autoconf/m4/pa_sym.m43
4 files changed, 71 insertions, 15 deletions
diff --git a/autoconf/gitignore b/autoconf/gitignore
deleted file mode 100644
index 8368d3fa..00000000
--- a/autoconf/gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-/autoconf/aclocal.m4
-/autoconf/compile
-/autoconf/config.*
-/autoconf/install-sh
-/config/config.h
-/config/config.h.in
-/config.log
-/config.status
-/configure
-/Makefile
diff --git a/autoconf/m4/pa_func_attribute.m4 b/autoconf/m4/pa_func_attribute.m4
index 74d35693..476d53bd 100644
--- a/autoconf/m4/pa_func_attribute.m4
+++ b/autoconf/m4/pa_func_attribute.m4
@@ -4,14 +4,23 @@ dnl
dnl See if this compiler supports the equivalent of a specific gcc
dnl attribute on a function, using the __attribute__(()) syntax.
dnl All arguments except the attribute name are optional.
+dnl
dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
-dnl prototype_args, call_args)
+dnl prototype_args, call_args, altname)
+dnl
+dnl This tests the attribute both on a function pointer and on a
+dnl direct function, as some gcc [and others?] versions have problems
+dnl with attributes on function pointers, and we might as well check both.
dnl --------------------------------------------------------------------------
-AC_DEFUN([PA_FUNC_ATTRIBUTE],
+AC_DEFUN([_PA_FUNC_ATTRIBUTE],
[AC_MSG_CHECKING([if $CC supports the $1 function attribute])
+ m4_define([_pa_faa],ifelse([$2],[],[],[($2)]))
+ m4_define([_pa_fam],ifelse([$2],[],[],[(m4_join([,],m4_for(_pa_n,1,m4_count($2),1,[m4_quote([x]_pa_n),])))]))
+ m4_define([_pa_suf],ifelse([$2],[],[],[m4_count($2)]))
+ m4_define([_pa_mac],ifelse([$6],[],[$1_func]_pa_suf,[$6]))
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
AC_INCLUDES_DEFAULT
-extern ifelse([$3],[],[void *],[$3]) __attribute__(($1$2))
+extern ifelse([$3],[],[void *],[$3]) __attribute__(([$1]_pa_faa))
bar(ifelse([$4],[],[int],[$4]));
ifelse([$3],[],[void *],[$3]) foo(void);
ifelse([$3],[],[void *],[$3]) foo(void)
@@ -21,7 +30,60 @@ ifelse([$3],[],[void *],[$3]) foo(void)
}
])],
[AC_MSG_RESULT([yes])
- AC_DEFINE(PA_SYM([HAVE_FUNC_ATTRIBUTE_],[$1]), 1,
+ AC_DEFINE(PA_SYM([HAVE_FUNC_ATTRIBUTE],_pa_suf,[_$1]), 1,
[Define to 1 if your compiler supports __attribute__(($1)) on functions])],
[AC_MSG_RESULT([no])])
+ AH_BOTTOM(m4_quote(m4_join([],
+ [#ifndef ],_pa_mac,[
+# ifdef ],PA_SYM([HAVE_FUNC_ATTRIBUTE],_pa_suf,[_$1]),[
+# define ],_pa_mac,m4_quote(_pa_fam),[ __attribute__(($1],m4_quote(_pa_fam),[))
+# else
+# define ],_pa_mac,m4_quote(_pa_fam),[
+# endif
+#endif])))
+])
+
+AC_DEFUN([_PA_FUNC_PTR_ATTRIBUTE],
+[AC_MSG_CHECKING([if $CC supports the $1 function attribute on pointers])
+ m4_define([_pa_faa],ifelse([$2],[],[],[($2)]))
+ m4_define([_pa_fam],ifelse([$2],[],[],[(m4_join([,],m4_for(_pa_n,1,m4_count($2),1,[m4_quote([x]_pa_n),])))]))
+ m4_define([_pa_suf],ifelse([$2],[],[],[m4_count($2)]))
+ m4_define([_pa_mac],ifelse([$6],[],[$1_func]_pa_suf,[$6])_ptr)
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+AC_INCLUDES_DEFAULT
+extern ifelse([$3],[],[void *],[$3]) __attribute__(([$1]_pa_faa))
+ (*bar1)(ifelse([$4],[],[int],[$4]));
+ifelse([$3],[],[void *],[$3]) foo1(void);
+ifelse([$3],[],[void *],[$3]) foo1(void)
+{
+ ifelse([$3],[void],[],[return])
+ bar1(ifelse([$5],[],[1],[$5]));
+}
+
+typedef ifelse([$3],[],[void *],[$3]) __attribute__(([$1]_pa_faa))
+ (*bar_t)(ifelse([$4],[],[int],[$4]));
+extern bar_t bar2;
+ifelse([$3],[],[void *],[$3]) foo2(void);
+ifelse([$3],[],[void *],[$3]) foo2(void)
+{
+ ifelse([$3],[void],[],[return])
+ bar2(ifelse([$5],[],[1],[$5]));
+}
+ ])],
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE(PA_SYM([HAVE_FUNC_PTR_ATTRIBUTE],_pa_suf,[_$1]), 1,
+ [Define to 1 if your compiler supports __attribute__(($1)) on function pointers])],
+ [AC_MSG_RESULT([no])])
+ AH_BOTTOM(m4_quote(m4_join([],
+ [#ifndef ],_pa_mac,[
+# ifdef ],PA_SYM([HAVE_FUNC_PTR_ATTRIBUTE],_pa_suf,[_$1]),[
+# define ],_pa_mac,m4_quote(_pa_fam),[ __attribute__(($1],m4_quote(_pa_fam),[))
+# else
+# define ],_pa_mac,m4_quote(_pa_fam),[
+# endif
+#endif])))
])
+
+AC_DEFUN([PA_FUNC_ATTRIBUTE],
+[_PA_FUNC_ATTRIBUTE([$1],[$2],[$3],[$4],[$5],[$6])
+ _PA_FUNC_PTR_ATTRIBUTE([$1],[$2],[$3],[$4],[$5],[$6])])
diff --git a/autoconf/m4/pa_func_attribute_error.m4 b/autoconf/m4/pa_func_attribute_error.m4
index 5f87a3b2..5315d261 100644
--- a/autoconf/m4/pa_func_attribute_error.m4
+++ b/autoconf/m4/pa_func_attribute_error.m4
@@ -4,6 +4,9 @@ dnl
dnl See if this compiler supports __attribute__((error("foo")))
dnl The generic version of this doesn't work as it makes the compiler
dnl throw an error by design.
+dnl
+dnl This doesn't use a function pointer because there is no need:
+dnl the error function will never be a function pointer.
dnl --------------------------------------------------------------------------
AC_DEFUN([PA_FUNC_ATTRIBUTE_ERROR],
[AC_MSG_CHECKING([if $CC supports the error function attribute])
diff --git a/autoconf/m4/pa_sym.m4 b/autoconf/m4/pa_sym.m4
index 742a534a..acfea45e 100644
--- a/autoconf/m4/pa_sym.m4
+++ b/autoconf/m4/pa_sym.m4
@@ -4,4 +4,5 @@ dnl
dnl Convert a (semi-) arbitrary string to a CPP symbol
dnl --------------------------------------------------------------------------
AC_DEFUN([PA_SYM],
-[m4_normalize([$1])m4_bpatsubsts(m4_toupper([$2]),[[^ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]+],[_],[^._?\(.*\)_.$],[[\1]])])
+[m4_bpatsubsts(m4_quote(m4_toupper([$*])),
+ [,],[],[[^ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]+],[_],[^._?\(.*\)_.$],[[\1]])])