From 9f5b8216c2af91286d9d2beb109f93ce776885ca Mon Sep 17 00:00:00 2001 From: grr Date: Wed, 25 Jun 1997 12:41:44 +0000 Subject: Sigh, Revert changes to endian.h - it was all confusion due to incorrect usage in new ip_* code, since fixed. Added usage notes to prevent future confusion in this regard. --- sys/arch/powerpc/include/endian.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'sys/arch/powerpc/include/endian.h') diff --git a/sys/arch/powerpc/include/endian.h b/sys/arch/powerpc/include/endian.h index ba0604ae164..b8e1eaaacc7 100644 --- a/sys/arch/powerpc/include/endian.h +++ b/sys/arch/powerpc/include/endian.h @@ -1,4 +1,4 @@ -/* $OpenBSD: endian.h,v 1.6 1997/06/25 12:32:53 downsj Exp $ */ +/* $OpenBSD: endian.h,v 1.7 1997/06/25 12:41:43 grr Exp $ */ /* $NetBSD: endian.h,v 1.2 1996/10/13 03:16:41 christos Exp $ */ /*- @@ -64,6 +64,13 @@ __END_DECLS /* * Macros for network/external number representation conversion. + * + * The way this works is that HTONS(x) modifies x and *can't* be used as + * and rvalue i.e. foo=HTONS(bar) is wrong. Likewise x=htons(x) should + * never be used where HTONS(x) will serve i.e. foo=htons(foo) is wrong. + * Failing to observe these rule will result in code that appears to work + * and probably does work, but generates gcc warnings on architectures + * where the macros are used to optimize away an unneeded conversion. */ #if BYTE_ORDER == BIG_ENDIAN && !defined(lint) #define ntohl(x) (x) @@ -71,10 +78,10 @@ __END_DECLS #define htonl(x) (x) #define htons(x) (x) -#define NTOHL(x) (void)(x) -#define NTOHS(x) (void)(x) -#define HTONL(x) (void)(x) -#define HTONS(x) (void)(x) +#define NTOHL(x) (void) (x) +#define NTOHS(x) (void) (x) +#define HTONL(x) (void) (x) +#define HTONS(x) (void) (x) #else -- cgit v1.2.3