diff --git a/sys/dev/aic7xxx/aic7xxx_osm.h b/sys/dev/aic7xxx/aic7xxx_osm.h index c3ce610f9564..86361ab3cef2 100644 --- a/sys/dev/aic7xxx/aic7xxx_osm.h +++ b/sys/dev/aic7xxx/aic7xxx_osm.h @@ -45,6 +45,7 @@ #include #include #include /* For device_t */ +#include #include #include #include diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c index 40bd87197826..d713687fba45 100644 --- a/sys/dev/ata/ata-dma.c +++ b/sys/dev/ata/ata-dma.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index 4f41a34da555..9c9520ecb48f 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index 50d18145a230..fe91327cb553 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c index 0c8f1d24ee19..06635a496206 100644 --- a/sys/dev/hme/if_hme.c +++ b/sys/dev/hme/if_hme.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/dev/iir/iir.c b/sys/dev/iir/iir.c index 4e072337b66d..38fe00a51957 100644 --- a/sys/dev/iir/iir.c +++ b/sys/dev/iir/iir.c @@ -48,6 +48,7 @@ /* #include "opt_iir.h" */ #include #include +#include #include #include #include diff --git a/sys/dev/iir/iir_ctrl.c b/sys/dev/iir/iir_ctrl.c index ca3fffe05232..0cfd2a9893e8 100644 --- a/sys/dev/iir/iir_ctrl.c +++ b/sys/dev/iir/iir_ctrl.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include diff --git a/sys/dev/iir/iir_pci.c b/sys/dev/iir/iir_pci.c index 9c083c27661c..d115de4aeb0e 100644 --- a/sys/dev/iir/iir_pci.c +++ b/sys/dev/iir/iir_pci.c @@ -44,6 +44,7 @@ #include #include +#include #include #include #include diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 5496b1ad57bb..28002720a7e0 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -30,9 +30,9 @@ #define ISP_PLATFORM_VERSION_MAJOR 5 #define ISP_PLATFORM_VERSION_MINOR 9 -#include #include #include +#include #include #include #include diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index b394e933b451..d1671cbf6f6c 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -87,6 +87,7 @@ #include #include +#include #include #ifdef FreeBSD_Bus_Io_Abstraction #include diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index f6ce4a45b92b..41d164f3c056 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -53,6 +53,7 @@ #include #include #elif defined(__FreeBSD__) +#include #include #include #include diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index abf9c2e223f4..372c51cfd12d 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -56,6 +56,7 @@ #include #include #elif defined(__FreeBSD__) +#include #include #include #include diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index f650bdd5f19a..0f7404e124f2 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -64,6 +64,7 @@ #include #include +#include #include #include #include diff --git a/sys/dev/wi/wi_hostap.c b/sys/dev/wi/wi_hostap.c index 794db22fc6d0..1cecb432fee9 100644 --- a/sys/dev/wi/wi_hostap.c +++ b/sys/dev/wi/wi_hostap.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include diff --git a/sys/kern/subr_mchain.c b/sys/kern/subr_mchain.c index 21fddac9a5c1..1a8c4bd178da 100644 --- a/sys/kern/subr_mchain.c +++ b/sys/kern/subr_mchain.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c index 66fa6ff4360a..d07d4f94c2d3 100644 --- a/sys/netsmb/smb_iod.c +++ b/sys/netsmb/smb_iod.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include diff --git a/sys/netsmb/smb_rq.c b/sys/netsmb/smb_rq.c index 002a62cc8f7a..eede5b1b986b 100644 --- a/sys/netsmb/smb_rq.c +++ b/sys/netsmb/smb_rq.c @@ -33,6 +33,7 @@ */ #include #include +#include #include #include #include diff --git a/sys/netsmb/smb_subr.c b/sys/netsmb/smb_subr.c index 58fd43e5bac0..4a37d6e3a716 100644 --- a/sys/netsmb/smb_subr.c +++ b/sys/netsmb/smb_subr.c @@ -33,6 +33,7 @@ */ #include #include +#include #include #include #include diff --git a/sys/pci/if_de.c b/sys/pci/if_de.c index 4f41a34da555..9c9520ecb48f 100644 --- a/sys/pci/if_de.c +++ b/sys/pci/if_de.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/sys/sys/endian.h b/sys/sys/endian.h new file mode 100644 index 000000000000..0675457e4632 --- /dev/null +++ b/sys/sys/endian.h @@ -0,0 +1,76 @@ +/*- + * Copyright (c) 2002 Thomas Moestl + * 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 +#include + +/* + * 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 fc47d259893e..9b216c3b41cf 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 */ /*