| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#ifndef _GLIBCXX_STDCKDINT_H |
| 30 |
#define _GLIBCXX_STDCKDINT_H |
| 31 |
|
| 32 |
#define __glibcxx_want_stdckdint_h |
| 33 |
#include <bits/version.h> |
| 34 |
|
| 35 |
#ifdef __cpp_lib_stdckdint_h |
| 36 |
|
| 37 |
#include <type_traits> |
| 38 |
#include <concepts> |
| 39 |
|
| 40 |
#define __STDC_VERSION_STDCKDINT_H__ 202311L |
| 41 |
|
| 42 |
#ifndef _GLIBCXX_DOXYGEN |
| 43 |
|
| 44 |
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) |
| 45 |
{ |
| 46 |
#endif |
| 47 |
|
| 48 |
namespace __detail |
| 49 |
{ |
| 50 |
template<typename _Tp> |
| 51 |
concept __cv_unqual_signed_or_unsigned_integer_type |
| 52 |
= std::same_as<_Tp, std::remove_cv_t<_Tp>> |
| 53 |
&& std::__is_standard_integer<_Tp>::value; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
template<typename _Tp1, typename _Tp2, typename _Tp3> |
| 75 |
inline bool |
| 76 |
ckd_add(_Tp1* __result, _Tp2 __a, _Tp3 __b) |
| 77 |
{ |
| 78 |
using __gnu_cxx::__detail::__cv_unqual_signed_or_unsigned_integer_type; |
| 79 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp1>); |
| 80 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp2>); |
| 81 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp3>); |
| 82 |
return __builtin_add_overflow(__a, __b, __result); |
| 83 |
} |
| 84 |
|
| 85 |
template<typename _Tp1, typename _Tp2, typename _Tp3> |
| 86 |
inline bool |
| 87 |
ckd_sub(_Tp1* __result, _Tp2 __a, _Tp3 __b) |
| 88 |
{ |
| 89 |
using __gnu_cxx::__detail::__cv_unqual_signed_or_unsigned_integer_type; |
| 90 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp1>); |
| 91 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp2>); |
| 92 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp3>); |
| 93 |
return __builtin_sub_overflow(__a, __b, __result); |
| 94 |
} |
| 95 |
|
| 96 |
template<typename _Tp1, typename _Tp2, typename _Tp3> |
| 97 |
inline bool |
| 98 |
ckd_mul(_Tp1* __result, _Tp2 __a, _Tp3 __b) |
| 99 |
{ |
| 100 |
using __gnu_cxx::__detail::__cv_unqual_signed_or_unsigned_integer_type; |
| 101 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp1>); |
| 102 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp2>); |
| 103 |
static_assert(__cv_unqual_signed_or_unsigned_integer_type<_Tp3>); |
| 104 |
return __builtin_mul_overflow(__a, __b, __result); |
| 105 |
} |
| 106 |
|
| 107 |
#ifndef _GLIBCXX_DOXYGEN |
| 108 |
} |
| 109 |
|
| 110 |
using __gnu_cxx::ckd_add; |
| 111 |
using __gnu_cxx::ckd_sub; |
| 112 |
using __gnu_cxx::ckd_mul; |
| 113 |
#endif |
| 114 |
|
| 115 |
#endif |
| 116 |
|
| 117 |
#endif |