summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2022-10-24 20:29:07 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2022-10-24 20:29:07 +0000
commit7b05defa0ec5f0bfb5d545e3dce14033c4126f32 (patch)
treec70745c0a96fecbd378250daf54a46da43497502
parente33f23a6b59e1886e6456dded7e5b74945c7d34e (diff)
parent64945e6386aeaec96d93057ff26a6e5a91377269 (diff)
downloadglib-7b05defa0ec5f0bfb5d545e3dce14033c4126f32.tar.gz
Merge branch 'wip/smcv/pointers-can-be-large' into 'main'
docs: Stop claiming that gsize is wide enough to hold a pointer See merge request GNOME/glib!3000
-rw-r--r--glib/docs.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/glib/docs.c b/glib/docs.c
index 631136d17..618ac679a 100644
--- a/glib/docs.c
+++ b/glib/docs.c
@@ -515,13 +515,22 @@
/**
* gsize:
*
- * An unsigned integer type of the result of the sizeof operator,
- * corresponding to the size_t type defined in C99.
- * This type is wide enough to hold the numeric value of a pointer,
- * so it is usually 32 bit wide on a 32-bit platform and 64 bit wide
+ * An unsigned integer type of the result of the `sizeof` operator,
+ * corresponding to the `size_t` type defined in C99.
+ *
+ * It is usually 32 bit wide on a 32-bit platform and 64 bit wide
* on a 64-bit platform. Values of this type can range from 0 to
* %G_MAXSIZE.
*
+ * This type is wide enough to hold the size of the largest possible
+ * memory allocation, but is not guaranteed to be wide enough to hold
+ * the numeric value of a pointer: on platforms that use tagged pointers,
+ * such as [CHERI](https://cheri-cpu.org/), pointers can be numerically
+ * larger than the size of the address space.
+ * If the numeric value of a pointer needs to be stored in an integer
+ * without information loss, use the standard C types `intptr_t` or
+ * `uintptr_t`, or the similar GLib types #gintptr or #guintptr.
+ *
* To print or scan values of this type, use
* %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
*/