Date: Thu, 21 Apr 2005 15:42:48 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Erik Trulsson <ertr1013@student.uu.se> Cc: freebsd-standards@FreeBSD.org Subject: Re: Standard type for code pointers? Message-ID: <20050421153551.Q89192@delplex.bde.org> In-Reply-To: <20050420155407.GA844@falcon.midgard.homeip.net> References: <84dead720504200541539f4c15@mail.gmail.com> <20050420155407.GA844@falcon.midgard.homeip.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 20 Apr 2005, Erik Trulsson wrote: > On Wed, Apr 20, 2005 at 08:34:18AM -0700, Marcel Moolenaar wrote: >> >> On Apr 20, 2005, at 5:41 AM, Joseph Koshy wrote: >> >>> I'm looking for a standard type that is defined to have at least >>> as many bits as needed to hold a pointer to code. What would >>> that be? >> >> intptr_t is probably what you want. > > Except that intptr_t need only be large enough to hold an object > pointer. This is not necessarily enough to hold a function pointer. > > The only standard types that are guaranteed to be able to hold a > function pointer are other function pointers. There is no standard type for this, but there FreeBSD has the following: uintfptr_t: like uintptr_t except for function types fptrdiff_t: like ptrdiff_t except for function types These are defined in <machine/profile.h> and are supposed to be used in all profiling code written in C in the last 10 years (gprof is much older and doesn't use them except via their use in <sys/gmon.h>; gprof converts almost everything to floating point anyway, and is probably horribly broken if the function address space isn't flat (but a non-flat space could be flattened for it)). Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050421153551.Q89192>