am c76550b3: Merge "Update x86 machine/endian.h from upstream"

* commit 'c76550b3377f50a2bc53536e2713e14edc8dbeac':
  Update x86 machine/endian.h from upstream
This commit is contained in:
Elliott Hughes 2013-06-25 14:22:14 -07:00 committed by Android Git Automerger
commit 51371ee0d8

View File

@ -1,4 +1,4 @@
/* $OpenBSD: endian.h,v 1.14 2005/12/13 00:35:23 millert Exp $ */
/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@ -24,38 +24,28 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _I386_ENDIAN_H_
#define _I386_ENDIAN_H_
#ifndef _MACHINE_ENDIAN_H_
#define _MACHINE_ENDIAN_H_
#ifdef __GNUC__
#if defined(_KERNEL) && !defined(I386_CPU)
#define __swap32md(x) ({ \
#define __swap32md(x) __statement({ \
uint32_t __swap32md_x = (x); \
\
__asm ("bswap %1" : "+r" (__swap32md_x)); \
__asm ("bswap %0" : "+r" (__swap32md_x)); \
__swap32md_x; \
})
#else
#define __swap32md(x) ({ \
uint32_t __swap32md_x = (x); \
\
__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" : \
"+r" (__swap32md_x)); \
__swap32md_x; \
})
#endif /* _KERNEL && !I386_CPU */
#define __swap64md(x) ({ \
#define __swap64md(x) __statement({ \
uint64_t __swap64md_x = (x); \
\
(uint64_t)__swap32md(__swap64md_x >> 32) | \
(uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
})
#define __swap16md(x) ({ \
#define __swap16md(x) __statement({ \
uint16_t __swap16md_x = (x); \
\
__asm ("rorw $8, %w1" : "+r" (__swap16md_x)); \
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
__swap16md_x; \
})
@ -68,4 +58,4 @@
#include <sys/types.h>
#include <sys/endian.h>
#endif /* _I386_ENDIAN_H_ */
#endif /* _MACHINE_ENDIAN_H_ */