From 616a494ec1841968b2b4abbc810c5534d767e56e Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 8 Dec 2015 13:51:17 -0800 Subject: [PATCH] Update endian.h from bionic. This consolidates the guts of the three endian.h files (endian.h, sys/endian.h, and machine/endian.h) into just sys/endian.h, and turns the others into headers that forward to it. This also consolidates all the architecture specific machine/endian.h files into a single generic header. Finally, this is also the update version of sys/endian.h, which just forwards to compiler builtins rather than implementing it ourselves. Change-Id: Ifce64dc684ce3d3231f3f43a94c083bbd8661840 --- .../arch-arm/include/machine/endian.h | 89 ------ .../arch-mips/include/machine/endian.h | 70 ----- .../arch-mips64/include/machine/endian.h | 70 ----- .../arch-x86/include/machine/endian.h | 61 ---- .../arch-x86_64/include/machine/endian.h | 63 ----- .../{arch-arm64 => }/include/machine/endian.h | 33 +-- ndk/platforms/android-21/include/sys/endian.h | 231 ++------------- .../arch-arm/include/machine/endian.h | 89 ------ .../android-3/include/machine/endian.h | 35 +++ ndk/platforms/android-3/include/sys/endian.h | 264 ++++-------------- .../arch-mips/include/machine/endian.h | 70 ----- .../arch-x86/include/machine/endian.h | 61 ---- 12 files changed, 115 insertions(+), 1021 deletions(-) delete mode 100644 ndk/platforms/android-21/arch-arm/include/machine/endian.h delete mode 100644 ndk/platforms/android-21/arch-mips/include/machine/endian.h delete mode 100644 ndk/platforms/android-21/arch-mips64/include/machine/endian.h delete mode 100644 ndk/platforms/android-21/arch-x86/include/machine/endian.h delete mode 100644 ndk/platforms/android-21/arch-x86_64/include/machine/endian.h rename ndk/platforms/android-21/{arch-arm64 => }/include/machine/endian.h (63%) delete mode 100644 ndk/platforms/android-3/arch-arm/include/machine/endian.h create mode 100644 ndk/platforms/android-3/include/machine/endian.h delete mode 100644 ndk/platforms/android-9/arch-mips/include/machine/endian.h delete mode 100644 ndk/platforms/android-9/arch-x86/include/machine/endian.h diff --git a/ndk/platforms/android-21/arch-arm/include/machine/endian.h b/ndk/platforms/android-21/arch-arm/include/machine/endian.h deleted file mode 100644 index f63e7b77e..000000000 --- a/ndk/platforms/android-21/arch-arm/include/machine/endian.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $ */ - -/* - * Copyright (C) 2010 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _ARM_ENDIAN_H_ -#define _ARM_ENDIAN_H_ - -#ifdef __GNUC__ - -/* - * REV and REV16 weren't available on ARM5 or ARM4. - * We don't include because it pollutes the - * namespace with macros like PLD. - */ -#if !defined __ARM_ARCH_5__ && !defined __ARM_ARCH_5T__ && \ - !defined __ARM_ARCH_5TE__ && !defined __ARM_ARCH_5TEJ__ && \ - !defined __ARM_ARCH_4T__ && !defined __ARM_ARCH_4__ - -/* According to RealView Assembler User's Guide, REV and REV16 are available - * in Thumb code and 16-bit instructions when used in Thumb-2 code. - * - * REV Rd, Rm - * Rd and Rm must both be Lo registers. - * - * REV16 Rd, Rm - * Rd and Rm must both be Lo registers. - * - * The +l constraint takes care of this without constraining us in ARM mode. - */ -#define __swap16md(x) ({ \ - register u_int16_t _x = (x); \ - __asm__ __volatile__("rev16 %0, %0" : "+l" (_x)); \ - _x; \ -}) - -#define __swap32md(x) ({ \ - register u_int32_t _x = (x); \ - __asm__ __volatile__("rev %0, %0" : "+l" (_x)); \ - _x; \ -}) - -#define __swap64md(x) ({ \ - u_int64_t _swap64md_x = (x); \ - (u_int64_t) __swap32md(_swap64md_x >> 32) | \ - (u_int64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __ARM_ARCH__ */ -#endif /* __GNUC__ */ - -#if defined(__ARMEB__) -#define _BYTE_ORDER _BIG_ENDIAN -#else -#define _BYTE_ORDER _LITTLE_ENDIAN -#endif -#define __STRICT_ALIGNMENT -#include -#include - -#endif /* !_ARM_ENDIAN_H_ */ diff --git a/ndk/platforms/android-21/arch-mips/include/machine/endian.h b/ndk/platforms/android-21/arch-mips/include/machine/endian.h deleted file mode 100644 index 41a9004f4..000000000 --- a/ndk/platforms/android-21/arch-mips/include/machine/endian.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */ - -/* - * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef _MIPS64_ENDIAN_H_ -#define _MIPS64_ENDIAN_H_ - -#ifdef __GNUC__ - -#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) -#define __swap16md(x) ({ \ - register uint16_t _x = (x); \ - register uint16_t _r; \ - __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x)); \ - _r; \ -}) - -#define __swap32md(x) ({ \ - register uint32_t _x = (x); \ - register uint32_t _r; \ - __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \ - _r; \ -}) - -#define __swap64md(x) ({ \ - uint64_t _swap64md_x = (x); \ - (uint64_t) __swap32md(_swap64md_x >> 32) | \ - (uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __mips32r2__ */ -#endif /* __GNUC__ */ - -#if defined(__MIPSEB__) -#define _BYTE_ORDER _BIG_ENDIAN -#else -#define _BYTE_ORDER _LITTLE_ENDIAN -#endif -#define __STRICT_ALIGNMENT -#include -#include - -#endif /* _MIPS64_ENDIAN_H_ */ diff --git a/ndk/platforms/android-21/arch-mips64/include/machine/endian.h b/ndk/platforms/android-21/arch-mips64/include/machine/endian.h deleted file mode 100644 index 41a9004f4..000000000 --- a/ndk/platforms/android-21/arch-mips64/include/machine/endian.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */ - -/* - * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef _MIPS64_ENDIAN_H_ -#define _MIPS64_ENDIAN_H_ - -#ifdef __GNUC__ - -#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) -#define __swap16md(x) ({ \ - register uint16_t _x = (x); \ - register uint16_t _r; \ - __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x)); \ - _r; \ -}) - -#define __swap32md(x) ({ \ - register uint32_t _x = (x); \ - register uint32_t _r; \ - __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \ - _r; \ -}) - -#define __swap64md(x) ({ \ - uint64_t _swap64md_x = (x); \ - (uint64_t) __swap32md(_swap64md_x >> 32) | \ - (uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __mips32r2__ */ -#endif /* __GNUC__ */ - -#if defined(__MIPSEB__) -#define _BYTE_ORDER _BIG_ENDIAN -#else -#define _BYTE_ORDER _LITTLE_ENDIAN -#endif -#define __STRICT_ALIGNMENT -#include -#include - -#endif /* _MIPS64_ENDIAN_H_ */ diff --git a/ndk/platforms/android-21/arch-x86/include/machine/endian.h b/ndk/platforms/android-21/arch-x86/include/machine/endian.h deleted file mode 100644 index e1506b110..000000000 --- a/ndk/platforms/android-21/arch-x86/include/machine/endian.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */ - -/*- - * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ - -#ifdef __GNUC__ - -#define __swap32md(x) __statement({ \ - uint32_t __swap32md_x = (x); \ - \ - __asm ("bswap %0" : "+r" (__swap32md_x)); \ - __swap32md_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) __statement({ \ - uint16_t __swap16md_x = (x); \ - \ - __asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \ - __swap16md_x; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __GNUC__ */ - -#define _BYTE_ORDER _LITTLE_ENDIAN -#include -#include - -#endif /* _MACHINE_ENDIAN_H_ */ diff --git a/ndk/platforms/android-21/arch-x86_64/include/machine/endian.h b/ndk/platforms/android-21/arch-x86_64/include/machine/endian.h deleted file mode 100644 index 4d9060ba7..000000000 --- a/ndk/platforms/android-21/arch-x86_64/include/machine/endian.h +++ /dev/null @@ -1,63 +0,0 @@ -/* $OpenBSD: endian.h,v 1.5 2011/03/12 22:27:48 guenther Exp $ */ - -/*- - * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ - -#include - -#ifdef __GNUC__ - -#define __swap32md(x) __statement({ \ - u_int32_t __swap32md_x = (x); \ - \ - __asm ("bswap %0" : "+r" (__swap32md_x)); \ - __swap32md_x; \ -}) - -#define __swap64md(x) __statement({ \ - u_int64_t __swap64md_x = (x); \ - \ - __asm ("bswapq %0" : "+r" (__swap64md_x)); \ - __swap64md_x; \ -}) - -#define __swap16md(x) __statement({ \ - u_int16_t __swap16md_x = (x); \ - \ - __asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \ - __swap16md_x; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __GNUC__ */ - -#define _BYTE_ORDER _LITTLE_ENDIAN -#include - -#endif /* _MACHINE_ENDIAN_H_ */ diff --git a/ndk/platforms/android-21/arch-arm64/include/machine/endian.h b/ndk/platforms/android-21/include/machine/endian.h similarity index 63% rename from ndk/platforms/android-21/arch-arm64/include/machine/endian.h rename to ndk/platforms/android-21/include/machine/endian.h index 87a038d0e..ac8951920 100644 --- a/ndk/platforms/android-21/arch-arm64/include/machine/endian.h +++ b/ndk/platforms/android-21/include/machine/endian.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Android Open Source Project + * Copyright (C) 2014 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,33 +26,10 @@ * SUCH DAMAGE. */ -#ifndef _AARCH64_ENDIAN_H_ -#define _AARCH64_ENDIAN_H_ +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ -#include +/* This file is for BSD source compatibility only. Use or instead. */ #include -#ifdef __GNUC__ - -#define __swap16md(x) ({ \ - register u_int16_t _x = (x); \ - __asm volatile ("rev16 %0, %0" : "+r" (_x)); \ - _x; \ -}) - -/* Use GCC builtins */ -#define __swap32md(x) __builtin_bswap32(x) -#define __swap64md(x) __builtin_bswap64(x) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __GNUC__ */ - -#if defined(__AARCH64EB__) -#define _BYTE_ORDER _BIG_ENDIAN -#else -#define _BYTE_ORDER _LITTLE_ENDIAN -#endif - -#endif /* _AARCH64_ENDIAN_H_ */ +#endif /* _MACHINE_ENDIAN_H_ */ diff --git a/ndk/platforms/android-21/include/sys/endian.h b/ndk/platforms/android-21/include/sys/endian.h index be4c90561..60cc0304c 100644 --- a/ndk/platforms/android-21/include/sys/endian.h +++ b/ndk/platforms/android-21/include/sys/endian.h @@ -1,5 +1,3 @@ -/* $OpenBSD: endian.h,v 1.17 2006/01/06 18:53:05 millert Exp $ */ - /*- * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. * @@ -24,169 +22,30 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * Generic definitions for little- and big-endian systems. Other endianesses - * has to be dealt with in the specific machine/endian.h file for that port. - * - * This file is meant to be included from a little- or big-endian port's - * machine/endian.h after setting _BYTE_ORDER to either 1234 for little endian - * or 4321 for big.. - */ - #ifndef _SYS_ENDIAN_H_ #define _SYS_ENDIAN_H_ #include -#include #include #define _LITTLE_ENDIAN 1234 #define _BIG_ENDIAN 4321 #define _PDP_ENDIAN 3412 +#define _BYTE_ORDER _LITTLE_ENDIAN +#define __LITTLE_ENDIAN_BITFIELD -#if __BSD_VISIBLE -#define LITTLE_ENDIAN _LITTLE_ENDIAN -#define BIG_ENDIAN _BIG_ENDIAN -#define PDP_ENDIAN _PDP_ENDIAN -#define BYTE_ORDER _BYTE_ORDER +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN _LITTLE_ENDIAN #endif - -#ifdef __GNUC__ - -#define __swap16gen(x) __statement({ \ - __uint16_t __swap16gen_x = (x); \ - \ - (__uint16_t)((__swap16gen_x & 0xff) << 8 | \ - (__swap16gen_x & 0xff00) >> 8); \ -}) - -#define __swap32gen(x) __statement({ \ - __uint32_t __swap32gen_x = (x); \ - \ - (__uint32_t)((__swap32gen_x & 0xff) << 24 | \ - (__swap32gen_x & 0xff00) << 8 | \ - (__swap32gen_x & 0xff0000) >> 8 | \ - (__swap32gen_x & 0xff000000) >> 24); \ -}) - -#define __swap64gen(x) __statement({ \ - __uint64_t __swap64gen_x = (x); \ - \ - (__uint64_t)((__swap64gen_x & 0xff) << 56 | \ - (__swap64gen_x & 0xff00ULL) << 40 | \ - (__swap64gen_x & 0xff0000ULL) << 24 | \ - (__swap64gen_x & 0xff000000ULL) << 8 | \ - (__swap64gen_x & 0xff00000000ULL) >> 8 | \ - (__swap64gen_x & 0xff0000000000ULL) >> 24 | \ - (__swap64gen_x & 0xff000000000000ULL) >> 40 | \ - (__swap64gen_x & 0xff00000000000000ULL) >> 56); \ -}) - -#else /* __GNUC__ */ - -/* Note that these macros evaluate their arguments several times. */ -#define __swap16gen(x) \ - (__uint16_t)(((__uint16_t)(x) & 0xff) << 8 | ((__uint16_t)(x) & 0xff00) >> 8) - -#define __swap32gen(x) \ - (__uint32_t)(((__uint32_t)(x) & 0xff) << 24 | \ - ((__uint32_t)(x) & 0xff00) << 8 | ((__uint32_t)(x) & 0xff0000) >> 8 |\ - ((__uint32_t)(x) & 0xff000000) >> 24) - -#define __swap64gen(x) \ - (__uint64_t)((((__uint64_t)(x) & 0xff) << 56) | \ - ((__uint64_t)(x) & 0xff00ULL) << 40 | \ - ((__uint64_t)(x) & 0xff0000ULL) << 24 | \ - ((__uint64_t)(x) & 0xff000000ULL) << 8 | \ - ((__uint64_t)(x) & 0xff00000000ULL) >> 8 | \ - ((__uint64_t)(x) & 0xff0000000000ULL) >> 24 | \ - ((__uint64_t)(x) & 0xff000000000000ULL) >> 40 | \ - ((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) - -#endif /* __GNUC__ */ - -/* - * Define MD_SWAP if you provide swap{16,32}md functions/macros that are - * optimized for your architecture, These will be used for swap{16,32} - * unless the argument is a constant and we are using GCC, where we can - * take advantage of the CSE phase much better by using the generic version. - */ -#ifdef MD_SWAP -#if __GNUC__ - -#define __swap16(x) __statement({ \ - __uint16_t __swap16_x = (x); \ - \ - __builtin_constant_p(x) ? __swap16gen(__swap16_x) : \ - __swap16md(__swap16_x); \ -}) - -#define __swap32(x) __statement({ \ - __uint32_t __swap32_x = (x); \ - \ - __builtin_constant_p(x) ? __swap32gen(__swap32_x) : \ - __swap32md(__swap32_x); \ -}) - -#define __swap64(x) __statement({ \ - __uint64_t __swap64_x = (x); \ - \ - __builtin_constant_p(x) ? __swap64gen(__swap64_x) : \ - __swap64md(__swap64_x); \ -}) - -#endif /* __GNUC__ */ - -#else /* MD_SWAP */ -#define __swap16 __swap16gen -#define __swap32 __swap32gen -#define __swap64 __swap64gen -#endif /* MD_SWAP */ - -#define __swap16_multi(v, n) do { \ - __size_t __swap16_multi_n = (n); \ - __uint16_t *__swap16_multi_v = (v); \ - \ - while (__swap16_multi_n) { \ - *__swap16_multi_v = swap16(*__swap16_multi_v); \ - __swap16_multi_v++; \ - __swap16_multi_n--; \ - } \ -} while (0) - -#if __BSD_VISIBLE -#define swap16 __swap16 -#define swap32 __swap32 -#define swap64 __swap64 -#define swap16_multi __swap16_multi -#endif /* __BSD_VISIBLE */ - -#if _BYTE_ORDER == _LITTLE_ENDIAN - -/* Can be overridden by machine/endian.h before inclusion of this file. */ -#ifndef _QUAD_HIGHWORD -#define _QUAD_HIGHWORD 1 -#endif -#ifndef _QUAD_LOWWORD -#define _QUAD_LOWWORD 0 +#ifndef __BIG_ENDIAN +#define __BIG_ENDIAN _BIG_ENDIAN #endif +#define __BYTE_ORDER _BYTE_ORDER -#if __BSD_VISIBLE -#define htobe16 __swap16 -#define htobe32 __swap32 -#define htobe64 __swap64 -#define betoh16 __swap16 -#define betoh32 __swap32 -#define betoh64 __swap64 - -#define htole16(x) (x) -#define htole32(x) (x) -#define htole64(x) (x) -#define letoh16(x) (x) -#define letoh32(x) (x) -#define letoh64(x) (x) -#endif /* __BSD_VISIBLE */ +#define __swap16 __builtin_bswap16 +#define __swap32 __builtin_bswap32 +#define __swap64 __builtin_bswap64 /* glibc compatibility. */ __BEGIN_DECLS @@ -205,67 +64,31 @@ __END_DECLS #define htonq(x) __swap64(x) #define ntohq(x) __swap64(x) -#define __LITTLE_ENDIAN_BITFIELD - -#endif /* _BYTE_ORDER */ - -#if _BYTE_ORDER == _BIG_ENDIAN - -/* Can be overridden by machine/endian.h before inclusion of this file. */ -#ifndef _QUAD_HIGHWORD -#define _QUAD_HIGHWORD 0 -#endif -#ifndef _QUAD_LOWWORD -#define _QUAD_LOWWORD 1 -#endif - #if __BSD_VISIBLE -#define htole16 __swap16 -#define htole32 __swap32 -#define htole64 __swap64 -#define letoh16 __swap16 -#define letoh32 __swap32 -#define letoh64 __swap64 +#define LITTLE_ENDIAN _LITTLE_ENDIAN +#define BIG_ENDIAN _BIG_ENDIAN +#define PDP_ENDIAN _PDP_ENDIAN +#define BYTE_ORDER _BYTE_ORDER -#define htobe16(x) (x) -#define htobe32(x) (x) -#define htobe64(x) (x) -#define betoh16(x) (x) -#define betoh32(x) (x) -#define betoh64(x) (x) -#endif /* __BSD_VISIBLE */ - -#define htons(x) (x) -#define htonl(x) (x) -#define ntohs(x) (x) -#define ntohl(x) (x) - -/* Bionic additions */ -#define ntohq(x) (x) -#define htonq(x) (x) - -#define __BIG_ENDIAN_BITFIELD - -#endif /* _BYTE_ORDER */ - -#if __BSD_VISIBLE #define NTOHL(x) (x) = ntohl((u_int32_t)(x)) #define NTOHS(x) (x) = ntohs((u_int16_t)(x)) #define HTONL(x) (x) = htonl((u_int32_t)(x)) #define HTONS(x) (x) = htons((u_int16_t)(x)) -#endif +#define htobe16 __swap16 +#define htobe32 __swap32 +#define htobe64 __swap64 +#define betoh16 __swap16 +#define betoh32 __swap32 +#define betoh64 __swap64 -#define __BYTE_ORDER _BYTE_ORDER -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#endif -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN _BIG_ENDIAN -#endif +#define htole16(x) (x) +#define htole32(x) (x) +#define htole64(x) (x) +#define letoh16(x) (x) +#define letoh32(x) (x) +#define letoh64(x) (x) - -#ifdef __BSD_VISIBLE /* * glibc-compatible beXXtoh/leXXtoh synonyms for htobeXX/htoleXX. * The BSDs export both sets of names, bionic historically only @@ -278,6 +101,6 @@ __END_DECLS #define le16toh(x) htole16(x) #define le32toh(x) htole32(x) #define le64toh(x) htole64(x) -#endif +#endif /* __BSD_VISIBLE */ #endif /* _SYS_ENDIAN_H_ */ diff --git a/ndk/platforms/android-3/arch-arm/include/machine/endian.h b/ndk/platforms/android-3/arch-arm/include/machine/endian.h deleted file mode 100644 index 7cba3b942..000000000 --- a/ndk/platforms/android-3/arch-arm/include/machine/endian.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $ */ - -/* - * Copyright (C) 2010 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _ARM_ENDIAN_H_ -#define _ARM_ENDIAN_H_ - -#ifdef __GNUC__ - -/* - * REV and REV16 weren't available on ARM5 or ARM4. - * We don't include because it pollutes the - * namespace with macros like PLD. - */ -#if !defined __ARM_ARCH_5__ && !defined __ARM_ARCH_5T__ && \ - !defined __ARM_ARCH_5TE__ && !defined __ARM_ARCH_5TEJ__ && \ - !defined __ARM_ARCH_4T__ && !defined __ARM_ARCH_4__ - -/* According to RealView Assembler User's Guide, REV and REV16 are available - * in Thumb code and 16-bit instructions when used in Thumb-2 code. - * - * REV Rd, Rm - * Rd and Rm must both be Lo registers. - * - * REV16 Rd, Rm - * Rd and Rm must both be Lo registers. - * - * The +l constraint takes care of this without constraining us in ARM mode. - */ -#define __swap16md(x) ({ \ - register u_int16_t _x = (x); \ - __asm volatile ("rev16 %0, %0" : "+l" (_x)); \ - _x; \ -}) - -#define __swap32md(x) ({ \ - register u_int32_t _x = (x); \ - __asm volatile ("rev %0, %0" : "+l" (_x)); \ - _x; \ -}) - -#define __swap64md(x) ({ \ - u_int64_t _swap64md_x = (x); \ - (u_int64_t) __swap32md(_swap64md_x >> 32) | \ - (u_int64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __ARM_ARCH__ */ -#endif /* __GNUC__ */ - -#if defined(__ARMEB__) -#define _BYTE_ORDER _BIG_ENDIAN -#else -#define _BYTE_ORDER _LITTLE_ENDIAN -#endif -#define __STRICT_ALIGNMENT -#include -#include - -#endif /* !_ARM_ENDIAN_H_ */ diff --git a/ndk/platforms/android-3/include/machine/endian.h b/ndk/platforms/android-3/include/machine/endian.h new file mode 100644 index 000000000..ac8951920 --- /dev/null +++ b/ndk/platforms/android-3/include/machine/endian.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +/* This file is for BSD source compatibility only. Use or instead. */ +#include + +#endif /* _MACHINE_ENDIAN_H_ */ diff --git a/ndk/platforms/android-3/include/sys/endian.h b/ndk/platforms/android-3/include/sys/endian.h index 2a0c65870..60cc0304c 100644 --- a/ndk/platforms/android-3/include/sys/endian.h +++ b/ndk/platforms/android-3/include/sys/endian.h @@ -1,5 +1,3 @@ -/* $OpenBSD: endian.h,v 1.17 2006/01/06 18:53:05 millert Exp $ */ - /*- * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. * @@ -24,170 +22,59 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * Generic definitions for little- and big-endian systems. Other endianesses - * has to be dealt with in the specific machine/endian.h file for that port. - * - * This file is meant to be included from a little- or big-endian port's - * machine/endian.h after setting _BYTE_ORDER to either 1234 for little endian - * or 4321 for big.. - */ - #ifndef _SYS_ENDIAN_H_ #define _SYS_ENDIAN_H_ #include -#include -#include + +#include #define _LITTLE_ENDIAN 1234 #define _BIG_ENDIAN 4321 #define _PDP_ENDIAN 3412 +#define _BYTE_ORDER _LITTLE_ENDIAN +#define __LITTLE_ENDIAN_BITFIELD -#if __BSD_VISIBLE -#define LITTLE_ENDIAN _LITTLE_ENDIAN -#define BIG_ENDIAN _BIG_ENDIAN -#define PDP_ENDIAN _PDP_ENDIAN -#define BYTE_ORDER _BYTE_ORDER +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN _LITTLE_ENDIAN #endif +#ifndef __BIG_ENDIAN +#define __BIG_ENDIAN _BIG_ENDIAN +#endif +#define __BYTE_ORDER _BYTE_ORDER -#ifdef __GNUC__ - -#define __swap16gen(x) __statement({ \ - __uint16_t __swap16gen_x = (x); \ - \ - (__uint16_t)((__swap16gen_x & 0xff) << 8 | \ - (__swap16gen_x & 0xff00) >> 8); \ -}) - -#define __swap32gen(x) __statement({ \ - __uint32_t __swap32gen_x = (x); \ - \ - (__uint32_t)((__swap32gen_x & 0xff) << 24 | \ - (__swap32gen_x & 0xff00) << 8 | \ - (__swap32gen_x & 0xff0000) >> 8 | \ - (__swap32gen_x & 0xff000000) >> 24); \ -}) - -#define __swap64gen(x) __statement({ \ - __uint64_t __swap64gen_x = (x); \ - \ - (__uint64_t)((__swap64gen_x & 0xff) << 56 | \ - (__swap64gen_x & 0xff00ULL) << 40 | \ - (__swap64gen_x & 0xff0000ULL) << 24 | \ - (__swap64gen_x & 0xff000000ULL) << 8 | \ - (__swap64gen_x & 0xff00000000ULL) >> 8 | \ - (__swap64gen_x & 0xff0000000000ULL) >> 24 | \ - (__swap64gen_x & 0xff000000000000ULL) >> 40 | \ - (__swap64gen_x & 0xff00000000000000ULL) >> 56); \ -}) - -#else /* __GNUC__ */ - -/* Note that these macros evaluate their arguments several times. */ -#define __swap16gen(x) \ - (__uint16_t)(((__uint16_t)(x) & 0xff) << 8 | ((__uint16_t)(x) & 0xff00) >> 8) - -#define __swap32gen(x) \ - (__uint32_t)(((__uint32_t)(x) & 0xff) << 24 | \ - ((__uint32_t)(x) & 0xff00) << 8 | ((__uint32_t)(x) & 0xff0000) >> 8 |\ - ((__uint32_t)(x) & 0xff000000) >> 24) - -#define __swap64gen(x) \ - (__uint64_t)((((__uint64_t)(x) & 0xff) << 56) | \ - ((__uint64_t)(x) & 0xff00ULL) << 40 | \ - ((__uint64_t)(x) & 0xff0000ULL) << 24 | \ - ((__uint64_t)(x) & 0xff000000ULL) << 8 | \ - ((__uint64_t)(x) & 0xff00000000ULL) >> 8 | \ - ((__uint64_t)(x) & 0xff0000000000ULL) >> 24 | \ - ((__uint64_t)(x) & 0xff000000000000ULL) >> 40 | \ - ((__uint64_t)(x) & 0xff00000000000000ULL) >> 56) - -#endif /* __GNUC__ */ - -/* - * Define MD_SWAP if you provide swap{16,32}md functions/macros that are - * optimized for your architecture, These will be used for swap{16,32} - * unless the argument is a constant and we are using GCC, where we can - * take advantage of the CSE phase much better by using the generic version. - */ -#ifdef MD_SWAP -#if __GNUC__ - -#define __swap16(x) __statement({ \ - __uint16_t __swap16_x = (x); \ - \ - __builtin_constant_p(x) ? __swap16gen(__swap16_x) : \ - __swap16md(__swap16_x); \ -}) - -#define __swap32(x) __statement({ \ - __uint32_t __swap32_x = (x); \ - \ - __builtin_constant_p(x) ? __swap32gen(__swap32_x) : \ - __swap32md(__swap32_x); \ -}) - -#define __swap64(x) __statement({ \ - __uint64_t __swap64_x = (x); \ - \ - __builtin_constant_p(x) ? __swap64gen(__swap64_x) : \ - __swap64md(__swap64_x); \ -}) - -#endif /* __GNUC__ */ - -#else /* MD_SWAP */ -#define __swap16 __swap16gen -#define __swap32 __swap32gen -#define __swap64 __swap64gen -#endif /* MD_SWAP */ - -#define __swap16_multi(v, n) do { \ - __size_t __swap16_multi_n = (n); \ - __uint16_t *__swap16_multi_v = (v); \ - \ - while (__swap16_multi_n) { \ - *__swap16_multi_v = swap16(*__swap16_multi_v); \ - __swap16_multi_v++; \ - __swap16_multi_n--; \ - } \ -} while (0) - -#if __BSD_VISIBLE -#define swap16 __swap16 -#define swap32 __swap32 -#define swap64 __swap64 -#define swap16_multi __swap16_multi +#define __swap16 __builtin_bswap16 +#define __swap32 __builtin_bswap32 +#define __swap64 __builtin_bswap64 +/* glibc compatibility. */ __BEGIN_DECLS -__uint64_t htobe64(__uint64_t); -__uint32_t htobe32(__uint32_t); -__uint16_t htobe16(__uint16_t); -__uint64_t betoh64(__uint64_t); -__uint32_t betoh32(__uint32_t); -__uint16_t betoh16(__uint16_t); - -__uint64_t htole64(__uint64_t); -__uint32_t htole32(__uint32_t); -__uint16_t htole16(__uint16_t); -__uint64_t letoh64(__uint64_t); -__uint32_t letoh32(__uint32_t); -__uint16_t letoh16(__uint16_t); +uint32_t htonl(uint32_t) __pure2; +uint16_t htons(uint16_t) __pure2; +uint32_t ntohl(uint32_t) __pure2; +uint16_t ntohs(uint16_t) __pure2; __END_DECLS -#endif /* __BSD_VISIBLE */ -#if _BYTE_ORDER == _LITTLE_ENDIAN +#define htonl(x) __swap32(x) +#define htons(x) __swap16(x) +#define ntohl(x) __swap32(x) +#define ntohs(x) __swap16(x) -/* Can be overridden by machine/endian.h before inclusion of this file. */ -#ifndef _QUAD_HIGHWORD -#define _QUAD_HIGHWORD 1 -#endif -#ifndef _QUAD_LOWWORD -#define _QUAD_LOWWORD 0 -#endif +/* Bionic additions */ +#define htonq(x) __swap64(x) +#define ntohq(x) __swap64(x) #if __BSD_VISIBLE +#define LITTLE_ENDIAN _LITTLE_ENDIAN +#define BIG_ENDIAN _BIG_ENDIAN +#define PDP_ENDIAN _PDP_ENDIAN +#define BYTE_ORDER _BYTE_ORDER + +#define NTOHL(x) (x) = ntohl((u_int32_t)(x)) +#define NTOHS(x) (x) = ntohs((u_int16_t)(x)) +#define HTONL(x) (x) = htonl((u_int32_t)(x)) +#define HTONS(x) (x) = htons((u_int16_t)(x)) + #define htobe16 __swap16 #define htobe32 __swap32 #define htobe64 __swap64 @@ -201,74 +88,19 @@ __END_DECLS #define letoh16(x) (x) #define letoh32(x) (x) #define letoh64(x) (x) + +/* + * glibc-compatible beXXtoh/leXXtoh synonyms for htobeXX/htoleXX. + * The BSDs export both sets of names, bionic historically only + * exported the ones above (or on the rhs here), and glibc only + * exports these names (on the lhs). + */ +#define be16toh(x) htobe16(x) +#define be32toh(x) htobe32(x) +#define be64toh(x) htobe64(x) +#define le16toh(x) htole16(x) +#define le32toh(x) htole32(x) +#define le64toh(x) htole64(x) #endif /* __BSD_VISIBLE */ -#define htons(x) __swap16(x) -#define htonl(x) __swap32(x) -#define ntohs(x) __swap16(x) -#define ntohl(x) __swap32(x) - -/* Bionic additions */ -#define ntohq(x) __swap64(x) -#define htonq(x) __swap64(x) - -#define __LITTLE_ENDIAN_BITFIELD - -#endif /* _BYTE_ORDER */ - -#if _BYTE_ORDER == _BIG_ENDIAN - -/* Can be overridden by machine/endian.h before inclusion of this file. */ -#ifndef _QUAD_HIGHWORD -#define _QUAD_HIGHWORD 0 -#endif -#ifndef _QUAD_LOWWORD -#define _QUAD_LOWWORD 1 -#endif - -#if __BSD_VISIBLE -#define htole16 __swap16 -#define htole32 __swap32 -#define htole64 __swap64 -#define letoh16 __swap16 -#define letoh32 __swap32 -#define letoh64 __swap64 - -#define htobe16(x) (x) -#define htobe32(x) (x) -#define htobe64(x) (x) -#define betoh16(x) (x) -#define betoh32(x) (x) -#define betoh64(x) (x) -#endif /* __BSD_VISIBLE */ - -#define htons(x) (x) -#define htonl(x) (x) -#define ntohs(x) (x) -#define ntohl(x) (x) - -/* Bionic additions */ -#define ntohq(x) (x) -#define htonq(x) (x) - -#define __BIG_ENDIAN_BITFIELD - -#endif /* _BYTE_ORDER */ - -#if __BSD_VISIBLE -#define NTOHL(x) (x) = ntohl((u_int32_t)(x)) -#define NTOHS(x) (x) = ntohs((u_int16_t)(x)) -#define HTONL(x) (x) = htonl((u_int32_t)(x)) -#define HTONS(x) (x) = htons((u_int16_t)(x)) -#endif - - -#define __BYTE_ORDER _BYTE_ORDER -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#endif -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN _BIG_ENDIAN -#endif - #endif /* _SYS_ENDIAN_H_ */ diff --git a/ndk/platforms/android-9/arch-mips/include/machine/endian.h b/ndk/platforms/android-9/arch-mips/include/machine/endian.h deleted file mode 100644 index 41a9004f4..000000000 --- a/ndk/platforms/android-9/arch-mips/include/machine/endian.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */ - -/* - * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifndef _MIPS64_ENDIAN_H_ -#define _MIPS64_ENDIAN_H_ - -#ifdef __GNUC__ - -#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2) -#define __swap16md(x) ({ \ - register uint16_t _x = (x); \ - register uint16_t _r; \ - __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x)); \ - _r; \ -}) - -#define __swap32md(x) ({ \ - register uint32_t _x = (x); \ - register uint32_t _r; \ - __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \ - _r; \ -}) - -#define __swap64md(x) ({ \ - uint64_t _swap64md_x = (x); \ - (uint64_t) __swap32md(_swap64md_x >> 32) | \ - (uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __mips32r2__ */ -#endif /* __GNUC__ */ - -#if defined(__MIPSEB__) -#define _BYTE_ORDER _BIG_ENDIAN -#else -#define _BYTE_ORDER _LITTLE_ENDIAN -#endif -#define __STRICT_ALIGNMENT -#include -#include - -#endif /* _MIPS64_ENDIAN_H_ */ diff --git a/ndk/platforms/android-9/arch-x86/include/machine/endian.h b/ndk/platforms/android-9/arch-x86/include/machine/endian.h deleted file mode 100644 index e1506b110..000000000 --- a/ndk/platforms/android-9/arch-x86/include/machine/endian.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */ - -/*- - * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ - -#ifdef __GNUC__ - -#define __swap32md(x) __statement({ \ - uint32_t __swap32md_x = (x); \ - \ - __asm ("bswap %0" : "+r" (__swap32md_x)); \ - __swap32md_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) __statement({ \ - uint16_t __swap16md_x = (x); \ - \ - __asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \ - __swap16md_x; \ -}) - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP - -#endif /* __GNUC__ */ - -#define _BYTE_ORDER _LITTLE_ENDIAN -#include -#include - -#endif /* _MACHINE_ENDIAN_H_ */