Re: Size-independent byte order swapping functions.

From: Pawel Jakub Dawidek (pjd_at_FreeBSD.org)
Date: 02/03/04

  • Next message: Luigi Rizzo: "Re: Size-independent byte order swapping functions."
    Date: Tue, 3 Feb 2004 11:38:04 +0100
    To: Poul-Henning Kamp <phk@phk.freebsd.dk>
    
    
    

    On Tue, Feb 03, 2004 at 11:01:55AM +0100, Poul-Henning Kamp wrote:
    +> >I'm planning to commit this patch:
    +> >
    +> > http://garage.freebsd.pl/patches/endian.h.patch
    +>
    +> I have a hard time seeing a sensible use for these.
    +>
    +> Endianess conversion is almost exclusively used in communications
    +> (even if the "transmission media" is a disk), and I can't possibly
    +> see how it can make sense to be lax about wordsize but strict about
    +> byteordering.
    +>
    +> Could you please tell us what you need these for and why you could
    +> not use the explicitly sized families of endian functions ?

    I found them very useful while doing many such translations.
    It protect from problems when you need to manage many such transformations.

    For example, you have some structure:

    struct mystruct {
            uint16_t ms_foo;
            uint32_t ms_bar;
            uint64_t ms_foobar;
    };

    and many places where you translate those fields.
    Suddenly, you need to change size of one of those fields.
    If you were using size-independent functions you don't need to change
    anything else, in other case diff will be much bigger with much
    mistake probability.

    Of course if only I found them useful, I'll stop right here.

    -- 
    Pawel Jakub Dawidek                       http://www.FreeBSD.org
    pjd@FreeBSD.org                           http://garage.freebsd.pl
    FreeBSD committer                         Am I Evil? Yes, I Am!
    
    



  • Next message: Luigi Rizzo: "Re: Size-independent byte order swapping functions."