Re: strcut casts unsigned long

Javier Martinez Canillas <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
>
> But does skb->_skb_dst allocate memory any where? It is unsigned long. This is hard part for me to understand. Any explain why unsigned long
> _skb_dst can be that?
>

skb->_skb_dst is a pointer. A pointer is nothing else that a variable
that stores a memory value (i.e: 0x0012ff5C). This value represent a
memory address. Usually pointers are defined as * type, so the
compiler can make type checking when analizing language expressions.
But you could represent as a generic void * pointer. In the kernel,
memoryaddresses are usually represented as variables of types unsigned
long.

To make an analogy, char and int variables are integers, but you
usually use char variables to represent ASCII codes. You can cast a
char to an int, even when int is  meant to represent integers. The
same way you could store a memory address either in a void * or
unsigned long variable.

I don't know why it is use unsigned long, but I guess that the GNU C
standard says that unsigned long it is the same size that the cpu word
size in all architechtures.

Best regards,

-----------------------------------------
Javier Martínez Canillas
+595 981 88 66 58
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.