diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cutils/atomic-arm.h | 167 | ||||
-rw-r--r-- | include/cutils/atomic-arm64.h | 156 | ||||
-rw-r--r-- | include/cutils/atomic-inline.h | 59 | ||||
-rw-r--r-- | include/cutils/atomic-mips.h | 174 | ||||
-rw-r--r-- | include/cutils/atomic-mips64.h | 166 | ||||
-rw-r--r-- | include/cutils/atomic-x86.h | 145 | ||||
-rw-r--r-- | include/cutils/atomic-x86_64.h | 151 | ||||
-rw-r--r-- | include/cutils/atomic.h | 133 | ||||
-rw-r--r-- | include/cutils/open_memstream.h | 4 | ||||
-rw-r--r-- | include/cutils/trace.h | 50 | ||||
-rw-r--r-- | include/log/logprint.h | 1 | ||||
-rw-r--r-- | include/private/android_filesystem_config.h | 5 | ||||
-rw-r--r-- | include/private/pixelflinger/ggl_fixed.h | 2 | ||||
-rw-r--r-- | include/utils/AndroidThreads.h | 3 | ||||
-rw-r--r-- | include/utils/Compat.h | 12 | ||||
-rw-r--r-- | include/utils/FileMap.h | 8 | ||||
-rw-r--r-- | include/utils/RefBase.h | 6 | ||||
-rw-r--r-- | include/utils/Thread.h | 4 | ||||
-rw-r--r-- | include/utils/Unicode.h | 4 | ||||
-rw-r--r-- | include/ziparchive/zip_archive.h | 31 |
20 files changed, 173 insertions, 1108 deletions
diff --git a/include/cutils/atomic-arm.h b/include/cutils/atomic-arm.h deleted file mode 100644 index 6b031b6..0000000 --- a/include/cutils/atomic-arm.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2010 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 ANDROID_CUTILS_ATOMIC_ARM_H -#define ANDROID_CUTILS_ATOMIC_ARM_H - -#include <stdint.h> - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier() -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE void android_memory_barrier() -{ -#if ANDROID_SMP == 0 - android_compiler_barrier(); -#else - __asm__ __volatile__ ("dmb" : : : "memory"); -#endif -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ("ldrex %0, [%3]\n" - "mov %1, #0\n" - "teq %0, %4\n" -#ifdef __thumb2__ - "it eq\n" -#endif - "strexeq %1, %5, [%3]" - : "=&r" (prev), "=&r" (status), "+m"(*ptr) - : "r" (ptr), "Ir" (old_value), "r" (new_value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, tmp, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ("ldrex %0, [%4]\n" - "add %1, %0, %5\n" - "strex %2, %1, [%4]" - : "=&r" (prev), "=&r" (tmp), - "=&r" (status), "+m" (*ptr) - : "r" (ptr), "Ir" (increment) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, tmp, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ("ldrex %0, [%4]\n" - "and %1, %0, %5\n" - "strex %2, %1, [%4]" - : "=&r" (prev), "=&r" (tmp), - "=&r" (status), "+m" (*ptr) - : "r" (ptr), "Ir" (value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, tmp, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ("ldrex %0, [%4]\n" - "orr %1, %0, %5\n" - "strex %2, %1, [%4]" - : "=&r" (prev), "=&r" (tmp), - "=&r" (status), "+m" (*ptr) - : "r" (ptr), "Ir" (value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_ARM_H */ diff --git a/include/cutils/atomic-arm64.h b/include/cutils/atomic-arm64.h deleted file mode 100644 index 7ae47d7..0000000 --- a/include/cutils/atomic-arm64.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 ANDROID_CUTILS_ATOMIC_AARCH64_H -#define ANDROID_CUTILS_ATOMIC_AARCH64_H - -#include <stdint.h> - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -/* - TODOAArch64: Revisit the below functions and check for potential - optimizations using assembly code or otherwise. -*/ - -extern ANDROID_ATOMIC_INLINE -void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -void android_memory_barrier(void) -{ - __asm__ __volatile__ ("dmb ish" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - prev = *ptr; - status = android_atomic_cas(prev, prev + increment, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - prev = *ptr; - status = android_atomic_cas(prev, prev & value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - prev = *ptr; - status = android_atomic_cas(prev, prev | value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_AARCH64_H */ diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h index a31e913..103c5b0 100644 --- a/include/cutils/atomic-inline.h +++ b/include/cutils/atomic-inline.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2014 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. @@ -14,59 +14,6 @@ * limitations under the License. */ -#ifndef ANDROID_CUTILS_ATOMIC_INLINE_H -#define ANDROID_CUTILS_ATOMIC_INLINE_H - -#ifdef __cplusplus -extern "C" { +#ifndef ANDROID_CUTILS_ATOMIC_H +#include <cutils/atomic.h> #endif - -/* - * Inline declarations and macros for some special-purpose atomic - * operations. These are intended for rare circumstances where a - * memory barrier needs to be issued inline rather than as a function - * call. - * - * Most code should not use these. - * - * Anything that does include this file must set ANDROID_SMP to either - * 0 or 1, indicating compilation for UP or SMP, respectively. - * - * Macros defined in this header: - * - * void ANDROID_MEMBAR_FULL(void) - * Full memory barrier. Provides a compiler reordering barrier, and - * on SMP systems emits an appropriate instruction. - */ - -#if !defined(ANDROID_SMP) -# error "Must define ANDROID_SMP before including atomic-inline.h" -#endif - -#if defined(__aarch64__) -#include <cutils/atomic-arm64.h> -#elif defined(__arm__) -#include <cutils/atomic-arm.h> -#elif defined(__i386__) -#include <cutils/atomic-x86.h> -#elif defined(__x86_64__) -#include <cutils/atomic-x86_64.h> -#elif defined(__mips64) -#include <cutils/atomic-mips64.h> -#elif defined(__mips__) -#include <cutils/atomic-mips.h> -#else -#error atomic operations are unsupported -#endif - -#if ANDROID_SMP == 0 -#define ANDROID_MEMBAR_FULL android_compiler_barrier -#else -#define ANDROID_MEMBAR_FULL android_memory_barrier -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */ diff --git a/include/cutils/atomic-mips.h b/include/cutils/atomic-mips.h deleted file mode 100644 index 5d4f097..0000000 --- a/include/cutils/atomic-mips.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2010 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 ANDROID_CUTILS_ATOMIC_MIPS_H -#define ANDROID_CUTILS_ATOMIC_MIPS_H - -#include <stdint.h> - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -#if ANDROID_SMP == 0 -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - android_compiler_barrier(); -} -#else -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - __asm__ __volatile__ ("sync" : : : "memory"); -} -#endif - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " li %[status], 1\n" - " bne %[prev], %[old], 9f\n" - " move %[status], %[new_value]\n" - " sc %[status], (%[ptr])\n" - "9:\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [old] "r" (old_value), [new_value] "r" (new_value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " addu %[status], %[prev], %[inc]\n" - " sc %[status], (%[ptr])\n" - : [status] "=&r" (status), [prev] "=&r" (prev) - : [ptr] "r" (ptr), [inc] "Ir" (increment) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " and %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " or %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_MIPS_H */ diff --git a/include/cutils/atomic-mips64.h b/include/cutils/atomic-mips64.h deleted file mode 100644 index 9d8f65e..0000000 --- a/include/cutils/atomic-mips64.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2010 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 ANDROID_CUTILS_ATOMIC_MIPS64_H -#define ANDROID_CUTILS_ATOMIC_MIPS64_H - -#include <stdint.h> - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - __asm__ __volatile__ ("sync" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " li %[status], 1\n" - " bne %[prev], %[old], 9f\n" - " move %[status], %[new_value]\n" - " sc %[status], (%[ptr])\n" - "9:\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [old] "r" (old_value), [new_value] "r" (new_value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " addu %[status], %[prev], %[inc]\n" - " sc %[status], (%[ptr])\n" - : [status] "=&r" (status), [prev] "=&r" (prev) - : [ptr] "r" (ptr), [inc] "Ir" (increment) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " and %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " or %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_MIPS_H */ diff --git a/include/cutils/atomic-x86.h b/include/cutils/atomic-x86.h deleted file mode 100644 index 06bf1a3..0000000 --- a/include/cutils/atomic-x86.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2010 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 ANDROID_CUTILS_ATOMIC_X86_H -#define ANDROID_CUTILS_ATOMIC_X86_H - -#include <stdint.h> - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -#if ANDROID_SMP == 0 -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - android_compiler_barrier(); -} -#else -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - __asm__ __volatile__ ("mfence" : : : "memory"); -} -#endif - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_compiler_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_compiler_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) -{ - int32_t prev; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - /* Loads are not reordered with other loads. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - /* Stores are not reordered with other stores. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - __asm__ __volatile__ ("lock; xaddl %0, %1" - : "+r" (increment), "+m" (*ptr) - : : "memory"); - /* increment now holds the old value of *ptr */ - return increment; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev & value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev | value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_X86_H */ diff --git a/include/cutils/atomic-x86_64.h b/include/cutils/atomic-x86_64.h deleted file mode 100644 index 99cb070..0000000 --- a/include/cutils/atomic-x86_64.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 ANDROID_CUTILS_ATOMIC_X86_64_H -#define ANDROID_CUTILS_ATOMIC_X86_64_H - -#include <stdint.h> - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE -void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -void android_memory_barrier(void) -{ - __asm__ __volatile__ ("mfence" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_compiler_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_compiler_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int32_t prev; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - /* Loads are not reordered with other loads. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - /* Stores are not reordered with other stores. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - __asm__ __volatile__ ("lock; xaddl %0, %1" - : "+r" (increment), "+m" (*ptr) - : : "memory"); - /* increment now holds the old value of *ptr */ - return increment; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev & value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev | value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_X86_64_H */ diff --git a/include/cutils/atomic.h b/include/cutils/atomic.h index 79409a7..ded972a 100644 --- a/include/cutils/atomic.h +++ b/include/cutils/atomic.h @@ -19,9 +19,10 @@ #include <stdint.h> #include <sys/types.h> +#include <stdatomic.h> -#ifdef __cplusplus -extern "C" { +#ifndef ANDROID_ATOMIC_INLINE +#define ANDROID_ATOMIC_INLINE static inline #endif /* @@ -77,11 +78,41 @@ extern "C" { * These have the same characteristics (e.g. what happens on overflow) * as the equivalent non-atomic C operations. */ -int32_t android_atomic_inc(volatile int32_t* addr); -int32_t android_atomic_dec(volatile int32_t* addr); -int32_t android_atomic_add(int32_t value, volatile int32_t* addr); -int32_t android_atomic_and(int32_t value, volatile int32_t* addr); -int32_t android_atomic_or(int32_t value, volatile int32_t* addr); +ANDROID_ATOMIC_INLINE +int32_t android_atomic_inc(volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + /* Int32_t, if it exists, is the same as int_least32_t. */ + return atomic_fetch_add_explicit(a, 1, memory_order_release); +} + +ANDROID_ATOMIC_INLINE +int32_t android_atomic_dec(volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return atomic_fetch_sub_explicit(a, 1, memory_order_release); +} + +ANDROID_ATOMIC_INLINE +int32_t android_atomic_add(int32_t value, volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return atomic_fetch_add_explicit(a, value, memory_order_release); +} + +ANDROID_ATOMIC_INLINE +int32_t android_atomic_and(int32_t value, volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return atomic_fetch_and_explicit(a, value, memory_order_release); +} + +ANDROID_ATOMIC_INLINE +int32_t android_atomic_or(int32_t value, volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return atomic_fetch_or_explicit(a, value, memory_order_release); +} /* * Perform an atomic load with "acquire" or "release" ordering. @@ -96,29 +127,53 @@ int32_t android_atomic_or(int32_t value, volatile int32_t* addr); * this comment, you are in the vast majority, and should not be * using release loads or replacing them with anything other than * locks or default sequentially consistent atomics. - * - * This is only necessary if you need the memory barrier. A 32-bit read - * from a 32-bit aligned address is atomic on all supported platforms. */ -int32_t android_atomic_acquire_load(volatile const int32_t* addr); -int32_t android_atomic_release_load(volatile const int32_t* addr); +ANDROID_ATOMIC_INLINE +int32_t android_atomic_acquire_load(volatile const int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return atomic_load_explicit(a, memory_order_acquire); +} + +ANDROID_ATOMIC_INLINE +int32_t android_atomic_release_load(volatile const int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + atomic_thread_fence(memory_order_seq_cst); + /* Any reasonable clients of this interface would probably prefer */ + /* something weaker. But some remaining clients seem to be */ + /* abusing this API in strange ways, e.g. by using it as a fence. */ + /* Thus we are conservative until we can get rid of remaining */ + /* clients (and this function). */ + return atomic_load_explicit(a, memory_order_relaxed); +} /* * Perform an atomic store with "acquire" or "release" ordering. * - * Note that the notion of a "acquire" ordering for a store does not + * Note that the notion of an "acquire" ordering for a store does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a trailing * atomic_thread_fence (typically with memory_order_release, * not memory_order_acquire!) instead. - * - * This is only necessary if you need the memory barrier. A 32-bit write - * to a 32-bit aligned address is atomic on all supported platforms. */ -void android_atomic_acquire_store(int32_t value, volatile int32_t* addr); -void android_atomic_release_store(int32_t value, volatile int32_t* addr); +ANDROID_ATOMIC_INLINE +void android_atomic_acquire_store(int32_t value, volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + atomic_store_explicit(a, value, memory_order_relaxed); + atomic_thread_fence(memory_order_seq_cst); + /* Again overly conservative to accomodate weird clients. */ +} + +ANDROID_ATOMIC_INLINE +void android_atomic_release_store(int32_t value, volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + atomic_store_explicit(a, value, memory_order_release); +} /* * Compare-and-set operation with "acquire" or "release" ordering. @@ -132,10 +187,44 @@ void android_atomic_release_store(int32_t value, volatile int32_t* addr); * Implementations that use the release CAS in a loop may be less efficient * than possible, because we re-issue the memory barrier on each iteration. */ +ANDROID_ATOMIC_INLINE int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr); + volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return (int)(!atomic_compare_exchange_strong_explicit( + a, &oldvalue, newvalue, + memory_order_acquire, + memory_order_acquire)); +} + +ANDROID_ATOMIC_INLINE int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr); + volatile int32_t* addr) +{ + volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + return (int)(!atomic_compare_exchange_strong_explicit( + a, &oldvalue, newvalue, + memory_order_release, + memory_order_relaxed)); +} + +/* + * Fence primitives. + */ +ANDROID_ATOMIC_INLINE +void android_compiler_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); + /* Could probably also be: */ + /* atomic_signal_fence(memory_order_seq_cst); */ +} + +ANDROID_ATOMIC_INLINE +void android_memory_barrier(void) +{ + atomic_thread_fence(memory_order_seq_cst); +} /* * Aliases for code using an older version of this header. These are now @@ -145,8 +234,4 @@ int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, #define android_atomic_write android_atomic_release_store #define android_atomic_cmpxchg android_atomic_release_cas -#ifdef __cplusplus -} // extern "C" -#endif - #endif // ANDROID_CUTILS_ATOMIC_H diff --git a/include/cutils/open_memstream.h b/include/cutils/open_memstream.h index b7998be..c1a81eb 100644 --- a/include/cutils/open_memstream.h +++ b/include/cutils/open_memstream.h @@ -19,7 +19,7 @@ #include <stdio.h> -#ifndef HAVE_OPEN_MEMSTREAM +#if defined(__APPLE__) #ifdef __cplusplus extern "C" { @@ -31,6 +31,6 @@ FILE* open_memstream(char** bufp, size_t* sizep); } #endif -#endif /*!HAVE_OPEN_MEMSTREAM*/ +#endif /* __APPLE__ */ #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ diff --git a/include/cutils/trace.h b/include/cutils/trace.h index fd24561..c863afd 100644 --- a/include/cutils/trace.h +++ b/include/cutils/trace.h @@ -86,13 +86,6 @@ __BEGIN_DECLS #ifdef HAVE_ANDROID_OS /** - * Maximum size of a message that can be logged to the trace buffer. - * Note this message includes a tag, the pid, and the string given as the name. - * Names should be kept short to get the most use of the trace buffer. - */ -#define ATRACE_MESSAGE_LENGTH 1024 - -/** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal @@ -184,11 +177,8 @@ static inline uint64_t atrace_is_tag_enabled(uint64_t tag) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "B|%d|%s", getpid(), name); - write(atrace_marker_fd, buf, len); + void atrace_begin_body(const char*); + atrace_begin_body(name); } } @@ -218,12 +208,8 @@ static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%" PRId32, - getpid(), name, cookie); - write(atrace_marker_fd, buf, len); + void atrace_async_begin_body(const char*, int32_t); + atrace_async_begin_body(name, cookie); } } @@ -232,20 +218,14 @@ static inline void atrace_async_begin(uint64_t tag, const char* name, * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) -static inline void atrace_async_end(uint64_t tag, const char* name, - int32_t cookie) +static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%" PRId32, - getpid(), name, cookie); - write(atrace_marker_fd, buf, len); + void atrace_async_end_body(const char*, int32_t); + atrace_async_end_body(name, cookie); } } - /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. @@ -254,12 +234,8 @@ static inline void atrace_async_end(uint64_t tag, const char* name, static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId32, - getpid(), name, value); - write(atrace_marker_fd, buf, len); + void atrace_int_body(const char*, int32_t); + atrace_int_body(name, value); } } @@ -271,12 +247,8 @@ static inline void atrace_int(uint64_t tag, const char* name, int32_t value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId64, - getpid(), name, value); - write(atrace_marker_fd, buf, len); + void atrace_int64_body(const char*, int64_t); + atrace_int64_body(name, value); } } diff --git a/include/log/logprint.h b/include/log/logprint.h index 481c96e..1e42b47 100644 --- a/include/log/logprint.h +++ b/include/log/logprint.h @@ -36,6 +36,7 @@ typedef enum { FORMAT_TIME, FORMAT_THREADTIME, FORMAT_LONG, + FORMAT_COLOR, } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index 5d9c3ea..b2f91a5 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -83,6 +83,11 @@ #define AID_CACHE 2001 /* cache access */ #define AID_DIAG 2002 /* access to diagnostic resources */ +/* The range 2900-2999 is reserved for OEM, and must never be + * used here */ +#define AID_OEM_RESERVED_START 2900 +#define AID_OEM_RESERVED_END 2999 + /* The 3000 series are intended for use as supplemental group id's only. * They indicate special Android capabilities that the kernel is aware of. */ #define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */ diff --git a/include/private/pixelflinger/ggl_fixed.h b/include/private/pixelflinger/ggl_fixed.h index d0493f3..787f620 100644 --- a/include/private/pixelflinger/ggl_fixed.h +++ b/include/private/pixelflinger/ggl_fixed.h @@ -190,7 +190,7 @@ inline int64_t gglMulii(int32_t x, int32_t y) ); return res; } -#elif defined(__mips__) +#elif defined(__mips__) && __mips_isa_rev < 6 /*inline MIPS implementations*/ inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST; diff --git a/include/utils/AndroidThreads.h b/include/utils/AndroidThreads.h index 4eee14d..3c640b6 100644 --- a/include/utils/AndroidThreads.h +++ b/include/utils/AndroidThreads.h @@ -73,9 +73,6 @@ extern void androidSetCreateThreadFunc(android_create_thread_fn func); // ------------------------------------------------------------------ // Extra functions working with raw pids. -// Get pid for the current thread. -extern pid_t androidGetTid(); - #ifdef HAVE_ANDROID_OS // Change the priority AND scheduling group of a particular thread. The priority // should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION diff --git a/include/utils/Compat.h b/include/utils/Compat.h index fb7748e..20a6920 100644 --- a/include/utils/Compat.h +++ b/include/utils/Compat.h @@ -19,11 +19,9 @@ #include <unistd.h> -/* Compatibility definitions for non-Linux (i.e., BSD-based) hosts. */ -#ifndef HAVE_OFF64_T -#if _FILE_OFFSET_BITS < 64 -#error "_FILE_OFFSET_BITS < 64; large files are not supported on this platform" -#endif /* _FILE_OFFSET_BITS < 64 */ +#if defined(__APPLE__) + +/* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ typedef off_t off64_t; @@ -31,13 +29,11 @@ static inline off64_t lseek64(int fd, off64_t offset, int whence) { return lseek(fd, offset, whence); } -#ifdef HAVE_PREAD static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { return pread(fd, buf, nbytes, offset); } -#endif -#endif /* !HAVE_OFF64_T */ +#endif /* __APPLE__ */ #if HAVE_PRINTF_ZD # define ZD "%zd" diff --git a/include/utils/FileMap.h b/include/utils/FileMap.h index dfe6d51..6c0aa52 100644 --- a/include/utils/FileMap.h +++ b/include/utils/FileMap.h @@ -24,7 +24,11 @@ #include <utils/Compat.h> -#ifdef HAVE_WIN32_FILEMAP +#if defined(__MINGW32__) +// Ensure that we always pull in winsock2.h before windows.h +#ifdef HAVE_WINSOCK +#include <winsock2.h> +#endif #include <windows.h> #endif @@ -123,7 +127,7 @@ private: off64_t mDataOffset; // offset used when map was created void* mDataPtr; // start of requested data, offset from base size_t mDataLength; // length, measured from "mDataPtr" -#ifdef HAVE_WIN32_FILEMAP +#if defined(__MINGW32__) HANDLE mFileHandle; // Win32 file handle HANDLE mFileMapping; // Win32 file mapping handle #endif diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h index 8e15c19..eac6a78 100644 --- a/include/utils/RefBase.h +++ b/include/utils/RefBase.h @@ -491,7 +491,8 @@ public: TYPE::renameRefId(d[i].get(), &s[i], &d[i]); } public: - Renamer(sp<TYPE>* d, sp<TYPE> const* s) : s(s), d(d) { } + Renamer(sp<TYPE>* d, sp<TYPE> const* s) : d(d), s(s) { } + virtual ~Renamer() { } }; memmove(d, s, n*sizeof(sp<TYPE>)); @@ -510,7 +511,8 @@ public: TYPE::renameRefId(d[i].get_refs(), &s[i], &d[i]); } public: - Renamer(wp<TYPE>* d, wp<TYPE> const* s) : s(s), d(d) { } + Renamer(wp<TYPE>* d, wp<TYPE> const* s) : d(d), s(s) { } + virtual ~Renamer() { } }; memmove(d, s, n*sizeof(wp<TYPE>)); diff --git a/include/utils/Thread.h b/include/utils/Thread.h index df30611..c867e95 100644 --- a/include/utils/Thread.h +++ b/include/utils/Thread.h @@ -71,8 +71,8 @@ public: bool isRunning() const; #ifdef HAVE_ANDROID_OS - // Return the thread's kernel ID, same as the thread itself calling gettid() or - // androidGetTid(), or -1 if the thread is not running. + // Return the thread's kernel ID, same as the thread itself calling gettid(), + // or -1 if the thread is not running. pid_t getTid() const; #endif diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h index 5b98de2..aaf951b 100644 --- a/include/utils/Unicode.h +++ b/include/utils/Unicode.h @@ -24,8 +24,8 @@ extern "C" { // Definitions exist in C++11 #if defined __cplusplus && __cplusplus < 201103L -typedef uint32_t char32_t; -typedef uint16_t char16_t; +typedef unsigned int char32_t; +typedef unsigned short char16_t; #endif // Standard string functions on char16_t strings. diff --git a/include/ziparchive/zip_archive.h b/include/ziparchive/zip_archive.h index 1877494..7da6e84 100644 --- a/include/ziparchive/zip_archive.h +++ b/include/ziparchive/zip_archive.h @@ -21,6 +21,7 @@ #define LIBZIPARCHIVE_ZIPARCHIVE_H_ #include <stdint.h> +#include <string.h> #include <sys/types.h> #include <utils/Compat.h> @@ -33,8 +34,16 @@ enum { }; struct ZipEntryName { - const char* name; + const uint8_t* name; uint16_t name_length; + + ZipEntryName() {} + + /* + * entry_name has to be an c-style string with only ASCII characters. + */ + explicit ZipEntryName(const char* entry_name) + : name(reinterpret_cast<const uint8_t*>(entry_name)), name_length(strlen(entry_name)) {} }; /* @@ -124,24 +133,24 @@ void CloseArchive(ZipArchiveHandle handle); * and length, a call to VerifyCrcAndLengths must be made after entry data * has been processed. */ -int32_t FindEntry(const ZipArchiveHandle handle, const char* entryName, +int32_t FindEntry(const ZipArchiveHandle handle, const ZipEntryName& entryName, ZipEntry* data); /* * Start iterating over all entries of a zip file. The order of iteration * is not guaranteed to be the same as the order of elements - * in the central directory but is stable for a given zip file. |cookie| - * must point to a writeable memory location, and will be set to the value - * of an opaque cookie which can be used to make one or more calls to - * Next. + * in the central directory but is stable for a given zip file. |cookie| will + * contain the value of an opaque cookie which can be used to make one or more + * calls to Next. All calls to StartIteration must be matched by a call to + * EndIteration to free any allocated memory. * * This method also accepts an optional prefix to restrict iteration to - * entry names that start with |prefix|. + * entry names that start with |optional_prefix|. * * Returns 0 on success and negative values on failure. */ int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr, - const char* prefix); + const ZipEntryName* optional_prefix); /* * Advance to the next element in the zipfile in iteration order. @@ -152,6 +161,12 @@ int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr, int32_t Next(void* cookie, ZipEntry* data, ZipEntryName *name); /* + * End iteration over all entries of a zip file and frees the memory allocated + * in StartIteration. + */ +void EndIteration(void* cookie); + +/* * Uncompress and write an entry to an open file identified by |fd|. * |entry->uncompressed_length| bytes will be written to the file at * its current offset, and the file will be truncated at the end of |