1 # gethrxtime.m4 serial 2
2 dnl Copyright (C) 2005 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_LIBSOURCES([gethrxtime.c, gethrxtime.h, xtime.h])
12 AC_REQUIRE([gl_ARITHMETIC_HRTIME_T])
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 AC_REQUIRE([gl_XTIME])
15 AC_CHECK_DECLS([gethrtime], [], [], [#include <time.h>])
16 case $ac_cv_have_decl_gethrtime,$gl_cv_arithmetic_hrtime_t in
19 AC_LIBOBJ([gethrxtime])
20 gl_PREREQ_GETHRXTIME;;
24 # Test whether hrtime_t is an arithmetic type.
25 # It is not arithmetic in older Solaris c89 (which insists on
26 # not having a long long int type).
27 AC_DEFUN([gl_ARITHMETIC_HRTIME_T],
29 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
30 AC_CACHE_CHECK([for arithmetic hrtime_t], gl_cv_arithmetic_hrtime_t,
32 [AC_LANG_PROGRAM([#include <time.h>],
33 [hrtime_t x = 0; return x/x;])],
34 [gl_cv_arithmetic_hrtime_t=yes],
35 [gl_cv_arithmetic_hrtime_t=no])])
36 if test $gl_cv_arithmetic_hrtime_t = yes; then
37 AC_DEFINE([HAVE_ARITHMETIC_HRTIME_T], 1,
38 [Define if you have an arithmetic hrtime_t type.])
42 # Prerequisites of lib/xtime.h.
45 AC_REQUIRE([AC_C_INLINE])
46 AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
50 # Prerequisites of lib/gethrxtime.c.
51 AC_DEFUN([gl_PREREQ_GETHRXTIME],
53 AC_REQUIRE([AC_HEADER_TIME])
54 AC_REQUIRE([gl_CLOCK_TIME])
55 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
56 AC_CHECK_FUNCS_ONCE(gettimeofday microuptime nanouptime)
58 if test $ac_cv_func_nanouptime != yes; then
60 AC_CACHE_CHECK([whether CLOCK_MONOTONIC is defined],
61 gl_cv_have_CLOCK_MONOTONIC,
62 [AC_EGREP_CPP([have_CLOCK_MONOTONIC],
65 # ifdef CLOCK_MONOTONIC
69 gl_cv_have_CLOCK_MONOTONIC=yes,
70 gl_cv_have_CLOCK_MONOTONIC=no)])
71 if test $gl_cv_have_CLOCK_MONOTONIC = yes; then
72 LIB_GETHRXTIME=$LIB_CLOCK_GETTIME
74 AC_SUBST([LIB_GETHRXTIME])