From owner-freebsd-current@FreeBSD.ORG Mon Mar 31 03:35:17 2008 Return-Path: Delivered-To: freebsd-current@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBF6A1065673 for ; Mon, 31 Mar 2008 03:35:17 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B424E8FC1A for ; Mon, 31 Mar 2008 03:35:17 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from apple.my.domain (root@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m2V3ZCkl054222 for ; Mon, 31 Mar 2008 03:35:15 GMT (envelope-from davidxu@freebsd.org) Message-ID: <47F05C44.9020603@freebsd.org> Date: Mon, 31 Mar 2008 11:36:36 +0800 From: David Xu User-Agent: Thunderbird 2.0.0.9 (X11/20071211) MIME-Version: 1.0 To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: localtime() vs localtime_r() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Mar 2008 03:35:18 -0000 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