summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2024-06-13 17:17:07 +0200
committerMichał Górny <mgorny@gentoo.org>2024-08-06 10:29:01 +0200
commit9c0708dcae5ef0792e2273968f6f6ff45d90b11f (patch)
tree529edb097e83fa9839dd6d711c01436808e2d9ec /eclass/toolchain-funcs.eclass
parenteclass/tests/toolchain-funcs.sh: Cover tc-is-lto (diff)
downloadgentoo-9c0708dcae5ef0792e2273968f6f6ff45d90b11f.tar.gz
gentoo-9c0708dcae5ef0792e2273968f6f6ff45d90b11f.tar.bz2
gentoo-9c0708dcae5ef0792e2273968f6f6ff45d90b11f.zip
toolchain-funcs.eclass: Add tc-has-64bit-time_t
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>
Diffstat (limited to 'eclass/toolchain-funcs.eclass')
-rw-r--r--eclass/toolchain-funcs.eclass12
1 files changed, 11 insertions, 1 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index e73af9772938..9f0953c079e3 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
@@ -1253,4 +1253,14 @@ tc-is-lto() {
return "${ret}"
}
+# @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