annotate m4/truncf.m4 @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 062361de7628
children e2e6dc79463b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39912
062361de7628 floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
1 # truncf.m4 serial 12
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 39912
diff changeset
2 dnl Copyright (C) 2007, 2010-2019 Free Software Foundation, Inc.
9285
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_TRUNCF],
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
9 m4_divert_text([DEFAULTS], [gl_truncf_required=plain])
9285
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 dnl Persuade glibc <math.h> to declare truncf().
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 if test "$ac_cv_have_decl_truncf" = yes; then
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 dnl Test whether truncf() can be used without libm.
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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>
39912
062361de7628 floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
24 float (*funcptr) (float) = truncf;
13578
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
25 float x;]],
39912
062361de7628 floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
26 [[x = funcptr(x) + truncf(x);]])],
9285
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 [TRUNCF_LIBM=])
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 if test "$TRUNCF_LIBM" = "?"; then
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 save_LIBS="$LIBS"
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 LIBS="$LIBS -lm"
13578
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
31 AC_LINK_IFELSE(
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
32 [AC_LANG_PROGRAM(
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
33 [[#ifndef __NO_MATH_INLINES
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
34 # define __NO_MATH_INLINES 1 /* for glibc */
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
35 #endif
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
36 #include <math.h>
39912
062361de7628 floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
37 float (*funcptr) (float) = truncf;
13578
1e26f884665f Modernize AC_TRY_LINK invocations.
Bruno Haible <bruno@clisp.org>
parents: 13139
diff changeset
38 float x;]],
39912
062361de7628 floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
39 [[x = funcptr(x) + truncf(x);]])],
9285
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 [TRUNCF_LIBM="-lm"])
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 LIBS="$save_LIBS"
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 fi
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 if test "$TRUNCF_LIBM" = "?"; then
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 TRUNCF_LIBM=
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 fi
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
46 m4_ifdef([gl_FUNC_TRUNCF_IEEE], [
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
47 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
48 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
49 AC_CACHE_CHECK([whether truncf works according to ISO C 99 with IEC 60559],
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
50 [gl_cv_func_truncf_ieee],
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
51 [
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
52 save_LIBS="$LIBS"
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
53 LIBS="$LIBS $TRUNCF_LIBM"
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
54 AC_RUN_IFELSE(
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
55 [AC_LANG_SOURCE([[
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
56 #ifndef __NO_MATH_INLINES
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
57 # define __NO_MATH_INLINES 1 /* for glibc */
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
58 #endif
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
59 #include <math.h>
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
60 ]gl_FLOAT_MINUS_ZERO_CODE[
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
61 ]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
62 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
63 int main (int argc, char *argv[])
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
64 {
15291
a9c28bdd16ab floor*-ieee, ceil*-ieee, trunc*-ieee, round*-ieee: More robust checks.
Bruno Haible <bruno@clisp.org>
parents: 15007
diff changeset
65 float (*my_truncf) (float) = argc ? truncf : dummy;
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
66 /* 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
67 if (signbitf (minus_zerof) && !signbitf (my_truncf (minus_zerof)))
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
68 return 1;
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
69 return 0;
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
70 }
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
71 ]])],
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
72 [gl_cv_func_truncf_ieee=yes],
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
73 [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
74 [case "$host_os" in
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
75 # Guess yes on glibc systems.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
76 *-gnu* | gnu*) gl_cv_func_truncf_ieee="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
77 # Guess yes on native Windows.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
78 mingw*) gl_cv_func_truncf_ieee="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
79 # If we don't know, assume the worst.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 18993
diff changeset
80 *) gl_cv_func_truncf_ieee="guessing no" ;;
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
81 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
82 ])
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
83 LIBS="$save_LIBS"
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
84 ])
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
85 case "$gl_cv_func_truncf_ieee" in
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
86 *yes) ;;
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
87 *) REPLACE_TRUNCF=1 ;;
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
88 esac
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
89 fi
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
90 ])
9285
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 else
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 HAVE_DECL_TRUNCF=0
13979
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
93 fi
84d7ae75b38f New module 'truncf-ieee'.
Bruno Haible <bruno@clisp.org>
parents: 13578
diff changeset
94 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
95 dnl No libraries are needed to link lib/truncf.c.
9285
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 TRUNCF_LIBM=
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 fi
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 AC_SUBST([TRUNCF_LIBM])
79e67a783774 New module 'truncf'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 ])