added missing dependencies to fix failing unistr/ tests
[gnulib.git] / m4 / gethrxtime.m4
1 # gethrxtime.m4 serial 9
2 dnl Copyright (C) 2005, 2006, 2008, 2009, 2010 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_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   LIB_GETHRXTIME=
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   AC_SUBST([LIB_GETHRXTIME])
23 ])
24
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],
29 [
30   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
31   AC_CACHE_CHECK([for arithmetic hrtime_t], [gl_cv_arithmetic_hrtime_t],
32     [AC_COMPILE_IFELSE(
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.])
40   fi
41 ])
42
43 # Prerequisites of lib/xtime.h.
44 AC_DEFUN([gl_XTIME],
45 [
46   AC_REQUIRE([AC_C_INLINE])
47   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
48   :
49 ])
50
51 # Prerequisites of lib/gethrxtime.c.
52 AC_DEFUN([gl_PREREQ_GETHRXTIME],
53 [
54   AC_REQUIRE([gl_CLOCK_TIME])
55   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
56   AC_CHECK_FUNCS_ONCE([microuptime nanouptime])
57
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],
62         [
63 #        include <time.h>
64 #        if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME
65           have_clock_gettime_macro
66 #        endif
67         ],
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
72     fi
73   fi
74 ])