[OpenIndiana-discuss] How to tell for sure what bit your OS is?

Richard L. Hamilton rlhamil at smart.net
Wed May 31 17:30:43 UTC 2017


> On May 31, 2017, at 13:01, Alan Coopersmith <alan.coopersmith at oracle.com> wrote:
> 
> On 05/31/17 09:43 AM, Richard L. Hamilton wrote:
>> The alternative would be a large times analog of large file support; why that wasn't done when 64-bit began, I don't understand. :-)
> 
> It was considered at Sun in the late 90's but discarded as going full LP64
> already provided a solution without combinatorial explosion of test matrices
> for large files x large times.  The large files API was created before LP64
> was an option on most Unixes, including Solaris.
> 

Testing, yes; that makes sense.

How are the time conversion functions doing with regard to time_t past INT32_MAX?  I see that (with a 64-bit executable) at least ctime() seems to work enough beyond for usual life and commercial purposes (aside from radioactive waste :-) ):

13:15:32[13]monster:/home/rlhamil> ./maxtime
time overflow after Tue Jan 19 03:14:07 2038
 in 32-bit signed two's complement
timestamp 9223372036854775807 (INT64_MAX) cannot be processed by ctime()
t=2147483647: Tue Jan 19 03:14:07 2038

t=4294967294: Sun Feb  7 06:28:14 2106

t=8589934588: Wed Mar 16 12:56:28 2242

t=17179869176: Wed May 30 01:52:56 2514

t=34359738352: Tue Oct 26 03:45:52 3058

t=68719476704: Sun Aug 20 07:31:44 4147

t=137438953408: Wed Apr  8 15:03:28 6325

t=274877906816: (null)
t=549755813632: (null)
t=1099511627264: (null)
t=2199023254528: (null)
t=4398046509056: (null)
t=8796093018112: (null)
t=17592186036224: (null)
t=35184372072448: (null)
t=70368744144896: (null)
t=140737488289792: (null)
t=281474976579584: (null)
t=562949953159168: (null)
t=1125899906318336: (null)
t=2251799812636672: (null)
t=4503599625273344: (null)
t=9007199250546688: (null)
t=18014398501093376: (null)
t=36028797002186752: (null)
t=72057594004373504: (null)
t=144115188008747008: (null)
t=288230376017494016: (null)
t=576460752034988032: (null)
t=1152921504069976064: (null)
t=2305843008139952128: (null)
t=4611686016279904256: (null)
t=9223372032559808512: (null)


However on a Mac, one gets quite a bit further with the doubling, with the last success in my sequence of tests at

t=36028797002186752: Tue Dec  1 02:05:52     1141709096


Here's the program, which I wrote mostly for giggles (the fate of the universe, let alone humans in a mere billion years to say nothing of nearly three hundred billion (INT64_MAX time_t), is very speculative at best).  It is of course not portable, since time_t doesn't have to even be an int, let alone 32 or 64 bit twos-compliment, although most are.

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>

int
main(int argc, char **argv)
{

	time_t t;

	char *ct;

	putenv("TZ=UTC0");

	t = INT32_MAX;
	printf("time overflow after %s in 32-bit signed two's complement\n",	ctime(&t));

	t = INT64_MAX;
	if ((ct = ctime(&t)) != NULL)
		printf("time overflow after %s in 64-bit signed two's complement\n",		ct);
	else
		printf("timestamp %lld (INT64_MAX) cannot be processed by ctime()\n", INT64_MAX);

	for (t=INT32_MAX;t<=INT64_MAX && t>=0L;t<<=1)
		printf("t=%ld: %s\n", t, ctime(&t));

	return 0;
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP
URL: <http://openindiana.org/pipermail/openindiana-discuss/attachments/20170531/cb060bcd/attachment.bin>


More information about the openindiana-discuss mailing list