commit:     f70ca0aa2b8c06f679e05a1b0a9509af6b5ae87a
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  4 23:31:57 2023 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Nov 13 22:12:47 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f70ca0aa

toolchain-funcs.eclass: Add functions to get pointer size in bytes

tc-get-ptr-size for CHOST and tc-get-build-ptr-size for CBUILD.

Closes: https://bugs.gentoo.org/328401
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 eclass/toolchain-funcs.eclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 8fef764ad597..5da93063866b 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1216,4 +1216,18 @@ tc-get-c-rtlib() {
        return 0
 }
 
+# @FUNCTION: tc-get-ptr-size
+# @RETURN: Size of a pointer in bytes for CHOST (e.g. 4 or 8).
+tc-get-ptr-size() {
+       $(tc-getCPP) -P - <<< __SIZEOF_POINTER__ ||
+               die "Could not determine CHOST pointer size"
+}
+
+# @FUNCTION: tc-get-build-ptr-size
+# @RETURN: Size of a pointer in bytes for CBUILD (e.g. 4 or 8).
+tc-get-build-ptr-size() {
+       $(tc-getBUILD_CPP) -P - <<< __SIZEOF_POINTER__ ||
+               die "Could not determine CBUILD pointer size"
+}
+
 fi

Reply via email to