lkml.org 
[lkml]   [2012]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    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:
    http://www.spinics.net/lists/vfl/msg25707.html

    There were also another proposal there that might solve:
    http://www.spinics.net/lists/vfl/msg25702.html


    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;
    #else
    typedef enum __enum_t;
    #endif

    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.

    Regards,
    Mauro
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2012-04-11 22:11    [W:0.045 / U:89.988 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site