intprops-internal.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /* intprops-internal.h -- properties of integer types not visible to users
  2. Copyright (C) 2001-2024 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify it
  4. under the terms of the GNU Lesser General Public License as published
  5. by the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  13. #ifndef _GL_INTPROPS_INTERNAL_H
  14. #define _GL_INTPROPS_INTERNAL_H
  15. #include <limits.h>
  16. /* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */
  17. #if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
  18. # pragma GCC diagnostic ignored "-Wtype-limits"
  19. #endif
  20. /* Return a value with the common real type of E and V and the value of V.
  21. Do not evaluate E. */
  22. #define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
  23. /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
  24. <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
  25. #define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
  26. /* The extra casts in the following macros work around compiler bugs,
  27. e.g., in Cray C 5.0.3.0. */
  28. /* True if the real type T is signed. */
  29. #define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
  30. /* Return 1 if the real expression E, after promotion, has a
  31. signed or floating type. Do not evaluate E. */
  32. #define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
  33. /* Minimum and maximum values for integer types and expressions. */
  34. /* The width in bits of the integer type or expression T.
  35. Do not evaluate T. T must not be a bit-field expression.
  36. Padding bits are not supported; this is checked at compile-time below. */
  37. #define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
  38. /* The maximum and minimum values for the type of the expression E,
  39. after integer promotion. E is not evaluated. */
  40. #define _GL_INT_MINIMUM(e) \
  41. (_GL_EXPR_SIGNED (e) \
  42. ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
  43. : _GL_INT_CONVERT (e, 0))
  44. #define _GL_INT_MAXIMUM(e) \
  45. (_GL_EXPR_SIGNED (e) \
  46. ? _GL_SIGNED_INT_MAXIMUM (e) \
  47. : _GL_INT_NEGATE_CONVERT (e, 1))
  48. #define _GL_SIGNED_INT_MAXIMUM(e) \
  49. (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
  50. /* Work around OpenVMS incompatibility with C99. */
  51. #if !defined LLONG_MAX && defined __INT64_MAX
  52. # define LLONG_MAX __INT64_MAX
  53. # define LLONG_MIN __INT64_MIN
  54. #endif
  55. /* This include file assumes that signed types are two's complement without
  56. padding bits; the above macros have undefined behavior otherwise.
  57. If this is a problem for you, please let us know how to fix it for your host.
  58. This assumption is tested by the intprops-tests module. */
  59. /* Does the __typeof__ keyword work? This could be done by
  60. 'configure', but for now it's easier to do it by hand. */
  61. #if (2 <= __GNUC__ \
  62. || (4 <= __clang_major__) \
  63. || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
  64. || (0x5110 <= __SUNPRO_C && !__STDC__))
  65. # define _GL_HAVE___TYPEOF__ 1
  66. #else
  67. # define _GL_HAVE___TYPEOF__ 0
  68. #endif
  69. /* Return 1 if the integer type or expression T might be signed. Return 0
  70. if it is definitely unsigned. T must not be a bit-field expression.
  71. This macro does not evaluate its argument, and expands to an
  72. integer constant expression. */
  73. #if _GL_HAVE___TYPEOF__
  74. # define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t))
  75. #else
  76. # define _GL_SIGNED_TYPE_OR_EXPR(t) 1
  77. #endif
  78. /* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
  79. A should not have side effects, and A's type should be an
  80. integer with minimum value MIN and maximum MAX. */
  81. #define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
  82. ((min) < 0 ? (a) < - (max) : 0 < (a))
  83. /* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
  84. (A, B, P) work when P is non-null. */
  85. #ifdef __EDG__
  86. /* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
  87. <https://bugs.gnu.org/53256>. */
  88. # define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
  89. #elif defined __has_builtin
  90. # define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
  91. /* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
  92. see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
  93. #elif 7 <= __GNUC__
  94. # define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
  95. #else
  96. # define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
  97. #endif
  98. /* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
  99. #if defined __clang_major__ && __clang_major__ < 14
  100. /* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
  101. # define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
  102. #else
  103. # define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
  104. #endif
  105. /* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
  106. __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
  107. #ifdef __EDG__
  108. /* In EDG-based compilers like ICC 2021.3 and earlier,
  109. __builtin_add_overflow_p etc. are not treated as integral constant
  110. expressions even when all arguments are. */
  111. # define _GL_HAS_BUILTIN_OVERFLOW_P 0
  112. #elif defined __has_builtin
  113. # define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
  114. #else
  115. # define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
  116. #endif
  117. #if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \
  118. && ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW))
  119. # include <stdckdint.h>
  120. #endif
  121. /* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
  122. Return 1 if the result overflows. Arguments should not have side
  123. effects and A, B and *R can be of any integer type other than char,
  124. bool, a bit-precise integer type, or an enumeration type. */
  125. #if _GL_HAS_BUILTIN_ADD_OVERFLOW
  126. # define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
  127. # define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
  128. #elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H
  129. # define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b))
  130. # define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b))
  131. #else
  132. # define _GL_INT_ADD_WRAPV(a, b, r) \
  133. _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
  134. # define _GL_INT_SUBTRACT_WRAPV(a, b, r) \
  135. _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
  136. #endif
  137. #if _GL_HAS_BUILTIN_MUL_OVERFLOW
  138. # if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
  139. || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
  140. && !defined __EDG__)
  141. # define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
  142. # else
  143. /* Work around GCC bug 91450. */
  144. # define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
  145. ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
  146. && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \
  147. (__typeof__ (*(r))) 0, \
  148. (__typeof__ (*(r))) -1)) \
  149. ? ((void) __builtin_mul_overflow (a, b, r), 1) \
  150. : __builtin_mul_overflow (a, b, r))
  151. # endif
  152. #elif defined ckd_mul && !defined _GL_STDCKDINT_H
  153. # define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b))
  154. #else
  155. # define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
  156. _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
  157. #endif
  158. /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
  159. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
  160. https://llvm.org/bugs/show_bug.cgi?id=25390
  161. For now, assume GCC < 14 and all Clang versions generate bogus
  162. warnings for _Generic. This matters only for compilers that
  163. lack relevant builtins. */
  164. #if (__GNUC__ && __GNUC__ < 14) || defined __clang__
  165. # define _GL__GENERIC_BOGUS 1
  166. #else
  167. # define _GL__GENERIC_BOGUS 0
  168. #endif
  169. /* Store the low-order bits of A <op> B into *R, where OP specifies
  170. the operation and OVERFLOW the overflow predicate. Return 1 if the
  171. result overflows. Arguments should not have side effects,
  172. and A, B and *R can be of any integer type other than char, bool, a
  173. bit-precise integer type, or an enumeration type. */
  174. #if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
  175. # define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
  176. (_Generic \
  177. (*(r), \
  178. signed char: \
  179. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  180. signed char, SCHAR_MIN, SCHAR_MAX), \
  181. unsigned char: \
  182. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  183. unsigned char, 0, UCHAR_MAX), \
  184. short int: \
  185. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  186. short int, SHRT_MIN, SHRT_MAX), \
  187. unsigned short int: \
  188. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  189. unsigned short int, 0, USHRT_MAX), \
  190. int: \
  191. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  192. int, INT_MIN, INT_MAX), \
  193. unsigned int: \
  194. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  195. unsigned int, 0, UINT_MAX), \
  196. long int: \
  197. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
  198. long int, LONG_MIN, LONG_MAX), \
  199. unsigned long int: \
  200. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
  201. unsigned long int, 0, ULONG_MAX), \
  202. long long int: \
  203. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
  204. long long int, LLONG_MIN, LLONG_MAX), \
  205. unsigned long long int: \
  206. _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
  207. unsigned long long int, 0, ULLONG_MAX)))
  208. #else
  209. /* Store the low-order bits of A <op> B into *R, where OP specifies
  210. the operation and OVERFLOW the overflow predicate. If *R is
  211. signed, its type is ST with bounds SMIN..SMAX; otherwise its type
  212. is UT with bounds U..UMAX. ST and UT are narrower than int.
  213. Return 1 if the result overflows. Arguments should not have side
  214. effects, and A, B and *R can be of any integer type other than
  215. char, bool, a bit-precise integer type, or an enumeration type. */
  216. # if _GL_HAVE___TYPEOF__
  217. # define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
  218. (_GL_TYPE_SIGNED (__typeof__ (*(r))) \
  219. ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
  220. : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
  221. # else
  222. # define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
  223. (overflow (a, b, smin, smax) \
  224. ? (overflow (a, b, 0, umax) \
  225. ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
  226. : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
  227. : (overflow (a, b, 0, umax) \
  228. ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
  229. : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
  230. # endif
  231. # define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
  232. (sizeof *(r) == sizeof (signed char) \
  233. ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
  234. signed char, SCHAR_MIN, SCHAR_MAX, \
  235. unsigned char, UCHAR_MAX) \
  236. : sizeof *(r) == sizeof (short int) \
  237. ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
  238. short int, SHRT_MIN, SHRT_MAX, \
  239. unsigned short int, USHRT_MAX) \
  240. : sizeof *(r) == sizeof (int) \
  241. ? (_GL_EXPR_SIGNED (*(r)) \
  242. ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  243. int, INT_MIN, INT_MAX) \
  244. : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  245. unsigned int, 0, UINT_MAX)) \
  246. : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
  247. # ifdef LLONG_MAX
  248. # define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
  249. (sizeof *(r) == sizeof (long int) \
  250. ? (_GL_EXPR_SIGNED (*(r)) \
  251. ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
  252. long int, LONG_MIN, LONG_MAX) \
  253. : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
  254. unsigned long int, 0, ULONG_MAX)) \
  255. : (_GL_EXPR_SIGNED (*(r)) \
  256. ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
  257. long long int, LLONG_MIN, LLONG_MAX) \
  258. : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
  259. unsigned long long int, 0, ULLONG_MAX)))
  260. # else
  261. # define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
  262. (_GL_EXPR_SIGNED (*(r)) \
  263. ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
  264. long int, LONG_MIN, LONG_MAX) \
  265. : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
  266. unsigned long int, 0, ULONG_MAX))
  267. # endif
  268. #endif
  269. /* Store the low-order bits of A <op> B into *R, where the operation
  270. is given by OP. Use the unsigned type UT for calculation to avoid
  271. overflow problems. *R's type is T, with extrema TMIN and TMAX.
  272. T can be any signed integer type other than char, bool, a
  273. bit-precise integer type, or an enumeration type.
  274. Return 1 if the result overflows. */
  275. #define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
  276. (overflow (a, b, tmin, tmax) \
  277. ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
  278. : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
  279. /* Return 1 if the integer expressions A - B and -A would overflow,
  280. respectively. Arguments should not have side effects,
  281. and can be any signed integer type other than char, bool, a
  282. bit-precise integer type, or an enumeration type.
  283. These macros are tuned for their last input argument being a constant. */
  284. #if _GL_HAS_BUILTIN_OVERFLOW_P
  285. # define _GL_INT_NEGATE_OVERFLOW(a) \
  286. __builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0)
  287. #else
  288. # define _GL_INT_NEGATE_OVERFLOW(a) \
  289. _GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
  290. #endif
  291. /* Return the low-order bits of A <op> B, where the operation is given
  292. by OP. Use the unsigned type UT for calculation to avoid undefined
  293. behavior on signed integer overflow, and convert the result to type T.
  294. UT is at least as wide as T and is no narrower than unsigned int,
  295. T is two's complement, and there is no padding or trap representations.
  296. Assume that converting UT to T yields the low-order bits, as is
  297. done in all known two's-complement C compilers. E.g., see:
  298. https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
  299. According to the C standard, converting UT to T yields an
  300. implementation-defined result or signal for values outside T's
  301. range. However, code that works around this theoretical problem
  302. runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
  303. https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
  304. As the compiler bug is real, don't try to work around the
  305. theoretical problem. */
  306. #define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
  307. ((t) ((ut) (a) op (ut) (b)))
  308. /* Return true if the numeric values A + B, A - B, A * B fall outside
  309. the range TMIN..TMAX. Arguments should not have side effects
  310. and can be any integer type other than char, bool,
  311. a bit-precise integer type, or an enumeration type.
  312. TMIN should be signed and nonpositive.
  313. TMAX should be positive, and should be signed unless TMIN is zero. */
  314. #define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
  315. ((b) < 0 \
  316. ? (((tmin) \
  317. ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
  318. && (a) < (tmin) - (b)) \
  319. : (a) <= -1 - (b)) \
  320. || ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
  321. : (a) < 0 \
  322. ? (((tmin) \
  323. ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
  324. && (b) < (tmin) - (a)) \
  325. : (b) <= -1 - (a)) \
  326. || ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
  327. && (tmax) < (a) + (b))) \
  328. : (tmax) < (b) || (tmax) - (b) < (a))
  329. #define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
  330. (((a) < 0) == ((b) < 0) \
  331. ? ((a) < (b) \
  332. ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
  333. : (tmax) < (a) - (b)) \
  334. : (a) < 0 \
  335. ? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
  336. || (a) - (tmin) < (b)) \
  337. : ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
  338. && _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
  339. && (tmax) <= -1 - (b)) \
  340. || (tmax) + (b) < (a)))
  341. #define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
  342. ((b) < 0 \
  343. ? ((a) < 0 \
  344. ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
  345. ? (a) < (tmax) / (b) \
  346. : ((_GL_INT_NEGATE_OVERFLOW (b) \
  347. ? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \
  348. : (tmax) / -(b)) \
  349. <= -1 - (a))) \
  350. : _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
  351. ? (_GL_EXPR_SIGNED (a) \
  352. ? 0 < (a) + (tmin) \
  353. : 0 < (a) && -1 - (tmin) < (a) - 1) \
  354. : (tmin) / (b) < (a)) \
  355. : (b) == 0 \
  356. ? 0 \
  357. : ((a) < 0 \
  358. ? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
  359. ? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
  360. : (tmin) / (a) < (b)) \
  361. : (tmax) / (b) < (a)))
  362. #endif /* _GL_INTPROPS_INTERNAL_H */