| 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.
|
|---|
| 6 |
|
|---|
| 7 | dnl Written by Paul Eggert.
|
|---|
| 8 |
|
|---|
| 9 | AC_DEFUN([gl_GETHRXTIME],
|
|---|
| 10 | [
|
|---|
| 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
|
|---|
| 17 | yes,yes) ;;
|
|---|
| 18 | *)
|
|---|
| 19 | AC_LIBOBJ([gethrxtime])
|
|---|
| 20 | gl_PREREQ_GETHRXTIME;;
|
|---|
| 21 | esac
|
|---|
| 22 | ])
|
|---|
| 23 |
|
|---|
| 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],
|
|---|
| 28 | [
|
|---|
| 29 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|---|
| 30 | AC_CACHE_CHECK([for arithmetic hrtime_t], gl_cv_arithmetic_hrtime_t,
|
|---|
| 31 | [AC_COMPILE_IFELSE(
|
|---|
| 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.])
|
|---|
| 39 | fi
|
|---|
| 40 | ])
|
|---|
| 41 |
|
|---|
| 42 | # Prerequisites of lib/xtime.h.
|
|---|
| 43 | AC_DEFUN([gl_XTIME],
|
|---|
| 44 | [
|
|---|
| 45 | AC_REQUIRE([AC_C_INLINE])
|
|---|
| 46 | AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
|
|---|
| 47 | :
|
|---|
| 48 | ])
|
|---|
| 49 |
|
|---|
| 50 | # Prerequisites of lib/gethrxtime.c.
|
|---|
| 51 | AC_DEFUN([gl_PREREQ_GETHRXTIME],
|
|---|
| 52 | [
|
|---|
| 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)
|
|---|
| 57 |
|
|---|
| 58 | if test $ac_cv_func_nanouptime != yes; then
|
|---|
| 59 | LIB_GETHRXTIME=
|
|---|
| 60 | AC_CACHE_CHECK([whether CLOCK_MONOTONIC is defined],
|
|---|
| 61 | gl_cv_have_CLOCK_MONOTONIC,
|
|---|
| 62 | [AC_EGREP_CPP([have_CLOCK_MONOTONIC],
|
|---|
| 63 | [
|
|---|
| 64 | # include <time.h>
|
|---|
| 65 | # ifdef CLOCK_MONOTONIC
|
|---|
| 66 | have_CLOCK_MONOTONIC
|
|---|
| 67 | # endif
|
|---|
| 68 | ],
|
|---|
| 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
|
|---|
| 73 | fi
|
|---|
| 74 | AC_SUBST([LIB_GETHRXTIME])
|
|---|
| 75 | fi
|
|---|
| 76 | ])
|
|---|