Date: Fri, 26 May 2023 11:40:01 +0200 From: Jens Gustedt <Jens.Gustedt@...ia.fr> To: musl@...ts.openwall.com Subject: [C23 stdckdint.h 1/1] C23: add the stdckdint.h header for checked integer operations These macros have a direct correspondence with gcc builtins, so the implementation for musl is trivial. Note that this only intefaces the type-generic features, so no function symbol is added to the library. Since also this is a new header that only exposes its contents when it is explicitly included, no feature test macros are needed. --- include/stdckdint.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 include/stdckdint.h diff --git a/include/stdckdint.h b/include/stdckdint.h new file mode 100644 index 00000000..893126dc --- /dev/null +++ b/include/stdckdint.h @@ -0,0 +1,8 @@ +#ifndef __STDC_VERSION_STDCKDINT_H__ +#define __STDC_VERSION_STDCKDINT_H__ 202311L + +#define ckd_add(R, A, B) __builtin_add_overflow ((A), (B), (R)) +#define ckd_sub(R, A, B) __builtin_sub_overflow ((A), (B), (R)) +#define ckd_mul(R, A, B) __builtin_mul_overflow ((A), (B), (R)) + +#endif -- 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.