Re: inline asm question(s)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mit, 2004-06-30 at 12:01, Jan Hudec wrote:
> On Wed, Jun 30, 2004 at 12:43:24 +0300, Nir Tzachar wrote:
> > On Wed, 30 Jun 2004, Jan Hudec wrote:
> > 
> > > > as i've said b4, i dont see what this macro has to do with the memory 
> > > > representation of the null pointer. 
> > > > the ((type *)0) member is used to get a pointer to a struct 'type',
> > > > which is located at address 0 -> hence, the address of the member is its
> > > > offset in the struct. nothing to do with actual memory... 
> > > 
> > > No. ((type *)0) is used to get a NULL pointer of given type. The
> > > C specification DOES say 0 must convert to NULL and does NOT say it must
> > > be located on address 0. In gcc, it always is, though.
> > 
> > thats my point. i dont care about C specifications, as u said before, but 

Probably you should since it is defined there.

> > what gcc does. if ((type *)0) was not located at address 0, this macro 
> > would not work.

Then the compiler is broken or not a C compiler.

And that *is* the point. All your "0" and "NULL" above are the C source
representation independent of the bitmap used on the hardware at
run-time. And it must always work.

> Yes. Well, though, it could still be saved. It's the condition that:
> (char *)a - (char *)b == (int)a - (int)b, that's relied upon. If, eg.

The pointer subtraction is only defined if both pointers point to the
same array. Yes, I know that this is (almost) never checked and works as
above (at least with the gcc).

> all addresses were moved by a constant, it would still work.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux