Re: Using intptr_t and uintptr_t in Kernel

From: Mikael Pettersson
Date: Tue Oct 13 2009 - 07:48:13 EST


Leonidas . writes:
> >  > typedef unsigned long           uintptr_t;
> >  >
> >  > but intptr_t is not defined at all. Also, isn't above definition
> >  > incorrect?
> >
> > No, it's correct because Linux requires sizeof(void*) == sizeof(long).
> >
> >  > Since the whole idea
> >  > behind uintptr_t is to store pointer in a int sized variable,
> >
> > uintptr_t will use _some_ integer type, not necessarily 'int'.
> >
> > If ISO C said 'int' there would be no need for {,u}intptr_t.
> >
> >  > are we
> >  > not assuming here that
> >  >
> >  > sizeof(int) = sizeof(unsigned long ) on all archs?
> >
> > No, see above.
> >
>
> Thanks, for the response, but frankly I am still confused.
> Let me recollect my thoughts in more concise manner.
>
>
> User space documentation for C99, http://linux.die.net/man/3/intptr_t says,
>
> typedef unsigned int uint16_t
> typedef uint16_t uintptr_t

That's based on what C99 states, but it's not the definition of uintptr_t
but a specification of the minimal size of that type. The page you're
referring to fails to mention that.

Anyway, this is not an issue with the kernel. Please direct C questions
to a C-specific forum, like comp.std.c. Or google n1124.pdf and read that.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/