Module: Mesa
Branch: main
Commit: 6a933b7f539426442418f8d875ea17631ac4a979
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6a933b7f539426442418f8d875ea17631ac4a979

Author: Yonggang Luo <[email protected]>
Date:   Sun Jun 12 10:02:23 2022 +0800

c11: Fixes the declaration of timespec_get in time.h for macOS

../src/util/tests/timespec_test.cpp:327:4: error: use of undeclared identifier 
'timespec_get'; did you mean 'timespec_eq'?
   timespec_get(&a, TIME_UTC);
   ^~~~~~~~~~~~
   timespec_eq
../src/util/timespec.h:299:1: note: 'timespec_eq' declared here
timespec_eq(const struct timespec *a, const struct timespec *b)

Signed-off-by: Yonggang Luo <[email protected]>
Acked-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16995>

---

 src/c11/time.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/c11/time.h b/src/c11/time.h
index 53d587c3eb6..b9f779c83d3 100644
--- a/src/c11/time.h
+++ b/src/c11/time.h
@@ -37,11 +37,22 @@ struct timespec
 
 /*-------------------------- functions --------------------------*/
 
-#ifndef HAVE_TIMESPEC_GET
+#if !defined(HAVE_TIMESPEC_GET)
+#define _HAVE_TIMESPEC_GET_NEED_DECL
+#elif defined(__APPLE__) && defined(__cplusplus) && (__cplusplus < 201703L)
+/* On macOS, the guard for declaration of timespec_get is by
+ * (defined(__cplusplus) && __cplusplus >= 201703L),
+ * fix the declaration for C++14 and lower here
+ */
+#define _HAVE_TIMESPEC_GET_NEED_DECL
+#endif
+
+#ifdef _HAVE_TIMESPEC_GET_NEED_DECL
 /*-------------------- 7.25.7 Time functions --------------------*/
 // 7.25.6.1
 int
 timespec_get(struct timespec *ts, int base);
+#undef _HAVE_TIMESPEC_GET_NEED_DECL
 #endif
 
 #ifdef __cplusplus

Reply via email to