public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH v2] toolchain-funcs.eclass: Add tc-has-64bit-time_t
@ 2024-06-13 17:07 Michał Górny
  0 siblings, 0 replies; only message in thread
From: Michał Górny @ 2024-06-13 17:07 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Michał Górny

Add a helper function to check whether time_t is 64-bit.  This could
be used e.g. to deselect tests that rely on timestamps exceeding Y2k38.
It is meant to be more future-proof than hardcoding a list of 32-bit
architectures, given the necessity of switching to 64-bit time_t
in the future.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/toolchain-funcs.eclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index cde84e6f34c8..d3130e0e9121 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1,4 +1,4 @@
-# Copyright 2002-2023 Gentoo Authors
+# Copyright 2002-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: toolchain-funcs.eclass
@@ -1251,4 +1251,14 @@ tc-is-lto() {
 	return 1
 }
 
+# @FUNCTION: tc-has-64bit-time_t
+# @RETURN: Shell true if time_t is at least 64 bits long, false otherwise
+tc-has-64bit-time_t() {
+	$(tc-getCC) ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null
+		#include <sys/types.h>
+		int test[sizeof(time_t) >= 8 ? 1 : -1];
+	EOF
+	return $?
+}
+
 fi
-- 
2.45.2



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-13 17:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-13 17:07 [gentoo-dev] [PATCH v2] toolchain-funcs.eclass: Add tc-has-64bit-time_t Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox