Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Feb 1999 20:41:29 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, dfr@nlsystems.com
Cc:        cvs-commiters@FreeBSD.ORG, mjacob@feral.com, wollman@khavrinen.lcs.mit.edu
Subject:   Re: sizeof (ptr) != sizeof (unsigned)
Message-ID:  <199902020941.UAA09865@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> >> >       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



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