Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Mar 2008 11:36:36 +0800
From:      David Xu <davidxu@FreeBSD.org>
To:        FreeBSD Current <freebsd-current@FreeBSD.org>
Subject:   localtime() vs localtime_r()
Message-ID:  <47F05C44.9020603@freebsd.org>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47F05C44.9020603>