Add the following functions/macros to support byte order conversions and
device drivers for bus system with other endinesses than the CPU (using interfaces compatible to NetBSD): - bwap16() and bswap32(). These have optimized implementations on some architectures; for those that don't, there exist generic implementations. - macros to convert from a certain byte order to host byte order and vice versa, using a naming scheme like le16toh(), htole16(). These are implemented using the bswap functions. - stream bus space access functions, which do not perform a byte order conversion (while the normal access functions would if the bus endianess differs from the CPU endianess). htons(), htonl(), ntohs() and ntohl() are implemented using the new functions above for kernel usage. None of the above interfaces is currently exported to user land. Make use of the new functions in a few places where local implementations of the same functionality existed. Reviewed by: mike, bde Tested on alpha by: mike
This commit is contained in:
parent
51aa959f05
commit
90ce56c287
@ -33,6 +33,10 @@ SRCS+= __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
|
||||
# private (pruned) versions of libc string functions
|
||||
SRCS+= strcasecmp.c
|
||||
|
||||
# byte order functions from libc
|
||||
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/net
|
||||
SRCS+= htons.S ntohs.S htonl.S ntohl.S
|
||||
|
||||
# string functions from libc
|
||||
.PATH: ${.CURDIR}/../libc/string
|
||||
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
|
||||
@ -50,9 +54,6 @@ SRCS+= bcmp.c bcopy.S bzero.S ffs.S index.c memccpy.c memchr.c memcmp.c \
|
||||
strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
|
||||
strspn.c strstr.c strtok.c swab.c
|
||||
|
||||
.PATH: ${.CURDIR}/../libc/alpha/net
|
||||
SRCS+= htons.S ntohs.S htonl.S ntohl.S
|
||||
|
||||
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
|
||||
SRCS+= __remqu.S __remq.S __remlu.S __reml.S
|
||||
|
||||
@ -100,9 +101,6 @@ SRCS+= bcmp.c bcopy.S bzero.S ffs.S index.c memccpy.c memchr.c memcmp.c \
|
||||
strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
|
||||
strspn.c strstr.c strtok.c swab.c
|
||||
|
||||
.PATH: ${.CURDIR}/../libc/ia64/net
|
||||
SRCS+= htons.S ntohs.S htonl.S ntohl.S
|
||||
|
||||
.PATH: ${.CURDIR}/../libc/ia64/gen
|
||||
SRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
|
||||
SRCS+= __udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S
|
||||
|
@ -365,6 +365,70 @@ void busspace_generic_barrier(struct alpha_busspace *space,
|
||||
#define bus_space_barrier(t, h, o, l, f) \
|
||||
(t)->ab_ops->abo_barrier(t, (h)+(o), l, f)
|
||||
|
||||
/*
|
||||
* Stream accesses are the same as normal accesses on alpha; there are no
|
||||
* supported bus systems with an endianess different from the host one.
|
||||
*/
|
||||
#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
|
||||
#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
|
||||
#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
|
||||
|
||||
#define bus_space_read_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_stream_1(t, h, o, v) \
|
||||
bus_space_write_1((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_2(t, h, o, v) \
|
||||
bus_space_write_2((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_4(t, h, o, v) \
|
||||
bus_space_write_4((t), (h), (o), (v))
|
||||
|
||||
#define bus_space_write_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_multi_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_multi_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_multi_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_multi_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_read_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_region_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_region_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_region_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_region_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
|
||||
|
||||
/*
|
||||
* Flags used in various bus DMA methods.
|
||||
*/
|
||||
|
@ -56,6 +56,14 @@
|
||||
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define _BSWAP16_DEFINED
|
||||
__uint16_t __bswap16(__uint16_t);
|
||||
#define _BSWAP32_DEFINED
|
||||
__uint32_t __bswap32(__uint32_t);
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
#endif /* !_MACHINE_ENDIAN_H_ */
|
||||
|
@ -43,4 +43,68 @@
|
||||
#endif
|
||||
#include <machine/bus_dma.h>
|
||||
|
||||
/*
|
||||
* Stream accesses are the same as normal accesses on i386/pc98; there are no
|
||||
* supported bus systems with an endianess different from the host one.
|
||||
*/
|
||||
#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
|
||||
#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
|
||||
#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
|
||||
|
||||
#define bus_space_read_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_stream_1(t, h, o, v) \
|
||||
bus_space_write_1((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_2(t, h, o, v) \
|
||||
bus_space_write_2((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_4(t, h, o, v) \
|
||||
bus_space_write_4((t), (h), (o), (v))
|
||||
|
||||
#define bus_space_write_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_multi_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_multi_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_multi_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_multi_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_read_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_region_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_region_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_region_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_region_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
|
||||
|
||||
#endif /* _I386_BUS_H_ */
|
||||
|
@ -215,9 +215,7 @@ isa/psm.c optional psm
|
||||
isa/syscons_isa.c optional sc
|
||||
isa/vga_isa.c optional vga
|
||||
kern/subr_diskmbr.c standard
|
||||
libkern/alpha/htonl.S standard
|
||||
libkern/alpha/htons.S standard
|
||||
libkern/alpha/ntohl.S standard
|
||||
libkern/alpha/ntohs.S standard
|
||||
libkern/alpha/bswap16.S standard
|
||||
libkern/alpha/bswap32.S standard
|
||||
libkern/bcmp.c standard
|
||||
libkern/ffs.c standard
|
||||
|
@ -99,10 +99,8 @@ isa/psm.c optional psm
|
||||
isa/syscons_isa.c optional sc
|
||||
isa/vga_isa.c optional vga
|
||||
kern/subr_diskmbr.c standard
|
||||
libkern/ia64/htonl.S standard
|
||||
libkern/ia64/htons.S standard
|
||||
libkern/ia64/ntohl.S standard
|
||||
libkern/ia64/ntohs.S standard
|
||||
libkern/ia64/bswap16.S standard
|
||||
libkern/ia64/bswap32.S standard
|
||||
libkern/ia64/__divsi3.S standard
|
||||
libkern/ia64/__modsi3.S standard
|
||||
libkern/ia64/__udivsi3.S standard
|
||||
|
@ -372,10 +372,8 @@ extern int ser_printf(const char *fmt, ...);
|
||||
#define GDT_SCRATCH_SZ 3072 /* 3KB scratch buffer */
|
||||
|
||||
/* macros */
|
||||
#define htole32(v) (v)
|
||||
#define htole16(v) (v)
|
||||
#define letoh32(v) (v)
|
||||
#define letoh16(v) (v)
|
||||
#define letoh32(v) le32toh(v)
|
||||
#define letoh16(v) le16toh(v)
|
||||
|
||||
/* Map minor numbers to device identity */
|
||||
#define LUN_MASK 0x0007
|
||||
|
@ -96,20 +96,6 @@ int ohcidebug = 1;
|
||||
#define DPRINTFN(n,x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The OHCI controller is little endian, so on big endian machines
|
||||
* the data strored in memory needs to be swapped.
|
||||
*/
|
||||
#if defined(__FreeBSD__)
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define htole32(x) (bswap32(x))
|
||||
#define le32toh(x) (bswap32(x))
|
||||
#else
|
||||
#define htole32(x) (x)
|
||||
#define le32toh(x) (x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct ohci_pipe;
|
||||
|
||||
Static ohci_soft_ed_t *ohci_alloc_sed(ohci_softc_t *);
|
||||
|
@ -112,7 +112,7 @@ int uhcinoloop = 0;
|
||||
* The UHCI controller is little endian, so on big endian machines
|
||||
* the data strored in memory needs to be swapped.
|
||||
*/
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__OpenBSD__)
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define htole32(x) (bswap32(x))
|
||||
#define le32toh(x) (bswap32(x))
|
||||
|
@ -314,7 +314,6 @@ typedef struct thread *usb_proc_ptr;
|
||||
/* XXX Change this when FreeBSD has memset */
|
||||
#define memcpy(d, s, l) bcopy((s),(d),(l))
|
||||
#define memset(d, v, l) bzero((d),(l))
|
||||
#define bswap32(x) swap32(x)
|
||||
#define kthread_create1(f, s, p, a0, a1) \
|
||||
kthread_create((f), (s), (p), RFHIGHPID, (a0), (a1))
|
||||
|
||||
|
@ -125,11 +125,9 @@ static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 };
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following is for compatibility with NetBSD, but should really be
|
||||
* brought in from NetBSD en toto.
|
||||
* The following is for compatibility with NetBSD.
|
||||
*/
|
||||
#define le16toh(a) (a)
|
||||
#define LE16TOH(a)
|
||||
#define LE16TOH(a) ((a) = le16toh((a)))
|
||||
|
||||
static void wi_intr __P((void *));
|
||||
static void wi_reset __P((struct wi_softc *));
|
||||
|
@ -43,4 +43,68 @@
|
||||
#endif
|
||||
#include <machine/bus_dma.h>
|
||||
|
||||
/*
|
||||
* Stream accesses are the same as normal accesses on i386/pc98; there are no
|
||||
* supported bus systems with an endianess different from the host one.
|
||||
*/
|
||||
#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
|
||||
#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
|
||||
#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
|
||||
|
||||
#define bus_space_read_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_stream_1(t, h, o, v) \
|
||||
bus_space_write_1((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_2(t, h, o, v) \
|
||||
bus_space_write_2((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_4(t, h, o, v) \
|
||||
bus_space_write_4((t), (h), (o), (v))
|
||||
|
||||
#define bus_space_write_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_multi_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_multi_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_multi_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_multi_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_read_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_region_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_region_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_region_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_region_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
|
||||
|
||||
#endif /* _I386_BUS_H_ */
|
||||
|
@ -58,12 +58,12 @@
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif /* ! _POSIX_SOURCE */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#ifdef __GNUC__
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define _BSWAP32_DEFINED
|
||||
static __inline __uint32_t
|
||||
__htonl(__uint32_t __x)
|
||||
__bswap32(__uint32_t __x)
|
||||
{
|
||||
#if defined(_KERNEL) && (defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)) && !defined(I386_CPU)
|
||||
__asm ("bswap %0" : "+r" (__x));
|
||||
@ -76,29 +76,16 @@ __htonl(__uint32_t __x)
|
||||
return __x;
|
||||
}
|
||||
|
||||
#define _BSWAP16_DEFINED
|
||||
static __inline __uint16_t
|
||||
__htons(__uint16_t __x)
|
||||
__bswap16(__uint16_t __x)
|
||||
{
|
||||
__asm ("xchgb %h0, %b0" : "+q" (__x));
|
||||
|
||||
return __x;
|
||||
}
|
||||
|
||||
static __inline __uint32_t
|
||||
__ntohl(__uint32_t __x)
|
||||
{
|
||||
|
||||
return (__htonl(__x));
|
||||
}
|
||||
|
||||
static __inline __uint16_t
|
||||
__ntohs(__uint16_t __x)
|
||||
{
|
||||
|
||||
return (__htons(__x));
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
@ -1000,6 +1000,70 @@ bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Stream accesses are the same as normal accesses on ia64; there are no
|
||||
* supported bus systems with an endianess different from the host one.
|
||||
*/
|
||||
#define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
|
||||
#define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
|
||||
#define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
|
||||
|
||||
#define bus_space_read_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_stream_1(t, h, o, v) \
|
||||
bus_space_write_1((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_2(t, h, o, v) \
|
||||
bus_space_write_2((t), (h), (o), (v))
|
||||
#define bus_space_write_stream_4(t, h, o, v) \
|
||||
bus_space_write_4((t), (h), (o), (v))
|
||||
|
||||
#define bus_space_write_multi_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_multi_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_multi_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_multi_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_multi_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_multi_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_multi_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_multi_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_multi_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_multi_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_read_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_read_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_read_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_read_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_read_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_write_region_stream_1(t, h, o, a, c) \
|
||||
bus_space_write_region_1((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_2(t, h, o, a, c) \
|
||||
bus_space_write_region_2((t), (h), (o), (a), (c))
|
||||
#define bus_space_write_region_stream_4(t, h, o, a, c) \
|
||||
bus_space_write_region_4((t), (h), (o), (a), (c))
|
||||
|
||||
#define bus_space_set_region_stream_1(t, h, o, v, c) \
|
||||
bus_space_set_region_1((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_2(t, h, o, v, c) \
|
||||
bus_space_set_region_2((t), (h), (o), (v), (c))
|
||||
#define bus_space_set_region_stream_4(t, h, o, v, c) \
|
||||
bus_space_set_region_4((t), (h), (o), (v), (c))
|
||||
|
||||
#define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
|
||||
bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
|
||||
|
||||
#endif /* defined(_MACHINE_BUS_PIO_H_) || defined(_MACHINE_BUS_MEMIO_H_) */
|
||||
|
||||
#if 0 /* Cause a link error for bus_space_copy_8 */
|
||||
|
@ -59,12 +59,12 @@
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#ifdef __GNUC__
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define _BSWAP64_DEFINED
|
||||
static __inline __uint64_t
|
||||
__uint8_swap_uint64(__uint64_t __x)
|
||||
__bswap64(__uint64_t __x)
|
||||
{
|
||||
__uint64_t __r;
|
||||
__asm __volatile("mux1 %0=%1,@rev"
|
||||
@ -72,36 +72,30 @@ __uint8_swap_uint64(__uint64_t __x)
|
||||
return __r;
|
||||
}
|
||||
|
||||
#define _BSWAP32_DEFINED
|
||||
static __inline __uint32_t
|
||||
__htonl(__uint32_t __x)
|
||||
__bswap32(__uint32_t __x)
|
||||
{
|
||||
|
||||
return (__uint8_swap_uint64(__x) >> 32);
|
||||
return (__bswap64(__x) >> 32);
|
||||
}
|
||||
|
||||
#define _BSWAP16_DEFINED
|
||||
static __inline __uint16_t
|
||||
__htons(__uint16_t __x)
|
||||
__bswap16(__uint16_t __x)
|
||||
{
|
||||
|
||||
return (__uint8_swap_uint64(__x) >> 48);
|
||||
return (__bswap64(__x) >> 48);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#else /* !__GNUC__ */
|
||||
/* XXX: use the libkern versions for now; these might go away soon. */
|
||||
#define _BSWAP16_DEFINED
|
||||
__uint16_t __bswap16(__uint16_t);
|
||||
#define _BSWAP32_DEFINED
|
||||
__uint32_t __bswap32(__uint32_t);
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_MACHINE_ENDIAN_H_ */
|
||||
|
@ -1,6 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
@ -26,9 +23,13 @@
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* from: NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd
|
||||
* from: src/sys/libkern/alpha/htons.S,v 1.3 2002/02/18 20:35:21
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define ALIAS htons
|
||||
#define NAME __htons
|
||||
#define NAME __bswap16
|
||||
|
||||
#include <libkern/alpha/byte_swap_2.S>
|
@ -1,6 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
@ -25,10 +22,14 @@
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* from: NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd
|
||||
* from: src/sys/libkern/alpha/htonl.S,v 1.3 2002/02/18 20:35:21
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define ALIAS htonl
|
||||
#define NAME __htonl
|
||||
#define NAME __bswap32
|
||||
|
||||
#include <libkern/alpha/byte_swap_4.S>
|
@ -30,8 +30,8 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if !defined(ALIAS) || !defined(NAME)
|
||||
#error ALIAS or NAME not defined
|
||||
#ifndef NAME
|
||||
#error NAME not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -39,7 +39,6 @@
|
||||
*
|
||||
* Argument is an unsigned 2-byte integer (u_int16_t).
|
||||
*/
|
||||
XLEAF(ALIAS, 1)
|
||||
LEAF(NAME, 1) /* a0 contains 0x0123 */
|
||||
extbl a0, 0, t0 /* t0 = 0x 23 */
|
||||
extbl a0, 1, t1 /* t1 = 0x 01 */
|
||||
|
@ -30,8 +30,8 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if !defined(ALIAS) || !defined(NAME)
|
||||
#error ALIAS or NAME not defined
|
||||
#ifndef NAME
|
||||
#error NAME not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -39,7 +39,6 @@
|
||||
*
|
||||
* Argument is an unsigned 4-byte integer (u_int32_t).
|
||||
*/
|
||||
XLEAF(ALIAS, 1)
|
||||
LEAF(NAME, 1) /* a0 contains 0x01234567 */
|
||||
extbl a0, 0, t0 /* t0 = 0x 67 */
|
||||
extbl a0, 1, t1 /* t1 = 0x 45 */
|
||||
|
@ -1,34 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:36:57 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#define ALIAS ntohl
|
||||
#define NAME __ntohl
|
||||
|
||||
#include <libkern/alpha/byte_swap_4.S>
|
@ -1,34 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:37:02 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#define ALIAS ntohs
|
||||
#define NAME __ntohs
|
||||
|
||||
#include <libkern/alpha/byte_swap_2.S>
|
@ -1,6 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
@ -26,9 +23,13 @@
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* from: NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd
|
||||
* from: src/sys/libkern/ia64/htons.S,v 1.2 2002/02/18 20:35:21
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define ALIAS htons
|
||||
#define NAME __htons
|
||||
#define NAME __bswap16
|
||||
|
||||
#include <libkern/ia64/byte_swap_2.S>
|
@ -1,6 +1,3 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
@ -26,9 +23,13 @@
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* from: NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd
|
||||
* from: src/sys/libkern/ia64/htonl.S,v 1.2 2002/02/18 20:35:21
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define ALIAS htonl
|
||||
#define NAME __htonl
|
||||
#define NAME __bswap32
|
||||
|
||||
#include <libkern/ia64/byte_swap_4.S>
|
@ -30,8 +30,8 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if !defined(ALIAS) || !defined(NAME)
|
||||
#error ALIAS or NAME not defined
|
||||
#ifndef NAME
|
||||
#error NAME not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -39,7 +39,6 @@
|
||||
*
|
||||
* Argument is an unsigned 2-byte integer (u_int16_t).
|
||||
*/
|
||||
WEAK_ALIAS(ALIAS, NAME)
|
||||
ENTRY(NAME, 1)
|
||||
mux1 r16=in0,@rev
|
||||
;;
|
||||
|
@ -30,8 +30,8 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if !defined(ALIAS) || !defined(NAME)
|
||||
#error ALIAS or NAME not defined
|
||||
#ifndef NAME
|
||||
#error NAME not defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -39,7 +39,6 @@
|
||||
*
|
||||
* Argument is an unsigned 4-byte integer (u_int32_t).
|
||||
*/
|
||||
WEAK_ALIAS(ALIAS, NAME)
|
||||
ENTRY(NAME, 1)
|
||||
mux1 r16=in0,@rev
|
||||
;;
|
||||
|
@ -1,34 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:36:57 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#define ALIAS ntohl
|
||||
#define NAME __ntohl
|
||||
|
||||
#include <libkern/ia64/byte_swap_4.S>
|
@ -1,34 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:37:02 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#define ALIAS ntohs
|
||||
#define NAME __ntohs
|
||||
|
||||
#include <libkern/ia64/byte_swap_2.S>
|
@ -60,18 +60,6 @@
|
||||
|
||||
#ifndef _KERNEL
|
||||
#include <sys/cdefs.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
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#define __htonl(x) (x)
|
||||
#define __htons(x) (x)
|
||||
#define __ntohl(x) (x)
|
||||
#define __ntohs(x) (x)
|
||||
|
||||
#endif /* !_MACHINE_ENDIAN_H_ */
|
||||
|
@ -57,9 +57,4 @@
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
#define __htonl(x) (x)
|
||||
#define __htons(x) (x)
|
||||
#define __ntohl(x) (x)
|
||||
#define __ntohs(x) (x)
|
||||
|
||||
#endif /* !_MACHINE_ENDIAN_H_ */
|
||||
|
@ -50,13 +50,13 @@
|
||||
((mag) & 0xffff) )
|
||||
|
||||
#define N_GETMAGIC_NET(ex) \
|
||||
(__ntohl((ex).a_midmag) & 0xffff)
|
||||
(ntohl((ex).a_midmag) & 0xffff)
|
||||
#define N_GETMID_NET(ex) \
|
||||
((__ntohl((ex).a_midmag) >> 16) & 0x03ff)
|
||||
((ntohl((ex).a_midmag) >> 16) & 0x03ff)
|
||||
#define N_GETFLAG_NET(ex) \
|
||||
((__ntohl((ex).a_midmag) >> 26) & 0x3f)
|
||||
((ntohl((ex).a_midmag) >> 26) & 0x3f)
|
||||
#define N_SETMAGIC_NET(ex,mag,mid,flag) \
|
||||
( (ex).a_midmag = __htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) \
|
||||
( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) \
|
||||
| (((mag)&0xffff)) ) )
|
||||
|
||||
#define N_ALIGN(ex,x) \
|
||||
|
@ -36,6 +36,28 @@
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
/*
|
||||
* XXX: remove these defines and change the function calls in the code. Use
|
||||
* it unconditionally if (when) the extended byte order functions become
|
||||
* available in user space.
|
||||
*/
|
||||
#define htoles(x) htole16((x))
|
||||
#define letohs(x) le16toh((x))
|
||||
#define htolel(x) htole32((x))
|
||||
#define letohl(x) le32toh((x))
|
||||
#define htoleq(x) htole64((int64_t)(x))
|
||||
#define letohq(x) le64toh((int64_t)(x))
|
||||
|
||||
#define htobes(x) htobe16((x))
|
||||
#define betohs(x) be16toh((x))
|
||||
#define htobel(x) htobe32((x))
|
||||
#define betohl(x) be32toh((x))
|
||||
#define htobeq(x) htobe64((int64_t)(x))
|
||||
#define betohq(x) be64toh((int64_t)(x))
|
||||
|
||||
#else
|
||||
/*
|
||||
* This macros probably belongs to the endian.h
|
||||
*/
|
||||
@ -78,6 +100,7 @@ betohq(int64_t x)
|
||||
#define letohl(x) ((u_int32_t)(x))
|
||||
*/
|
||||
#endif /* (BYTE_ORDER == LITTLE_ENDIAN) */
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
@ -188,28 +188,92 @@
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* Kernel exposed versions of byteorder(3) functions.
|
||||
*
|
||||
* XXX this section should only be defined in the kernel, but some userland
|
||||
* software utilizes it.
|
||||
* Extended byte order support functions, for kernel use only currently.
|
||||
* First, generic implementation of the byte swapping functions for those
|
||||
* architectures that do not have optimized variants of each.
|
||||
*/
|
||||
#ifndef _BYTEORDER_FUNC_DEFINED
|
||||
#define _BYTEORDER_FUNC_DEFINED
|
||||
#define htonl(x) __htonl(x)
|
||||
#define htons(x) __htons(x)
|
||||
#define ntohl(x) __ntohl(x)
|
||||
#define ntohs(x) __ntohs(x)
|
||||
#ifndef _BSWAP16_DEFINED
|
||||
#define _BSWAP16_DEFINED
|
||||
static __inline __uint16_t
|
||||
__bswap16(__uint16_t x)
|
||||
{
|
||||
return ((x >> 8) | ((x << 8) & 0xff00U));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _BSWAP32_DEFINED
|
||||
#define _BSWAP32_DEFINED
|
||||
static __inline __uint32_t
|
||||
__bswap32(__uint32_t x)
|
||||
{
|
||||
return ((x >> 24) | ((x >> 8) & 0xff00U) | ((x << 8) & 0xff0000U) |
|
||||
((x << 24) & 0xff000000U));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _BSWAP64_DEFINED
|
||||
#define _BSWAP64_DEFINED
|
||||
static __inline __uint64_t
|
||||
__bswap64(__uint64_t x)
|
||||
{
|
||||
return ((x >> 56) | ((x >> 40) & 0xff00UL) | ((x >> 24) & 0xff0000UL) |
|
||||
((x >> 8) & 0xff000000UL) | ((x << 8) & 0xff00000000UL) |
|
||||
((x << 24) & 0xff0000000000UL) | ((x << 40) & 0xff000000000000UL) |
|
||||
((x << 56)));
|
||||
}
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
|
||||
#define htonl(x) htobe32((x))
|
||||
#define htons(x) htobe16((x))
|
||||
#define ntohl(x) be32toh((x))
|
||||
#define ntohs(x) be16toh((x))
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
* XXX deprecated uppercase variants for byteorder(3) functions.
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define NTOHL(x) ((x) = __ntohl(x))
|
||||
#define NTOHS(x) ((x) = __ntohs(x))
|
||||
#define HTONL(x) ((x) = __htonl(x))
|
||||
#define HTONS(x) ((x) = __htons(x))
|
||||
#define NTOHL(x) ((x) = ntohl(x))
|
||||
#define NTOHS(x) ((x) = ntohs(x))
|
||||
#define HTONL(x) ((x) = htonl(x))
|
||||
#define HTONS(x) ((x) = htons(x))
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user