diff options
author | mike <mike@FreeBSD.org> | 2002-02-18 20:35:27 +0000 |
---|---|---|
committer | mike <mike@FreeBSD.org> | 2002-02-18 20:35:27 +0000 |
commit | bcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f (patch) | |
tree | 970c36894ee638248ec810bd7570ac8aabb5eaf5 /sys/ia64/include | |
parent | f2e166dc7a7880a8564c2a7cb8ca2b94566d8d6b (diff) | |
download | FreeBSD-src-bcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f.zip FreeBSD-src-bcee06d42c20a8ea0e6c6ffb8924e16e7e793c0f.tar.gz |
o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
complexities associated with having MD (asm and inline) versions, and
having to prevent exposure of these functions in other headers that
happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.
Tested on: alpha, i386
Reviewed by: bde, jake, tmm
Diffstat (limited to 'sys/ia64/include')
-rw-r--r-- | sys/ia64/include/endian.h | 88 |
1 files changed, 32 insertions, 56 deletions
diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h index b4b5a0b..bfc2381 100644 --- a/sys/ia64/include/endian.h +++ b/sys/ia64/include/endian.h @@ -1,7 +1,4 @@ -/* $FreeBSD$ */ -/* From: NetBSD: endian.h,v 1.5 1997/10/09 15:42:19 bouyer Exp */ - -/* +/*- * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -34,10 +31,14 @@ * SUCH DAMAGE. * * @(#)endian.h 8.1 (Berkeley) 6/10/93 + * $NetBSD: endian.h,v 1.5 1997/10/09 15:42:19 bouyer Exp $ + * $FreeBSD$ */ -#ifndef _ENDIAN_H_ -#define _ENDIAN_H_ +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +#include <sys/cdefs.h> /* * Define the order of 32-bit words in 64-bit words. @@ -45,44 +46,17 @@ #define _QUAD_HIGHWORD 1 #define _QUAD_LOWWORD 0 -#ifndef _POSIX_SOURCE /* * Definitions for byte order, according to byte significance from low * address to high. */ +#ifndef _POSIX_SOURCE #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER LITTLE_ENDIAN - -#ifndef _KERNEL -#include <sys/cdefs.h> -#endif -#include <machine/ansi.h> - -__BEGIN_DECLS -__uint32_t htonl __P((__uint32_t)); -__uint16_t htons __P((__uint16_t)); -__uint32_t ntohl __P((__uint32_t)); -__uint16_t ntohs __P((__uint16_t)); -__END_DECLS - -/* - * 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 +#endif /* !_POSIX_SOURCE */ #ifdef __GNUC__ @@ -96,31 +70,33 @@ __uint8_swap_uint64(__uint64_t __x) } static __inline __uint32_t -__uint8_swap_uint32(__uint32_t __x) +__htonl(__uint32_t __x) { - return __uint8_swap_uint64(__x) >> 32; + + return (__uint8_swap_uint64(__x) >> 32); } static __inline __uint16_t -__uint8_swap_uint16(__uint16_t __x) +__htons(__uint16_t __x) { - return __uint8_swap_uint64(__x) >> 48; + + return (__uint8_swap_uint64(__x) >> 48); } -/* - * Macros for network/external number representation conversion. - */ -#define ntohl __uint8_swap_uint32 -#define ntohs __uint8_swap_uint16 -#define htonl __uint8_swap_uint32 -#define htons __uint8_swap_uint16 - -#endif /* __GNUC__ */ - -#define NTOHL(x) (x) = ntohl((__uint32_t)x) -#define NTOHS(x) (x) = ntohs((__uint16_t)x) -#define HTONL(x) (x) = htonl((__uint32_t)x) -#define HTONS(x) (x) = htons((__uint16_t)x) -#endif -#endif /* !_POSIX_SOURCE */ -#endif /* !_ENDIAN_H_ */ +static __inline __uint32_t +__ntohl(__uint32_t __x) +{ + + return (__uint8_swap_uint64(__x) >> 32); +} + +static __inline __uint16_t +__ntohs(__uint16_t __x) +{ + + return (__uint8_swap_uint64(__x) >> 48); +} + +#endif /* __GNUC__ */ + +#endif /* !_MACHINE_ENDIAN_H_ */ |