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