linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <martinez.javier@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: strcut casts unsigned long
Date: Fri, 13 Aug 2010 17:49:14 -0400	[thread overview]
Message-ID: <AANLkTinGyk2y94XDtDL7cdnPZkwMWaT2MrkBWrtEQmxU@mail.gmail.com> (raw)
In-Reply-To: <929805.17464.qm@web57903.mail.re3.yahoo.com>

>
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2010-08-13 21:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13  2:17 strcut casts unsigned long hong zhang
2010-08-13  6:44 ` ratheesh k
2010-08-13 13:23   ` Javier Martinez Canillas
2010-08-13 21:25   ` hong zhang
2010-08-13 21:49     ` Javier Martinez Canillas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTinGyk2y94XDtDL7cdnPZkwMWaT2MrkBWrtEQmxU@mail.gmail.com \
    --to=martinez.javier@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).