Messages in this thread | | | From | (H. Peter Anvin) | Subject | Re: Q: void* vs. unsigned long | Date | 16 Feb 1999 05:00:24 GMT |
| |
Followup to: <36C8F5B0.6D56F88D@quark.vpplus.com> By author: Brian Gerst <bgerst@quark.vpplus.com> In newsgroup: linux.dev.kernel > > > > I'm curious about the mixed use of void* and unsigned long in the kernel to > > represent addresses (as in tqueue.h vs. timer.h). Is it simply a case of > > author preference, or is it subtle semantics for the case where a datam is > > most likely an integer value but _could_ also be a pointer? Or is it more > > complicated? With the future in mind, what is recommended to budding > > kernel hackers? > > sizeof (void *) == sizeof (unsigned long) if and only if you are on a > 32-bit arch, like i386. The only place unsigned long should be used is > in arch specific code, and even then it's use should not be encouraged. > If such code exists in the general kernel (device drivers, file systems, > etc.) then it is severely broken from a portability standpoint and will > not work on 64-bit arches. >
Actually, it will. sizeof(unsigned long) == sizeof(void *) == 8 on 64-bit architectures.
-hpa -- "Linux is a very complete and sophisticated operating system. There are, and will be, large numbers of applications available for it." -- Paul Maritz, Group Vice President for Platforms And Applications, Microsoft Corporation [Reference at: http://www.kernel.org/~hpa/ms.html]
- 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/
| |