diff --git a/lib/time.in.h b/lib/time.in.h index 6d4c771963..4bd5488edc 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -112,11 +112,22 @@ struct __time_t_must_be_integral { /* Set *TS to the current time, and return BASE. Upon failure, return 0. */ # if @GNULIB_TIMESPEC_GET@ -# if ! @HAVE_TIMESPEC_GET@ +# ifdef _MSC_VER +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define timespec_get rpl_timespec_get +# endif +_GL_FUNCDECL_RPL (timespec_get, int, + (struct timespec *ts, int base) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (timespec_get, int, + (struct timespec *ts, int base)); +# else +# if ! @HAVE_TIMESPEC_GET@ _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); +# endif _GL_CXXALIASWARN (timespec_get); # endif diff --git a/m4/gettime.m4 b/m4/gettime.m4 index c3e0713b57..f0aeb4d0e4 100644 --- a/m4/gettime.m4 +++ b/m4/gettime.m4 @@ -1,4 +1,4 @@ -# gettime.m4 serial 12 +# gettime.m4 serial 11 dnl Copyright (C) 2002, 2004-2006, 2009-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,34 +9,7 @@ AC_DEFUN([gl_GETTIME], dnl Prerequisites of lib/gettime.c. AC_REQUIRE([gl_CLOCK_TIME]) AC_REQUIRE([gl_TIMESPEC]) - - AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET]) - if test $gl_cv_func_timespec_get = yes; then - AC_DEFINE([HAVE_TIMESPEC_GET], [1], - [Define if you have the timespec_get function.]) - fi -]) - -dnl Tests whether the function timespec_get exists. -dnl Sets gl_cv_func_timespec_get. -AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET], -[ - dnl Persuade OpenBSD to declare timespec_get(). - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - dnl We can't use AC_CHECK_FUNC here, because timespec_get() is defined as a - dnl static inline function in on MSVC 14. - AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include - struct timespec ts; - ]], - [[return timespec_get (&ts, 0);]]) - ], - [gl_cv_func_timespec_get=yes], - [gl_cv_func_timespec_get=no]) - ]) + AC_CHECK_FUNCS_ONCE([timespec_get]) ]) AC_DEFUN([gl_GETTIME_RES], diff --git a/m4/timespec_get.m4 b/m4/timespec_get.m4 index acea56d626..cc5ce299de 100644 --- a/m4/timespec_get.m4 +++ b/m4/timespec_get.m4 @@ -1,4 +1,4 @@ -# timespec_get.m4 serial 3 +# timespec_get.m4 serial 2 dnl Copyright (C) 2021-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,8 +11,8 @@ AC_DEFUN([gl_FUNC_TIMESPEC_GET], dnl Persuade OpenBSD to declare timespec_get(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET]) - if test $gl_cv_func_timespec_get != yes; then + AC_CHECK_FUNCS_ONCE([timespec_get]) + if test $ac_cv_func_timespec_get != yes; then HAVE_TIMESPEC_GET=0 fi ])