diff options
author | bde <bde@FreeBSD.org> | 1997-04-20 11:44:32 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-04-20 11:44:32 +0000 |
commit | 09b8b5d768e9d1d148cd4772f704d565708f3fc6 (patch) | |
tree | 7f9d3e8401e77e4eec18654fbe478eb6e762a18a /sys | |
parent | 8f01634fd18fbc0abdbe3f2186b89f67998ffd0f (diff) | |
download | FreeBSD-src-09b8b5d768e9d1d148cd4772f704d565708f3fc6.zip FreeBSD-src-09b8b5d768e9d1d148cd4772f704d565708f3fc6.tar.gz |
Fixed linting of and compilation of the gcc byte-swapping macros
properly. Simply don't use the gcc macros if we're not gcc, and
declare prototypes for the byte-swapping functions in case the
macro versions are not used. The previous fix was wrong and broke
libpcap, which abuses -Dlint.
Don't pollute the namespace if _POSIX_SOURCE is defined. This is
broken - it makes almost everything in <machine/endian.h> inaccessible
if _POSIX_SOURCE is defined, yet <machine/endian.h> is not a POSIX
header. Other systems don't do it any better.
Removed always-false `BYTE_ORDER == BIG_ENDIAN' ifdef.
Obtained from: partly from Lite(2?) and NetBSD
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/include/endian.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h index ebac340..da56176 100644 --- a/sys/i386/include/endian.h +++ b/sys/i386/include/endian.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)endian.h 7.8 (Berkeley) 4/3/91 - * $Id: endian.h,v 1.13 1997/02/22 09:34:31 peter Exp $ + * $Id: endian.h,v 1.14 1997/03/17 00:51:51 nate Exp $ */ #ifndef _MACHINE_ENDIAN_H_ @@ -43,6 +43,8 @@ #define _QUAD_HIGHWORD 1 #define _QUAD_LOWWORD 0 +#ifndef _POSIX_SOURCE + /* * Definitions for byte order, according to byte significance from low * address to high. @@ -61,6 +63,13 @@ #endif #endif +__BEGIN_DECLS +unsigned long htonl __P((unsigned long)); +unsigned short htons __P((unsigned short)); +unsigned long ntohl __P((unsigned long)); +unsigned short ntohs __P((unsigned short)); +__END_DECLS + #define __word_swap_long(x) \ __extension__ ({ register u_long __X = (x); \ __asm ("rorl $16, %1" \ @@ -96,19 +105,6 @@ __extension__ ({ register u_short __X = (x); \ /* * Macros for network/external number representation conversion. */ -#if BYTE_ORDER == BIG_ENDIAN || defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#define NTOHL(x) (x) -#define NTOHS(x) (x) -#define HTONL(x) (x) -#define HTONS(x) (x) - -#else - #ifdef __GNUC__ #define ntohl __byte_swap_long #define ntohs __byte_swap_word @@ -120,6 +116,7 @@ __extension__ ({ register u_short __X = (x); \ #define NTOHS(x) ((x) = ntohs((u_short)(x))) #define HTONL(x) ((x) = htonl((u_long)(x))) #define HTONS(x) ((x) = htons((u_short)(x))) -#endif + +#endif /* ! _POSIX_SOURCE */ #endif /* !_MACHINE_ENDIAN_H_ */ |