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