Do the Windows oldnames workaround through the C++ GNULIB_NAMESPACE.
[gnulib.git] / m4 / gethrxtime.m4
blob38300727581cc1ec077ea1e3c9d2bf84e67ecd9d
1 # gethrxtime.m4 serial 13
2 dnl Copyright (C) 2005-2006, 2008-2020 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   LIB_GETHRXTIME=
16   if test $ac_cv_have_decl_gethrtime = no \
17      || test $gl_cv_arithmetic_hrtime_t = no; then
18     dnl Find libraries needed to link lib/gethrxtime.c.
19     AC_REQUIRE([gl_CLOCK_TIME])
20     AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
21     AC_CHECK_FUNCS_ONCE([microuptime nanouptime])
22     if test $ac_cv_func_nanouptime != yes \
23        && { test $ac_cv_have_decl_gethrtime = no \
24             || test $gl_cv_arithmetic_hrtime_t = no; }; then
25       AC_CACHE_CHECK([whether CLOCK_MONOTONIC or CLOCK_REALTIME is defined],
26         [gl_cv_have_clock_gettime_macro],
27         [AC_EGREP_CPP([have_clock_gettime_macro],
28           [
29 #          include <time.h>
30 #          if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME
31             have_clock_gettime_macro
32 #          endif
33           ],
34           [gl_cv_have_clock_gettime_macro=yes],
35           [gl_cv_have_clock_gettime_macro=no])])
36       if test $gl_cv_have_clock_gettime_macro = yes; then
37         LIB_GETHRXTIME=$LIB_CLOCK_GETTIME
38       fi
39     fi
40   fi
41   AC_SUBST([LIB_GETHRXTIME])
44 # Test whether hrtime_t is an arithmetic type.
45 # It is not arithmetic in older Solaris c89 (which insists on
46 # not having a long long int type).
47 AC_DEFUN([gl_ARITHMETIC_HRTIME_T],
49   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
50   AC_CACHE_CHECK([for arithmetic hrtime_t], [gl_cv_arithmetic_hrtime_t],
51     [AC_COMPILE_IFELSE(
52        [AC_LANG_PROGRAM([[#include <time.h>]],
53           [[hrtime_t x = 0; return x/x;]])],
54        [gl_cv_arithmetic_hrtime_t=yes],
55        [gl_cv_arithmetic_hrtime_t=no])])
56   if test $gl_cv_arithmetic_hrtime_t = yes; then
57     AC_DEFINE([HAVE_ARITHMETIC_HRTIME_T], [1],
58       [Define if you have an arithmetic hrtime_t type.])
59   fi
62 # Prerequisites of lib/xtime.h.
63 AC_DEFUN([gl_XTIME],
65   :