From owner-cvs-all Tue Feb 2 01:41:38 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA16229 for cvs-all-outgoing; Tue, 2 Feb 1999 01:41:38 -0800 (PST) (envelope-from owner-cvs-all@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA16219 for ; Tue, 2 Feb 1999 01:41:33 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id UAA09865; Tue, 2 Feb 1999 20:41:29 +1100 Date: Tue, 2 Feb 1999 20:41:29 +1100 From: Bruce Evans Message-Id: <199902020941.UAA09865@godzilla.zeta.org.au> To: bde@zeta.org.au, dfr@nlsystems.com Subject: Re: sizeof (ptr) != sizeof (unsigned) Cc: cvs-commiters@FreeBSD.ORG, mjacob@feral.com, wollman@khavrinen.lcs.mit.edu Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk >> >> > bcopy(&p1->p_procsig->ps_begincopy, &p2->p_procsig->ps_begincopy, >> >> > (unsigned)&p1->p_procsig->ps_endcopy - >> >> > (unsigned)&p1->p_procsig->ps_begincopy); >It isn't likely to be a problem since it is just working out the >difference between the pointers. Why not cast to u_intptr_t instead since >that is supposed to be an int of the right width. Because casting to uintptr_t is inferior to casting to `char *'. Here is what the C9x draft says about uintptr_t: > The following type designates an unsigned integer type with > the property that any valid pointer to void can be converted > to this type, then converted back to pointer to void, and > the result will compare equal to the original pointer: > > uintptr_t > > (These types need not exist in an implementation.) I.e., if you want to use uintptr_t portably, then you first have to ifdef on the symbol that says whether uintptr_t exists. If it exists, then it can be used to represent object pointers (to represent an arbitrary object pointer, first convert to pointer to void). That's all. The representation is unspecified, so uintptr_t can't be used to do pointer arithmetic. I didn't know it was so limited whan I started using it in the kernel. I probably should have used vm_offset_t. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message