This is the mail archive of the
mailing list for the glibc project.
Re: [PATCHv3 00/24] ILP32 support in ARM64
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Zack Weinberg <zackw at panix dot com>, libc-alpha at sourceware dot org
- Date: Tue, 17 Feb 2015 14:17:21 -0800
- Subject: Re: [PATCHv3 00/24] ILP32 support in ARM64
- Authentication-results: sourceware.org; auth=none
- References: <CAKCAbMiQh2DVjgB_-By8FN2VN01_BkEoVJQunJ9KhWdYM8wJOw at mail dot gmail dot com> <20150215042302 dot GN23507 at brightrain dot aerifal dot cx> <CAKCAbMi8xZ8x3ECwus2LTvaurA66TLA38KgpOj=cAp7k3UwYvQ at mail dot gmail dot com> <20150215160330 dot GP23507 at brightrain dot aerifal dot cx> <54E38AAD dot 6040308 at panix dot com>
On 02/17/2015 10:38 AM, Zack Weinberg wrote:
No, because that loses precision. The most common solution in portable
programs is to convert tv_nsec to 'long' (or to 'int' -- that's good
enough for POSIX) before printing. This works on both POSIX and x32
GNU/Linux. One needs to convert tv_sec anyway, and it's easy to convert
tv_nsec too. Something like this, say:
I expect the
overwhelming majority of programs print tv_nsec by converting it to
_double_ for ease of combination with tv_sec.
printf_timespec (struct timespec ts)
if ((time_t) -1 < 0)
return printf ("%jd.%.9d", (intmax_t) ts.tv_sec, (int) ts.tv_nsec);
return printf ("%ju.%.9d", (uintmax_t) ts.tv_sec, (int) ts.tv_nsec);
Typical GNU software already does this sort of thing.