localtime() vs localtime_r()

From: David Xu <davidxu_at_FreeBSD.org>
Date: Mon, 31 Mar 2008 11:36:36 +0800
According POSIX specification, it seems localtime_r() is not only
a reentrant version of localtime(), but also a performance-wise version.

http://www.opengroup.org/onlinepubs/000095399/functions/localtime.html


[TSF] [Option Start] The localtime_r() function shall convert the time 
in seconds since the Epoch pointed to by timer into a broken-down time 
stored in the structure to which result points. The localtime_r() 
function shall also return a pointer to that same structure.

Unlike localtime(), the reentrant version is not required to set tzname.

[TSF] [Option Start] If the reentrant version does not set tzname, it 
shall not set daylight and shall not set timezone. [Option End]


Our implementation does set tzname, tomezone and daylight, it is a bit
slower than glibc because ours has to call getenv() everytime.

Regards,
David Xu
Received on Mon Mar 31 2008 - 01:35:17 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:29 UTC