From 61a3e1462c5ed9c1a7bf6075b70af7ff7b8df2ee Mon Sep 17 00:00:00 2001 From: Andrew Hsieh Date: Sat, 18 Aug 2012 16:10:35 +0800 Subject: [PATCH] Update stdint.h; Refresh /include/machine/* stdint.h: https://android-review.googlesource.com/#/c/41714/ https://android-review.googlesource.com/#/c/40576/ /include/machine/*: to be consistent with bionic/libc//include/machine/* Change-Id: Ieeb44c3e864bf64c4cad4d3c9d94024a7b520181 --- .../arch-arm/include/machine/_types.h | 2 - .../android-3/arch-arm/include/machine/asm.h | 16 +- .../arch-arm/include/machine/cpu-features.h | 41 ++++- .../arch-arm/include/machine/setjmp.h | 149 +++++++++--------- ndk/platforms/android-3/include/stdint.h | 38 +---- .../arch-mips/include/machine/kernel.h | 6 +- .../arch-mips/include/machine/signal.h | 6 +- .../arch-x86/include/machine/_types.h | 2 - 8 files changed, 133 insertions(+), 127 deletions(-) diff --git a/ndk/platforms/android-3/arch-arm/include/machine/_types.h b/ndk/platforms/android-3/arch-arm/include/machine/_types.h index 6d10e12b4..3e779ca85 100644 --- a/ndk/platforms/android-3/arch-arm/include/machine/_types.h +++ b/ndk/platforms/android-3/arch-arm/include/machine/_types.h @@ -46,8 +46,6 @@ typedef long ssize_t; typedef long ptrdiff_t; #endif -//#include - /* 7.18.1.1 Exact-width integer types */ typedef __signed char __int8_t; typedef unsigned char __uint8_t; diff --git a/ndk/platforms/android-3/arch-arm/include/machine/asm.h b/ndk/platforms/android-3/arch-arm/include/machine/asm.h index c7bd017aa..047e54d17 100644 --- a/ndk/platforms/android-3/arch-arm/include/machine/asm.h +++ b/ndk/platforms/android-3/arch-arm/include/machine/asm.h @@ -70,7 +70,13 @@ #define _ASM_TYPE_FUNCTION #function #define _ASM_TYPE_OBJECT #object #define _ENTRY(x) \ - .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: + .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x: .fnstart + +#define _ASM_SIZE(x) .size x, .-x; + +#define _END(x) \ + .fnend; \ + _ASM_SIZE(x) #ifdef GPROF # ifdef __ELF__ @@ -86,8 +92,16 @@ #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE #define ENTRY_NP(y) _ENTRY(_C_LABEL(y)) +#define END(y) _END(_C_LABEL(y)) #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE #define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y)) +#define ASEND(y) _END(_ASM_LABEL(y)) + +#ifdef __ELF__ +#define ENTRY_PRIVATE(y) ENTRY(y); .hidden _C_LABEL(y) +#else +#define ENTRY_PRIVATE(y) ENTRY(y) +#endif #define ASMSTR .asciz diff --git a/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h b/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h index f83600648..80d3fda64 100644 --- a/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h +++ b/ndk/platforms/android-3/arch-arm/include/machine/cpu-features.h @@ -38,7 +38,7 @@ * IMPORTANT: We have no intention to support anything below an ARMv4T ! */ -/* _ARM_ARCH_REVISION is a number corresponding to the ARM revision +/* __ARM_ARCH__ is a number corresponding to the ARM revision * we're going to support * * it looks like our toolchain doesn't define __ARM_ARCH__ @@ -142,15 +142,50 @@ * * ldr pc, [] * - * note that this affects any instruction that explicitely changes the + * note that this affects any instruction that explicitly changes the * value of the pc register, including ldm { ...,pc } or 'add pc, #offset' */ #if __ARM_ARCH__ >= 5 # define __ARM_HAVE_PC_INTERWORK #endif +/* define __ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecture to be + * used in replacement of deprecated swp instruction + */ +#if __ARM_ARCH__ >= 6 +# define __ARM_HAVE_LDREX_STREX +#endif + +/* define __ARM_HAVE_DMB for ARMv7 architecture + */ +#if __ARM_ARCH__ >= 7 +# define __ARM_HAVE_DMB +#endif + +/* define __ARM_HAVE_LDREXD for ARMv7 architecture + * (also present in ARMv6K, but not implemented in ARMv7-M, neither of which + * we care about) + */ +#if __ARM_ARCH__ >= 7 +# define __ARM_HAVE_LDREXD +#endif + +/* define _ARM_HAVE_VFP if we have VFPv3 + */ +#if __ARM_ARCH__ >= 7 && defined __VFP_FP__ +# define __ARM_HAVE_VFP +#endif + +/* define _ARM_HAVE_NEON for ARMv7 architecture if we support the + * Neon SIMD instruction set extensions. This also implies + * that VFPv3-D32 is supported. + */ +#if __ARM_ARCH__ >= 7 && defined __ARM_NEON__ +# define __ARM_HAVE_NEON +#endif /* Assembly-only macros */ +#ifdef __ASSEMBLY__ /* define a handy PLD(address) macro since the cache preload * is an optional opcode @@ -161,4 +196,6 @@ # define PLD(reg,offset) /* nothing */ #endif +#endif /* ! __ASSEMBLY__ */ + #endif /* _ARM_MACHINE_CPU_FEATURES_H */ diff --git a/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h b/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h index f20cab2e9..0941202d5 100644 --- a/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h +++ b/ndk/platforms/android-3/arch-arm/include/machine/setjmp.h @@ -1,87 +1,82 @@ -/* $OpenBSD: setjmp.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */ -/* $NetBSD: setjmp.h,v 1.2 2001/08/25 14:45:59 bjh21 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. + */ /* * machine/setjmp.h: machine dependent setjmp-related information. */ -#ifdef __ELF__ -#define _JBLEN 64 /* size, in longs, of a jmp_buf */ -#else -#define _JBLEN 29 /* size, in longs, of a jmp_buf */ -#endif - -/* - * NOTE: The internal structure of a jmp_buf is *PRIVATE* - * This information is provided as there is software - * that fiddles with this with obtain the stack pointer - * (yes really ! and its commercial !). +/* _JBLEN is the size of a jmp_buf in longs. + * Do not modify this value or you will break the ABI ! * - * Description of the setjmp buffer - * - * word 0 magic number (dependant on creator) - * 1 - 3 f4 fp register 4 - * 4 - 6 f5 fp register 5 - * 7 - 9 f6 fp register 6 - * 10 - 12 f7 fp register 7 - * 13 fpsr fp status register - * 14 r4 register 4 - * 15 r5 register 5 - * 16 r6 register 6 - * 17 r7 register 7 - * 18 r8 register 8 - * 19 r9 register 9 - * 20 r10 register 10 (sl) - * 21 r11 register 11 (fp) - * 22 r12 register 12 (ip) - * 23 r13 register 13 (sp) - * 24 r14 register 14 (lr) - * 25 signal mask (dependant on magic) - * 26 (con't) - * 27 (con't) - * 28 (con't) - * - * The magic number number identifies the jmp_buf and - * how the buffer was created as well as providing - * a sanity check - * - * A side note I should mention - Please do not tamper - * with the floating point fields. While they are - * always saved and restored at the moment this cannot - * be garenteed especially if the compiler happens - * to be generating soft-float code so no fp - * registers will be used. - * - * Whilst this can be seen an encouraging people to - * use the setjmp buffer in this way I think that it - * is for the best then if changes occur compiles will - * break rather than just having new builds falling over - * mysteriously. + * This value comes from the original OpenBSD ARM-specific header + * that was replaced by this one. */ +#define _JBLEN 64 + +/* According to the ARM AAPCS document, we only need to save + * the following registers: + * + * Core r4-r14 + * + * VFP d8-d15 (see section 5.1.2.1) + * + * Registers s16-s31 (d8-d15, q4-q7) must be preserved across subroutine + * calls; registers s0-s15 (d0-d7, q0-q3) do not need to be preserved + * (and can be used for passing arguments or returning results in standard + * procedure-call variants). Registers d16-d31 (q8-q15), if present, do + * not need to be preserved. + * + * FPSCR saved because GLibc does saves it too. + * + */ + +/* The internal structure of a jmp_buf is totally private. + * Current layout (may change in the future): + * + * word name description + * 0 magic magic number + * 1 sigmask signal mask (not used with _setjmp / _longjmp) + * 2 float_base base of float registers (d8 to d15) + * 18 float_state floating-point status and control register + * 19 core_base base of core registers (r4 to r14) + * 30 reserved reserved entries (room to grow) + * 64 + * + * NOTE: float_base must be at an even word index, since the + * FP registers will be loaded/stored with instructions + * that expect 8-byte alignment. + */ + +#define _JB_MAGIC 0 +#define _JB_SIGMASK (_JB_MAGIC+1) +#define _JB_FLOAT_BASE (_JB_SIGMASK+1) +#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2) +#define _JB_CORE_BASE (_JB_FLOAT_STATE+1) #define _JB_MAGIC__SETJMP 0x4278f500 #define _JB_MAGIC_SETJMP 0x4278f501 - -/* Valid for all jmp_buf's */ - -#define _JB_MAGIC 0 -#define _JB_REG_F4 1 -#define _JB_REG_F5 4 -#define _JB_REG_F6 7 -#define _JB_REG_F7 10 -#define _JB_REG_FPSR 13 -#define _JB_REG_R4 14 -#define _JB_REG_R5 15 -#define _JB_REG_R6 16 -#define _JB_REG_R7 17 -#define _JB_REG_R8 18 -#define _JB_REG_R9 19 -#define _JB_REG_R10 20 -#define _JB_REG_R11 21 -#define _JB_REG_R12 22 -#define _JB_REG_R13 23 -#define _JB_REG_R14 24 - -/* Only valid with the _JB_MAGIC_SETJMP magic */ - -#define _JB_SIGMASK 25 diff --git a/ndk/platforms/android-3/include/stdint.h b/ndk/platforms/android-3/include/stdint.h index e7914750f..49879cb5b 100644 --- a/ndk/platforms/android-3/include/stdint.h +++ b/ndk/platforms/android-3/include/stdint.h @@ -31,8 +31,6 @@ #include #include - - #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) # define __STDINT_LIMITS #endif @@ -41,20 +39,14 @@ # define __STDINT_MACROS #endif -#if !defined __STRICT_ANSI__ || __STDC_VERSION__ >= 199901L -# define __STDC_INT64__ -#endif - typedef __int8_t int8_t; typedef __uint8_t uint8_t; typedef __int16_t int16_t; typedef __uint16_t uint16_t; typedef __int32_t int32_t; typedef __uint32_t uint32_t; -#if defined(__STDC_INT64__) typedef __int64_t int64_t; typedef __uint64_t uint64_t; -#endif /* * int8_t & uint8_t @@ -93,7 +85,6 @@ typedef uint8_t uint_fast8_t; * int16_t & uint16_t */ - typedef int16_t int_least16_t; typedef int32_t int_fast16_t; @@ -156,17 +147,16 @@ typedef uint32_t uint_fast32_t; # define UINT_FAST32_C(c) UINT32_C(c) #endif -#if defined(__STDC_INT64__) /* * int64_t */ + typedef int64_t int_least64_t; typedef int64_t int_fast64_t; typedef uint64_t uint_least64_t; typedef uint64_t uint_fast64_t; - #ifdef __STDINT_LIMITS # define INT64_MIN (__INT64_C(-9223372036854775807)-1) # define INT64_MAX (__INT64_C(9223372036854775807)) @@ -193,13 +183,10 @@ typedef uint64_t uint_fast64_t; # define UINT_FAST64_C(c) UINT64_C(c) #endif - # define __PRI64_RANK "ll" # define __PRIFAST_RANK "" # define __PRIPTR_RANK "" -#endif /* __STDC_INT64__ */ - /* * intptr_t & uintptr_t */ @@ -221,14 +208,10 @@ typedef unsigned int uintptr_t; # define PTRDIFF_C(c) INT32_C(c) #endif - - /* * intmax_t & uintmax_t */ -#if defined(__STDC_INT64__) - typedef uint64_t uintmax_t; typedef int64_t intmax_t; @@ -243,25 +226,6 @@ typedef int64_t intmax_t; # define UINTMAX_C(c) UINT64_C(c) #endif -#else /* !__STDC_INT64__ */ - -typedef uint32_t uintmax_t; -typedef int32_t intmax_t; - -#ifdef __STDINT_LIMITS -# define INTMAX_MIN INT32_MIN -# define INTMAX_MAX INT32_MAX -# define UINTMAX_MAX UINT32_MAX -#endif - -#ifdef __STDINT_MACROS -# define INTMAX_C(c) INT32_C(c) -# define UINTMAX_C(c) UINT32_C(c) -#endif - -#endif /* !__STDC_INT64__ */ - - /* size_t is defined by the GCC-specific */ #ifndef _SSIZE_T_DEFINED_ #define _SSIZE_T_DEFINED_ diff --git a/ndk/platforms/android-9/arch-mips/include/machine/kernel.h b/ndk/platforms/android-9/arch-mips/include/machine/kernel.h index 462b8e3be..69ad40cd1 100644 --- a/ndk/platforms/android-9/arch-mips/include/machine/kernel.h +++ b/ndk/platforms/android-9/arch-mips/include/machine/kernel.h @@ -25,8 +25,8 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef _ARCH_ARM_KERNEL_H -#define _ARCH_ARM_KERNEL_H +#ifndef _ARCH_MIPS_KERNEL_H +#define _ARCH_MIPS_KERNEL_H /* this file contains kernel-specific definitions that were optimized out of our processed kernel headers, but still useful nonetheless... */ @@ -39,4 +39,4 @@ typedef unsigned long __kernel_fsblkcnt_t; typedef unsigned long __kernel_fsfilcnt_t; typedef unsigned int __kernel_id_t; -#endif /* _ARCH_ARM_KERNEL_H */ +#endif /* _ARCH_MIPS_KERNEL_H */ diff --git a/ndk/platforms/android-9/arch-mips/include/machine/signal.h b/ndk/platforms/android-9/arch-mips/include/machine/signal.h index 96ebf76b6..4efb856f0 100644 --- a/ndk/platforms/android-9/arch-mips/include/machine/signal.h +++ b/ndk/platforms/android-9/arch-mips/include/machine/signal.h @@ -57,7 +57,7 @@ typedef int sig_atomic_t; * a non-standard exit is performed. */ -#if defined(ANDROID_CHANGES) +#if defined(__ANDROID__) /* * The Linux and OpenBSD sigcontext structures are slightly different @@ -104,7 +104,7 @@ struct sigcontext { #else /* __LANGUAGE_ASSEMBLY */ -#ifdef ANDROID_CHANGES +#ifdef __ANDROID__ #define SC_REGMASK (0*REGSZ) #define SC_STATUS (1*REGSZ) @@ -140,7 +140,7 @@ struct sigcontext { #define SC_FPUSED (70 * REGSZ) #define SC_FPC_EIR (71 * REGSZ) -#endif /*ANDROID CHANGES*/ +#endif /* __ANDROID__ */ #endif /* __LANGUAGE_ASSEMBLY */ diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h index 65892a11e..d3d9eeb6a 100644 --- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h +++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h @@ -58,8 +58,6 @@ typedef long int ssize_t; # endif #endif -#include - /* 7.18.1.1 Exact-width integer types */ typedef __signed char __int8_t; typedef unsigned char __uint8_t;