Re: Q: void* vs. unsigned long

Oliver Xymoron (oxymoron@waste.org)
Mon, 15 Feb 1999 23:38:56 -0600 (CST)


On 16 Feb 1999, H. Peter Anvin wrote:

> > sizeof (void *) == sizeof (unsigned long) if and only if you are on a
> > 32-bit arch, like i386.
>
> Actually, it will. sizeof(unsigned long) == sizeof(void *) == 8 on
> 64-bit architectures.

And probably a couple 16-bit systems as well. But that's just
coincidence. For instance, if the 386 wasn't so woefully register-impaired,
unsigned long would be 64-bit. And I'd bet a quarter that sizeof(void *)
will not be 16 on a 128-bit machine (when we finally see one).

But what we need here is "an integral type which can represent all
possible pointer values". Unsigned long should be safe for that on all
sane architectures/compilers[1] and might even be guaranteed by the C
standard. Probably won't work on all DSPs though, but we're not likely to
see any of those running Linux soon for other reasons.

[1] 386 with 48-bit selector:offset pointer model ala Watcom is not sane

--
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.." 

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/