Properly quote AC_CHECK_DECLS' 4th argument.
[gnulib.git] / m4 / gethrxtime.m4
1 # gethrxtime.m4 serial 11
2 dnl Copyright (C) 2005-2006, 2008-2011 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 dnl Written by Paul Eggert.
8
9 AC_DEFUN([gl_GETHRXTIME],
10 [
11   AC_REQUIRE([gl_ARITHMETIC_HRTIME_T])
12   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13   AC_REQUIRE([gl_XTIME])
14   AC_CHECK_DECLS([gethrtime], [], [], [[#include <time.h>]])
15   LIB_GETHRXTIME=
16   if test $ac_cv_have_decl_gethrtime = no \
17      || test $gl_cv_arithmetic_hrtime_t = no; then
18     dnl Find libraries needed to link lib/gethrxtime.c.
19     AC_REQUIRE([gl_CLOCK_TIME])
20     AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
21     AC_CHECK_FUNCS_ONCE([nanouptime])
22     if test $ac_cv_func_nanouptime != yes; then
23       AC_CACHE_CHECK([whether CLOCK_MONOTONIC or CLOCK_REALTIME is defined],
24         [gl_cv_have_clock_gettime_macro],
25         [AC_EGREP_CPP([have_clock_gettime_macro],
26           [
27 #          include <time.h>
28 #          if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME
29             have_clock_gettime_macro
30 #          endif
31           ],
32           [gl_cv_have_clock_gettime_macro=yes],
33           [gl_cv_have_clock_gettime_macro=no])])
34       if test $gl_cv_have_clock_gettime_macro = yes; then
35         LIB_GETHRXTIME=$LIB_CLOCK_GETTIME
36       fi
37     fi
38   fi
39   AC_SUBST([LIB_GETHRXTIME])
40 ])
41
42 # Test whether hrtime_t is an arithmetic type.
43 # It is not arithmetic in older Solaris c89 (which insists on
44 # not having a long long int type).
45 AC_DEFUN([gl_ARITHMETIC_HRTIME_T],
46 [
47   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
48   AC_CACHE_CHECK([for arithmetic hrtime_t], [gl_cv_arithmetic_hrtime_t],
49     [AC_COMPILE_IFELSE(
50        [AC_LANG_PROGRAM([[#include <time.h>]],
51           [[hrtime_t x = 0; return x/x;]])],
52        [gl_cv_arithmetic_hrtime_t=yes],
53        [gl_cv_arithmetic_hrtime_t=no])])
54   if test $gl_cv_arithmetic_hrtime_t = yes; then
55     AC_DEFINE([HAVE_ARITHMETIC_HRTIME_T], [1],
56       [Define if you have an arithmetic hrtime_t type.])
57   fi
58 ])
59
60 # Prerequisites of lib/xtime.h.
61 AC_DEFUN([gl_XTIME],
62 [
63   AC_REQUIRE([AC_C_INLINE])
64   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
65   :
66 ])
67
68 # Prerequisites of lib/gethrxtime.c.
69 AC_DEFUN([gl_PREREQ_GETHRXTIME],
70 [
71   AC_CHECK_FUNCS_ONCE([microuptime])
72   :
73 ])