dtrace: Address KMSAN warnings in dtrace_disx86
[freebsd/src.git] / include / stdckdint.h
blobaf3074dded89c2e41007bd5b060abbfedebc2cad
1 /*-
2 * Copyright (c) 2023 Dag-Erling Smørgrav
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
7 #ifndef __STDC_VERSION_STDCKDINT_H__
8 #define __STDC_VERSION_STDCKDINT_H__ 202311L
10 #include <sys/cdefs.h>
12 #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 2023
14 #if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_add_overflow)
15 #define ckd_add(result, a, b) \
16 (_Bool)__builtin_add_overflow((a), (b), (result))
17 #else
18 #define ckd_add(result, a, b) \
19 _Static_assert(0, "checked addition not supported")
20 #endif
22 #if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_sub_overflow)
23 #define ckd_sub(result, a, b) \
24 (_Bool)__builtin_sub_overflow((a), (b), (result))
25 #else
26 #define ckd_sub(result, a, b) \
27 _Static_assert(0, "checked subtraction not supported")
28 #endif
30 #if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_mul_overflow)
31 #define ckd_mul(result, a, b) \
32 (_Bool)__builtin_mul_overflow((a), (b), (result))
33 #else
34 #define ckd_mul(result, a, b) \
35 _Static_assert(0, "checked multiplication not supported")
36 #endif
38 #endif
40 #endif