2023-05-17 Paul Eggert <eggert@cs.ucla.edu>
+ stdckdint: use in more modules
+ * lib/nstrftime.c (__strftime_internal):
+ * lib/timespec-add.c (timespec_add):
+ * lib/timespec-sub.c (timespec_sub):
+ * lib/xstrtol.c (bkm_scale):
+ Prefer ckd_add to INT_ADD_WRAPV etc., and include stdckdint.h.
+ * modules/nstrftime, modules/timespec-add, modules/timespec-sub:
+ * modules/xstrtol:
+ (Depends-on): Add stdckdint.
+
nstrftime: suggest to glibc how to avoid alloca
* lib/nstrftime.c (widen) [COMPILE_WIDE]: Remove.
(__strftime_internal) [COMPILE_WIDE): Instead of converting the
#endif
#include <limits.h>
+#include <stdckdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
width = 0;
do
{
- if (INT_MULTIPLY_WRAPV (width, 10, &width)
- || INT_ADD_WRAPV (width, *f - L_('0'), &width))
+ if (ckd_mul (&width, width, 10)
+ || ckd_add (&width, width, *f - L_('0')))
width = INT_MAX;
++f;
}
}
ts->tv_nsec = r;
/* Overflow is possible, as Solaris 11 stat can yield
- tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000.
- INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
+ tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. */
if (ckd_add (&ts->tv_sec, q, ts->tv_sec))
{
errno = EOVERFLOW;
#include <config.h>
#include "timespec.h"
+#include <stdckdint.h>
#include "intprops.h"
struct timespec
{
rns = nsd;
time_t bs1;
- if (!INT_ADD_WRAPV (bs, 1, &bs1))
+ if (!ckd_add (&bs1, bs, 1))
bs = bs1;
else if (rs < 0)
rs++;
goto high_overflow;
}
- if (INT_ADD_WRAPV (rs, bs, &rs))
+ if (ckd_add (&rs, rs, bs))
{
if (bs < 0)
{
#include <config.h>
#include "timespec.h"
+#include <stdckdint.h>
#include "intprops.h"
struct timespec
{
rns = ns + TIMESPEC_HZ;
time_t bs1;
- if (!INT_ADD_WRAPV (bs, 1, &bs1))
+ if (!ckd_add (&bs1, bs, 1))
bs = bs1;
else if (- TYPE_SIGNED (time_t) < rs)
rs--;
goto low_overflow;
}
- if (INT_SUBTRACT_WRAPV (rs, bs, &rs))
+ if (ckd_sub (&rs, rs, bs))
{
if (0 < bs)
{
#include <ctype.h>
#include <errno.h>
#include <limits.h>
+#include <stdckdint.h>
#include <stdlib.h>
#include <string.h>
bkm_scale (__strtol_t *x, int scale_factor)
{
__strtol_t scaled;
- if (INT_MULTIPLY_WRAPV (*x, scale_factor, &scaled))
+ if (ckd_mul (&scaled, *x, scale_factor))
{
*x = *x < 0 ? TYPE_MINIMUM (__strtol_t) : TYPE_MAXIMUM (__strtol_t);
return LONGINT_OVERFLOW;
intprops
libc-config
stdbool
+stdckdint
time_rz
configure.ac:
Depends-on:
c99
intprops
+stdckdint
timespec
configure.ac:
Depends-on:
c99
intprops
+stdckdint
timespec
configure.ac:
Depends-on:
assure
intprops
+stdckdint
stdint
configure.ac: