git: dca634d1544b - main - new type: ptraddr_t
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Nov 2025 14:56:05 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=dca634d1544b5cd202dcd06c8c5ea5cbea6c3300
commit dca634d1544b5cd202dcd06c8c5ea5cbea6c3300
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-11-27 14:54:55 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2025-11-27 14:54:55 +0000
new type: ptraddr_t
ptraddr_t is an unsigned integer type that can hold the address of any
pointer. It differes from uintptr_t in that it does not carry
provenance which is useful for CHERI in that it can disambigurate the
provenance of uintptr_t expressions. It differes from size_t in that
some segmented architecture (not supported by FreeBSD) may have a size_t
that does not hold an address.
ptraddr_t is not yet standardized, but is currently proposed for
inclusion in C++2Y.
Prefer the compiler defined __PTRADDR_TYPE__ defintion where available
as this a new type and we don't need to worry about historical values.
Fall back to __size_t where unavailable.
Reviewed by: kib, markj
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D53817
---
share/man/man7/arch.7 | 5 +++--
sys/sys/_types.h | 6 ++++++
sys/sys/stddef.h | 8 ++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/share/man/man7/arch.7 b/share/man/man7/arch.7
index 5170a27768b8..628d3837f011 100644
--- a/share/man/man7/arch.7
+++ b/share/man/man7/arch.7
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 1, 2025
+.Dd November 27, 2025
.Dt ARCH 7
.Os
.Sh NAME
@@ -48,7 +48,8 @@ and later, unless otherwise noted.
.Fx
uses a flat address space.
Variables of types
-.Vt unsigned long
+.Vt unsigned long ,
+.Vt ptraddr_t ,
and
.Vt size_t
have the same representation.
diff --git a/sys/sys/_types.h b/sys/sys/_types.h
index 6b70b8dc6e32..6e69b06f689d 100644
--- a/sys/sys/_types.h
+++ b/sys/sys/_types.h
@@ -103,6 +103,12 @@ typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
#error unsupported ptrdiff_t size
#endif
+#ifdef __PTRADDR_TYPE__
+typedef __PTRADDR_TYPE__ __ptraddr_t;
+#else
+typedef __size_t __ptraddr_t;
+#endif
+
/*
* Target-dependent type definitions.
*/
diff --git a/sys/sys/stddef.h b/sys/sys/stddef.h
index 73636f5a2370..90186eed7624 100644
--- a/sys/sys/stddef.h
+++ b/sys/sys/stddef.h
@@ -32,6 +32,14 @@
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>
+#include <sys/_visible.h>
+
+#if __BSD_VISIBLE
+#ifndef _PTRADDR_T_DECLARED
+typedef __ptraddr_t ptraddr_t;
+#define _PTRADDR_T_DECLARED
+#endif
+#endif
#ifndef _PTRDIFF_T_DECLARED
typedef __ptrdiff_t ptrdiff_t;