[lkml]   [2005]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Use of C99 int types
    On Apr 05, 2005, at 08:18, Richard B. Johnson wrote:
    > One cannot just use 'int' or 'long', in particular when interfacing
    > with an operating system. For example, look at the socket interface
    > code. Parameters are put into an array of longs and a pointer to
    > this array is passed to the socket interface. It's a mess when
    > converting this code to 64-bit world.


    > If originally one used a structure of the correct POSIX integer
    > types, and a pointer to the structure was passed, then absolutely
    > nothing in the source-code would have to be changed at all when
    > compiling that interface for a 64-bit machine.

    But you _can't_ use the POSIX integer types. When compiling the
    kernel, if you use the types, you must define them in the kernel
    headers. On the other hand, when compiling userspace stuff, you
    _can't_ have them defined in the kernel headers because libc also
    defines them. The solution is to use __{s,u}{8,16,32,64}, which
    are _only_ defined by the kernel, not by libc or gcc, and can be
    therefore used in the ABI.

    > The continual short-cuts, with the continual "special-case"
    > hacks is what makes porting difficult. That's what the POSIX
    > types was supposed to help prevent.

    Except the POSIX types themselves are not usable for the boundary
    code for the reasons of double definition. Google for Linus'
    posts on this topic a couple months ago.

    > That's why I think if there was a stdint.h file in the kernel,
    > when people were performing maintenance or porting their code,
    > they could start using those types.

    The types _are_ available from the kernel headers, but only when
    compiling with __KERNEL__, to avoid conflicts from the libc

    Kyle Moffett

    Version: 3.12
    GCM/CS/IT/U d- s++: a18 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$
    L++++(+++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+
    PGP+++ t+(+++) 5 X R? tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r
    ------END GEEK CODE BLOCK------

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-04-06 13:31    [W:0.038 / U:0.920 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site