1 # gethrxtime.m4 serial 10
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.
7 dnl Written by Paul Eggert.
9 AC_DEFUN([gl_GETHRXTIME],
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>])
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],
28 # if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME
29 have_clock_gettime_macro
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
39 AC_SUBST([LIB_GETHRXTIME])
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],
47 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
48 AC_CACHE_CHECK([for arithmetic hrtime_t], [gl_cv_arithmetic_hrtime_t],
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.])
60 # Prerequisites of lib/xtime.h.
63 AC_REQUIRE([AC_C_INLINE])
64 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
68 # Prerequisites of lib/gethrxtime.c.
69 AC_DEFUN([gl_PREREQ_GETHRXTIME],
71 AC_CHECK_FUNCS_ONCE([microuptime])