summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-04-25 12:48:17 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-04-25 12:48:17 +0000
commit68e38b64b657b9b450c700bebde98075566e4bdd (patch)
tree7a0561f10b980eea014137db8feb260835bcba9b
parente16ac7e15dd48f1dd7f3b8ff98f5eaf12f0a7982 (diff)
downloadmpfr-68e38b64b657b9b450c700bebde98075566e4bdd.tar.gz
Added support for _Noreturn function specifier (ISO C11).
* acinclude.m4: define MPFR_HAVE_NORETURN if _Noreturn is supported. * src/mpfr-impl.h: use _Noreturn when MPFR_HAVE_NORETURN is defined. Tested with GCC 4.6 (no _Noreturn) and 4.7 (supports _Noreturn). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8156 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--acinclude.m49
-rw-r--r--src/mpfr-impl.h17
2 files changed, 20 insertions, 6 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index cfe5e283a..6109d3750 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -137,6 +137,15 @@ AC_CHECK_TYPE( [union fpc_csr],
#endif
])
+dnl Check for _Noreturn function specifier (ISO C11)
+AC_CACHE_CHECK([for _Noreturn], mpfr_cv_have_noreturn, [
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Noreturn void foo(int);]])],
+ mpfr_cv_have_noreturn=yes, mpfr_cv_have_noreturn=no)
+])
+if test "$mpfr_cv_have_noreturn" = "yes"; then
+ AC_DEFINE(MPFR_HAVE_NORETURN,1,[Define if the _Noreturn function specifier is supported.])
+fi
+
dnl Check for fesetround
AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [
saved_LIBS="$LIBS"
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h
index f8434fb16..61211cfa7 100644
--- a/src/mpfr-impl.h
+++ b/src/mpfr-impl.h
@@ -224,13 +224,19 @@ typedef __gmp_const mp_limb_t *mpfr_limb_srcptr;
# error "Can't compute log2(GMP_NUMB_BITS)"
#endif
+#if defined(MPFR_HAVE_NORETURN)
+/* _Noreturn is specified by ISO C11 (Section 6.7.4);
+ in GCC, it is supported as of version 4.7. */
+# define MPFR_NORETURN _Noreturn
+#elif __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
+# define MPFR_NORETURN __attribute__ ((noreturn))
+#else
+# define MPFR_NORETURN
+#endif
+
#if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
-/* For the future: N1478: Supporting the 'noreturn' property in C1x
- http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1478.htm */
-# define MPFR_NORETURN_ATTR __attribute__ ((noreturn))
# define MPFR_CONST_ATTR __attribute__ ((const))
#else
-# define MPFR_NORETURN_ATTR
# define MPFR_CONST_ATTR
#endif
@@ -1928,8 +1934,7 @@ __MPFR_DECLSPEC void mpfr_dump_mant _MPFR_PROTO ((const mp_limb_t *,
__MPFR_DECLSPEC int mpfr_round_near_x _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_uexp_t, int,
mpfr_rnd_t));
-__MPFR_DECLSPEC void mpfr_abort_prec_max _MPFR_PROTO ((void))
- MPFR_NORETURN_ATTR;
+__MPFR_DECLSPEC MPFR_NORETURN void mpfr_abort_prec_max _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mpfr_limb_ptr, gmp_randstate_t,
mpfr_prec_t));