From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Is sizeof(void *) ever != sizeof(unsigned long)? From: Nigel Cunningham Reply-To: ncunningham@linuxmail.org Content-Type: text/plain Message-Id: <1102155752.1018.7.camel@desktop.cunninghams> Mime-Version: 1.0 Date: Sat, 04 Dec 2004 21:40:09 +1100 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Linux Memory Management List-ID: 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: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: Is sizeof(void *) ever != sizeof(unsigned long)? From: Robert Love In-Reply-To: <1102155752.1018.7.camel@desktop.cunninghams> References: <1102155752.1018.7.camel@desktop.cunninghams> Content-Type: text/plain Date: Sat, 04 Dec 2004 11:26:17 -0500 Message-Id: <1102177577.6052.39.camel@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: ncunningham@linuxmail.org Cc: Linux Memory Management List-ID: 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: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <20041204170217.45200.qmail@web53908.mail.yahoo.com> Date: Sat, 4 Dec 2004 09:02:17 -0800 (PST) From: Fawad Lateef Subject: Re: Is sizeof(void *) ever != sizeof(unsigned long)? In-Reply-To: <1102155752.1018.7.camel@desktop.cunninghams> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-linux-mm@kvack.org Return-Path: To: ncunningham@linuxmail.org Cc: linux-mm@kvack.org List-ID: The sizeof() 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: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: Is sizeof(void *) ever != sizeof(unsigned long)? From: Nigel Cunningham Reply-To: ncunningham@linuxmail.org In-Reply-To: <1102177577.6052.39.camel@localhost> References: <1102155752.1018.7.camel@desktop.cunninghams> <1102177577.6052.39.camel@localhost> Content-Type: text/plain Message-Id: <1102194893.4884.2.camel@desktop.cunninghams> Mime-Version: 1.0 Date: Sun, 05 Dec 2004 08:14:54 +1100 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Robert Love , Fawad Lateef Cc: Linux Memory Management List-ID: 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: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: Is sizeof(void *) ever != sizeof(unsigned long)? From: Robert Love In-Reply-To: <20041204170217.45200.qmail@web53908.mail.yahoo.com> References: <20041204170217.45200.qmail@web53908.mail.yahoo.com> Content-Type: text/plain Date: Sat, 04 Dec 2004 16:32:41 -0500 Message-Id: <1102195961.6052.71.camel@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Fawad Lateef Cc: ncunningham@linuxmail.org, linux-mm@kvack.org List-ID: On Sat, 2004-12-04 at 09:02 -0800, Fawad Lateef wrote: > The sizeof() 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: aart@kvack.org