mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
include/stdckdint.h: make the header compatible with C++
by removing the cast to _Bool. The _Bool type is not defined for C++,
and the specification from the gcc info doc states that the return
type of the __builtin_{add,sub,mul}_overflow() is bool already.
This is done instead of including stdbool.h to avoid namespace
pollution, since defining bool from stdckdint.h simingly is not
sanctioned by ISO/IEC 9899:2024.
PR: 290299
Reviewed by: des
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53149
This commit is contained in:
parent
96d82d2d13
commit
3c052bec12
1 changed files with 3 additions and 3 deletions
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_add_overflow)
|
||||
#define ckd_add(result, a, b) \
|
||||
(_Bool)__builtin_add_overflow((a), (b), (result))
|
||||
__builtin_add_overflow((a), (b), (result))
|
||||
#else
|
||||
#define ckd_add(result, a, b) \
|
||||
_Static_assert(0, "checked addition not supported")
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_sub_overflow)
|
||||
#define ckd_sub(result, a, b) \
|
||||
(_Bool)__builtin_sub_overflow((a), (b), (result))
|
||||
__builtin_sub_overflow((a), (b), (result))
|
||||
#else
|
||||
#define ckd_sub(result, a, b) \
|
||||
_Static_assert(0, "checked subtraction not supported")
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#if __GNUC_PREREQ__(5, 1) || __has_builtin(__builtin_mul_overflow)
|
||||
#define ckd_mul(result, a, b) \
|
||||
(_Bool)__builtin_mul_overflow((a), (b), (result))
|
||||
__builtin_mul_overflow((a), (b), (result))
|
||||
#else
|
||||
#define ckd_mul(result, a, b) \
|
||||
_Static_assert(0, "checked multiplication not supported")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue