OSDN Git Service

Update x86 machine/endian.h from upstream
authorPavel Chupin <pavel.v.chupin@intel.com>
Fri, 19 Apr 2013 09:09:25 +0000 (13:09 +0400)
committerElliott Hughes <enh@google.com>
Tue, 25 Jun 2013 21:17:58 +0000 (14:17 -0700)
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>
libc/arch-x86/include/machine/endian.h

index e7ad257..e1506b1 100644 (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.
  * 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_ */