From owner-freebsd-current@FreeBSD.ORG Tue Apr 1 10:59:12 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36E421065670; Tue, 1 Apr 2008 10:59:12 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from mail11.syd.optusnet.com.au (mail11.syd.optusnet.com.au [211.29.132.192]) by mx1.freebsd.org (Postfix) with ESMTP id BC7488FC28; Tue, 1 Apr 2008 10:59:11 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from server.vk2pj.dyndns.org (c220-239-20-82.belrs4.nsw.optusnet.com.au [220.239.20.82]) by mail11.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id m31Ax922014907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 1 Apr 2008 21:59:10 +1100 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.2/8.14.1) with ESMTP id m31Ax9Dt054780; Tue, 1 Apr 2008 21:59:09 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.2/8.14.2/Submit) id m31Ax9Xg054779; Tue, 1 Apr 2008 21:59:09 +1100 (EST) (envelope-from peter) Date: Tue, 1 Apr 2008 21:59:09 +1100 From: Peter Jeremy To: David Xu Message-ID: <20080401105909.GD24181@server.vk2pj.dyndns.org> References: <47F05C44.9020603@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GpGaEY17fSl8rd50" Content-Disposition: inline In-Reply-To: <47F05C44.9020603@freebsd.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.17 (2007-11-01) Cc: FreeBSD Current Subject: Re: 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: Tue, 01 Apr 2008 10:59:12 -0000 --GpGaEY17fSl8rd50 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 31, 2008 at 11:36:36AM +0800, David Xu wrote: >According POSIX specification, it seems localtime_r() is not only >a reentrant version of localtime(), but also a performance-wise version. IMO, localtime_r() is _not_ reentrant because it implicitly uses TZ =66rom the environment, rather than having TZ (ither as TZ or struct state) passed as an argument. I have an application that does conversions between timezones and this lack is a PITA. >Our implementation does set tzname, tomezone and daylight, it is a bit >slower than glibc because ours has to call getenv() everytime. Given that POSIX stuffed the definition of localtime_r(), it's not clear how to avoid this. I guess you could change the tzset_basic() call in localtime_r() to something like: static initialised =3D 0; if (!initialised) { tzset_basic(); initialised =3D 1; } which means it won't see changes to TZ. --=20 Peter Jeremy Please excuse any delays as the result of my ISP's inability to implement an MTA that is either RFC2821-compliant or matches their claimed behaviour. --GpGaEY17fSl8rd50 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.8 (FreeBSD) iEYEARECAAYFAkfyFX0ACgkQ/opHv/APuIeR6QCdHwfOftuwEyES2xv2kYyFajfl Ul8An1ztBUIsyTD5BGdOj1x86j0RpG4M =IfCH -----END PGP SIGNATURE----- --GpGaEY17fSl8rd50--