Lines Matching full:arg2
37 // If the result of adding arg1 and arg2 will fit in an int32_t (without
40 bool SafeInt32Add(std::int32_t arg1, std::int32_t arg2, std::int32_t *result);
42 // Returns the result of adding arg1 and arg2 if it will fit in the result type
45 std::int32_t SafeInt32Add(std::int32_t arg1, std::int32_t arg2);
46 std::int64_t SafeInt64Add(std::int64_t arg1, std::int64_t arg2);
48 // If the result of adding arg1 and arg2 will fit in a uint32_t (without
51 bool SafeUint32Add(std::uint32_t arg1, std::uint32_t arg2,
54 // Returns the result of adding arg1 and arg2 if it will fit in the result type
57 std::uint32_t SafeUint32Add(std::uint32_t arg1, std::uint32_t arg2);
58 std::uint64_t SafeUint64Add(std::uint64_t arg1, std::uint64_t arg2);
60 // If the subtraction of arg2 from arg1 will not result in an int32_t under- or
63 bool SafeInt32Sub(std::int32_t arg1, std::int32_t arg2, std::int32_t *result);
65 // Returns the result of subtracting arg2 from arg1 if this operation will not
68 std::int32_t SafeInt32Sub(std::int32_t arg1, std::int32_t arg2);
70 // Returns the result of subtracting arg2 from arg1 if this operation will not
73 std::uint32_t SafeUint32Sub(std::uint32_t arg1, std::uint32_t arg2);
75 // Returns the result of multiplying arg1 and arg2 if it will fit in a int32_t
78 std::int32_t SafeInt32Mult(std::int32_t arg1, std::int32_t arg2);
83 bool SafeUint32Mult(std::uint32_t arg1, std::uint32_t arg2,
85 bool SafeUint32Mult(std::uint32_t arg1, std::uint32_t arg2, std::uint32_t arg3,
87 bool SafeUint32Mult(std::uint32_t arg1, std::uint32_t arg2, std::uint32_t arg3,
93 std::uint32_t SafeUint32Mult(std::uint32_t arg1, std::uint32_t arg2);
94 std::uint32_t SafeUint32Mult(std::uint32_t arg1, std::uint32_t arg2,
96 std::uint32_t SafeUint32Mult(std::uint32_t arg1, std::uint32_t arg2,
99 // Returns the result of multiplying arg1 and arg2 if it will fit in a size_t
102 std::size_t SafeSizetMult(std::size_t arg1, std::size_t arg2);
108 std::int64_t SafeInt64MultSlow(std::int64_t arg1, std::int64_t arg2);
113 inline std::int64_t SafeInt64MultByClang(std::int64_t arg1, std::int64_t arg2) {
116 if (__builtin_smull_overflow(arg1, arg2, &result)) {
118 if (__builtin_smulll_overflow(arg1, arg2, &result)) {
131 std::int64_t arg2) {
136 __int128 result = static_cast<__int128>(arg1) * static_cast<__int128>(arg2);
146 // Returns the result of multiplying arg1 and arg2 if it will fit in an int64_t
149 inline std::int64_t SafeInt64Mult(std::int64_t arg1, std::int64_t arg2) {
151 return dng_internal::SafeInt64MultByClang(arg1, arg2);
153 return dng_internal::SafeInt64MultByInt128(arg1, arg2);
155 return dng_internal::SafeInt64MultSlow(arg1, arg2);
159 // Returns the result of dividing arg1 by arg2; if the result is not an integer,
160 // rounds up to the next integer. If arg2 is zero, throws a dng_exception with
163 // for all combinations of arg1 and arg2.
164 std::uint32_t SafeUint32DivideUp(std::uint32_t arg1, std::uint32_t arg2);