| 1 |
# floorl.m4 |
| 2 |
# serial 12 |
| 3 |
dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_FUNC_FLOORL], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_MATH_H_DEFAULTS]) |
| 12 |
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) |
| 13 |
|
| 14 |
dnl Persuade glibc <math.h> to declare floorl(). |
| 15 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 16 |
|
| 17 |
dnl Test whether floorl() is declared. |
| 18 |
AC_CHECK_DECLS([floorl], , , [[#include <math.h>]]) |
| 19 |
if test "$ac_cv_have_decl_floorl" = yes; then |
| 20 |
dnl Test whether floorl() can be used without libm. |
| 21 |
gl_FUNC_FLOORL_LIBS |
| 22 |
if test "$FLOORL_LIBM" = "?"; then |
| 23 |
dnl Sun C 5.0 on Solaris declares floorl() and has it in the system-wide |
| 24 |
dnl libm.so, but not in the libm.so that the compiler uses. |
| 25 |
REPLACE_FLOORL=1 |
| 26 |
fi |
| 27 |
else |
| 28 |
HAVE_DECL_FLOORL=0 |
| 29 |
fi |
| 30 |
if test $HAVE_DECL_FLOORL = 0 || test $REPLACE_FLOORL = 1; then |
| 31 |
dnl Find libraries needed to link lib/floorl.c. |
| 32 |
if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then |
| 33 |
AC_REQUIRE([gl_FUNC_FLOOR]) |
| 34 |
FLOORL_LIBM="$FLOOR_LIBM" |
| 35 |
else |
| 36 |
FLOORL_LIBM= |
| 37 |
fi |
| 38 |
fi |
| 39 |
AC_SUBST([FLOORL_LIBM]) |
| 40 |
]) |
| 41 |
|
| 42 |
# Determines the libraries needed to get the floorl() function. |
| 43 |
# Sets FLOORL_LIBM. |
| 44 |
AC_DEFUN([gl_FUNC_FLOORL_LIBS], |
| 45 |
[ |
| 46 |
gl_CACHE_VAL_SILENT([gl_cv_func_floorl_libm], [ |
| 47 |
gl_cv_func_floorl_libm=? |
| 48 |
AC_LINK_IFELSE( |
| 49 |
[AC_LANG_PROGRAM( |
| 50 |
[[#ifndef __NO_MATH_INLINES |
| 51 |
# define __NO_MATH_INLINES 1 /* for glibc */ |
| 52 |
#endif |
| 53 |
#include <math.h> |
| 54 |
long double (*funcptr) (long double) = floorl; |
| 55 |
long double x;]], |
| 56 |
[[x = funcptr (x) + floorl(x);]])], |
| 57 |
[gl_cv_func_floorl_libm=]) |
| 58 |
if test "$gl_cv_func_floorl_libm" = "?"; then |
| 59 |
saved_LIBS="$LIBS" |
| 60 |
LIBS="$LIBS -lm" |
| 61 |
AC_LINK_IFELSE( |
| 62 |
[AC_LANG_PROGRAM( |
| 63 |
[[#ifndef __NO_MATH_INLINES |
| 64 |
# define __NO_MATH_INLINES 1 /* for glibc */ |
| 65 |
#endif |
| 66 |
#include <math.h> |
| 67 |
long double (*funcptr) (long double) = floorl; |
| 68 |
long double x;]], |
| 69 |
[[x = funcptr (x) + floorl(x);]])], |
| 70 |
[gl_cv_func_floorl_libm="-lm"]) |
| 71 |
LIBS="$saved_LIBS" |
| 72 |
fi |
| 73 |
]) |
| 74 |
FLOORL_LIBM="$gl_cv_func_floorl_libm" |
| 75 |
]) |