[CFT] Importing NetBSD's vis/unvis(3)

Jilles Tjoelker jilles at stack.nl
Fri Dec 14 13:46:54 UTC 2012


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


More information about the freebsd-arch mailing list