From owner-freebsd-standards@FreeBSD.ORG Thu Apr 21 05:42:55 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1BC2316A4CE for ; Thu, 21 Apr 2005 05:42:55 +0000 (GMT) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8275943D39 for ; Thu, 21 Apr 2005 05:42:54 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])j3L5grJu031023; Thu, 21 Apr 2005 15:42:53 +1000 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) j3L5gm0I010875; Thu, 21 Apr 2005 15:42:50 +1000 Date: Thu, 21 Apr 2005 15:42:48 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Erik Trulsson In-Reply-To: <20050420155407.GA844@falcon.midgard.homeip.net> Message-ID: <20050421153551.Q89192@delplex.bde.org> References: <84dead720504200541539f4c15@mail.gmail.com> <20050420155407.GA844@falcon.midgard.homeip.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed cc: freebsd-standards@FreeBSD.org Subject: Re: Standard type for code pointers? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2005 05:42:55 -0000 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 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 ; 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