* Is sizeof(void *) ever != sizeof(unsigned long)?
@ 2004-12-04 10:40 Nigel Cunningham
2004-12-04 16:26 ` Robert Love
2004-12-04 17:02 ` Fawad Lateef
0 siblings, 2 replies; 5+ messages in thread
From: Nigel Cunningham @ 2004-12-04 10:40 UTC (permalink / raw)
To: Linux Memory Management
Hi.
I guess the subject line says it all.
Regards,
Nigel
--
Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901
You see, at just the right time, when we were still powerless, Christ
died for the ungodly. -- Romans 5:6
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is sizeof(void *) ever != sizeof(unsigned long)?
2004-12-04 10:40 Is sizeof(void *) ever != sizeof(unsigned long)? Nigel Cunningham
@ 2004-12-04 16:26 ` Robert Love
2004-12-04 21:14 ` Nigel Cunningham
2004-12-04 17:02 ` Fawad Lateef
1 sibling, 1 reply; 5+ messages in thread
From: Robert Love @ 2004-12-04 16:26 UTC (permalink / raw)
To: ncunningham; +Cc: Linux Memory Management
On Sat, 2004-12-04 at 21:40 +1100, Nigel Cunningham wrote:
> I guess the subject line says it all.
In general? Sure. There is no guarantee in C or the "ABI Writer's
Handbook."
In Linux, though, especially the kernel, we run with that assumption.
An "unsigned long" can always hold a pointer, it is always equal to the
wordsize. This just means that architecture ports in Linux have to be
LP32 or LP64 or whatever.
A lot of code in the kernel uses an "unsigned long" instead of a "void*"
to hold a generic memory address. I personally like this practice, if
you never intend to directly dereference the pointer.
Robert Love
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is sizeof(void *) ever != sizeof(unsigned long)?
2004-12-04 10:40 Is sizeof(void *) ever != sizeof(unsigned long)? Nigel Cunningham
2004-12-04 16:26 ` Robert Love
@ 2004-12-04 17:02 ` Fawad Lateef
2004-12-04 21:32 ` Robert Love
1 sibling, 1 reply; 5+ messages in thread
From: Fawad Lateef @ 2004-12-04 17:02 UTC (permalink / raw)
To: ncunningham; +Cc: linux-mm
The sizeof(<pointer>) is always of 32bits or 4bytes on
x86 Architecture, and you can say that it is actually
the virtual address size of the Architecture. And
unsigned long is actually what I understand is the
size which a single architecture can address in a
single atempt, like roughly you can say that in x86
architecture long can be accesses in single cycle.
By defination, they can be not equal to each other but
practically it is same .........
Thanks and Regards,
Fawad
__________________________________
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is sizeof(void *) ever != sizeof(unsigned long)?
2004-12-04 16:26 ` Robert Love
@ 2004-12-04 21:14 ` Nigel Cunningham
0 siblings, 0 replies; 5+ messages in thread
From: Nigel Cunningham @ 2004-12-04 21:14 UTC (permalink / raw)
To: Robert Love, Fawad Lateef; +Cc: Linux Memory Management
Thanks for the replies.
Regards,
Nigel
--
Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901
You see, at just the right time, when we were still powerless, Christ
died for the ungodly. -- Romans 5:6
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Is sizeof(void *) ever != sizeof(unsigned long)?
2004-12-04 17:02 ` Fawad Lateef
@ 2004-12-04 21:32 ` Robert Love
0 siblings, 0 replies; 5+ messages in thread
From: Robert Love @ 2004-12-04 21:32 UTC (permalink / raw)
To: Fawad Lateef; +Cc: ncunningham, linux-mm
On Sat, 2004-12-04 at 09:02 -0800, Fawad Lateef wrote:
> The sizeof(<pointer>) is always of 32bits or 4bytes on
> x86 Architecture, and you can say that it is actually
> the virtual address size of the Architecture. And
> unsigned long is actually what I understand is the
> size which a single architecture can address in a
> single atempt, like roughly you can say that in x86
> architecture long can be accesses in single cycle.
I think the term that you want is "word size" -- you want to say that a
C long type is guaranteed to be the word size, which is generally the
size of a single GPR.
But that is not true, actually. Nothing in C or anywhere else says that
the long type has to be the size of a GPR. Specifically in Linux, the
SPARC64 user-space ABI has a 32-bit long type despite being a 64-bit
architecture--in other words, SPARC64 has a 32-bit user-space even
though it is a 64-bit architecture.
In the kernel, however, we have the ABI such that both pointers and
longs are the same size, generally the size of the GPR. But there is a
difference between physical requirements, C requirements, the user-space
ABI, and the kernel ABI.
> By defination, they can be not equal to each other but
> practically it is same .........
By definition (the Linux kernel ABI) they _are_ equal in size to each
other.
Robert Love
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-12-04 21:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-04 10:40 Is sizeof(void *) ever != sizeof(unsigned long)? Nigel Cunningham
2004-12-04 16:26 ` Robert Love
2004-12-04 21:14 ` Nigel Cunningham
2004-12-04 17:02 ` Fawad Lateef
2004-12-04 21:32 ` Robert Love
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox