localtime() vs localtime_r()
David Xu
davidxu at FreeBSD.org
Sun Mar 30 20:35:18 PDT 2008
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
More information about the freebsd-current
mailing list