|
| 1 | +--- ./oathtool/gl/intprops.h |
| 2 | ++++ ./oathtool/gl/intprops.h |
| 3 | +@@ -222,20 +222,23 @@ |
| 4 | + ? (a) < (min) >> (b) \ |
| 5 | + : (max) >> (b) < (a)) |
| 6 | + |
| 7 | +-/* True if __builtin_add_overflow (A, B, P) works when P is null. */ |
| 8 | +-#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__) |
| 9 | ++/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ |
| 10 | ++#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__) |
| 11 | ++ |
| 12 | ++/* True if __builtin_add_overflow_p (A, B, C) works. */ |
| 13 | ++#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) |
| 14 | + |
| 15 | + /* The _GL*_OVERFLOW macros have the same restrictions as the |
| 16 | + *_RANGE_OVERFLOW macros, except that they do not assume that operands |
| 17 | + (e.g., A and B) have the same type as MIN and MAX. Instead, they assume |
| 18 | + that the result (e.g., A + B) has that type. */ |
| 19 | +-#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL |
| 20 | +-# define _GL_ADD_OVERFLOW(a, b, min, max) |
| 21 | +- __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0) |
| 22 | +-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) |
| 23 | +- __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0) |
| 24 | +-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) |
| 25 | +- __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0) |
| 26 | ++#if _GL_HAS_BUILTIN_OVERFLOW_P |
| 27 | ++# define _GL_ADD_OVERFLOW(a, b, min, max) \ |
| 28 | ++ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) |
| 29 | ++# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ |
| 30 | ++ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) |
| 31 | ++# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ |
| 32 | ++ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) |
| 33 | + #else |
| 34 | + # define _GL_ADD_OVERFLOW(a, b, min, max) \ |
| 35 | + ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ |
| 36 | +@@ -315,7 +318,7 @@ |
| 37 | + _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) |
| 38 | + #define INT_SUBTRACT_OVERFLOW(a, b) \ |
| 39 | + _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) |
| 40 | +-#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL |
| 41 | ++#if _GL_HAS_BUILTIN_OVERFLOW_WITH_P |
| 42 | + # define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) |
| 43 | + #else |
| 44 | + # define INT_NEGATE_OVERFLOW(a) \ |
| 45 | +@@ -349,10 +352,6 @@ |
| 46 | + #define INT_MULTIPLY_WRAPV(a, b, r) \ |
| 47 | + _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) |
| 48 | + |
| 49 | +-#ifndef __has_builtin |
| 50 | +-# define __has_builtin(x) 0 |
| 51 | +-#endif |
| 52 | +- |
| 53 | + /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: |
| 54 | + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 |
| 55 | + https://llvm.org/bugs/show_bug.cgi?id=25390 |
| 56 | +@@ -369,7 +368,7 @@ |
| 57 | + the operation. BUILTIN is the builtin operation, and OVERFLOW the |
| 58 | + overflow predicate. Return 1 if the result overflows. See above |
| 59 | + for restrictions. */ |
| 60 | +-#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow) |
| 61 | ++#if _GL_HAS_BUILTIN_OVERFLOW |
| 62 | + # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) |
| 63 | + #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS |
| 64 | + # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ |
| 65 | +@@ -412,7 +411,7 @@ |
| 66 | + # else |
| 67 | + # define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ |
| 68 | + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ |
| 69 | +- long int, LONG_MIN, LONG_MAX)) |
| 70 | ++ long int, LONG_MIN, LONG_MAX) |
| 71 | + # endif |
| 72 | + #endif |
| 73 | + |
| 74 | +--- ./pskctool/gl/intprops.h |
| 75 | ++++ ./pskctool/gl/intprops.h |
| 76 | +@@ -222,20 +222,23 @@ |
| 77 | + ? (a) < (min) >> (b) \ |
| 78 | + : (max) >> (b) < (a)) |
| 79 | + |
| 80 | +-/* True if __builtin_add_overflow (A, B, P) works when P is null. */ |
| 81 | +-#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__) |
| 82 | ++/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ |
| 83 | ++#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__) |
| 84 | ++ |
| 85 | ++/* True if __builtin_add_overflow_p (A, B, C) works. */ |
| 86 | ++#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) |
| 87 | + |
| 88 | + /* The _GL*_OVERFLOW macros have the same restrictions as the |
| 89 | + *_RANGE_OVERFLOW macros, except that they do not assume that operands |
| 90 | + (e.g., A and B) have the same type as MIN and MAX. Instead, they assume |
| 91 | + that the result (e.g., A + B) has that type. */ |
| 92 | +-#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL |
| 93 | +-# define _GL_ADD_OVERFLOW(a, b, min, max) |
| 94 | +- __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0) |
| 95 | +-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) |
| 96 | +- __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0) |
| 97 | +-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) |
| 98 | +- __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0) |
| 99 | ++#if _GL_HAS_BUILTIN_OVERFLOW_P |
| 100 | ++# define _GL_ADD_OVERFLOW(a, b, min, max) \ |
| 101 | ++ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) |
| 102 | ++# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ |
| 103 | ++ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) |
| 104 | ++# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ |
| 105 | ++ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) |
| 106 | + #else |
| 107 | + # define _GL_ADD_OVERFLOW(a, b, min, max) \ |
| 108 | + ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ |
| 109 | +@@ -315,7 +318,7 @@ |
| 110 | + _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) |
| 111 | + #define INT_SUBTRACT_OVERFLOW(a, b) \ |
| 112 | + _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) |
| 113 | +-#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL |
| 114 | ++#if _GL_HAS_BUILTIN_OVERFLOW_WITH_P |
| 115 | + # define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) |
| 116 | + #else |
| 117 | + # define INT_NEGATE_OVERFLOW(a) \ |
| 118 | +@@ -349,10 +352,6 @@ |
| 119 | + #define INT_MULTIPLY_WRAPV(a, b, r) \ |
| 120 | + _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) |
| 121 | + |
| 122 | +-#ifndef __has_builtin |
| 123 | +-# define __has_builtin(x) 0 |
| 124 | +-#endif |
| 125 | +- |
| 126 | + /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: |
| 127 | + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 |
| 128 | + https://llvm.org/bugs/show_bug.cgi?id=25390 |
| 129 | +@@ -369,7 +368,7 @@ |
| 130 | + the operation. BUILTIN is the builtin operation, and OVERFLOW the |
| 131 | + overflow predicate. Return 1 if the result overflows. See above |
| 132 | + for restrictions. */ |
| 133 | +-#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow) |
| 134 | ++#if _GL_HAS_BUILTIN_OVERFLOW |
| 135 | + # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) |
| 136 | + #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS |
| 137 | + # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ |
| 138 | +@@ -412,7 +411,7 @@ |
| 139 | + # else |
| 140 | + # define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ |
| 141 | + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ |
| 142 | +- long int, LONG_MIN, LONG_MAX)) |
| 143 | ++ long int, LONG_MIN, LONG_MAX) |
| 144 | + # endif |
| 145 | + #endif |
| 146 | + |
| 147 | +--- ./libpskc/gl/intprops.h |
| 148 | ++++ ./libpskc/gl/intprops.h |
| 149 | +@@ -222,20 +222,23 @@ |
| 150 | + ? (a) < (min) >> (b) \ |
| 151 | + : (max) >> (b) < (a)) |
| 152 | + |
| 153 | +-/* True if __builtin_add_overflow (A, B, P) works when P is null. */ |
| 154 | +-#define _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL (7 <= __GNUC__) |
| 155 | ++/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ |
| 156 | ++#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__) |
| 157 | ++ |
| 158 | ++/* True if __builtin_add_overflow_p (A, B, C) works. */ |
| 159 | ++#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) |
| 160 | + |
| 161 | + /* The _GL*_OVERFLOW macros have the same restrictions as the |
| 162 | + *_RANGE_OVERFLOW macros, except that they do not assume that operands |
| 163 | + (e.g., A and B) have the same type as MIN and MAX. Instead, they assume |
| 164 | + that the result (e.g., A + B) has that type. */ |
| 165 | +-#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL |
| 166 | +-# define _GL_ADD_OVERFLOW(a, b, min, max) |
| 167 | +- __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0) |
| 168 | +-# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) |
| 169 | +- __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0) |
| 170 | +-# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) |
| 171 | +- __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0) |
| 172 | ++#if _GL_HAS_BUILTIN_OVERFLOW_P |
| 173 | ++# define _GL_ADD_OVERFLOW(a, b, min, max) \ |
| 174 | ++ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0) |
| 175 | ++# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ |
| 176 | ++ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0) |
| 177 | ++# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ |
| 178 | ++ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0) |
| 179 | + #else |
| 180 | + # define _GL_ADD_OVERFLOW(a, b, min, max) \ |
| 181 | + ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ |
| 182 | +@@ -315,7 +318,7 @@ |
| 183 | + _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) |
| 184 | + #define INT_SUBTRACT_OVERFLOW(a, b) \ |
| 185 | + _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) |
| 186 | +-#if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL |
| 187 | ++#if _GL_HAS_BUILTIN_OVERFLOW_WITH_P |
| 188 | + # define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) |
| 189 | + #else |
| 190 | + # define INT_NEGATE_OVERFLOW(a) \ |
| 191 | +@@ -349,10 +352,6 @@ |
| 192 | + #define INT_MULTIPLY_WRAPV(a, b, r) \ |
| 193 | + _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW) |
| 194 | + |
| 195 | +-#ifndef __has_builtin |
| 196 | +-# define __has_builtin(x) 0 |
| 197 | +-#endif |
| 198 | +- |
| 199 | + /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: |
| 200 | + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 |
| 201 | + https://llvm.org/bugs/show_bug.cgi?id=25390 |
| 202 | +@@ -369,7 +368,7 @@ |
| 203 | + the operation. BUILTIN is the builtin operation, and OVERFLOW the |
| 204 | + overflow predicate. Return 1 if the result overflows. See above |
| 205 | + for restrictions. */ |
| 206 | +-#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow) |
| 207 | ++#if _GL_HAS_BUILTIN_OVERFLOW |
| 208 | + # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) |
| 209 | + #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS |
| 210 | + # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ |
| 211 | +@@ -412,7 +411,7 @@ |
| 212 | + # else |
| 213 | + # define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ |
| 214 | + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ |
| 215 | +- long int, LONG_MIN, LONG_MAX)) |
| 216 | ++ long int, LONG_MIN, LONG_MAX) |
| 217 | + # endif |
| 218 | + #endif |
| 219 | + |
0 commit comments