diff options
author | mike <mike@FreeBSD.org> | 2002-04-26 22:48:23 +0000 |
---|---|---|
committer | mike <mike@FreeBSD.org> | 2002-04-26 22:48:23 +0000 |
commit | 99e543a853914f0d84a2b13980587577cffaf336 (patch) | |
tree | 115cd24c3ccb3e000a42bda8da856032a6fe36b5 | |
parent | 796c52983674dea76052f2a77579bc008120a41c (diff) | |
download | FreeBSD-src-99e543a853914f0d84a2b13980587577cffaf336.zip FreeBSD-src-99e543a853914f0d84a2b13980587577cffaf336.tar.gz |
Move the new byte order function prototypes from <sys/param.h> to
<sys/endian.h>. This puts us in line with NetBSD and OpenBSD.
-rw-r--r-- | sys/dev/aic7xxx/aic7xxx_osm.h | 1 | ||||
-rw-r--r-- | sys/dev/ata/ata-dma.c | 1 | ||||
-rw-r--r-- | sys/dev/de/if_de.c | 1 | ||||
-rw-r--r-- | sys/dev/gem/if_gem.c | 1 | ||||
-rw-r--r-- | sys/dev/hme/if_hme.c | 1 | ||||
-rw-r--r-- | sys/dev/iir/iir.c | 1 | ||||
-rw-r--r-- | sys/dev/iir/iir_ctrl.c | 1 | ||||
-rw-r--r-- | sys/dev/iir/iir_pci.c | 1 | ||||
-rw-r--r-- | sys/dev/isp/isp_freebsd.h | 2 | ||||
-rw-r--r-- | sys/dev/sym/sym_hipd.c | 1 | ||||
-rw-r--r-- | sys/dev/usb/ohci.c | 1 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 1 | ||||
-rw-r--r-- | sys/dev/wi/if_wi.c | 1 | ||||
-rw-r--r-- | sys/dev/wi/wi_hostap.c | 1 | ||||
-rw-r--r-- | sys/kern/subr_mchain.c | 1 | ||||
-rw-r--r-- | sys/netsmb/smb_iod.c | 1 | ||||
-rw-r--r-- | sys/netsmb/smb_rq.c | 1 | ||||
-rw-r--r-- | sys/netsmb/smb_subr.c | 1 | ||||
-rw-r--r-- | sys/pci/if_de.c | 1 | ||||
-rw-r--r-- | sys/sys/endian.h | 76 | ||||
-rw-r--r-- | sys/sys/param.h | 37 |
21 files changed, 96 insertions, 37 deletions
diff --git a/sys/dev/aic7xxx/aic7xxx_osm.h b/sys/dev/aic7xxx/aic7xxx_osm.h index c3ce610..86361ab 100644 --- a/sys/dev/aic7xxx/aic7xxx_osm.h +++ b/sys/dev/aic7xxx/aic7xxx_osm.h @@ -45,6 +45,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> /* For device_t */ +#include <sys/endian.h> #include <sys/eventhandler.h> #include <sys/kernel.h> #include <sys/malloc.h> diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c index 40bd871..d713687 100644 --- a/sys/dev/ata/ata-dma.c +++ b/sys/dev/ata/ata-dma.c @@ -32,6 +32,7 @@ #include <sys/systm.h> #include <sys/ata.h> #include <sys/bio.h> +#include <sys/endian.h> #include <sys/malloc.h> #include <sys/bus.h> #include <sys/disk.h> diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index 4f41a34..9c9520e 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -42,6 +42,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/sockio.h> diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index 50d1814..fe91327 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -38,6 +38,7 @@ #include <sys/systm.h> #include <sys/bus.h> #include <sys/callout.h> +#include <sys/endian.h> #include <sys/mbuf.h> #include <sys/malloc.h> #include <sys/kernel.h> diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c index 0c8f1d2..06635a4 100644 --- a/sys/dev/hme/if_hme.c +++ b/sys/dev/hme/if_hme.c @@ -62,6 +62,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> +#include <sys/endian.h> #include <sys/kernel.h> #include <sys/ktr.h> #include <sys/mbuf.h> diff --git a/sys/dev/iir/iir.c b/sys/dev/iir/iir.c index 4e07233..38fe00a 100644 --- a/sys/dev/iir/iir.c +++ b/sys/dev/iir/iir.c @@ -48,6 +48,7 @@ /* #include "opt_iir.h" */ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/eventhandler.h> #include <sys/malloc.h> #include <sys/kernel.h> diff --git a/sys/dev/iir/iir_ctrl.c b/sys/dev/iir/iir_ctrl.c index ca3fffe..0cfd2a9 100644 --- a/sys/dev/iir/iir_ctrl.c +++ b/sys/dev/iir/iir_ctrl.c @@ -41,6 +41,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/malloc.h> #include <sys/kernel.h> #include <sys/uio.h> diff --git a/sys/dev/iir/iir_pci.c b/sys/dev/iir/iir_pci.c index 9c083c2..d115de4 100644 --- a/sys/dev/iir/iir_pci.c +++ b/sys/dev/iir/iir_pci.c @@ -44,6 +44,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/kernel.h> #include <sys/module.h> #include <sys/bus.h> diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 5496b1a..28002720 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -31,8 +31,8 @@ #define ISP_PLATFORM_VERSION_MINOR 9 #include <sys/param.h> -#include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/kernel.h> #include <sys/queue.h> #include <sys/lock.h> diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index b394e93..d1671cb 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -87,6 +87,7 @@ #include <sys/systm.h> #include <sys/malloc.h> +#include <sys/endian.h> #include <sys/kernel.h> #ifdef FreeBSD_Bus_Io_Abstraction #include <sys/module.h> diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index f6ce4a4..41d164f 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -53,6 +53,7 @@ #include <sys/device.h> #include <sys/select.h> #elif defined(__FreeBSD__) +#include <sys/endian.h> #include <sys/module.h> #include <sys/bus.h> #include <machine/bus_pio.h> diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index abf9c2e..372c51c 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -56,6 +56,7 @@ #include <sys/device.h> #include <sys/select.h> #elif defined(__FreeBSD__) +#include <sys/endian.h> #include <sys/module.h> #include <sys/bus.h> #include <machine/bus_pio.h> diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index f650bdd..0f7404e 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -64,6 +64,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/sockio.h> #include <sys/mbuf.h> #include <sys/proc.h> diff --git a/sys/dev/wi/wi_hostap.c b/sys/dev/wi/wi_hostap.c index 794db22..1cecb43 100644 --- a/sys/dev/wi/wi_hostap.c +++ b/sys/dev/wi/wi_hostap.c @@ -40,6 +40,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/sockio.h> #include <sys/mbuf.h> #include <sys/malloc.h> diff --git a/sys/kern/subr_mchain.c b/sys/kern/subr_mchain.c index 21fddac..1a8c4bd 100644 --- a/sys/kern/subr_mchain.c +++ b/sys/kern/subr_mchain.c @@ -35,6 +35,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/errno.h> #include <sys/mbuf.h> #include <sys/module.h> diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c index 66fa6ff..d07d4f9 100644 --- a/sys/netsmb/smb_iod.c +++ b/sys/netsmb/smb_iod.c @@ -34,6 +34,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/proc.h> #include <sys/kernel.h> #include <sys/kthread.h> diff --git a/sys/netsmb/smb_rq.c b/sys/netsmb/smb_rq.c index 002a62c..eede5b1 100644 --- a/sys/netsmb/smb_rq.c +++ b/sys/netsmb/smb_rq.c @@ -33,6 +33,7 @@ */ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/proc.h> diff --git a/sys/netsmb/smb_subr.c b/sys/netsmb/smb_subr.c index 58fd43e..4a37d6e 100644 --- a/sys/netsmb/smb_subr.c +++ b/sys/netsmb/smb_subr.c @@ -33,6 +33,7 @@ */ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/proc.h> diff --git a/sys/pci/if_de.c b/sys/pci/if_de.c index 4f41a34..9c9520e 100644 --- a/sys/pci/if_de.c +++ b/sys/pci/if_de.c @@ -42,6 +42,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/endian.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/sockio.h> diff --git a/sys/sys/endian.h b/sys/sys/endian.h new file mode 100644 index 0000000..0675457 --- /dev/null +++ b/sys/sys/endian.h @@ -0,0 +1,76 @@ +/*- + * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_ENDIAN_H_ +#define _SYS_ENDIAN_H_ + +#include <sys/cdefs.h> +#include <machine/endian.h> + +/* + * General byte order swapping functions. + */ +#define bswap16(x) __bswap16(x) +#define bswap32(x) __bswap32(x) +#define bswap64(x) __bswap64(x) + +/* + * Host to big endian, host to little endian, big endian to host, and little + * endian to host byte order functions as detailed in byteorder(9). + */ +#if _BYTE_ORDER == _LITTLE_ENDIAN +#define htobe16(x) bswap16((x)) +#define htobe32(x) bswap32((x)) +#define htobe64(x) bswap64((x)) +#define htole16(x) ((__uint16_t)(x)) +#define htole32(x) ((__uint32_t)(x)) +#define htole64(x) ((__uint64_t)(x)) + +#define be16toh(x) bswap16((x)) +#define be32toh(x) bswap32((x)) +#define be64toh(x) bswap64((x)) +#define le16toh(x) ((__uint16_t)(x)) +#define le32toh(x) ((__uint32_t)(x)) +#define le64toh(x) ((__uint64_t)(x)) +#else /* _BYTE_ORDER != _LITTLE_ENDIAN */ +#define htobe16(x) ((__uint16_t)(x)) +#define htobe32(x) ((__uint32_t)(x)) +#define htobe64(x) ((__uint64_t)(x)) +#define htole16(x) bswap16((x)) +#define htole32(x) bswap32((x)) +#define htole64(x) bswap64((x)) + +#define be16toh(x) ((__uint16_t)(x)) +#define be32toh(x) ((__uint32_t)(x)) +#define be64toh(x) ((__uint64_t)(x)) +#define le16toh(x) bswap16((x)) +#define le32toh(x) bswap32((x)) +#define le64toh(x) bswap64((x)) +#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */ + +#endif /* _SYS_ENDIAN_H_ */ diff --git a/sys/sys/param.h b/sys/sys/param.h index fc47d25..9b216c3 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -187,10 +187,10 @@ #define MAX(a,b) (((a)>(b))?(a):(b)) #endif +#ifdef _KERNEL /* * Basic byte order function prototypes for non-inline functions. */ -#ifdef _KERNEL #ifndef _BYTEORDER_PROTOTYPED #define _BYTEORDER_PROTOTYPED __BEGIN_DECLS @@ -208,41 +208,6 @@ __END_DECLS #define ntohl(x) __ntohl(x) #define ntohs(x) __ntohs(x) #endif /* !_BYTEORDER_FUNC_DEFINED */ - -#define bswap16(x) __bswap16(x) -#define bswap32(x) __bswap32(x) -#define bswap64(x) __bswap64(x) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define htobe16(x) bswap16((x)) -#define htobe32(x) bswap32((x)) -#define htobe64(x) bswap64((x)) -#define htole16(x) ((__uint16_t)(x)) -#define htole32(x) ((__uint32_t)(x)) -#define htole64(x) ((__uint64_t)(x)) - -#define be16toh(x) bswap16((x)) -#define be32toh(x) bswap32((x)) -#define be64toh(x) bswap64((x)) -#define le16toh(x) ((__uint16_t)(x)) -#define le32toh(x) ((__uint32_t)(x)) -#define le64toh(x) ((__uint64_t)(x)) -#else /* BYTE_ORDER != LITTLE_ENDIAN */ -#define htobe16(x) ((__uint16_t)(x)) -#define htobe32(x) ((__uint32_t)(x)) -#define htobe64(x) ((__uint64_t)(x)) -#define htole16(x) bswap16((x)) -#define htole32(x) bswap32((x)) -#define htole64(x) bswap64((x)) - -#define be16toh(x) ((__uint16_t)(x)) -#define be32toh(x) ((__uint32_t)(x)) -#define be64toh(x) ((__uint64_t)(x)) -#define le16toh(x) bswap16((x)) -#define le32toh(x) bswap32((x)) -#define le64toh(x) bswap64((x)) -#endif /* BYTE_ORDER */ - #endif /* _KERNEL */ /* |