9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: [9fans] gmtime() ulong
Date: Mon,  3 Jun 2013 01:31:10 +0200	[thread overview]
Message-ID: <9fd46f174ab35243e649a8cec6705de6@gmx.de> (raw)

a while ago, libc's gmtime() was changed like this:

-	hms = tim % 86400L;
-	day = tim / 86400L;
+	hms = (ulong)tim % 86400L;
+	day = (ulong)tim / 86400L;
	if(hms < 0) {
		...

i asked what this change tried to intend here:

http://9fans.net/archive/2013/05/12

anyone?

on the topic, i thought about how to handle the 2038 problem
in general with 9p which uses unsigned 32bit integers for atime
and mtime fields.

whenever we get 32 bit time field that cannot represent time,
we could interpret it in context of the system time.

say, if we get to interpret a mtime or atime filed from (old?)
9p server, we do:

/* new types */
vlong now, mtime;

/*
 * get current system time, with some form of new time()
 * function returning 64bit signed integer.
 */
now = time(0);

/*
 * olddir->mtime being 32bit unsigned integer from legacy system
 * and mtime being new 64bit signed integer time
 */
mtime = now + (vlong)(olddir->mtime - (now & 0xFFFFFFFF));

so whenever we get some old 32 bit long time type, we assume that the
values just wrap arround and we have to interpret it in context
to the current time assuming that the time delta to current time will
be smaller than 2^32 seconds.

does this make any sense?

--
cinap



             reply	other threads:[~2013-06-02 23:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-02 23:31 cinap_lenrek [this message]
2013-06-03  1:03 ` cinap_lenrek
2013-06-03  2:28 ` erik quanstrom
2013-06-03 19:09 ` Richard Miller
2013-06-03 19:11   ` erik quanstrom
2013-06-03 19:15     ` Richard Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9fd46f174ab35243e649a8cec6705de6@gmx.de \
    --to=cinap_lenrek@gmx.de \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).