[lkml]   [2012]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [RFC] [PATCH] v4l2: use unsigned rather than enums in ioctl() structs
    Em 11-04-2012 15:47, Rémi Denis-Courmont escreveu:
    > Hello,
    > Le mercredi 11 avril 2012 20:02:00 Mauro Carvalho Chehab, vous avez écrit :
    >> Using unsigned instead of enum is not a good idea, from API POV, as
    >> unsigned has different sizes on 32 bits and 64 bits.
    > Fair enough. But then we can do that instead:
    > typedef XXX __enum_t;
    > where XXX is the unsigned integer with the right number of bits. Since Linux
    > does not use short enums, this ought to work fine.

    I forgot to comment about that on the last e-mail.

    A solution close to the above one were already proposed:

    There were also another proposal there that might solve:

    Something like:

    #if sizeof(enum) == 1
    typedef u8 __enum_t;
    #elif sizeof(enum) == 2
    typedef u16 __enum_t;
    #elif sizeof(enum) == 4
    typedef u32 __enum_t;
    #elif sizeof(enum) == 8
    typedef u64 __enum_t;
    typedef enum __enum_t;

    Can actually work. Not sure if I really like adding a typedef, but maybe
    this is the less dirty way to fix it.

    We'll need to properly test the v4l2-compat32 code, as it will need
    to handle a different enum size on userspace. So, there, we'll likely
    need to replace every enum with just "u32". Hmm... arm with 64 bits
    (if/when added) may be an additional issue for the compat stuff.

    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: 2012-04-11 22:11    [W:0.024 / U:31.248 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site