1 # gethrxtime.m4 serial 6
2 dnl Copyright (C) 2005, 2006 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>])
15 case $ac_cv_have_decl_gethrtime,$gl_cv_arithmetic_hrtime_t in
18 AC_LIBOBJ([gethrxtime])
19 gl_PREREQ_GETHRXTIME;;
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],
28 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
29 AC_CACHE_CHECK([for arithmetic hrtime_t], gl_cv_arithmetic_hrtime_t,
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.])
41 # Prerequisites of lib/xtime.h.
44 AC_REQUIRE([AC_C_INLINE])
45 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
49 # Prerequisites of lib/gethrxtime.c.
50 AC_DEFUN([gl_PREREQ_GETHRXTIME],
52 AC_REQUIRE([gl_CLOCK_TIME])
53 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
54 AC_CHECK_FUNCS_ONCE(microuptime nanouptime)
56 if test $ac_cv_func_nanouptime != yes; then
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],
63 # if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME
64 have_clock_gettime_macro
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
72 AC_SUBST([LIB_GETHRXTIME])