RE: sys_init_module()

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

 



=> I'm guessing that a compiler would see that it's an offset from 0, and
=> hence know that something 8 bytes from the start of the struct returns an
=> 8.

This is the reason why I am looking for somebody having the standards.  

=> 
=> However, I'll admit that I may be wrong, and I don't have an architecture
=> that I could test this on.  In these cases (where I don't really know for
=> sure) I always use some safe code:
=> 
=> (void *)&((struct a*)0L)->field - (void *)(struct a*)0L
=> 
=> which is similar to what you suggested in an earlier post.

Hmm...!
 
=> Note that before the (void*) cast, the first expression (the address of
=> "field") is a pointer to the type of "field", while the second is to
=> something of type struct.  You cast to (unsigned long) to compare them,
=> but I prefer to use pointer arithmetic (subtracting 2 pointers of the
=> same type is perfectly legal, and since the addressed objects are
=> different I use (void*)).

Yep! This is also nice.  But stil the question remains unsolved. Actually, on
"#c", at OPN, I discussed this question. The conclusion was that this might fail
on architectures where null-pointer is not represented as 0(zero). But still, no
solid proofs yet.

-neeraj

--
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