1 # gethrxtime.m4 serial 9
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 case $ac_cv_have_decl_gethrtime,$gl_cv_arithmetic_hrtime_t in
19 AC_LIBOBJ([gethrxtime])
20 gl_PREREQ_GETHRXTIME;;
22 AC_SUBST([LIB_GETHRXTIME])
25 # Test whether hrtime_t is an arithmetic type.
26 # It is not arithmetic in older Solaris c89 (which insists on
27 # not having a long long int type).
28 AC_DEFUN([gl_ARITHMETIC_HRTIME_T],
30 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
31 AC_CACHE_CHECK([for arithmetic hrtime_t], [gl_cv_arithmetic_hrtime_t],
33 [AC_LANG_PROGRAM([[#include <time.h>]],
34 [[hrtime_t x = 0; return x/x;]])],
35 [gl_cv_arithmetic_hrtime_t=yes],
36 [gl_cv_arithmetic_hrtime_t=no])])
37 if test $gl_cv_arithmetic_hrtime_t = yes; then
38 AC_DEFINE([HAVE_ARITHMETIC_HRTIME_T], [1],
39 [Define if you have an arithmetic hrtime_t type.])
43 # Prerequisites of lib/xtime.h.
46 AC_REQUIRE([AC_C_INLINE])
47 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
51 # Prerequisites of lib/gethrxtime.c.
52 AC_DEFUN([gl_PREREQ_GETHRXTIME],
54 AC_REQUIRE([gl_CLOCK_TIME])
55 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
56 AC_CHECK_FUNCS_ONCE([microuptime nanouptime])
58 if test $ac_cv_func_nanouptime != yes; then
59 AC_CACHE_CHECK([whether CLOCK_MONOTONIC or CLOCK_REALTIME is defined],
60 gl_cv_have_clock_gettime_macro,
61 [AC_EGREP_CPP([have_clock_gettime_macro],
64 # if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME
65 have_clock_gettime_macro
68 gl_cv_have_clock_gettime_macro=yes,
69 gl_cv_have_clock_gettime_macro=no)])
70 if test $gl_cv_have_clock_gettime_macro = yes; then
71 LIB_GETHRXTIME=$LIB_CLOCK_GETTIME