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