Mercurial > hg > octave-jordi > gnulib-hg
annotate m4/truncf.m4 @ 18079:4c948fd76734 default tip master
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 24 Aug 2015 06:09:19 -0700 |
parents | ab58d4870664 |
children |
rev | line source |
---|---|
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
1 # truncf.m4 serial 9 |
17848 | 2 dnl Copyright (C) 2007, 2010-2015 Free Software Foundation, Inc. |
9285 | 3 dnl This file is free software; the Free Software Foundation |
4 dnl gives unlimited permission to copy and/or distribute it, | |
5 dnl with or without modifications, as long as this notice is preserved. | |
6 | |
7 AC_DEFUN([gl_FUNC_TRUNCF], | |
8 [ | |
13979 | 9 m4_divert_text([DEFAULTS], [gl_truncf_required=plain]) |
9285 | 10 AC_REQUIRE([gl_MATH_H_DEFAULTS]) |
11 dnl Persuade glibc <math.h> to declare truncf(). | |
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | |
13 dnl Test whether truncf() is declared. | |
15618
9d4b273deacd
Properly quote AC_CHECK_DECLS' 4th argument.
Bruno Haible <bruno@clisp.org>
parents:
15291
diff
changeset
|
14 AC_CHECK_DECLS([truncf], , , [[#include <math.h>]]) |
9285 | 15 if test "$ac_cv_have_decl_truncf" = yes; then |
16 dnl Test whether truncf() can be used without libm. | |
17 TRUNCF_LIBM=? | |
13578
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
18 AC_LINK_IFELSE( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
19 [AC_LANG_PROGRAM( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
20 [[#ifndef __NO_MATH_INLINES |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
21 # define __NO_MATH_INLINES 1 /* for glibc */ |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
22 #endif |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
23 #include <math.h> |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
24 float x;]], |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
25 [[x = truncf(x);]])], |
9285 | 26 [TRUNCF_LIBM=]) |
27 if test "$TRUNCF_LIBM" = "?"; then | |
28 save_LIBS="$LIBS" | |
29 LIBS="$LIBS -lm" | |
13578
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
30 AC_LINK_IFELSE( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
31 [AC_LANG_PROGRAM( |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
32 [[#ifndef __NO_MATH_INLINES |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
33 # define __NO_MATH_INLINES 1 /* for glibc */ |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
34 #endif |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
35 #include <math.h> |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
36 float x;]], |
1e26f884665f
Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents:
13139
diff
changeset
|
37 [[x = truncf(x);]])], |
9285 | 38 [TRUNCF_LIBM="-lm"]) |
39 LIBS="$save_LIBS" | |
40 fi | |
41 if test "$TRUNCF_LIBM" = "?"; then | |
42 TRUNCF_LIBM= | |
43 fi | |
13979 | 44 m4_ifdef([gl_FUNC_TRUNCF_IEEE], [ |
45 if test $gl_truncf_required = ieee && test $REPLACE_TRUNCF = 0; then | |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
46 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
13979 | 47 AC_CACHE_CHECK([whether truncf works according to ISO C 99 with IEC 60559], |
48 [gl_cv_func_truncf_ieee], | |
49 [ | |
50 save_LIBS="$LIBS" | |
51 LIBS="$LIBS $TRUNCF_LIBM" | |
52 AC_RUN_IFELSE( | |
53 [AC_LANG_SOURCE([[ | |
54 #ifndef __NO_MATH_INLINES | |
55 # define __NO_MATH_INLINES 1 /* for glibc */ | |
56 #endif | |
57 #include <math.h> | |
58 ]gl_FLOAT_MINUS_ZERO_CODE[ | |
59 ]gl_FLOAT_SIGNBIT_CODE[ | |
15291
a9c28bdd16ab
floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.
Bruno Haible <bruno@clisp.org>
parents:
15007
diff
changeset
|
60 static float dummy (float f) { return 0; } |
a9c28bdd16ab
floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.
Bruno Haible <bruno@clisp.org>
parents:
15007
diff
changeset
|
61 int main (int argc, char *argv[]) |
13979 | 62 { |
15291
a9c28bdd16ab
floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.
Bruno Haible <bruno@clisp.org>
parents:
15007
diff
changeset
|
63 float (*my_truncf) (float) = argc ? truncf : dummy; |
13979 | 64 /* Test whether truncf (-0.0f) is -0.0f. */ |
15291
a9c28bdd16ab
floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.
Bruno Haible <bruno@clisp.org>
parents:
15007
diff
changeset
|
65 if (signbitf (minus_zerof) && !signbitf (my_truncf (minus_zerof))) |
13979 | 66 return 1; |
67 return 0; | |
68 } | |
69 ]])], | |
70 [gl_cv_func_truncf_ieee=yes], | |
71 [gl_cv_func_truncf_ieee=no], | |
16811
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
72 [case "$host_os" in |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
73 # Guess yes on glibc systems. |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
74 *-gnu*) gl_cv_func_truncf_ieee="guessing yes" ;; |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
75 # If we don't know, assume the worst. |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
76 *) gl_cv_func_truncf_ieee="guessing no" ;; |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
77 esac |
b187fc49964b
Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
78 ]) |
13979 | 79 LIBS="$save_LIBS" |
80 ]) | |
81 case "$gl_cv_func_truncf_ieee" in | |
82 *yes) ;; | |
83 *) REPLACE_TRUNCF=1 ;; | |
84 esac | |
85 fi | |
86 ]) | |
9285 | 87 else |
88 HAVE_DECL_TRUNCF=0 | |
13979 | 89 fi |
90 if test $HAVE_DECL_TRUNCF = 0 || test $REPLACE_TRUNCF = 1; then | |
15007
d3a315873582
truncf: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
91 dnl No libraries are needed to link lib/truncf.c. |
9285 | 92 TRUNCF_LIBM= |
93 fi | |
94 AC_SUBST([TRUNCF_LIBM]) | |
95 ]) |