]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: headers: Define {u}intptr_t and {u}intcap_t for CHERI
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 11 Jun 2021 11:52:26 +0000 (12:52 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 5 Aug 2022 18:45:19 +0000 (19:45 +0100)
The CHERI pure capability programming model for C requires special
definition of {u}intptr_t.

Only the pure capability model is supported for hosted compilation,
but for freestanding compilation there is limited support for other
(hybrid capability) programming models too, which require new
{u}intcap_t type definitions.

posix/bits/types.h
stdlib/stdint.h

index f912e77a021763044e922f36ebcc801f2fd47fd7..e315dfd77999af6320fbfbe4ae38e62762d07f30 100644 (file)
@@ -204,7 +204,11 @@ typedef __off64_t __loff_t;        /* Type of file sizes and offsets (LFS).  */
 typedef char *__caddr_t;
 
 /* Duplicates info from stdint.h but this is used in unistd.h.  */
+#ifdef __CHERI_PURE_CAPABILITY__
+__STD_TYPE __intcap_t __intptr_t;
+#else
 __STD_TYPE __SWORD_TYPE __intptr_t;
+#endif
 
 /* Duplicate info from sys/socket.h.  */
 __STD_TYPE __U32_TYPE __socklen_t;
index 2d666f79fd97aa419ad1febcb420914fbe1a0dd1..b80b6bbac15b6a0d33e563e4009bf614f2acfc3e 100644 (file)
@@ -84,10 +84,22 @@ typedef unsigned long long int      uint_fast64_t;
 /* Types for `void *' pointers.  */
 #if __WORDSIZE == 64
 # ifndef __intptr_t_defined
+#  ifdef __CHERI_PURE_CAPABILITY__
+typedef __intcap_t             intptr_t;
+#  else
 typedef long int               intptr_t;
+#  endif
 #  define __intptr_t_defined
 # endif
+# ifdef __CHERI_PURE_CAPABILITY__
+typedef __uintcap_t            uintptr_t;
+# else
 typedef unsigned long int      uintptr_t;
+# endif
+# if defined __CHERI__ && !defined __CHERI_PURE_CAPABILITY__
+typedef __uintcap_t            uintcap_t;
+typedef __intcap_t             intcap_t;
+# endif
 #else
 # ifndef __intptr_t_defined
 typedef int                    intptr_t;