From owner-freebsd-arch@FreeBSD.ORG Thu Dec 4 19:54:43 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31B891065676 for ; Thu, 4 Dec 2008 19:54:43 +0000 (UTC) (envelope-from max@love2party.net) Received: from mout-bounce.kundenserver.de (mout-bounce.kundenserver.de [212.227.17.2]) by mx1.freebsd.org (Postfix) with ESMTP id B6FCB8FC0C for ; Thu, 4 Dec 2008 19:54:42 +0000 (UTC) (envelope-from max@love2party.net) Received: from vampire.homelinux.org (dslb-088-066-028-001.pools.arcor-ip.net [88.66.28.1]) by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis) id 0ML2xA-1L8K5P0IfO-0007WA; Thu, 04 Dec 2008 20:42:07 +0100 Received: (qmail 86542 invoked from network); 4 Dec 2008 19:42:06 -0000 Received: from unknown (HELO fbsd8.laiers.local) (192.168.4.151) by router.laiers.local with SMTP; 4 Dec 2008 19:42:06 -0000 From: Max Laier Organization: FreeBSD To: freebsd-arch@freebsd.org Date: Thu, 4 Dec 2008 20:42:05 +0100 User-Agent: KMail/1.10.1 (FreeBSD/8.0-CURRENT; KDE/4.1.1; i386; ; ) References: <49381DD4.2000506@kasimir.com> <49382502.1040403@delphij.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200812042042.06181.max@love2party.net> X-Provags-ID: V01U2FsdGVkX18GI/MQvPvYjdmfbXaSBrkGz3WJnQe3riJRLTl hYq9SzBgyhG3NMRtLyuQc39+ftnkwnInSm+WXFJqfdH1KOMiKm Gc7WFc4R+8OoddD/xSBXQ== Cc: Florian Smeets , d@delphij.net Subject: Re: Adding strndup(3) to libc viable/useful? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2008 19:54:43 -0000 On Thursday 04 December 2008 20:27:01 Peter Wemm wrote: > On Thu, Dec 4, 2008 at 10:44 AM, Xin LI wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > Hi, Florian, > > > > Florian Smeets wrote: > >> Hi, > >> > >> first of all i hope arch is the correct place to discuss this. > >> > >> While porting an application to FreeBSD i found that FreeBSDs libc does > >> not have strndup. NetBSD added this about 2 years ago. A port of this to > >> FreeBSD was very easy. > >> > >> There are 13 ports in the ports tree right now that patch in strndup via > >> a patch in the files/ dir, well actually 12 bring there own version of > >> strndup and one replaces it with a call to malloc/strncpy. > >> > >> Would it make sense to add this to our libc? A patch which does this is > >> available here at http://webmail.solomo.de/~flo/strndup.patch > >> > >> I don't know if there is such a thing as minimum number of ports to > >> require a function so that it can be added to the base system... > >> > >> Any feedback appreciated. > > > > I think whether or not to add it really depends on how popular it is :) > > We included strdup() because it is a very common extension. > > > > Your patch looks fine but perhaps it would be a good idea to explicitly > > mention that this is not a commonly implemented GNU extension > > (inheritedly, this could reduce portability). > > glibc has had this for a long time and the trend for this function > seems to be gaining ground. I think solaris is the last remaining > major holdout. > > str*() namespace belongs to the implementation (us). > > There are lots of places where I've seen strndup() implemented as > compatability shims. Everything from Asterisk to Varnish. I wouldn't > be suprised if there were ports that had this knowledge hard coded. > > FWIW, there are a bunch of other useful utility str*() and mem*() > functions that glibc has that we do not. strnvis! (from OpenBSD) > I've run into the lack of fmemopen() in the past. I found an > implementation from rwatson. -- /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News