|
Message-Id: <1fe28ea2525f112264a1a819d8ce50a97504ab8b.1684932892.git.Jens.Gustedt@inria.fr> Date: Wed, 24 May 2023 21:38:52 +0200 From: Jens Gustedt <Jens.Gustedt@...ia.fr> To: musl@...ts.openwall.com Subject: [C23 new stdlib 2/4] C23: add the memalignment function The name is reserved, so we don't need to protect it via a feature macro or a weak symbol. --- include/stdlib.h | 3 +++ src/stdlib/memalignment.c | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 src/stdlib/memalignment.c diff --git a/include/stdlib.h b/include/stdlib.h index 7800074d..68993c04 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -178,6 +178,9 @@ long double strtold_l(const char *__restrict, char **__restrict, struct __locale typedef int once_flag; void call_once(once_flag *, void (*)(void)); +size_t (memalignment)(const void *); +#define memalignment(P) (((size_t)1)<<__builtin_ctzll((unsigned long long)P)) + #ifdef __cplusplus } #endif diff --git a/src/stdlib/memalignment.c b/src/stdlib/memalignment.c new file mode 100644 index 00000000..58b68954 --- /dev/null +++ b/src/stdlib/memalignment.c @@ -0,0 +1,6 @@ +#include <stdlib.h> + +size_t (memalignment)(const void *p) +{ + return memalignment(p); +} -- 2.34.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.