Move the new byte order function prototypes from <sys/param.h> to

<sys/endian.h>.  This puts us in line with NetBSD and OpenBSD.
This commit is contained in:
Mike Barcroft 2002-04-26 22:48:23 +00:00
parent cbd53e95fe
commit a30d4b3270
21 changed files with 96 additions and 37 deletions

View File

@ -45,6 +45,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/bus.h> /* For device_t */ #include <sys/bus.h> /* For device_t */
#include <sys/endian.h>
#include <sys/eventhandler.h> #include <sys/eventhandler.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/malloc.h> #include <sys/malloc.h>

View File

@ -32,6 +32,7 @@
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/ata.h> #include <sys/ata.h>
#include <sys/bio.h> #include <sys/bio.h>
#include <sys/endian.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <sys/disk.h> #include <sys/disk.h>

View File

@ -42,6 +42,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/sockio.h> #include <sys/sockio.h>

View File

@ -38,6 +38,7 @@
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <sys/callout.h> #include <sys/callout.h>
#include <sys/endian.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/kernel.h> #include <sys/kernel.h>

View File

@ -62,6 +62,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <sys/endian.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/ktr.h> #include <sys/ktr.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>

View File

@ -48,6 +48,7 @@
/* #include "opt_iir.h" */ /* #include "opt_iir.h" */
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/eventhandler.h> #include <sys/eventhandler.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/kernel.h> #include <sys/kernel.h>

View File

@ -41,6 +41,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/uio.h> #include <sys/uio.h>

View File

@ -44,6 +44,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/module.h> #include <sys/module.h>
#include <sys/bus.h> #include <sys/bus.h>

View File

@ -30,9 +30,9 @@
#define ISP_PLATFORM_VERSION_MAJOR 5 #define ISP_PLATFORM_VERSION_MAJOR 5
#define ISP_PLATFORM_VERSION_MINOR 9 #define ISP_PLATFORM_VERSION_MINOR 9
#include <sys/param.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/lock.h> #include <sys/lock.h>

View File

@ -87,6 +87,7 @@
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/endian.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#ifdef FreeBSD_Bus_Io_Abstraction #ifdef FreeBSD_Bus_Io_Abstraction
#include <sys/module.h> #include <sys/module.h>

View File

@ -53,6 +53,7 @@
#include <sys/device.h> #include <sys/device.h>
#include <sys/select.h> #include <sys/select.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
#include <sys/endian.h>
#include <sys/module.h> #include <sys/module.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <machine/bus_pio.h> #include <machine/bus_pio.h>

View File

@ -56,6 +56,7 @@
#include <sys/device.h> #include <sys/device.h>
#include <sys/select.h> #include <sys/select.h>
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
#include <sys/endian.h>
#include <sys/module.h> #include <sys/module.h>
#include <sys/bus.h> #include <sys/bus.h>
#include <machine/bus_pio.h> #include <machine/bus_pio.h>

View File

@ -64,6 +64,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/sockio.h> #include <sys/sockio.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/proc.h> #include <sys/proc.h>

View File

@ -40,6 +40,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/sockio.h> #include <sys/sockio.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/malloc.h> #include <sys/malloc.h>

View File

@ -35,6 +35,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/errno.h> #include <sys/errno.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/module.h> #include <sys/module.h>

View File

@ -34,6 +34,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/kthread.h> #include <sys/kthread.h>

View File

@ -33,6 +33,7 @@
*/ */
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/proc.h> #include <sys/proc.h>

View File

@ -33,6 +33,7 @@
*/ */
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/proc.h> #include <sys/proc.h>

View File

@ -42,6 +42,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/endian.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/sockio.h> #include <sys/sockio.h>

76
sys/sys/endian.h Normal file
View File

@ -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_ */

View File

@ -187,10 +187,10 @@
#define MAX(a,b) (((a)>(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b))
#endif #endif
#ifdef _KERNEL
/* /*
* Basic byte order function prototypes for non-inline functions. * Basic byte order function prototypes for non-inline functions.
*/ */
#ifdef _KERNEL
#ifndef _BYTEORDER_PROTOTYPED #ifndef _BYTEORDER_PROTOTYPED
#define _BYTEORDER_PROTOTYPED #define _BYTEORDER_PROTOTYPED
__BEGIN_DECLS __BEGIN_DECLS
@ -208,41 +208,6 @@ __END_DECLS
#define ntohl(x) __ntohl(x) #define ntohl(x) __ntohl(x)
#define ntohs(x) __ntohs(x) #define ntohs(x) __ntohs(x)
#endif /* !_BYTEORDER_FUNC_DEFINED */ #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 */ #endif /* _KERNEL */
/* /*