Changeset 17c14273 in mainline
- Timestamp:
- 2018-01-17T18:11:05Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e347396
- Parents:
- 2467b41
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/strtol.c
r2467b41 r17c14273 55 55 } 56 56 return INT_MAX; 57 } 58 59 /* FIXME: workaround for GCC "optimizing" the overflow check 60 * into soft-emulated 128b multiplication using `__multi3`, 61 * which we don't currently implement. 62 */ 63 __attribute__((noinline)) static uintmax_t _max_value(int base) 64 { 65 return UINTMAX_MAX / base; 57 66 } 58 67 … … 111 120 112 121 uintmax_t result = 0; 122 uintmax_t max = _max_value(base); 113 123 int digit; 114 124 115 125 while (digit = _digit_value(*nptr), digit < base) { 116 126 117 if ( __builtin_mul_overflow(result, base, &result)||118 __builtin_add_overflow(result , digit, &result)) {127 if (result > max || 128 __builtin_add_overflow(result * base, digit, &result)) { 119 129 120 130 errno = ERANGE;
Note:
See TracChangeset
for help on using the changeset viewer.