From owner-freebsd-arch@FreeBSD.ORG Fri Dec 14 13:46:54 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3FCA55AC; Fri, 14 Dec 2012 13:46:54 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id CD8CB8FC14; Fri, 14 Dec 2012 13:46:53 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id D0446358C5A; Fri, 14 Dec 2012 14:46:52 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id B88452848C; Fri, 14 Dec 2012 14:46:52 +0100 (CET) Date: Fri, 14 Dec 2012 14:46:52 +0100 From: Jilles Tjoelker To: Brooks Davis Subject: Re: [CFT] Importing NetBSD's vis/unvis(3) Message-ID: <20121214134652.GB89880@stack.nl> References: <20121211202925.GA40927@lor.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121211202925.GA40927@lor.one-eyed-alien.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 13:46:54 -0000 On Tue, Dec 11, 2012 at 02:29:25PM -0600, Brooks Davis wrote: > As part of importing NetBSD's mtree I need to add more vis(3) API > functions from NetBSD. The easiest path seems to be a wholesale import > of their code with the addition of VIS_GLOB support for compatibility. > The attached patch accomplishes this. Please review or test. > The ABI of unvis changes slightly so I've added a compatibility shim for > it. Looks like NetBSD changed it such that it cannot be kept compatible this time, by using vis(3) flags for unvis(3) which must collide with our old unvis(3) flags. > Note that old files must be removed in addition to applying the patch so > Make finds the right files. > http://people.freebsd.org/~brooks/patches/vis.diff > [snip] > diff -ruN contrib/libc-vis/unvis.c contrib/libc-vis/unvis.c > --- contrib/libc-vis/unvis.c 1969-12-31 18:00:00.000000000 -0600 > +++ contrib/libc-vis/unvis.c 2012-10-20 09:22:09.000000000 -0500 > @@ -0,0 +1,562 @@ > [snip] > +/* > + * RFC 1866 > + */ > +static const struct nv { > + const char *name; > + uint8_t value; > +} nv[] = { > + { "AElig", 198 }, /* capital AE diphthong (ligature) */ > + { "Aacute", 193 }, /* capital A, acute accent */ > + { "Acirc", 194 }, /* capital A, circumflex accent */ > [snip] > +}; Please avoid adding 100 relative relocations, for example by changing const char *name to char name[7]. RTLD will have to adjust 100 pointers for the load address of libc.so.7, and even in a static library the pointers take up a disproportionate amount of space. > [snip] > +#define CHECKSPACE() \ > + do { \ > + if (dlen-- == 0) { \ > + errno = ENOSPC; \ > + return -1; \ > + } \ > + } while (/*CONSTCOND*/0) A creative use of [ENOSPC], but NetBSD does it too... > [snip] -- Jilles Tjoelker