diff options
author | Steve Kondik <shade@chemlab.org> | 2012-11-18 19:44:25 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-11-18 19:44:25 -0800 |
commit | 5015fe9bf8869e794cfd972189876e5ff67a3a77 (patch) | |
tree | ac5fbd6139872dbaabf3c3fa01d1ad3af441d72f /libc/private | |
parent | 7f687eb12e9977215416469c3edfc9f464a5883c (diff) | |
parent | f29c214d6ad97f9a5348407cc66a58aec2228ca9 (diff) | |
download | bionic-5015fe9bf8869e794cfd972189876e5ff67a3a77.zip bionic-5015fe9bf8869e794cfd972189876e5ff67a3a77.tar.gz bionic-5015fe9bf8869e794cfd972189876e5ff67a3a77.tar.bz2 |
Merge branch 'jb-mr1-release' of https://android.googlesource.com/platform/bionic into mr1
Conflicts:
libc/Android.mk
libc/bionic/system_properties.c
libc/kernel/common/linux/msm_mdp.h
libc/tools/gensyscalls.py
libm/Android.mk
linker/linker.c
Change-Id: I11944300d7fcf2fd9dc587d8c7a937bf5366bcc0
Diffstat (limited to 'libc/private')
-rw-r--r-- | libc/private/__dso_handle.h (renamed from libc/private/__dso_handle.S) | 16 | ||||
-rw-r--r-- | libc/private/__dso_handle_so.h (renamed from libc/private/__dso_handle_so.S) | 16 | ||||
-rw-r--r-- | libc/private/bionic_atomic_gcc_builtin.h | 11 | ||||
-rw-r--r-- | libc/private/bionic_atomic_inline.h | 8 | ||||
-rw-r--r-- | libc/private/bionic_atomic_mips.h | 102 | ||||
-rw-r--r-- | libc/private/bionic_tls.h | 15 | ||||
-rw-r--r-- | libc/private/logd.h | 26 |
7 files changed, 160 insertions, 34 deletions
diff --git a/libc/private/__dso_handle.S b/libc/private/__dso_handle.h index 3e80128..e67ce7c 100644 --- a/libc/private/__dso_handle.S +++ b/libc/private/__dso_handle.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2012 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,17 +26,9 @@ * SUCH DAMAGE. */ -# The __dso_handle global variable is used by static -# C++ constructors and destructors in the binary. -# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor -# - .section .bss - .align 4 #ifndef CRT_LEGACY_WORKAROUND - .hidden __dso_handle +__attribute__ ((visibility ("hidden"))) #endif - - .globl __dso_handle -__dso_handle: - .long 0 +__attribute__ ((section (".bss"))) +void *__dso_handle = (void *) 0; diff --git a/libc/private/__dso_handle_so.S b/libc/private/__dso_handle_so.h index 77a5d7f..732799b 100644 --- a/libc/private/__dso_handle_so.S +++ b/libc/private/__dso_handle_so.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2012 The Android Open Source Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,13 +26,7 @@ * SUCH DAMAGE. */ -# The __dso_handle global variable is used by static -# C++ constructors and destructors in the binary. -# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor -# - .data - .align 4 - .hidden __dso_handle - .globl __dso_handle -__dso_handle: - .long __dso_handle + +__attribute__ ((visibility ("hidden"))) +__attribute__ ((section (".data"))) +void *__dso_handle = &__dso_handle; diff --git a/libc/private/bionic_atomic_gcc_builtin.h b/libc/private/bionic_atomic_gcc_builtin.h index e7c5761..2919f7f 100644 --- a/libc/private/bionic_atomic_gcc_builtin.h +++ b/libc/private/bionic_atomic_gcc_builtin.h @@ -31,18 +31,17 @@ __ATOMIC_INLINE__ int __bionic_cmpxchg(int32_t old_value, int32_t new_value, volatile int32_t* ptr) { /* We must return 0 on success */ - return __sync_bool_compare_and_swap(ptr, old_value, new_value) == 0; + return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; } __ATOMIC_INLINE__ int32_t __bionic_swap(int32_t new_value, volatile int32_t* ptr) { - int32_t prev; + int32_t old_value; do { - prev = *ptr; - status = __sync_val_compare_and_swap(ptr, prev, new_value); - } while (status == 0); - return prev; + old_value = *ptr; + } while (__sync_val_compare_and_swap(ptr, old_value, new_value) != old_value); + return old_value; } __ATOMIC_INLINE__ int32_t diff --git a/libc/private/bionic_atomic_inline.h b/libc/private/bionic_atomic_inline.h index 821ad39..6819af6 100644 --- a/libc/private/bionic_atomic_inline.h +++ b/libc/private/bionic_atomic_inline.h @@ -50,11 +50,13 @@ extern "C" { #define __ATOMIC_INLINE__ static __inline__ __attribute__((always_inline)) #ifdef __arm__ -# include <bionic_atomic_arm.h> +# include "bionic_atomic_arm.h" #elif defined(__i386__) -# include <bionic_atomic_x86.h> +# include "bionic_atomic_x86.h" +#elif defined(__mips__) +# include "bionic_atomic_mips.h" #else -# include <bionic_atomic_gcc_builtin.h> +# include "bionic_atomic_gcc_builtin.h" #endif #define ANDROID_MEMBAR_FULL __bionic_memory_barrier diff --git a/libc/private/bionic_atomic_mips.h b/libc/private/bionic_atomic_mips.h new file mode 100644 index 0000000..28fe88d --- /dev/null +++ b/libc/private/bionic_atomic_mips.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef BIONIC_ATOMIC_MIPS_H +#define BIONIC_ATOMIC_MIPS_H + +/* Define a full memory barrier, this is only needed if we build the + * platform for a multi-core device. + */ +#if defined(ANDROID_SMP) && ANDROID_SMP == 1 +__ATOMIC_INLINE__ void +__bionic_memory_barrier() +{ + __asm__ __volatile__ ( "sync" : : : "memory" ); +} +#else +__ATOMIC_INLINE__ void +__bionic_memory_barrier() +{ + /* A simple compiler barrier */ + __asm__ __volatile__ ( "" : : : "memory" ); +} +#endif + +/* Compare-and-swap, without any explicit barriers. Note that this function + * returns 0 on success, and 1 on failure. The opposite convention is typically + * used on other platforms. + */ +__ATOMIC_INLINE__ int +__bionic_cmpxchg(int32_t old_value, int32_t new_value, volatile int32_t* ptr) +{ + int32_t prev, status; + __asm__ __volatile__ ("1: move %[status], %[new_value] \n" + " ll %[prev], 0(%[ptr]) \n" + " bne %[old_value], %[prev], 2f \n" + " sc %[status], 0(%[ptr]) \n" + " beqz %[status], 1b \n" + "2: \n" + : [prev]"=&r"(prev), [status]"=&r"(status), "+m"(*ptr) + : [new_value]"r"(new_value), [old_value]"r"(old_value), [ptr]"r"(ptr) + : "memory"); + return prev != old_value; +} + + +/* Swap, without any explicit barriers */ +__ATOMIC_INLINE__ int32_t +__bionic_swap(int32_t new_value, volatile int32_t *ptr) +{ + int32_t prev, status; + __asm__ __volatile__ ("1: move %[status], %[new_value] \n" + " ll %[prev], 0(%[ptr]) \n" + " sc %[status], 0(%[ptr]) \n" + " beqz %[status], 1b \n" + : [prev]"=&r"(prev), [status]"=&r"(status), "+m"(*ptr) + : [ptr]"r"(ptr), [new_value]"r"(new_value) + : "memory"); + return prev; +} + +/* Atomic increment, without explicit barriers */ +__ATOMIC_INLINE__ int32_t +__bionic_atomic_inc(volatile int32_t *ptr) +{ + int32_t prev, status; + __asm__ __volatile__ ("1: ll %[prev], 0(%[ptr]) \n" + " addiu %[status], %[prev], 1 \n" + " sc %[status], 0(%[ptr]) \n" + " beqz %[status], 1b \n" + : [prev]"=&r" (prev), [status]"=&r"(status), "+m" (*ptr) + : [ptr]"r"(ptr) + : "memory"); + return prev; +} + +/* Atomic decrement, without explicit barriers */ +__ATOMIC_INLINE__ int32_t +__bionic_atomic_dec(volatile int32_t *ptr) +{ + int32_t prev, status; + __asm__ __volatile__ ("1: ll %[prev], 0(%[ptr]) \n" + " addiu %[status], %[prev], -1 \n" + " sc %[status], 0(%[ptr]) \n" + " beqz %[status], 1b \n" + : [prev]"=&r" (prev), [status]"=&r"(status), "+m" (*ptr) + : [ptr]"r"(ptr) + : "memory"); + return prev; +} +#endif /* BIONIC_ATOMIC_MIPS_H */ diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h index f3a4ca0..2456ebb 100644 --- a/libc/private/bionic_tls.h +++ b/libc/private/bionic_tls.h @@ -136,9 +136,20 @@ extern int __set_tls(void *ptr); # define __get_tls() ( *((volatile void **) 0xffff0ff0) ) # endif # endif /* !LIBC_STATIC */ -#else /* !ARM */ +#elif defined(__mips__) +# define __get_tls() \ + ({ register unsigned int __val asm("v1"); \ + asm ( \ + " .set push\n" \ + " .set mips32r2\n" \ + " rdhwr %0,$29\n" \ + " .set pop\n" \ + : "=r"(__val) \ + ); \ + (volatile void*)__val; }) +#else extern void* __get_tls( void ); -#endif /* !ARM */ +#endif /* return the stack base and size, used by our malloc debugger */ extern void* __get_stack_base(int *p_stack_size); diff --git a/libc/private/logd.h b/libc/private/logd.h index 4a9b62e..c81a91a 100644 --- a/libc/private/logd.h +++ b/libc/private/logd.h @@ -30,6 +30,21 @@ #include <stdarg.h> +#define BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW 80100 +#define BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW 80105 +#define BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW 80110 +#define BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW 80115 +#define BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW 80120 +#define BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW 80125 +#define BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW 80130 + +#define BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW 80200 +#define BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW 80205 + +#define BIONIC_EVENT_RESOLVER_OLD_RESPONSE 80300 +#define BIONIC_EVENT_RESOLVER_WRONG_SERVER 80305 +#define BIONIC_EVENT_RESOLVER_WRONG_QUERY 80310 + enum { ANDROID_LOG_UNKNOWN = 0, ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ @@ -44,8 +59,19 @@ enum { ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ }; +#ifdef __cplusplus +extern "C" { +#endif + int __libc_android_log_write(int prio, const char* tag, const char* buffer); int __libc_android_log_print(int prio, const char *tag, const char *fmt, ...); int __libc_android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); +void __libc_android_log_event_int(int32_t tag, int value); +void __libc_android_log_event_uid(int32_t tag); + +#ifdef __cplusplus +}; +#endif + #endif /* _ANDROID_BIONIC_LOGD_H */ |