aboutsummaryrefslogtreecommitdiff
path: root/include/stdlib.h
diff options
context:
space:
mode:
authorRobert Clausecker <fuz@FreeBSD.org>2025-11-10 17:54:41 +0000
committerRobert Clausecker <fuz@FreeBSD.org>2025-11-12 12:23:09 +0000
commit6c57e368eb1777f6097158eeca2fcc175d068dba (patch)
treed4beaf080335301d96832ff471f64e2fc136b94b /include/stdlib.h
parent4ab2d625e1462e9a78cb8086906c1a3da3aa6713 (diff)
lib/libc: implement C23 memalignment()
This new function computes the alignment of a pointer. It is part of ISO/IEC 9899:2024, the new C standard. If the pointer is a null pointer, null is returned. I have tried to write an implementation that can cope with traditional address-based architectures, even if size_t and uintptr_t are of different length. Adjustments may be needed for CHERI though. A man page is provided, too. No unit test for now. Reviewed by: kib, imp, ziaee (manpages), pauamma@gundo.com Approved by: markj (mentor) MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D53673
Diffstat (limited to 'include/stdlib.h')
-rw-r--r--include/stdlib.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index 784cb63bfc5b..3e54b5feb6de 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -167,6 +167,14 @@ int at_quick_exit(void (*)(void)) __noexcept;
_Noreturn void
quick_exit(int) /* __noexcept -- not ready ABI issues? */;
#endif /* __ISO_C_VISIBLE >= 2011 */
+
+/*
+ * C23 extensions
+ */
+#if __ISO_C_VISIBLE >= 2023
+size_t memalignment(const void *) __pure2;
+#endif /* __ISO_C_VISIBLE >= 2023 */
+
/*
* Extensions made by POSIX relative to C.
*/