Debian Codegraph @

m4/gettime.m4

raw
1 # gettime.m4 serial 14
2 dnl Copyright (C) 2002, 2004-2006, 2009-2023 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 AC_DEFUN([gl_GETTIME],
8 [
9 dnl Prerequisites of lib/gettime.c.
10 AC_REQUIRE([gl_CLOCK_TIME])
11 AC_REQUIRE([gl_TIMESPEC])
12
13 AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET])
14 if test $gl_cv_func_timespec_get = yes; then
15 AC_DEFINE([HAVE_TIMESPEC_GET], [1],
16 [Define if you have the timespec_get function.])
17 fi
18 ])
19
20 dnl Tests whether the function timespec_get exists.
21 dnl Sets gl_cv_func_timespec_get and gl_cv_onwards_func_timespec_get.
22 AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET],
23 [
24 AC_REQUIRE([AC_CANONICAL_HOST])
25
26 dnl Persuade OpenBSD <time.h> to declare timespec_get().
27 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
28
29 dnl We can't use AC_CHECK_FUNC here, because timespec_get() is defined as a
30 dnl static inline function in <time.h> on MSVC 14.
31 dnl But at the same time, we need to notice a missing declaration, like
32 dnl gl_CHECK_FUNCS_ANDROID does.
33 AC_CHECK_DECL([timespec_get], , , [[#include <time.h>]])
34 AC_CACHE_CHECK([for timespec_get], [gl_cv_onwards_func_timespec_get],
35 [if test $ac_cv_have_decl_timespec_get = yes; then
36 AC_LINK_IFELSE(
37 [AC_LANG_PROGRAM(
38 [[#include <time.h>
39 struct timespec ts;
40 ]],
41 [[return timespec_get (&ts, 0);]])
42 ],
43 [gl_cv_onwards_func_timespec_get=yes],
44 [gl_cv_onwards_func_timespec_get=no])
45 else
46 gl_cv_onwards_func_timespec_get=no
47 fi
48 case "$host_os" in
49 linux*-android*)
50 if test $gl_cv_onwards_func_timespec_get = no; then
51 gl_cv_onwards_func_timespec_get='future OS version'
52 fi
53 ;;
54 esac
55 ])
56 case "$gl_cv_onwards_func_timespec_get" in
57 future*) gl_cv_func_timespec_get=no ;;
58 *) gl_cv_func_timespec_get=$gl_cv_onwards_func_timespec_get ;;
59 esac
60 ])
61
62 AC_DEFUN([gl_GETTIME_RES],
63 [
64 dnl Prerequisites of lib/gettime-res.c.
65 AC_REQUIRE([gl_CLOCK_TIME])
66 AC_REQUIRE([gl_TIMESPEC])
67 AC_CHECK_FUNCS_ONCE([timespec_getres])
68 ])