Date: Fri, 15 Jan 2021 04:47:06 +0100 From: Walter von Entferndt <walter.von.entferndt@posteo.net> To: freebsd-hackers@freebsd.org Subject: Re: Implicit assumptions (was: Re: Some fun with -O2) Message-ID: <4842729.YNO7O01DYZ@t450s.local.lan> In-Reply-To: <AE6F148E-3733-4CAE-A4D7-A2E940688E40@yahoo.com> References: <mailman.29.1610625600.45116.freebsd-hackers@freebsd.org> <12075361.5MqMfjp4zD@t450s.local.lan> <AE6F148E-3733-4CAE-A4D7-A2E940688E40@yahoo.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Eventually we have a compile-time constant expression
[-- Attachment #2 --]
--- check_mktime.c.orig 2021-01-15 03:19:33.962253000 +0100
+++ check_mktime.c 2021-01-15 04:04:22.291014000 +0100
@@ -1,13 +1,16 @@
/* Test program from Paul Eggert (eggert@twinsun.com)
and Tony Leneis (tony@plaza.ds.adp.com). */
# include <sys/time.h>
+# include <sys/param.h> /* NBBY: #bits of a byte */
# include <time.h>
# include <unistd.h>
+# include <stdlib.h>
/* Work around redefinition to rpl_putenv by other config tests. */
#undef putenv
-static time_t time_t_max;
+const time_t t0 = (time_t) 1 << (NBBY*sizeof t0 - 2); /* unused elsewhere */
+static const time_t time_t_max = t0|(t0 - 1);
/* Values we'll use to set the TZ environment variable. */
static const char *const tz_strings[] = {
@@ -106,9 +109,6 @@
time_t t, delta;
int i, j;
- for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
- continue;
- time_t_max--;
delta = time_t_max / 997; /* a suitable prime number */
for (i = 0; i < N_STRINGS; i++)
{
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4842729.YNO7O01DYZ>
