Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Feb 2004 11:38:04 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: Size-independent byte order swapping functions.
Message-ID:  <20040203103804.GP4200@garage.freebsd.pl>
In-Reply-To: <6923.1075802515@critter.freebsd.dk>
References:  <20040203083444.GM4200@garage.freebsd.pl> <6923.1075802515@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

--U+NfgObvpQT1Q9Yq
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
+>=20
+> I have a hard time seeing a sensible use for these.
+>=20
+> 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.
+>=20
+> 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.

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

--U+NfgObvpQT1Q9Yq
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQFAH3oMForvXbEpPzQRAkgSAJ9rg3kBVfmhUickNVTBzmjVr/JuXACePni+
+mRCAQGmosK4MC8Em204nxI=
=xx5e
-----END PGP SIGNATURE-----

--U+NfgObvpQT1Q9Yq--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040203103804.GP4200>