replace __byte_swap_long_variable and __byte_swap_word_variable

#define ({ })  with  static __inline { }
This commit is contained in:
lukem 2001-11-02 05:17:59 +00:00
parent 472dcba2fb
commit 153d16f7b1
1 changed files with 23 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: byte_swap.h,v 1.3 2001/05/30 12:28:44 mrg Exp $ */
/* $NetBSD: byte_swap.h,v 1.4 2001/11/02 05:17:59 lukem Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -43,28 +43,29 @@
#include "opt_cputype.h"
#endif
#if defined(_KERNEL) && !defined(_LKM) && !defined(I386_CPU)
#define __byte_swap_long_variable(x) __extension__ \
({ register in_addr_t __x = (x); \
__asm ("bswap %1" \
: "=r" (__x) \
: "0" (__x)); \
__x; })
#else
#define __byte_swap_long_variable(x) __extension__ \
({ register in_addr_t __x = (x); \
__asm ("rorw $8, %w1\n\trorl $16, %1\n\trorw $8, %w1" \
: "=r" (__x) \
: "0" (__x)); \
__x; })
#endif /* _KERNEL && ... */
#define __byte_swap_word_variable(x) __extension__ \
({ register in_port_t __x = (x); \
__asm ("rorw $8, %w1" \
: "=r" (__x) \
: "0" (__x)); \
__x; })
static __inline u_int32_t __byte_swap_long_variable(u_int32_t);
static __inline u_int16_t __byte_swap_word_variable(u_int16_t);
static __inline u_int32_t
__byte_swap_long_variable(u_int32_t x)
{
__asm __volatile (
#if defined(_KERNEL) && !defined(_LKM) && !defined(I386_CPU)
"bswap %1"
#else
"rorw $8, %w1\n\trorl $16, %1\n\trorw $8, %w1"
#endif
: "=r" (x) : "0" (x));
return x;
}
static __inline u_int16_t
__byte_swap_word_variable(u_int16_t x)
{
__asm __volatile ("rorw $8, %w1" : "=r" (x) : "0" (x));
return x;
}
#ifdef __OPTIMIZE__