Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 May 2011 20:06:52 -0400
From:      Alexander Kabaev <kabaev@gmail.com>
To:        Warner Losh <imp@bsdimp.com>
Cc:        Bruce, mdf@freebsd.org, Evans <brde@optusnet.com.au>, freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: sizeof(function pointer)
Message-ID:  <20110531200652.3fd6fcbe@kan.dnsalias.net>
In-Reply-To: <D541877D-0EE5-4EC3-9197-E9F2A7A10AC1@bsdimp.com>
References:  <BANLkTimctcBWRrYVLyc-WLgePyCXqaPTGA@mail.gmail.com> <D541877D-0EE5-4EC3-9197-E9F2A7A10AC1@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/T7iGdQ5fH88cY+VF2hw12sz
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Tue, 31 May 2011 17:18:16 -0600
Warner Losh <imp@bsdimp.com> wrote:

>=20
> On May 31, 2011, at 5:07 PM, mdf@freebsd.org wrote:
>=20
> > I am looking into potentially MFC'ing r212367 and related, that adds
> > drains to sbufs.  The reason for MFC is that several pieces of new
> > code in CURRENT are using the drain functionality and it would make
> > MFCing those changes much easier.
> >=20
> > The problem is that r212367 added a pointer to a drain function in
> > the sbuf (it replaced a pointer to void).  The C standard doesn't
> > guarantee that a void * and a function pointer have the same size,
> > though its true on amd64, i386 and I believe PPC.  What I'm
> > wondering is, though not guaranteed by the standard, is it
> > *practically* true that sizeof(void *) =3D=3D sizeof(int(*)(void)),
> > such that an MFC won't break binary compatibility for any supported
> > architecture?  (The standard does guarantee, though not in words,
> > that all function pointers have the same size, since it guarantees
> > that pointers to functions can be cast to other pointers to
> > functions and back without changing the value).
> >=20
> > Another possibility is to malloc a blob that is sizeof(int(*)(void))
> > and store that in a renamed s_unused; this is a bit messier but
> > guaranteed to work.  I'd just rather the code be an MCF instead of a
> > partial re-write.
>=20
> It is the same on MIPS too for all three ABIs that we support (and
> all ABIs that I know about).  It is true on ARM as well.
>=20
> Usually it is different only on segmented architectures like 16-bit
> x86.
>=20

Not so on ia64, where they have special function descriptor type.

--=20
Alexander Kabaev

--Sig_/T7iGdQ5fH88cY+VF2hw12sz
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)

iD8DBQFN5YKhQ6z1jMm+XZYRAiK3AKCSuEio0fx7ad5Fz2KpK+nuHTgKfwCfe3Ct
Cd5nVJmXm44uRN/E6dm36yE=
=hwor
-----END PGP SIGNATURE-----

--Sig_/T7iGdQ5fH88cY+VF2hw12sz--



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