Implement 'round', 'roundf', 'roundl' modules.
[gnulib.git] / m4 / roundl.m4
1 # roundl.m4 serial 1
2 dnl Copyright (C) 2007 Free Software Foundation, Inc.
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_ROUNDL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   dnl Persuade glibc <math.h> to declare roundl().
11   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12   dnl Test whether roundl() is declared.
13   gl_CHECK_LIBM_FUNC([roundl], [x = roundl(x);], [], [
14     dnl No.  Are both floorl() and ceill() available?  If so then we can use
15     dnl them to implement roundl(), on the assumption that they're fast.
16     gl_CHECK_LIBM_FUNC([floorl], [x = floorl(x);], [
17       AC_CHECK_DECL([ceill], 
18         [dnl Yes.  Both are declared.  Link against the necessary library.
19          ROUNDL_LIBM="$FLOORL_LIBM"],
20         [: dnl No. We will use an implementation that doesn't need them.
21 ], [#include <math.h>
22 ])])])])