summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-09-04 17:09:53 +0200
committerBruno Haible <bruno@clisp.org>2022-09-04 17:09:53 +0200
commitb1318f348156069f9e16f75bc9b1a764a81fe1f9 (patch)
tree530720af16d611acd495b95abba5def2086e4aa9 /m4
parent99b0ab09036e16ad845438938d9b607f2d3f346a (diff)
downloadgnulib-b1318f348156069f9e16f75bc9b1a764a81fe1f9.tar.gz
timespec_get: Fix compilation error with MSVC 14.
* m4/gettime.m4 (gl_CHECK_FUNC_TIMESPEC_GET): New macro. (gl_GETTIME): Use it instead of AC_CHECK_FUNCS_ONCE. * m4/timespec_get.m4 (gl_FUNC_TIMESPEC_GET): Likewise.
Diffstat (limited to 'm4')
-rw-r--r--m4/gettime.m431
-rw-r--r--m4/timespec_get.m46
2 files changed, 32 insertions, 5 deletions
diff --git a/m4/gettime.m4 b/m4/gettime.m4
index f0aeb4d0e4..c3e0713b57 100644
--- a/m4/gettime.m4
+++ b/m4/gettime.m4
@@ -1,4 +1,4 @@
-# gettime.m4 serial 11
+# gettime.m4 serial 12
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,7 +9,34 @@ AC_DEFUN([gl_GETTIME],
dnl Prerequisites of lib/gettime.c.
AC_REQUIRE([gl_CLOCK_TIME])
AC_REQUIRE([gl_TIMESPEC])
- AC_CHECK_FUNCS_ONCE([timespec_get])
+
+ 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 <time.h> 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 <time.h> on MSVC 14.
+ AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <time.h>
+ struct timespec ts;
+ ]],
+ [[return timespec_get (&ts, 0);]])
+ ],
+ [gl_cv_func_timespec_get=yes],
+ [gl_cv_func_timespec_get=no])
+ ])
])
AC_DEFUN([gl_GETTIME_RES],
diff --git a/m4/timespec_get.m4 b/m4/timespec_get.m4
index cc5ce299de..acea56d626 100644
--- a/m4/timespec_get.m4
+++ b/m4/timespec_get.m4
@@ -1,4 +1,4 @@
-# timespec_get.m4 serial 2
+# timespec_get.m4 serial 3
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 <time.h> to declare timespec_get().
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
- AC_CHECK_FUNCS_ONCE([timespec_get])
- if test $ac_cv_func_timespec_get != yes; then
+ AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET])
+ if test $gl_cv_func_timespec_get != yes; then
HAVE_TIMESPEC_GET=0
fi
])