From owner-freebsd-current@FreeBSD.ORG Mon Apr 25 13:24:12 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7FEE316A4CE for ; Mon, 25 Apr 2005 13:24:12 +0000 (GMT) Received: from mail-sin2.microsoft.com (mail-sin2.microsoft.com [207.46.50.82]) by mx1.FreeBSD.org (Postfix) with ESMTP id ADC0143D49 for ; Mon, 25 Apr 2005 13:24:11 +0000 (GMT) (envelope-from mayank@microsoft.com) Received: from APS-MSG-01.southpacific.corp.microsoft.com ([157.60.218.45]) by mail-sin2.microsoft.com with Microsoft SMTPSVC(6.0.3790.211); Mon, 25 Apr 2005 21:19:09 +0800 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Apr 2005 21:19:12 +0800 Message-ID: <3A5384BC2FBA4C488865F2275A036BFF027C1614@APS-MSG-01.southpacific.corp.microsoft.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Query regarding thread safety of few libc stdio functions thread-index: AcVJmHm33y2izWcETyyNZsTSYWUJwAAABKhw From: "Mayank Kumar" To: X-OriginalArrivalTime: 25 Apr 2005 13:19:09.0886 (UTC) FILETIME=[5D95F5E0:01C54999] Subject: Query regarding thread safety of few libc stdio functions X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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, 25 Apr 2005 13:24:12 -0000 Hi All Recently I have been looking at few freebsd libc functions and I found That they were not thread safe. Can one of you please confirm. Following functions in freebsd libc are not thread safe:- 1: vsnprintf 2: vsprintf 3: vsscanf theere are many more. Functions like vfprintf are written as follows:- ------------- int ret; FLOCKFILE(fp); ret =3D __vfprintf(fp, fmt0, ap); FUNLOCKFILE(fp); return (ret); ---------------- Which ensures that they are thread safe. Why is the same case not followed for eg with vsnprintf or vsprintf Vsnprintf calls directly __vfprintf which is not thread safe. Hence How is there thready safey guranteed. Any help on this front Would be helpful. Thanks and regards Mayank