avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #44519] Use int64_t for time_t and an earlier epoch


From: Gregor Riepl
Subject: [avr-libc-dev] [bug #44519] Use int64_t for time_t and an earlier epoch than 2000-01-01 00:00:00
Date: Thu, 12 Mar 2015 15:11:30 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.5.0

URL:
  <http://savannah.nongnu.org/bugs/?44519>

                 Summary: Use int64_t for time_t and an earlier epoch than
2000-01-01 00:00:00
                 Project: AVR C Runtime Library
            Submitted by: onitake
            Submitted on: Thu 12 Mar 2015 03:11:29 PM GMT
                Category: Library
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: libc code
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: Unknown
           Fixed Release: None

    _______________________________________________________

Details:

This feature request applies to avr-libc 1.8.1. (the bug tracker does not list
this version)

avr-libc contains an implementation of the POSIX/ISO C time API. The
documentation states that, due to limitation of the 8bit AVR architecture,
some corners were cut and the API is limited in respect to ISO C.

This generally ok, but time_t is represented by an unsigned 32bit integer.
This runs contrary to efforts to modernize the C time API. Most modern C
runtime library implementors have opted to use a signed 64bit integer, which
avoids the "Year 2038 Problem". avr-libc avoids this problem differently, at a
cost: The time epoch is defined as midnight Jan 1 2000, and time_t is an
unsigned type. This allows for dates up to Feb 2136 to be represented, but
earlier dates than Jan 2000 are invalid.

While doing calculations on 64bit quantities bears a performance cost on an
8bit architecture, that cost is relatively small for most operations. For what
it's worth, the same applies to 32bit quantities anyway. Also, modern compiler
handle the "emulation" of 32bit and 64bit arithmetic automatically.

With these things in mind, I request that the avr-libc time implementation be
changed to use a signed 64bit type to represent a timestamp (time_t), and the
epoch be changed to an earlier date than Jan 1 2000, such as the Unix epoch
(midnight Jan 1 1970) or a different commonly used one (Jan 1 1900, Jan 1
1601). Allowing for negative timestamps to represent valid dates is also a
possibility.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?44519>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]