Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 2002 03:48:49 +0100
From:      Tony Finch <dot@dotat.at>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        standards@freebsd.org, jdp@freebsd.org
Subject:   Re: Q&D implementation of dlfunc()
Message-ID:  <20020529034849.A30428@chiark.greenend.org.uk>
In-Reply-To: <200205290223.g4T2NOMD009676@khavrinen.lcs.mit.edu>; from wollman@khavrinen.lcs.mit.edu on Tue, May 28, 2002 at 10:23:24PM -0400
References:  <200205290223.g4T2NOMD009676@khavrinen.lcs.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 28, 2002 at 10:23:24PM -0400, Garrett Wollman wrote:
> Those who follow the Austin Group lists will be aware of an issue
> raised (and not resolved there) about the unsuitability of the return
> type of dlsym() for its most common use.

They've also been arguing about it on comp.std.c.

> +/*
> + * The actual type declared by this typedef is immaterial, provided that
> + * it is a function pointer.  Its purpose is to provide a return type for
> + * dlfunc() which can be cast to a function pointer type without depending
> + * on behavior undefined by the C standard which might trigger a compiler
> + * diagnostic.  We intentionally declare a very unlikely type signature
> + * to force a diagnostic should the application not cast the return value
> + * of dlfunc() appropriately.
> + */
> +typedef void (*__dlfunc_t)(void (*)(char, short, int, ...));

I'd be inclined to be less obfuscated by using a structure type to
"guarantee" the uniqueness of the argument type of __dlfunc_t --
something like

	struct __dlfunc_arg {
		int dummy;
	};
	typedef void (*__dlfunc_t)(struct __dlfunc_arg);

and s/We .*/We use a unique structure as the argument type/.

(The structure type could be made truly unique by declaring it in the
argument list itself, but compilers will rightly warn about this since
it makes the resulting function type unusable -- which is what we want
except for the warning.)

What does "Q&D" mean?

Tony.
-- 
f.a.n.finch <dot@dotat.at> http://dotat.at/
HEBRIDES BAILEY: CYCLONIC OR SOUTHEASTERLY BECOMING SOUTHWESTERLY, 4 OR 5,
OCCASIONALLY 6 LATER. RAIN OR SHOWERS. MODERATE OR GOOD.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020529034849.A30428>