Update x86 machine/endian.h from upstream

After download new version from upstream (OpenBSD 1.17) did the
following:
 * changed all u_int* types to uint*
 * add #include <sys/types.h>

All these changes are Android-specific and had been done before for
previous version (1.14).

Bug: http://code.google.com/p/android/issues/detail?id=54465
Change-Id: Ieb44e7fce4e794d997bb00ee0dd417fb61521720
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
This commit is contained in:
Pavel Chupin
2013-04-19 13:09:25 +04:00
committed by Elliott Hughes
parent 7d624e9aff
commit 64a4f6adf7

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