[lkml]   [2005]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [RFC] Splitting out kernel<=>userspace ABI headers
    On Sep 14, 2005, at 09:46:04, Bill Davidsen wrote:
    > H. Peter Anvin wrote:
    >> Followup to: <>
    >> By author: Erik Andersen <>
    >> In newsgroup:
    >>> <uClibc maintainer hat on>
    >>> That would be wonderful.
    >>> </off>
    >>> It would be especially nice if everything targeting user space
    >>> were to use only all the nice standard ISO C99 types as defined
    >>> in include/stdint.h such as uint32_t and friends...
    >> Absolutely not. This would be a POSIX namespace violation; they
    >> *must* use double-underscore types.
    > Could you explain why you think it would be a violation to use
    > POSIX types instead of defining our own? That's what the types are
    > for, to avoid having everyone define some slightly conflicting types.
    > The kernel predates C99, sort of, and it would be a massive but
    > valuable task to figure out where a type is really, for instance,
    > 32 bits rather than "size of default int" in length, etc, and use
    > POSIX types where they are correct. Fewer things to maintain, and
    > would make it clear when something is 32 bits by default and when
    > it really must be 32 bits.

    Argh, it seems I'm going to be giving this example forever! Here's
    why this won't work. We want to have sys/stat.h do something like
    the following:

    # define __kabi_stat64 stat
    # include <kabi/stat.h>
    /* Now we expect struct stat to be defined with correct types */

    Since struct stat in that case uses fixed-bit-size types, the header
    fine <kabi/stat.h> needs to include a file providing those types. If
    it used stdint.h types, such as uint32_t, then it would need to
    #include <stdint.h> or provide the stdint.h types itself. In order
    to remain POSIX compliant, sys/stat.h must not include stdint.h or
    assume that stdint.h is included or that those types were defined by
    the user program. Therefore, kabi/*.h cannot use the stdint.h types
    at all! The solution is a separate file, kabi/types.h, which
    properly defines __kabi_[su]{8,16,32,64} which are safe to include
    and reuse anywhere. Then sys/types.h would look like this:

    # include <kabi/types.h>
    typedef __kabi_u8 u_int8;
    typedef __kabi_s8 int8;
    typedef __kabi_u16 u_int16;
    typedef __kabi_s16 int16;

    Kyle Moffett

    Premature optimization is the root of all evil in programming
    -- C.A.R. Hoare

    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-09-14 20:17    [W:0.024 / U:9.036 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site