summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/backtrace/Backtrace.h33
-rw-r--r--include/backtrace/BacktraceMap.h17
-rw-r--r--include/ctest/ctest.h70
-rw-r--r--include/cutils/android_reboot.h2
-rw-r--r--include/cutils/aref.h4
-rw-r--r--include/cutils/atomic-arm.h167
-rw-r--r--include/cutils/atomic-arm64.h156
-rw-r--r--include/cutils/atomic-inline.h72
-rw-r--r--include/cutils/atomic-mips.h174
-rw-r--r--include/cutils/atomic-mips64.h166
-rw-r--r--include/cutils/atomic-x86.h145
-rw-r--r--include/cutils/atomic-x86_64.h151
-rw-r--r--include/cutils/atomic.h133
-rw-r--r--include/cutils/cpu_info.h34
-rw-r--r--include/cutils/debugger.h40
-rw-r--r--include/cutils/dir_hash.h26
-rw-r--r--include/cutils/klog.h4
-rw-r--r--include/cutils/memory.h2
-rw-r--r--include/cutils/open_memstream.h4
-rw-r--r--include/cutils/partition_utils.h1
-rw-r--r--include/cutils/properties.h16
-rw-r--r--include/cutils/sockets.h30
-rw-r--r--include/cutils/str_parms.h5
-rw-r--r--include/cutils/threads.h27
-rw-r--r--include/cutils/trace.h74
-rw-r--r--include/cutils/uevent.h1
-rw-r--r--include/log/log.h120
-rw-r--r--include/log/log_read.h12
-rw-r--r--include/log/logd.h15
-rw-r--r--include/log/logger.h7
-rw-r--r--include/log/logprint.h1
-rw-r--r--include/log/uio.h13
-rw-r--r--include/memtrack/memtrack.h4
-rw-r--r--include/pixelflinger/format.h136
-rw-r--r--include/pixelflinger/pixelflinger.h330
-rw-r--r--include/private/android_filesystem_capability.h4
-rw-r--r--include/private/android_filesystem_config.h146
-rw-r--r--include/private/android_logger.h98
-rw-r--r--include/private/pixelflinger/ggl_context.h565
-rw-r--r--include/private/pixelflinger/ggl_fixed.h633
-rw-r--r--include/system/graphics.h211
-rw-r--r--include/system/window.h78
-rw-r--r--include/sysutils/NetlinkEvent.h1
-rw-r--r--include/sysutils/NetlinkListener.h1
-rw-r--r--include/utils/AndroidThreads.h5
-rw-r--r--include/utils/Compat.h39
-rw-r--r--include/utils/Condition.h14
-rw-r--r--include/utils/Endian.h15
-rw-r--r--include/utils/FileMap.h26
-rw-r--r--include/utils/Mutex.h36
-rw-r--r--include/utils/RWLock.h6
-rw-r--r--include/utils/RefBase.h6
-rw-r--r--include/utils/Singleton.h7
-rw-r--r--include/utils/Thread.h6
-rw-r--r--include/utils/Timers.h32
-rw-r--r--include/utils/Unicode.h6
-rw-r--r--include/ziparchive/zip_archive.h36
-rw-r--r--include/zipfile/zipfile.h58
58 files changed, 818 insertions, 3403 deletions
diff --git a/include/backtrace/Backtrace.h b/include/backtrace/Backtrace.h
index e07d322..290682a 100644
--- a/include/backtrace/Backtrace.h
+++ b/include/backtrace/Backtrace.h
@@ -39,14 +39,11 @@ struct backtrace_frame_data_t {
uintptr_t pc; // The absolute pc.
uintptr_t sp; // The top of the stack.
size_t stack_size; // The size of the stack, zero indicate an unknown stack size.
- const backtrace_map_t* map; // The map associated with the given pc.
+ backtrace_map_t map; // The map associated with the given pc.
std::string func_name; // The function name associated with this pc, NULL if not found.
uintptr_t func_offset; // pc relative to the start of the function, only valid if func_name is not NULL.
};
-// Forward declarations.
-class BacktraceImpl;
-
#if defined(__APPLE__)
struct __darwin_ucontext;
typedef __darwin_ucontext ucontext_t;
@@ -72,26 +69,32 @@ public:
virtual ~Backtrace();
// Get the current stack trace and store in the backtrace_ structure.
- virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL);
+ virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0;
// Get the function name and offset into the function given the pc.
// If the string is empty, then no valid function name was found.
virtual std::string GetFunctionName(uintptr_t pc, uintptr_t* offset);
- // Find the map associated with the given pc.
- virtual const backtrace_map_t* FindMap(uintptr_t pc);
+ // Fill in the map data associated with the given pc.
+ virtual void FillInMap(uintptr_t pc, backtrace_map_t* map);
// Read the data at a specific address.
virtual bool ReadWord(uintptr_t ptr, word_t* out_value) = 0;
+ // Read arbitrary data from a specific address. If a read request would
+ // span from one map to another, this call only reads up until the end
+ // of the current map.
+ // Returns the total number of bytes actually read.
+ virtual size_t Read(uintptr_t addr, uint8_t* buffer, size_t bytes) = 0;
+
// Create a string representing the formatted line of backtrace information
// for a single frame.
virtual std::string FormatFrameData(size_t frame_num);
virtual std::string FormatFrameData(const backtrace_frame_data_t* frame);
- pid_t Pid() { return pid_; }
- pid_t Tid() { return tid_; }
- size_t NumFrames() { return frames_.size(); }
+ pid_t Pid() const { return pid_; }
+ pid_t Tid() const { return tid_; }
+ size_t NumFrames() const { return frames_.size(); }
const backtrace_frame_data_t* GetFrame(size_t frame_num) {
if (frame_num >= frames_.size()) {
@@ -111,7 +114,11 @@ public:
BacktraceMap* GetMap() { return map_; }
protected:
- Backtrace(BacktraceImpl* impl, pid_t pid, BacktraceMap* map);
+ Backtrace(pid_t pid, pid_t tid, BacktraceMap* map);
+
+ // The name returned is not demangled, GetFunctionName() takes care of
+ // demangling the name.
+ virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) = 0;
virtual bool VerifyReadWordArgs(uintptr_t ptr, word_t* out_value);
@@ -124,10 +131,6 @@ protected:
bool map_shared_;
std::vector<backtrace_frame_data_t> frames_;
-
- BacktraceImpl* impl_;
-
- friend class BacktraceImpl;
};
#endif // _BACKTRACE_BACKTRACE_H
diff --git a/include/backtrace/BacktraceMap.h b/include/backtrace/BacktraceMap.h
index 4ed23a8..da96307 100644
--- a/include/backtrace/BacktraceMap.h
+++ b/include/backtrace/BacktraceMap.h
@@ -33,6 +33,8 @@
#include <string>
struct backtrace_map_t {
+ backtrace_map_t(): start(0), end(0), flags(0) {}
+
uintptr_t start;
uintptr_t end;
int flags;
@@ -48,15 +50,16 @@ public:
virtual ~BacktraceMap();
- // Get the map data structure for the given address.
- virtual const backtrace_map_t* Find(uintptr_t addr);
+ // Fill in the map data structure for the given address.
+ virtual void FillIn(uintptr_t addr, backtrace_map_t* map);
// The flags returned are the same flags as used by the mmap call.
// The values are PROT_*.
int GetFlags(uintptr_t pc) {
- const backtrace_map_t* map = Find(pc);
- if (map) {
- return map->flags;
+ backtrace_map_t map;
+ FillIn(pc, &map);
+ if (IsValid(map)) {
+ return map.flags;
}
return PROT_NONE;
}
@@ -75,6 +78,10 @@ public:
virtual bool Build();
+ static inline bool IsValid(const backtrace_map_t& map) {
+ return map.end > 0;
+ }
+
protected:
BacktraceMap(pid_t pid);
diff --git a/include/ctest/ctest.h b/include/ctest/ctest.h
deleted file mode 100644
index 1a83b20..0000000
--- a/include/ctest/ctest.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-/**
- * Very simple unit testing framework.
- */
-
-#ifndef __CUTILS_TEST_H
-#define __CUTILS_TEST_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Adds a test to the test suite.
- */
-#define addTest(test) addNamedTest(#test, &test)
-
-/**
- * Asserts that a condition is true. The test fails if it isn't.
- */
-#define assertTrue(value, message) assertTrueWithSource(value, __FILE__, __LINE__, message);
-
-/**
- * Asserts that a condition is false. The test fails if the value is true.
- */
-#define assertFalse(value, message) assertTrueWithSource(!value, __FILE__, __LINE__, message);
-
-/** Fails a test with the given message. */
-#define fail(message) assertTrueWithSource(0, __FILE__, __LINE__, message);
-
-/**
- * Asserts that two values are ==.
- */
-#define assertSame(a, b) assertTrueWithSource(a == b, __FILE__, __LINE__, "Expected same value.");
-
-/**
- * Asserts that two values are !=.
- */
-#define assertNotSame(a, b) assertTrueWithSource(a != b, __FILE__, __LINE__,\
- "Expected different values");
-
-/**
- * Runs a test suite.
- */
-void runTests(void);
-
-// Do not call these functions directly. Use macros above instead.
-void addNamedTest(const char* name, void (*test)(void));
-void assertTrueWithSource(int value, const char* file, int line, char* message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CUTILS_TEST_H */
diff --git a/include/cutils/android_reboot.h b/include/cutils/android_reboot.h
index 8c30e8e..85e1b7e 100644
--- a/include/cutils/android_reboot.h
+++ b/include/cutils/android_reboot.h
@@ -27,7 +27,7 @@ __BEGIN_DECLS
/* Properties */
#define ANDROID_RB_PROPERTY "sys.powerctl"
-int android_reboot(int cmd, int flags, char *arg);
+int android_reboot(int cmd, int flags, const char *arg);
__END_DECLS
diff --git a/include/cutils/aref.h b/include/cutils/aref.h
index 460ac02..3bd36ea 100644
--- a/include/cutils/aref.h
+++ b/include/cutils/aref.h
@@ -20,11 +20,7 @@
#include <stddef.h>
#include <sys/cdefs.h>
-#ifdef ANDROID_SMP
-#include <cutils/atomic-inline.h>
-#else
#include <cutils/atomic.h>
-#endif
__BEGIN_DECLS
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
deleted file mode 100644
index a31e913..0000000
--- a/include/cutils/atomic-inline.h
+++ /dev/null
@@ -1,72 +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_INLINE_H
-#define ANDROID_CUTILS_ATOMIC_INLINE_H
-
-#ifdef __cplusplus
-extern "C" {
-#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/cpu_info.h b/include/cutils/cpu_info.h
deleted file mode 100644
index 78c1884..0000000
--- a/include/cutils/cpu_info.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2007 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 __CUTILS_CPU_INFO_H
-#define __CUTILS_CPU_INFO_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* returns a string contiaining an ASCII representation of the CPU serial number,
-** or NULL if cpu info not available.
-** The string is a static variable, so don't call free() on it.
-*/
-extern const char* get_cpu_serial_number(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CUTILS_CPU_INFO_H */
diff --git a/include/cutils/debugger.h b/include/cutils/debugger.h
index bae687d..285e1af 100644
--- a/include/cutils/debugger.h
+++ b/include/cutils/debugger.h
@@ -17,20 +17,14 @@
#ifndef __CUTILS_DEBUGGER_H
#define __CUTILS_DEBUGGER_H
+#include <sys/cdefs.h>
#include <sys/types.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
-#define DEBUGGER32_SOCKET_NAME "android:debuggerd"
-#define DEBUGGER64_SOCKET_NAME "android:debuggerd64"
-
-#if defined(__LP64__)
-#define DEBUGGER_SOCKET_NAME DEBUGGER64_SOCKET_NAME
-#else
-#define DEBUGGER_SOCKET_NAME DEBUGGER32_SOCKET_NAME
-#endif
+#define DEBUGGER_SOCKET_NAME "android:debuggerd"
+#define DEBUGGER32_SOCKET_NAME "android:debuggerd32"
+#define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME
typedef enum {
// dump a crash
@@ -41,23 +35,17 @@ typedef enum {
DEBUGGER_ACTION_DUMP_BACKTRACE,
} debugger_action_t;
-typedef struct {
- debugger_action_t action;
+// Make sure that all values have a fixed size so that this structure
+// is the same for 32 bit and 64 bit processes.
+// NOTE: Any changes to this structure must also be reflected in
+// bionic/linker/debugger.cpp.
+typedef struct __attribute__((packed)) {
+ int32_t action;
pid_t tid;
- uintptr_t abort_msg_address;
+ uint64_t abort_msg_address;
int32_t original_si_code;
} debugger_msg_t;
-#if defined(__LP64__)
-// For a 64 bit process to contact the 32 bit debuggerd.
-typedef struct {
- debugger_action_t action;
- pid_t tid;
- uint32_t abort_msg_address;
- int32_t original_si_code;
-} debugger32_msg_t;
-#endif
-
/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root).
* Stores the tombstone path in the provided buffer.
* Returns 0 on success, -1 on error.
@@ -84,8 +72,6 @@ int dump_backtrace_to_file(pid_t tid, int fd);
*/
int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs);
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
#endif /* __CUTILS_DEBUGGER_H */
diff --git a/include/cutils/dir_hash.h b/include/cutils/dir_hash.h
deleted file mode 100644
index fbb4d02..0000000
--- a/include/cutils/dir_hash.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-typedef enum {
- SHA_1,
-} HashAlgorithm;
-
-int get_file_hash(HashAlgorithm algorithm, const char *path,
- char *output_string, size_t max_output_string);
-
-int get_recursive_hash_manifest(HashAlgorithm algorithm,
- const char *directory_path,
- char **output_string);
diff --git a/include/cutils/klog.h b/include/cutils/klog.h
index d5ae6d7..295d62b 100644
--- a/include/cutils/klog.h
+++ b/include/cutils/klog.h
@@ -18,6 +18,7 @@
#define _CUTILS_KLOG_H_
#include <sys/cdefs.h>
+#include <sys/uio.h>
#include <stdarg.h>
__BEGIN_DECLS
@@ -26,9 +27,10 @@ void klog_init(void);
int klog_get_level(void);
void klog_set_level(int level);
/* TODO: void klog_close(void); - and make klog_fd users thread safe. */
+
void klog_write(int level, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3)));
-void klog_vwrite(int level, const char *fmt, va_list ap);
+void klog_writev(int level, const struct iovec* iov, int iov_count);
__END_DECLS
diff --git a/include/cutils/memory.h b/include/cutils/memory.h
index e725cdd..4d26882 100644
--- a/include/cutils/memory.h
+++ b/include/cutils/memory.h
@@ -30,7 +30,7 @@ void android_memset16(uint16_t* dst, uint16_t value, size_t size);
/* size is given in bytes and must be multiple of 4 */
void android_memset32(uint32_t* dst, uint32_t value, size_t size);
-#if !HAVE_STRLCPY
+#if defined(__GLIBC__) || defined(_WIN32)
/* Declaration of strlcpy() for platforms that don't already have it. */
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
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/partition_utils.h b/include/cutils/partition_utils.h
index 597df92..72ca80d 100644
--- a/include/cutils/partition_utils.h
+++ b/include/cutils/partition_utils.h
@@ -20,7 +20,6 @@
__BEGIN_DECLS
int partition_wiped(char *source);
-void erase_footer(const char *dev_path, long long size);
__END_DECLS
diff --git a/include/cutils/properties.h b/include/cutils/properties.h
index 798db8b..24aa224 100644
--- a/include/cutils/properties.h
+++ b/include/cutils/properties.h
@@ -126,22 +126,6 @@ int property_get(const char *key, char *value, const char *default_value) {
#endif
-#ifdef HAVE_SYSTEM_PROPERTY_SERVER
-/*
- * We have an external property server instead of built-in libc support.
- * Used by the simulator.
- */
-#define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop"
-
-enum {
- kSystemPropertyUnknown = 0,
- kSystemPropertyGet,
- kSystemPropertySet,
- kSystemPropertyList
-};
-#endif /*HAVE_SYSTEM_PROPERTY_SERVER*/
-
-
#ifdef __cplusplus
}
#endif
diff --git a/include/cutils/sockets.h b/include/cutils/sockets.h
index daf43ec..f8076ca 100644
--- a/include/cutils/sockets.h
+++ b/include/cutils/sockets.h
@@ -18,6 +18,7 @@
#define __CUTILS_SOCKETS_H
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
@@ -25,7 +26,7 @@
#ifdef HAVE_WINSOCK
#include <winsock2.h>
typedef int socklen_t;
-#elif HAVE_SYS_SOCKET_H
+#else
#include <sys/socket.h>
#endif
@@ -46,30 +47,19 @@ extern "C" {
*/
static inline int android_get_control_socket(const char *name)
{
- char key[64] = ANDROID_SOCKET_ENV_PREFIX;
- const char *val;
- int fd;
+ char key[64];
+ snprintf(key, sizeof(key), ANDROID_SOCKET_ENV_PREFIX "%s", name);
- /* build our environment variable, counting cycles like a wolf ... */
-#if HAVE_STRLCPY
- strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
- name,
- sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
-#else /* for the host, which may lack the almightly strncpy ... */
- strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
- name,
- sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
- key[sizeof(key)-1] = '\0';
-#endif
-
- val = getenv(key);
- if (!val)
+ const char* val = getenv(key);
+ if (!val) {
return -1;
+ }
errno = 0;
- fd = strtol(val, NULL, 10);
- if (errno)
+ int fd = strtol(val, NULL, 10);
+ if (errno) {
return -1;
+ }
return fd;
}
diff --git a/include/cutils/str_parms.h b/include/cutils/str_parms.h
index 66f3637..aa1435a 100644
--- a/include/cutils/str_parms.h
+++ b/include/cutils/str_parms.h
@@ -18,6 +18,9 @@
#define __CUTILS_STR_PARMS_H
#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
struct str_parms;
@@ -52,4 +55,6 @@ char *str_parms_to_str(struct str_parms *str_parms);
/* debug */
void str_parms_dump(struct str_parms *str_parms);
+__END_DECLS
+
#endif /* __CUTILS_STR_PARMS_H */
diff --git a/include/cutils/threads.h b/include/cutils/threads.h
index acf8f48..3133cdb 100644
--- a/include/cutils/threads.h
+++ b/include/cutils/threads.h
@@ -29,20 +29,22 @@ extern "C" {
/***********************************************************************/
/***********************************************************************/
-#ifdef HAVE_PTHREADS
+#if !defined(_WIN32)
#include <pthread.h>
+#include <sys/types.h>
typedef struct {
pthread_mutex_t lock;
int has_tls;
pthread_key_t tls;
-
} thread_store_t;
+extern pid_t gettid();
+
#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 }
-#elif defined HAVE_WIN32_THREADS
+#else // !defined(_WIN32)
#include <windows.h>
@@ -51,20 +53,17 @@ typedef struct {
int has_tls;
DWORD tls;
CRITICAL_SECTION lock;
-
} thread_store_t;
#define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} }
-#else
-# error "no thread_store_t implementation for your platform !!"
-#endif
+#endif // !defined(_WIN32)
typedef void (*thread_store_destruct_t)(void* value);
extern void* thread_store_get(thread_store_t* store);
-extern void thread_store_set(thread_store_t* store,
+extern void thread_store_set(thread_store_t* store,
void* value,
thread_store_destruct_t destroy);
@@ -76,7 +75,7 @@ extern void thread_store_set(thread_store_t* store,
/***********************************************************************/
/***********************************************************************/
-#ifdef HAVE_PTHREADS
+#if !defined(_WIN32)
typedef pthread_mutex_t mutex_t;
@@ -98,10 +97,10 @@ static __inline__ void mutex_destroy(mutex_t* lock)
{
pthread_mutex_destroy(lock);
}
-#endif
-#ifdef HAVE_WIN32_THREADS
-typedef struct {
+#else // !defined(_WIN32)
+
+typedef struct {
int init;
CRITICAL_SECTION lock[1];
} mutex_t;
@@ -134,10 +133,10 @@ static __inline__ void mutex_destroy(mutex_t* lock)
{
if (lock->init) {
lock->init = 0;
- DeleteCriticalSection(lock->lock);
+ DeleteCriticalSection(lock->lock);
}
}
-#endif
+#endif // !defined(_WIN32)
#ifdef __cplusplus
}
diff --git a/include/cutils/trace.h b/include/cutils/trace.h
index fd24561..e4ed179 100644
--- a/include/cutils/trace.h
+++ b/include/cutils/trace.h
@@ -18,6 +18,7 @@
#define _LIBS_CUTILS_TRACE_H
#include <inttypes.h>
+#include <stdatomic.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -26,11 +27,6 @@
#include <unistd.h>
#include <cutils/compiler.h>
-#ifdef ANDROID_SMP
-#include <cutils/atomic-inline.h>
-#else
-#include <cutils/atomic.h>
-#endif
__BEGIN_DECLS
@@ -84,14 +80,6 @@ __BEGIN_DECLS
#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h
#endif
-#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.
@@ -125,7 +113,7 @@ void atrace_set_tracing_enabled(bool enabled);
* Nonzero indicates setup has completed.
* Note: This does NOT indicate whether or not setup was successful.
*/
-extern volatile int32_t atrace_is_ready;
+extern atomic_bool atrace_is_ready;
/**
* Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY.
@@ -148,7 +136,7 @@ extern int atrace_marker_fd;
#define ATRACE_INIT() atrace_init()
static inline void atrace_init()
{
- if (CC_UNLIKELY(!android_atomic_acquire_load(&atrace_is_ready))) {
+ if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
atrace_setup();
}
}
@@ -184,11 +172,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 +203,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 +213,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 +229,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,28 +242,11 @@ 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);
}
}
-#else // not HAVE_ANDROID_OS
-
-#define ATRACE_INIT()
-#define ATRACE_GET_ENABLED_TAGS()
-#define ATRACE_ENABLED() 0
-#define ATRACE_BEGIN(name)
-#define ATRACE_END()
-#define ATRACE_ASYNC_BEGIN(name, cookie)
-#define ATRACE_ASYNC_END(name, cookie)
-#define ATRACE_INT(name, value)
-
-#endif // not HAVE_ANDROID_OS
-
__END_DECLS
#endif // _LIBS_CUTILS_TRACE_H
diff --git a/include/cutils/uevent.h b/include/cutils/uevent.h
index 4cca7e5..da1c2aa 100644
--- a/include/cutils/uevent.h
+++ b/include/cutils/uevent.h
@@ -27,6 +27,7 @@ extern "C" {
int uevent_open_socket(int buf_sz, bool passcred);
ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length);
ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid);
+ssize_t uevent_kernel_recv(int socket, void *buffer, size_t length, bool require_group, uid_t *uid);
#ifdef __cplusplus
}
diff --git a/include/log/log.h b/include/log/log.h
index ace12d6..ce253e2 100644
--- a/include/log/log.h
+++ b/include/log/log.h
@@ -28,14 +28,12 @@
#ifndef _LIBS_LOG_LOG_H
#define _LIBS_LOG_LOG_H
-#include <sys/types.h>
-#ifdef HAVE_PTHREADS
-#include <pthread.h>
-#endif
#include <stdarg.h>
#include <stdio.h>
+#include <sys/types.h>
#include <time.h>
#include <unistd.h>
+
#include <log/logd.h>
#include <log/uio.h>
@@ -69,6 +67,23 @@ extern "C" {
// ---------------------------------------------------------------------
+#ifndef __predict_false
+#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
+#endif
+
+/*
+ * -DLINT_RLOG in sources that you want to enforce that all logging
+ * goes to the radio log buffer. If any logging goes to any of the other
+ * log buffers, there will be a compile or link error to highlight the
+ * problem. This is not a replacement for a full audit of the code since
+ * this only catches compiled code, not ifdef'd debug code. Options to
+ * defining this, either temporarily to do a spot check, or permanently
+ * to enforce, in all the communications trees; We have hopes to ensure
+ * that by supplying just the radio log buffer that the communications
+ * teams will have their one-stop shop for triaging issues.
+ */
+#ifndef LINT_RLOG
+
/*
* Simplified macro to send a verbose log message using the current LOG_TAG.
*/
@@ -81,14 +96,12 @@ extern "C" {
#endif
#endif
-#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
-
#ifndef ALOGV_IF
#if LOG_NDEBUG
#define ALOGV_IF(cond, ...) ((void)0)
#else
#define ALOGV_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -103,7 +116,7 @@ extern "C" {
#ifndef ALOGD_IF
#define ALOGD_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -117,7 +130,7 @@ extern "C" {
#ifndef ALOGI_IF
#define ALOGI_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -131,7 +144,7 @@ extern "C" {
#ifndef ALOGW_IF
#define ALOGW_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -145,7 +158,7 @@ extern "C" {
#ifndef ALOGE_IF
#define ALOGE_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -203,7 +216,8 @@ extern "C" {
* Simplified macro to send a verbose system log message using the current LOG_TAG.
*/
#ifndef SLOGV
-#define __SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define __SLOGV(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0)
#else
@@ -211,14 +225,12 @@ extern "C" {
#endif
#endif
-#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
-
#ifndef SLOGV_IF
#if LOG_NDEBUG
#define SLOGV_IF(cond, ...) ((void)0)
#else
#define SLOGV_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -228,12 +240,13 @@ extern "C" {
* Simplified macro to send a debug system log message using the current LOG_TAG.
*/
#ifndef SLOGD
-#define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#define SLOGD(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGD_IF
#define SLOGD_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -242,12 +255,13 @@ extern "C" {
* Simplified macro to send an info system log message using the current LOG_TAG.
*/
#ifndef SLOGI
-#define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#define SLOGI(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGI_IF
#define SLOGI_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -256,12 +270,13 @@ extern "C" {
* Simplified macro to send a warning system log message using the current LOG_TAG.
*/
#ifndef SLOGW
-#define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define SLOGW(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGW_IF
#define SLOGW_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -270,23 +285,27 @@ extern "C" {
* Simplified macro to send an error system log message using the current LOG_TAG.
*/
#ifndef SLOGE
-#define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#define SLOGE(...) \
+ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGE_IF
#define SLOGE_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
+#endif /* !LINT_RLOG */
+
// ---------------------------------------------------------------------
/*
* Simplified macro to send a verbose radio log message using the current LOG_TAG.
*/
#ifndef RLOGV
-#define __RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define __RLOGV(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0)
#else
@@ -294,14 +313,12 @@ extern "C" {
#endif
#endif
-#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
-
#ifndef RLOGV_IF
#if LOG_NDEBUG
#define RLOGV_IF(cond, ...) ((void)0)
#else
#define RLOGV_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -311,12 +328,13 @@ extern "C" {
* Simplified macro to send a debug radio log message using the current LOG_TAG.
*/
#ifndef RLOGD
-#define RLOGD(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#define RLOGD(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGD_IF
#define RLOGD_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -325,12 +343,13 @@ extern "C" {
* Simplified macro to send an info radio log message using the current LOG_TAG.
*/
#ifndef RLOGI
-#define RLOGI(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#define RLOGI(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGI_IF
#define RLOGI_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -339,12 +358,13 @@ extern "C" {
* Simplified macro to send a warning radio log message using the current LOG_TAG.
*/
#ifndef RLOGW
-#define RLOGW(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define RLOGW(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGW_IF
#define RLOGW_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -353,12 +373,13 @@ extern "C" {
* Simplified macro to send an error radio log message using the current LOG_TAG.
*/
#ifndef RLOGE
-#define RLOGE(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#define RLOGE(...) \
+ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef RLOGE_IF
#define RLOGE_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
@@ -374,7 +395,7 @@ extern "C" {
*/
#ifndef LOG_ALWAYS_FATAL_IF
#define LOG_ALWAYS_FATAL_IF(cond, ...) \
- ( (CONDITION(cond)) \
+ ( (__predict_false(cond)) \
? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
: (void)0 )
#endif
@@ -534,8 +555,23 @@ typedef enum {
#define android_btWriteLog(tag, type, payload, len) \
__android_log_btwrite(tag, type, payload, len)
+/*
+ * IF_ALOG uses android_testLog, but IF_ALOG can be overridden.
+ * android_testLog will remain constant in its purpose as a wrapper
+ * for Android logging filter policy, and can be subject to
+ * change. It can be reused by the developers that override
+ * IF_ALOG as a convenient means to reimplement their policy
+ * over Android.
+ */
+#if LOG_NDEBUG /* Production */
+#define android_testLog(prio, tag) \
+ (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0)
+#else
+#define android_testLog(prio, tag) \
+ (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0)
+#endif
+
// TODO: remove these prototypes and their users
-#define android_testLog(prio, tag) (1)
#define android_writevLog(vec,num) do{}while(0)
#define android_write1Log(str,len) do{}while (0)
#define android_setMinPriority(tag, prio) do{}while(0)
@@ -546,11 +582,15 @@ typedef enum {
typedef enum log_id {
LOG_ID_MIN = 0,
+#ifndef LINT_RLOG
LOG_ID_MAIN = 0,
+#endif
LOG_ID_RADIO = 1,
+#ifndef LINT_RLOG
LOG_ID_EVENTS = 2,
LOG_ID_SYSTEM = 3,
LOG_ID_CRASH = 4,
+#endif
LOG_ID_MAX
} log_id_t;
@@ -558,6 +598,12 @@ typedef enum log_id {
#define typeof_log_id_t unsigned char
/*
+ * Use the per-tag properties "log.tag.<tagname>" to generate a runtime
+ * result of non-zero to expose a log.
+ */
+int __android_log_is_loggable(int prio, const char *tag, int def);
+
+/*
* Send a simple string to the log.
*/
int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
diff --git a/include/log/log_read.h b/include/log/log_read.h
index 946711a..1b70aff 100644
--- a/include/log/log_read.h
+++ b/include/log/log_read.h
@@ -100,6 +100,12 @@ public:
log_time local(*this);
return local -= T;
}
+ log_time operator+= (const timespec &T);
+ log_time operator+ (const timespec &T) const
+ {
+ log_time local(*this);
+ return local += T;
+ }
// log_time
bool operator== (const log_time &T) const
@@ -134,6 +140,12 @@ public:
log_time local(*this);
return local -= T;
}
+ log_time operator+= (const log_time &T);
+ log_time operator+ (const log_time &T) const
+ {
+ log_time local(*this);
+ return local += T;
+ }
uint64_t nsec() const
{
diff --git a/include/log/logd.h b/include/log/logd.h
index 2e6f220..0fe515f 100644
--- a/include/log/logd.h
+++ b/include/log/logd.h
@@ -23,16 +23,17 @@
#include <android/log.h>
/* the rest is only used internally by the system */
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <sys/types.h>
-#ifdef HAVE_PTHREADS
+#if !defined(_WIN32)
#include <pthread.h>
#endif
-#include <log/uio.h>
#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <log/uio.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/log/logger.h b/include/log/logger.h
index 53be1d3..f030dab 100644
--- a/include/log/logger.h
+++ b/include/log/logger.h
@@ -154,6 +154,13 @@ ssize_t android_logger_get_prune_list(struct logger_list *logger_list,
int android_logger_set_prune_list(struct logger_list *logger_list,
char *buf, size_t len);
+#define ANDROID_LOG_RDONLY O_RDONLY
+#define ANDROID_LOG_WRONLY O_WRONLY
+#define ANDROID_LOG_RDWR O_RDWR
+#define ANDROID_LOG_ACCMODE O_ACCMODE
+#define ANDROID_LOG_NONBLOCK O_NONBLOCK
+#define ANDROID_LOG_PSTORE 0x80000000
+
struct logger_list *android_logger_list_alloc(int mode,
unsigned int tail,
pid_t pid);
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/log/uio.h b/include/log/uio.h
index a71f515..7059da5 100644
--- a/include/log/uio.h
+++ b/include/log/uio.h
@@ -14,20 +14,23 @@
* limitations under the License.
*/
-//
-// implementation of sys/uio.h for platforms that don't have it (Win32)
-//
#ifndef _LIBS_CUTILS_UIO_H
#define _LIBS_CUTILS_UIO_H
-#ifdef HAVE_SYS_UIO_H
+#if !defined(_WIN32)
+
#include <sys/uio.h>
+
#else
#ifdef __cplusplus
extern "C" {
#endif
+//
+// Implementation of sys/uio.h for Win32.
+//
+
#include <stddef.h>
struct iovec {
@@ -42,7 +45,7 @@ extern int writev( int fd, const struct iovec* vecs, int count );
}
#endif
-#endif /* !HAVE_SYS_UIO_H */
+#endif
#endif /* _LIBS_UTILS_UIO_H */
diff --git a/include/memtrack/memtrack.h b/include/memtrack/memtrack.h
index 0f1f85e..3917300 100644
--- a/include/memtrack/memtrack.h
+++ b/include/memtrack/memtrack.h
@@ -121,7 +121,7 @@ ssize_t memtrack_proc_gl_total(struct memtrack_proc *p);
ssize_t memtrack_proc_gl_pss(struct memtrack_proc *p);
/**
- * memtrack_proc_gl_total
+ * memtrack_proc_other_total
*
* Same as memtrack_proc_graphics_total, but counts miscellaneous memory
* not tracked by gl or graphics calls above.
@@ -131,7 +131,7 @@ ssize_t memtrack_proc_gl_pss(struct memtrack_proc *p);
ssize_t memtrack_proc_other_total(struct memtrack_proc *p);
/**
- * memtrack_proc_gl_pss
+ * memtrack_proc_other_pss
*
* Same as memtrack_proc_graphics_total, but counts miscellaneous memory
* not tracked by gl or graphics calls above.
diff --git a/include/pixelflinger/format.h b/include/pixelflinger/format.h
deleted file mode 100644
index 82eeca4..0000000
--- a/include/pixelflinger/format.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2005 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_PIXELFLINGER_FORMAT_H
-#define ANDROID_PIXELFLINGER_FORMAT_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-enum GGLPixelFormat {
- // these constants need to match those
- // in graphics/PixelFormat.java, ui/PixelFormat.h, BlitHardware.h
- GGL_PIXEL_FORMAT_UNKNOWN = 0,
- GGL_PIXEL_FORMAT_NONE = 0,
-
- GGL_PIXEL_FORMAT_RGBA_8888 = 1, // 4x8-bit ARGB
- GGL_PIXEL_FORMAT_RGBX_8888 = 2, // 3x8-bit RGB stored in 32-bit chunks
- GGL_PIXEL_FORMAT_RGB_888 = 3, // 3x8-bit RGB
- GGL_PIXEL_FORMAT_RGB_565 = 4, // 16-bit RGB
- GGL_PIXEL_FORMAT_BGRA_8888 = 5, // 4x8-bit BGRA
- GGL_PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit RGBA
- GGL_PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit RGBA
-
- GGL_PIXEL_FORMAT_A_8 = 8, // 8-bit A
- GGL_PIXEL_FORMAT_L_8 = 9, // 8-bit L (R=G=B = L)
- GGL_PIXEL_FORMAT_LA_88 = 0xA, // 16-bit LA
- GGL_PIXEL_FORMAT_RGB_332 = 0xB, // 8-bit RGB (non paletted)
-
- // reserved range. don't use.
- GGL_PIXEL_FORMAT_RESERVED_10 = 0x10,
- GGL_PIXEL_FORMAT_RESERVED_11 = 0x11,
- GGL_PIXEL_FORMAT_RESERVED_12 = 0x12,
- GGL_PIXEL_FORMAT_RESERVED_13 = 0x13,
- GGL_PIXEL_FORMAT_RESERVED_14 = 0x14,
- GGL_PIXEL_FORMAT_RESERVED_15 = 0x15,
- GGL_PIXEL_FORMAT_RESERVED_16 = 0x16,
- GGL_PIXEL_FORMAT_RESERVED_17 = 0x17,
-
- // reserved/special formats
- GGL_PIXEL_FORMAT_Z_16 = 0x18,
- GGL_PIXEL_FORMAT_S_8 = 0x19,
- GGL_PIXEL_FORMAT_SZ_24 = 0x1A,
- GGL_PIXEL_FORMAT_SZ_8 = 0x1B,
-
- // reserved range. don't use.
- GGL_PIXEL_FORMAT_RESERVED_20 = 0x20,
- GGL_PIXEL_FORMAT_RESERVED_21 = 0x21,
-};
-
-enum GGLFormatComponents {
- GGL_STENCIL_INDEX = 0x1901,
- GGL_DEPTH_COMPONENT = 0x1902,
- GGL_ALPHA = 0x1906,
- GGL_RGB = 0x1907,
- GGL_RGBA = 0x1908,
- GGL_LUMINANCE = 0x1909,
- GGL_LUMINANCE_ALPHA = 0x190A,
-};
-
-enum GGLFormatComponentIndex {
- GGL_INDEX_ALPHA = 0,
- GGL_INDEX_RED = 1,
- GGL_INDEX_GREEN = 2,
- GGL_INDEX_BLUE = 3,
- GGL_INDEX_STENCIL = 0,
- GGL_INDEX_DEPTH = 1,
- GGL_INDEX_Y = 0,
- GGL_INDEX_CB = 1,
- GGL_INDEX_CR = 2,
-};
-
-typedef struct {
-#ifdef __cplusplus
- enum {
- ALPHA = GGL_INDEX_ALPHA,
- RED = GGL_INDEX_RED,
- GREEN = GGL_INDEX_GREEN,
- BLUE = GGL_INDEX_BLUE,
- STENCIL = GGL_INDEX_STENCIL,
- DEPTH = GGL_INDEX_DEPTH,
- LUMA = GGL_INDEX_Y,
- CHROMAB = GGL_INDEX_CB,
- CHROMAR = GGL_INDEX_CR,
- };
- inline uint32_t mask(int i) const {
- return ((1<<(c[i].h-c[i].l))-1)<<c[i].l;
- }
- inline uint32_t bits(int i) const {
- return c[i].h - c[i].l;
- }
-#endif
- uint8_t size; // bytes per pixel
- uint8_t bitsPerPixel;
- union {
- struct {
- uint8_t ah; // alpha high bit position + 1
- uint8_t al; // alpha low bit position
- uint8_t rh; // red high bit position + 1
- uint8_t rl; // red low bit position
- uint8_t gh; // green high bit position + 1
- uint8_t gl; // green low bit position
- uint8_t bh; // blue high bit position + 1
- uint8_t bl; // blue low bit position
- };
- struct {
- uint8_t h;
- uint8_t l;
- } __attribute__((__packed__)) c[4];
- } __attribute__((__packed__));
- uint16_t components; // GGLFormatComponents
-} GGLFormat;
-
-
-#ifdef __cplusplus
-extern "C" const GGLFormat* gglGetPixelFormatTable(size_t* numEntries = 0);
-#else
-const GGLFormat* gglGetPixelFormatTable(size_t* numEntries);
-#endif
-
-
-// ----------------------------------------------------------------------------
-
-#endif // ANDROID_PIXELFLINGER_FORMAT_H
diff --git a/include/pixelflinger/pixelflinger.h b/include/pixelflinger/pixelflinger.h
deleted file mode 100644
index 8a2b442..0000000
--- a/include/pixelflinger/pixelflinger.h
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (C) 2007 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_PIXELFLINGER_H
-#define ANDROID_PIXELFLINGER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <pixelflinger/format.h>
-
-// GGL types
-
-typedef int8_t GGLbyte; // b
-typedef int16_t GGLshort; // s
-typedef int32_t GGLint; // i
-typedef ssize_t GGLsizei; // i
-typedef int32_t GGLfixed; // x
-typedef int32_t GGLclampx; // x
-typedef float GGLfloat; // f
-typedef float GGLclampf; // f
-typedef double GGLdouble; // d
-typedef double GGLclampd; // d
-typedef uint8_t GGLubyte; // ub
-typedef uint8_t GGLboolean; // ub
-typedef uint16_t GGLushort; // us
-typedef uint32_t GGLuint; // ui
-typedef unsigned int GGLenum; // ui
-typedef unsigned int GGLbitfield; // ui
-typedef void GGLvoid;
-typedef int32_t GGLfixed32;
-typedef int32_t GGLcolor;
-typedef int32_t GGLcoord;
-
-// ----------------------------------------------------------------------------
-
-#define GGL_MAX_VIEWPORT_DIMS 4096
-#define GGL_MAX_TEXTURE_SIZE 4096
-#define GGL_MAX_ALIASED_POINT_SIZE 0x7FFFFFF
-#define GGL_MAX_SMOOTH_POINT_SIZE 2048
-#define GGL_MAX_SMOOTH_LINE_WIDTH 2048
-
-// ----------------------------------------------------------------------------
-
-// All these names are compatible with their OpenGL equivalents
-// some of them are listed only for completeness
-enum GGLNames {
- GGL_FALSE = 0,
- GGL_TRUE = 1,
-
- // enable/disable
- GGL_SCISSOR_TEST = 0x0C11,
- GGL_TEXTURE_2D = 0x0DE1,
- GGL_ALPHA_TEST = 0x0BC0,
- GGL_BLEND = 0x0BE2,
- GGL_COLOR_LOGIC_OP = 0x0BF2,
- GGL_DITHER = 0x0BD0,
- GGL_STENCIL_TEST = 0x0B90,
- GGL_DEPTH_TEST = 0x0B71,
- GGL_AA = 0x80000001,
- GGL_W_LERP = 0x80000004,
- GGL_POINT_SMOOTH_NICE = 0x80000005,
-
- // buffers, pixel drawing/reading
- GGL_COLOR = 0x1800,
-
- // fog
- GGL_FOG = 0x0B60,
-
- // shade model
- GGL_FLAT = 0x1D00,
- GGL_SMOOTH = 0x1D01,
-
- // Texture parameter name
- GGL_TEXTURE_MIN_FILTER = 0x2801,
- GGL_TEXTURE_MAG_FILTER = 0x2800,
- GGL_TEXTURE_WRAP_S = 0x2802,
- GGL_TEXTURE_WRAP_T = 0x2803,
- GGL_TEXTURE_WRAP_R = 0x2804,
-
- // Texture Filter
- GGL_NEAREST = 0x2600,
- GGL_LINEAR = 0x2601,
- GGL_NEAREST_MIPMAP_NEAREST = 0x2700,
- GGL_LINEAR_MIPMAP_NEAREST = 0x2701,
- GGL_NEAREST_MIPMAP_LINEAR = 0x2702,
- GGL_LINEAR_MIPMAP_LINEAR = 0x2703,
-
- // Texture Wrap Mode
- GGL_CLAMP = 0x2900,
- GGL_REPEAT = 0x2901,
- GGL_CLAMP_TO_EDGE = 0x812F,
-
- // Texture Env Mode
- GGL_REPLACE = 0x1E01,
- GGL_MODULATE = 0x2100,
- GGL_DECAL = 0x2101,
- GGL_ADD = 0x0104,
-
- // Texture Env Parameter
- GGL_TEXTURE_ENV_MODE = 0x2200,
- GGL_TEXTURE_ENV_COLOR = 0x2201,
-
- // Texture Env Target
- GGL_TEXTURE_ENV = 0x2300,
-
- // Texture coord generation
- GGL_TEXTURE_GEN_MODE = 0x2500,
- GGL_S = 0x2000,
- GGL_T = 0x2001,
- GGL_R = 0x2002,
- GGL_Q = 0x2003,
- GGL_ONE_TO_ONE = 0x80000002,
- GGL_AUTOMATIC = 0x80000003,
-
- // AlphaFunction
- GGL_NEVER = 0x0200,
- GGL_LESS = 0x0201,
- GGL_EQUAL = 0x0202,
- GGL_LEQUAL = 0x0203,
- GGL_GREATER = 0x0204,
- GGL_NOTEQUAL = 0x0205,
- GGL_GEQUAL = 0x0206,
- GGL_ALWAYS = 0x0207,
-
- // LogicOp
- GGL_CLEAR = 0x1500, // 0
- GGL_AND = 0x1501, // s & d
- GGL_AND_REVERSE = 0x1502, // s & ~d
- GGL_COPY = 0x1503, // s
- GGL_AND_INVERTED = 0x1504, // ~s & d
- GGL_NOOP = 0x1505, // d
- GGL_XOR = 0x1506, // s ^ d
- GGL_OR = 0x1507, // s | d
- GGL_NOR = 0x1508, // ~(s | d)
- GGL_EQUIV = 0x1509, // ~(s ^ d)
- GGL_INVERT = 0x150A, // ~d
- GGL_OR_REVERSE = 0x150B, // s | ~d
- GGL_COPY_INVERTED = 0x150C, // ~s
- GGL_OR_INVERTED = 0x150D, // ~s | d
- GGL_NAND = 0x150E, // ~(s & d)
- GGL_SET = 0x150F, // 1
-
- // blending equation & function
- GGL_ZERO = 0, // SD
- GGL_ONE = 1, // SD
- GGL_SRC_COLOR = 0x0300, // D
- GGL_ONE_MINUS_SRC_COLOR = 0x0301, // D
- GGL_SRC_ALPHA = 0x0302, // SD
- GGL_ONE_MINUS_SRC_ALPHA = 0x0303, // SD
- GGL_DST_ALPHA = 0x0304, // SD
- GGL_ONE_MINUS_DST_ALPHA = 0x0305, // SD
- GGL_DST_COLOR = 0x0306, // S
- GGL_ONE_MINUS_DST_COLOR = 0x0307, // S
- GGL_SRC_ALPHA_SATURATE = 0x0308, // S
-
- // clear bits
- GGL_DEPTH_BUFFER_BIT = 0x00000100,
- GGL_STENCIL_BUFFER_BIT = 0x00000400,
- GGL_COLOR_BUFFER_BIT = 0x00004000,
-
- // errors
- GGL_NO_ERROR = 0,
- GGL_INVALID_ENUM = 0x0500,
- GGL_INVALID_VALUE = 0x0501,
- GGL_INVALID_OPERATION = 0x0502,
- GGL_STACK_OVERFLOW = 0x0503,
- GGL_STACK_UNDERFLOW = 0x0504,
- GGL_OUT_OF_MEMORY = 0x0505
-};
-
-// ----------------------------------------------------------------------------
-
-typedef struct {
- GGLsizei version; // always set to sizeof(GGLSurface)
- GGLuint width; // width in pixels
- GGLuint height; // height in pixels
- GGLint stride; // stride in pixels
- GGLubyte* data; // pointer to the bits
- GGLubyte format; // pixel format
- GGLubyte rfu[3]; // must be zero
- // these values are dependent on the used format
- union {
- GGLint compressedFormat;
- GGLint vstride;
- };
- void* reserved;
-} GGLSurface;
-
-
-typedef struct {
- // immediate rendering
- void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
- void (*linex)(void *con,
- const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
- void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b);
- void (*trianglex)(void* c,
- GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
-
- // scissor
- void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
-
- // Set the textures and color buffers
- void (*activeTexture)(void* c, GGLuint tmu);
- void (*bindTexture)(void* c, const GGLSurface* surface);
- void (*colorBuffer)(void* c, const GGLSurface* surface);
- void (*readBuffer)(void* c, const GGLSurface* surface);
- void (*depthBuffer)(void* c, const GGLSurface* surface);
- void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
-
- // enable/disable features
- void (*enable)(void* c, GGLenum name);
- void (*disable)(void* c, GGLenum name);
- void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
-
- // specify the fragment's color
- void (*shadeModel)(void* c, GGLenum mode);
- void (*color4xv)(void* c, const GGLclampx* color);
- // specify color iterators (16.16)
- void (*colorGrad12xv)(void* c, const GGLcolor* grad);
-
- // specify Z coordinate iterators (0.32)
- void (*zGrad3xv)(void* c, const GGLfixed32* grad);
-
- // specify W coordinate iterators (16.16)
- void (*wGrad3xv)(void* c, const GGLfixed* grad);
-
- // specify fog iterator & color (16.16)
- void (*fogGrad3xv)(void* c, const GGLfixed* grad);
- void (*fogColor3xv)(void* c, const GGLclampx* color);
-
- // specify blending parameters
- void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
- void (*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,
- GGLenum srcAlpha, GGLenum dstAplha);
-
- // texture environnement (REPLACE / MODULATE / DECAL / BLEND)
- void (*texEnvi)(void* c, GGLenum target,
- GGLenum pname,
- GGLint param);
-
- void (*texEnvxv)(void* c, GGLenum target,
- GGLenum pname, const GGLfixed* params);
-
- // texture parameters (Wrapping, filter)
- void (*texParameteri)(void* c, GGLenum target,
- GGLenum pname,
- GGLint param);
-
- // texture iterators (16.16)
- void (*texCoord2i)(void* c, GGLint s, GGLint t);
- void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
-
- // s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
- // This api uses block floating-point for S and T texture coordinates.
- // All values are given in 16.16, scaled by 'scale'. In other words,
- // set scale to 0, for 16.16 values.
- void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
-
- void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
-
- // masking
- void (*colorMask)(void* c, GGLboolean red,
- GGLboolean green,
- GGLboolean blue,
- GGLboolean alpha);
-
- void (*depthMask)(void* c, GGLboolean flag);
-
- void (*stencilMask)(void* c, GGLuint mask);
-
- // alpha func
- void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
-
- // depth func
- void (*depthFunc)(void* c, GGLenum func);
-
- // logic op
- void (*logicOp)(void* c, GGLenum opcode);
-
- // clear
- void (*clear)(void* c, GGLbitfield mask);
- void (*clearColorx)(void* c,
- GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
- void (*clearDepthx)(void* c, GGLclampx depth);
- void (*clearStencil)(void* c, GGLint s);
-
- // framebuffer operations
- void (*copyPixels)(void* c, GGLint x, GGLint y,
- GGLsizei width, GGLsizei height, GGLenum type);
- void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
- void (*rasterPos2i)(void* c, GGLint x, GGLint y);
-} GGLContext;
-
-// ----------------------------------------------------------------------------
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// construct / destroy the context
-ssize_t gglInit(GGLContext** context);
-ssize_t gglUninit(GGLContext* context);
-
-GGLint gglBitBlit(
- GGLContext* c,
- int tmu,
- GGLint crop[4],
- GGLint where[4]);
-
-#ifdef __cplusplus
-};
-#endif
-
-// ----------------------------------------------------------------------------
-
-#endif // ANDROID_PIXELFLINGER_H
diff --git a/include/private/android_filesystem_capability.h b/include/private/android_filesystem_capability.h
index 0505cda..b92d3db 100644
--- a/include/private/android_filesystem_capability.h
+++ b/include/private/android_filesystem_capability.h
@@ -105,7 +105,9 @@ struct vfs_cap_data {
#define CAP_MAC_ADMIN 33
#define CAP_SYSLOG 34
#define CAP_WAKE_ALARM 35
-#define CAP_LAST_CAP CAP_WAKE_ALARM
+#define CAP_BLOCK_SUSPEND 36
+#define CAP_AUDIT_READ 37
+#define CAP_LAST_CAP CAP_AUDIT_READ
#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
#define CAP_TO_INDEX(x) ((x) >> 5)
#define CAP_TO_MASK(x) (1 << ((x) & 31))
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 2f528b9..02fe2b5 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -22,8 +22,7 @@
#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
#define _ANDROID_FILESYSTEM_CONFIG_H_
-#include <string.h>
-#include <sys/stat.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdint.h>
@@ -83,6 +82,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 */
@@ -109,6 +113,14 @@
#define AID_SHARED_GID_END 59999 /* start of gids for apps in each user to share */
#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
+/*
+ * Used in:
+ * bionic/libc/bionic/stubs.cpp
+ * external/libselinux/src/android.c
+ * system/core/logd/LogStatistics.cpp
+ * system/core/init/ueventd.cpp
+ * system/core/init/util.cpp
+ */
struct android_id_info {
const char *name;
unsigned aid;
@@ -186,124 +198,26 @@ struct fs_path_config {
const char *prefix;
};
-/* Rules for directories.
-** These rules are applied based on "first match", so they
-** should start with the most specific path and work their
-** way up to the root.
-*/
-
-static const struct fs_path_config android_dirs[] = {
- { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
- { 00771, AID_ROOT, AID_ROOT, 0, "data/dalvik-cache" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
- { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" },
- { 00771, AID_SHELL, AID_SHELL, 0, "data/local" },
- { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" },
- { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" },
- { 00771, AID_SHARED_RELRO, AID_SHARED_RELRO, 0, "data/misc/shared_relro" },
- { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
- { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" },
- { 00755, AID_ROOT, AID_SHELL, 0, "vendor" },
- { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" },
- { 00755, AID_ROOT, AID_ROOT, 0, 0 },
-};
-
-/* Rules for files.
-** These rules are applied based on "first match", so they
-** should start with the most specific path and work their
-** way up to the root. Prefixes ending in * denotes wildcard
-** and will allow partial matches.
-*/
-static const struct fs_path_config android_files[] = {
- { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" },
- { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" },
- { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" },
- { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" },
- { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" },
- { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" },
- { 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" },
- { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
- { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" },
- { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" },
- { 00644, AID_APP, AID_APP, 0, "data/data/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/bin/ping" },
+/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
- /* the following file is INTENTIONALLY set-gid and not set-uid.
- * Do not change. */
- { 02750, AID_ROOT, AID_INET, 0, "system/bin/netcfg" },
+__BEGIN_DECLS
- /* the following five files are INTENTIONALLY set-uid, but they
- * are NOT included on user builds. */
- { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
- { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" },
- { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" },
- { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
- { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" },
-
- /* the following files have enhanced capabilities and ARE included in user builds. */
- { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" },
-
- { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" },
- { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "init*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
- { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },
- { 00644, AID_ROOT, AID_ROOT, 0, 0 },
-};
-
-static inline void fs_config(const char *path, int dir,
- unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities)
-{
- const struct fs_path_config *pc;
- int plen;
+/*
+ * Used in:
+ * build/tools/fs_config/fs_config.c
+ * build/tools/fs_get_stats/fs_get_stats.c
+ * external/genext2fs/genext2fs.c
+ * external/squashfs-tools/squashfs-tools/android.c
+ * system/core/cpio/mkbootfs.c
+ * system/core/adb/file_sync_service.cpp
+ * system/extras/ext4_utils/canned_fs_config.c
+ */
+void fs_config(const char *path, int dir,
+ unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities);
- if (path[0] == '/') {
- path++;
- }
+ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc);
- pc = dir ? android_dirs : android_files;
- plen = strlen(path);
- for(; pc->prefix; pc++){
- int len = strlen(pc->prefix);
- if (dir) {
- if(plen < len) continue;
- if(!strncmp(pc->prefix, path, len)) break;
- continue;
- }
- /* If name ends in * then allow partial matches. */
- if (pc->prefix[len -1] == '*') {
- if(!strncmp(pc->prefix, path, len - 1)) break;
- } else if (plen == len){
- if(!strncmp(pc->prefix, path, len)) break;
- }
- }
- *uid = pc->uid;
- *gid = pc->gid;
- *mode = (*mode & (~07777)) | pc->mode;
- *capabilities = pc->capabilities;
+__END_DECLS
-#if 0
- fprintf(stderr,"< '%s' '%s' %d %d %o >\n",
- path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode);
-#endif
-}
#endif
#endif
diff --git a/include/private/android_logger.h b/include/private/android_logger.h
new file mode 100644
index 0000000..04238a6
--- /dev/null
+++ b/include/private/android_logger.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+/* This file is used to define the internal protocol for the Android Logger */
+
+#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
+#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
+
+#include <stdint.h>
+
+#include <log/log.h>
+#include <log/log_read.h>
+
+#define LOGGER_MAGIC 'l'
+
+/* Header Structure to pstore */
+typedef struct __attribute__((__packed__)) {
+ uint8_t magic;
+ uint16_t len;
+ uint16_t uid;
+ uint16_t pid;
+} android_pmsg_log_header_t;
+
+/* Header Structure to logd, and second header for pstore */
+typedef struct __attribute__((__packed__)) {
+ typeof_log_id_t id;
+ uint16_t tid;
+ log_time realtime;
+} android_log_header_t;
+
+/* Event Header Structure to logd */
+typedef struct __attribute__((__packed__)) {
+ int32_t tag; // Little Endian Order
+} android_event_header_t;
+
+/* Event payload EVENT_TYPE_INT */
+typedef struct __attribute__((__packed__)) {
+ int8_t type; // EVENT_TYPE_INT
+ int32_t data; // Little Endian Order
+} android_event_int_t;
+
+/* Event with single EVENT_TYPE_INT */
+typedef struct __attribute__((__packed__)) {
+ android_event_header_t header;
+ android_event_int_t payload;
+} android_log_event_int_t;
+
+/* Event payload EVENT_TYPE_LONG */
+typedef struct __attribute__((__packed__)) {
+ int8_t type; // EVENT_TYPE_LONG
+ int64_t data; // Little Endian Order
+} android_event_long_t;
+
+/* Event with single EVENT_TYPE_LONG */
+typedef struct __attribute__((__packed__)) {
+ android_event_header_t header;
+ android_event_long_t payload;
+} android_log_event_long_t;
+
+/*
+ * Event payload EVENT_TYPE_STRING
+ *
+ * Danger: do not embed this structure into another structure.
+ * This structure uses a flexible array member, and when
+ * compiled using g++, __builtin_object_size(data, 1) returns
+ * a bad value. This is possibly a g++ bug, or a bug due to
+ * the fact that flexible array members are not supported
+ * in C++.
+ * http://stackoverflow.com/questions/4412749/are-flexible-array-members-valid-in-c
+ */
+typedef struct __attribute__((__packed__)) {
+ int8_t type; // EVENT_TYPE_STRING;
+ int32_t length; // Little Endian Order
+ char data[];
+} android_event_string_t;
+
+/* Event with single EVENT_TYPE_STRING */
+typedef struct __attribute__((__packed__)) {
+ android_event_header_t header;
+ int8_t type; // EVENT_TYPE_STRING;
+ int32_t length; // Little Endian Order
+ char data[];
+} android_log_event_string_t;
+
+#endif
diff --git a/include/private/pixelflinger/ggl_context.h b/include/private/pixelflinger/ggl_context.h
deleted file mode 100644
index d43655c..0000000
--- a/include/private/pixelflinger/ggl_context.h
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * Copyright (C) 2006 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_GGL_CONTEXT_H
-#define ANDROID_GGL_CONTEXT_H
-
-#include <stdint.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/types.h>
-#include <endian.h>
-
-#include <pixelflinger/pixelflinger.h>
-#include <private/pixelflinger/ggl_fixed.h>
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-
-inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
- return v;
-}
-inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
- return v;
-}
-
-#else
-
-inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
-#if defined(__mips__) && __mips==32 && __mips_isa_rev>=2
- uint32_t r;
- __asm__("wsbh %0, %1;"
- "rotr %0, %0, 16"
- : "=r" (r)
- : "r" (v)
- );
- return r;
-#else
- return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-#endif
-}
-inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
-#if defined(__mips__) && __mips==32 && __mips_isa_rev>=2
- uint32_t r;
- __asm__("wsbh %0, %1;"
- "rotr %0, %0, 16"
- : "=r" (r)
- : "r" (v)
- );
- return r;
-#else
- return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
-#endif
-}
-
-#endif
-
-// ----------------------------------------------------------------------------
-
-const int GGL_DITHER_BITS = 6; // dither weights stored on 6 bits
-const int GGL_DITHER_ORDER_SHIFT= 3;
-const int GGL_DITHER_ORDER = (1<<GGL_DITHER_ORDER_SHIFT);
-const int GGL_DITHER_SIZE = GGL_DITHER_ORDER * GGL_DITHER_ORDER;
-const int GGL_DITHER_MASK = GGL_DITHER_ORDER-1;
-
-// ----------------------------------------------------------------------------
-
-const int GGL_SUBPIXEL_BITS = 4;
-
-// TRI_FRACTION_BITS defines the number of bits we want to use
-// for the sub-pixel coordinates during the edge stepping, the
-// value shouldn't be more than 7, or bad things are going to
-// happen when drawing large triangles (8 doesn't work because
-// 32 bit muls will loose the sign bit)
-
-#define TRI_FRACTION_BITS (GGL_SUBPIXEL_BITS)
-#define TRI_ONE (1 << TRI_FRACTION_BITS)
-#define TRI_HALF (1 << (TRI_FRACTION_BITS-1))
-#define TRI_FROM_INT(x) ((x) << TRI_FRACTION_BITS)
-#define TRI_FRAC(x) ((x) & (TRI_ONE-1))
-#define TRI_FLOOR(x) ((x) & ~(TRI_ONE-1))
-#define TRI_CEIL(x) (((x) + (TRI_ONE-1)) & ~(TRI_ONE-1))
-#define TRI_ROUND(x) (((x) + TRI_HALF ) & ~(TRI_ONE-1))
-
-#define TRI_ROUDNING (1 << (16 - TRI_FRACTION_BITS - 1))
-#define TRI_FROM_FIXED(x) (((x)+TRI_ROUDNING) >> (16-TRI_FRACTION_BITS))
-
-#define TRI_SNAP_NEXT_HALF(x) (TRI_CEIL((x)+TRI_HALF) - TRI_HALF)
-#define TRI_SNAP_PREV_HALF(x) (TRI_CEIL((x)-TRI_HALF) - TRI_HALF)
-
-// ----------------------------------------------------------------------------
-
-const int GGL_COLOR_BITS = 24;
-
-// To maintain 8-bits color chanels, with a maximum GGLSurface
-// size of 4096 and GGL_SUBPIXEL_BITS=4, we need 8 + 12 + 4 = 24 bits
-// for encoding the color iterators
-
-inline GGLcolor gglFixedToIteratedColor(GGLfixed c) {
- return (c << 8) - c;
-}
-
-// ----------------------------------------------------------------------------
-
-template<bool> struct CTA;
-template<> struct CTA<true> { };
-
-#define GGL_CONTEXT(con, c) context_t *con = static_cast<context_t *>(c)
-#define GGL_OFFSETOF(field) uintptr_t(&(((context_t*)0)->field))
-#define GGL_INIT_PROC(p, f) p.f = ggl_ ## f;
-#define GGL_BETWEEN(x, L, H) (uint32_t((x)-(L)) <= ((H)-(L)))
-
-#define ggl_likely(x) __builtin_expect(!!(x), 1)
-#define ggl_unlikely(x) __builtin_expect(!!(x), 0)
-
-const int GGL_TEXTURE_UNIT_COUNT = 2;
-const int GGL_TMU_STATE = 0x00000001;
-const int GGL_CB_STATE = 0x00000002;
-const int GGL_PIXEL_PIPELINE_STATE = 0x00000004;
-
-// ----------------------------------------------------------------------------
-
-#define GGL_RESERVE_NEEDS(name, l, s) \
- const uint32_t GGL_NEEDS_##name##_MASK = (((1LU<<(s))-1)<<l); \
- const uint32_t GGL_NEEDS_##name##_SHIFT = (l);
-
-#define GGL_BUILD_NEEDS(val, name) \
- (((val)<<(GGL_NEEDS_##name##_SHIFT)) & GGL_NEEDS_##name##_MASK)
-
-#define GGL_READ_NEEDS(name, n) \
- (uint32_t(n & GGL_NEEDS_##name##_MASK) >> GGL_NEEDS_##name##_SHIFT)
-
-#define GGL_NEED_MASK(name) (uint32_t(GGL_NEEDS_##name##_MASK))
-#define GGL_NEED(name, val) GGL_BUILD_NEEDS(val, name)
-
-GGL_RESERVE_NEEDS( CB_FORMAT, 0, 6 )
-GGL_RESERVE_NEEDS( SHADE, 6, 1 )
-GGL_RESERVE_NEEDS( W, 7, 1 )
-GGL_RESERVE_NEEDS( BLEND_SRC, 8, 4 )
-GGL_RESERVE_NEEDS( BLEND_DST, 12, 4 )
-GGL_RESERVE_NEEDS( BLEND_SRCA, 16, 4 )
-GGL_RESERVE_NEEDS( BLEND_DSTA, 20, 4 )
-GGL_RESERVE_NEEDS( LOGIC_OP, 24, 4 )
-GGL_RESERVE_NEEDS( MASK_ARGB, 28, 4 )
-
-GGL_RESERVE_NEEDS( P_ALPHA_TEST, 0, 3 )
-GGL_RESERVE_NEEDS( P_AA, 3, 1 )
-GGL_RESERVE_NEEDS( P_DEPTH_TEST, 4, 3 )
-GGL_RESERVE_NEEDS( P_MASK_Z, 7, 1 )
-GGL_RESERVE_NEEDS( P_DITHER, 8, 1 )
-GGL_RESERVE_NEEDS( P_FOG, 9, 1 )
-GGL_RESERVE_NEEDS( P_RESERVED1, 10,22 )
-
-GGL_RESERVE_NEEDS( T_FORMAT, 0, 6 )
-GGL_RESERVE_NEEDS( T_RESERVED0, 6, 1 )
-GGL_RESERVE_NEEDS( T_POT, 7, 1 )
-GGL_RESERVE_NEEDS( T_S_WRAP, 8, 2 )
-GGL_RESERVE_NEEDS( T_T_WRAP, 10, 2 )
-GGL_RESERVE_NEEDS( T_ENV, 12, 3 )
-GGL_RESERVE_NEEDS( T_LINEAR, 15, 1 )
-
-const int GGL_NEEDS_WRAP_CLAMP_TO_EDGE = 0;
-const int GGL_NEEDS_WRAP_REPEAT = 1;
-const int GGL_NEEDS_WRAP_11 = 2;
-
-inline uint32_t ggl_wrap_to_needs(uint32_t e) {
- switch (e) {
- case GGL_CLAMP: return GGL_NEEDS_WRAP_CLAMP_TO_EDGE;
- case GGL_REPEAT: return GGL_NEEDS_WRAP_REPEAT;
- }
- return 0;
-}
-
-inline uint32_t ggl_blendfactor_to_needs(uint32_t b) {
- if (b <= 1) return b;
- return (b & 0xF)+2;
-}
-
-inline uint32_t ggl_needs_to_blendfactor(uint32_t n) {
- if (n <= 1) return n;
- return (n - 2) + 0x300;
-}
-
-inline uint32_t ggl_env_to_needs(uint32_t e) {
- switch (e) {
- case GGL_REPLACE: return 0;
- case GGL_MODULATE: return 1;
- case GGL_DECAL: return 2;
- case GGL_BLEND: return 3;
- case GGL_ADD: return 4;
- }
- return 0;
-}
-
-inline uint32_t ggl_needs_to_env(uint32_t n) {
- const uint32_t envs[] = { GGL_REPLACE, GGL_MODULATE,
- GGL_DECAL, GGL_BLEND, GGL_ADD };
- return envs[n];
-
-}
-
-// ----------------------------------------------------------------------------
-
-enum {
- GGL_ENABLE_BLENDING = 0x00000001,
- GGL_ENABLE_SMOOTH = 0x00000002,
- GGL_ENABLE_AA = 0x00000004,
- GGL_ENABLE_LOGIC_OP = 0x00000008,
- GGL_ENABLE_ALPHA_TEST = 0x00000010,
- GGL_ENABLE_SCISSOR_TEST = 0x00000020,
- GGL_ENABLE_TMUS = 0x00000040,
- GGL_ENABLE_DEPTH_TEST = 0x00000080,
- GGL_ENABLE_STENCIL_TEST = 0x00000100,
- GGL_ENABLE_W = 0x00000200,
- GGL_ENABLE_DITHER = 0x00000400,
- GGL_ENABLE_FOG = 0x00000800,
- GGL_ENABLE_POINT_AA_NICE= 0x00001000
-};
-
-// ----------------------------------------------------------------------------
-
-class needs_filter_t;
-struct needs_t {
- inline int match(const needs_filter_t& filter);
- inline bool operator == (const needs_t& rhs) const {
- return (n==rhs.n) &&
- (p==rhs.p) &&
- (t[0]==rhs.t[0]) &&
- (t[1]==rhs.t[1]);
- }
- inline bool operator != (const needs_t& rhs) const {
- return !operator == (rhs);
- }
- uint32_t n;
- uint32_t p;
- uint32_t t[GGL_TEXTURE_UNIT_COUNT];
-};
-
-inline int compare_type(const needs_t& lhs, const needs_t& rhs) {
- return memcmp(&lhs, &rhs, sizeof(needs_t));
-}
-
-struct needs_filter_t {
- needs_t value;
- needs_t mask;
-};
-
-int needs_t::match(const needs_filter_t& filter) {
- uint32_t result =
- ((filter.value.n ^ n) & filter.mask.n) |
- ((filter.value.p ^ p) & filter.mask.p) |
- ((filter.value.t[0] ^ t[0]) & filter.mask.t[0]) |
- ((filter.value.t[1] ^ t[1]) & filter.mask.t[1]);
- return (result == 0);
-}
-
-// ----------------------------------------------------------------------------
-
-struct context_t;
-class Assembly;
-
-struct blend_state_t {
- uint32_t src;
- uint32_t dst;
- uint32_t src_alpha;
- uint32_t dst_alpha;
- uint8_t reserved;
- uint8_t alpha_separate;
- uint8_t operation;
- uint8_t equation;
-};
-
-struct mask_state_t {
- uint8_t color;
- uint8_t depth;
- uint32_t stencil;
-};
-
-struct clear_state_t {
- GGLclampx r;
- GGLclampx g;
- GGLclampx b;
- GGLclampx a;
- GGLclampx depth;
- GGLint stencil;
- uint32_t colorPacked;
- uint32_t depthPacked;
- uint32_t stencilPacked;
- uint32_t dirty;
-};
-
-struct fog_state_t {
- uint8_t color[4];
-};
-
-struct logic_op_state_t {
- uint16_t opcode;
-};
-
-struct alpha_test_state_t {
- uint16_t func;
- GGLcolor ref;
-};
-
-struct depth_test_state_t {
- uint16_t func;
- GGLclampx clearValue;
-};
-
-struct scissor_t {
- uint32_t user_left;
- uint32_t user_right;
- uint32_t user_top;
- uint32_t user_bottom;
- uint32_t left;
- uint32_t right;
- uint32_t top;
- uint32_t bottom;
-};
-
-struct pixel_t {
- uint32_t c[4];
- uint8_t s[4];
-};
-
-struct surface_t {
- union {
- GGLSurface s;
- // Keep the following struct field types in line with the corresponding
- // GGLSurface fields to avoid mismatches leading to errors.
- struct {
- GGLsizei reserved;
- GGLuint width;
- GGLuint height;
- GGLint stride;
- GGLubyte* data;
- GGLubyte format;
- GGLubyte dirty;
- GGLubyte pad[2];
- };
- };
- void (*read) (const surface_t* s, context_t* c,
- uint32_t x, uint32_t y, pixel_t* pixel);
- void (*write)(const surface_t* s, context_t* c,
- uint32_t x, uint32_t y, const pixel_t* pixel);
-};
-
-// ----------------------------------------------------------------------------
-
-struct texture_shade_t {
- union {
- struct {
- int32_t is0;
- int32_t idsdx;
- int32_t idsdy;
- int sscale;
- int32_t it0;
- int32_t idtdx;
- int32_t idtdy;
- int tscale;
- };
- struct {
- int32_t v;
- int32_t dx;
- int32_t dy;
- int scale;
- } st[2];
- };
-};
-
-struct texture_iterators_t {
- // these are not encoded in the same way than in the
- // texture_shade_t structure
- union {
- struct {
- GGLfixed ydsdy;
- GGLfixed dsdx;
- GGLfixed dsdy;
- int sscale;
- GGLfixed ydtdy;
- GGLfixed dtdx;
- GGLfixed dtdy;
- int tscale;
- };
- struct {
- GGLfixed ydvdy;
- GGLfixed dvdx;
- GGLfixed dvdy;
- int scale;
- } st[2];
- };
-};
-
-struct texture_t {
- surface_t surface;
- texture_iterators_t iterators;
- texture_shade_t shade;
- uint32_t s_coord;
- uint32_t t_coord;
- uint16_t s_wrap;
- uint16_t t_wrap;
- uint16_t min_filter;
- uint16_t mag_filter;
- uint16_t env;
- uint8_t env_color[4];
- uint8_t enable;
- uint8_t dirty;
-};
-
-struct raster_t {
- GGLfixed x;
- GGLfixed y;
-};
-
-struct framebuffer_t {
- surface_t color;
- surface_t read;
- surface_t depth;
- surface_t stencil;
- int16_t *coverage;
- size_t coverageBufferSize;
-};
-
-// ----------------------------------------------------------------------------
-
-struct iterators_t {
- int32_t xl;
- int32_t xr;
- int32_t y;
- GGLcolor ydady;
- GGLcolor ydrdy;
- GGLcolor ydgdy;
- GGLcolor ydbdy;
- GGLfixed ydzdy;
- GGLfixed ydwdy;
- GGLfixed ydfdy;
-};
-
-struct shade_t {
- GGLcolor a0;
- GGLcolor dadx;
- GGLcolor dady;
- GGLcolor r0;
- GGLcolor drdx;
- GGLcolor drdy;
- GGLcolor g0;
- GGLcolor dgdx;
- GGLcolor dgdy;
- GGLcolor b0;
- GGLcolor dbdx;
- GGLcolor dbdy;
- uint32_t z0;
- GGLfixed32 dzdx;
- GGLfixed32 dzdy;
- GGLfixed w0;
- GGLfixed dwdx;
- GGLfixed dwdy;
- uint32_t f0;
- GGLfixed dfdx;
- GGLfixed dfdy;
-};
-
-// these are used in the generated code
-// we use this mirror structure to improve
-// data locality in the pixel pipeline
-struct generated_tex_vars_t {
- uint32_t width;
- uint32_t height;
- uint32_t stride;
- uintptr_t data;
- int32_t dsdx;
- int32_t dtdx;
- int32_t spill[2];
-};
-
-struct generated_vars_t {
- struct {
- int32_t c;
- int32_t dx;
- } argb[4];
- int32_t aref;
- int32_t dzdx;
- int32_t zbase;
- int32_t f;
- int32_t dfdx;
- int32_t spill[3];
- generated_tex_vars_t texture[GGL_TEXTURE_UNIT_COUNT];
- int32_t rt;
- int32_t lb;
-};
-
-// ----------------------------------------------------------------------------
-
-struct state_t {
- framebuffer_t buffers;
- texture_t texture[GGL_TEXTURE_UNIT_COUNT];
- scissor_t scissor;
- raster_t raster;
- blend_state_t blend;
- alpha_test_state_t alpha_test;
- depth_test_state_t depth_test;
- mask_state_t mask;
- clear_state_t clear;
- fog_state_t fog;
- logic_op_state_t logic_op;
- uint32_t enables;
- uint32_t enabled_tmu;
- needs_t needs;
-};
-
-// ----------------------------------------------------------------------------
-
-struct context_t {
- GGLContext procs;
- state_t state;
- shade_t shade;
- iterators_t iterators;
- generated_vars_t generated_vars __attribute__((aligned(32)));
- uint8_t ditherMatrix[GGL_DITHER_SIZE] __attribute__((aligned(32)));
- uint32_t packed;
- uint32_t packed8888;
- const GGLFormat* formats;
- uint32_t dirty;
- texture_t* activeTMU;
- uint32_t activeTMUIndex;
-
- void (*init_y)(context_t* c, int32_t y);
- void (*step_y)(context_t* c);
- void (*scanline)(context_t* c);
- void (*span)(context_t* c);
- void (*rect)(context_t* c, size_t yc);
-
- void* base;
- Assembly* scanline_as;
- GGLenum error;
-};
-
-// ----------------------------------------------------------------------------
-
-void ggl_init_context(context_t* context);
-void ggl_uninit_context(context_t* context);
-void ggl_error(context_t* c, GGLenum error);
-int64_t ggl_system_time();
-
-// ----------------------------------------------------------------------------
-
-};
-
-#endif // ANDROID_GGL_CONTEXT_H
-
diff --git a/include/private/pixelflinger/ggl_fixed.h b/include/private/pixelflinger/ggl_fixed.h
deleted file mode 100644
index d0493f3..0000000
--- a/include/private/pixelflinger/ggl_fixed.h
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (C) 2005 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_GGL_FIXED_H
-#define ANDROID_GGL_FIXED_H
-
-#include <math.h>
-#include <pixelflinger/pixelflinger.h>
-
-// ----------------------------------------------------------------------------
-
-#define CONST __attribute__((const))
-#define ALWAYS_INLINE __attribute__((always_inline))
-
-const GGLfixed FIXED_BITS = 16;
-const GGLfixed FIXED_EPSILON = 1;
-const GGLfixed FIXED_ONE = 1L<<FIXED_BITS;
-const GGLfixed FIXED_HALF = 1L<<(FIXED_BITS-1);
-const GGLfixed FIXED_MIN = 0x80000000L;
-const GGLfixed FIXED_MAX = 0x7FFFFFFFL;
-
-inline GGLfixed gglIntToFixed(GGLfixed i) ALWAYS_INLINE ;
-inline GGLfixed gglFixedToIntRound(GGLfixed f) ALWAYS_INLINE ;
-inline GGLfixed gglFixedToIntFloor(GGLfixed f) ALWAYS_INLINE ;
-inline GGLfixed gglFixedToIntCeil(GGLfixed f) ALWAYS_INLINE ;
-inline GGLfixed gglFracx(GGLfixed v) ALWAYS_INLINE ;
-inline GGLfixed gglFloorx(GGLfixed v) ALWAYS_INLINE ;
-inline GGLfixed gglCeilx(GGLfixed v) ALWAYS_INLINE ;
-inline GGLfixed gglCenterx(GGLfixed v) ALWAYS_INLINE ;
-inline GGLfixed gglRoundx(GGLfixed v) ALWAYS_INLINE ;
-
-GGLfixed gglIntToFixed(GGLfixed i) {
- return i<<FIXED_BITS;
-}
-GGLfixed gglFixedToIntRound(GGLfixed f) {
- return (f + FIXED_HALF)>>FIXED_BITS;
-}
-GGLfixed gglFixedToIntFloor(GGLfixed f) {
- return f>>FIXED_BITS;
-}
-GGLfixed gglFixedToIntCeil(GGLfixed f) {
- return (f + ((1<<FIXED_BITS) - 1))>>FIXED_BITS;
-}
-
-GGLfixed gglFracx(GGLfixed v) {
- return v & ((1<<FIXED_BITS)-1);
-}
-GGLfixed gglFloorx(GGLfixed v) {
- return gglFixedToIntFloor(v)<<FIXED_BITS;
-}
-GGLfixed gglCeilx(GGLfixed v) {
- return gglFixedToIntCeil(v)<<FIXED_BITS;
-}
-GGLfixed gglCenterx(GGLfixed v) {
- return gglFloorx(v + FIXED_HALF) | FIXED_HALF;
-}
-GGLfixed gglRoundx(GGLfixed v) {
- return gglFixedToIntRound(v)<<FIXED_BITS;
-}
-
-// conversion from (unsigned) int, short, byte to fixed...
-#define GGL_B_TO_X(_x) GGLfixed( ((int32_t(_x)+1)>>1)<<10 )
-#define GGL_S_TO_X(_x) GGLfixed( ((int32_t(_x)+1)>>1)<<2 )
-#define GGL_I_TO_X(_x) GGLfixed( ((int32_t(_x)>>1)+1)>>14 )
-#define GGL_UB_TO_X(_x) GGLfixed( uint32_t(_x) + \
- (uint32_t(_x)<<8) + \
- (uint32_t(_x)>>7) )
-#define GGL_US_TO_X(_x) GGLfixed( (_x) + ((_x)>>15) )
-#define GGL_UI_TO_X(_x) GGLfixed( (((_x)>>1)+1)>>15 )
-
-// ----------------------------------------------------------------------------
-
-GGLfixed gglPowx(GGLfixed x, GGLfixed y) CONST;
-GGLfixed gglSqrtx(GGLfixed a) CONST;
-GGLfixed gglSqrtRecipx(GGLfixed x) CONST;
-GGLfixed gglFastDivx(GGLfixed n, GGLfixed d) CONST;
-int32_t gglMulDivi(int32_t a, int32_t b, int32_t c);
-
-int32_t gglRecipQNormalized(int32_t x, int* exponent);
-int32_t gglRecipQ(GGLfixed x, int q) CONST;
-
-inline GGLfixed gglRecip(GGLfixed x) CONST;
-inline GGLfixed gglRecip(GGLfixed x) {
- return gglRecipQ(x, 16);
-}
-
-inline GGLfixed gglRecip28(GGLfixed x) CONST;
-int32_t gglRecip28(GGLfixed x) {
- return gglRecipQ(x, 28);
-}
-
-// ----------------------------------------------------------------------------
-
-#if defined(__arm__) && !defined(__thumb__)
-
-// inline ARM implementations
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) {
- GGLfixed result, t;
- if (__builtin_constant_p(shift)) {
- asm("smull %[lo], %[hi], %[x], %[y] \n"
- "movs %[lo], %[lo], lsr %[rshift] \n"
- "adc %[lo], %[lo], %[hi], lsl %[lshift] \n"
- : [lo]"=r"(result), [hi]"=r"(t), [x]"=r"(x)
- : "%[x]"(x), [y]"r"(y), [lshift] "I"(32-shift), [rshift] "I"(shift)
- : "cc"
- );
- } else {
- asm("smull %[lo], %[hi], %[x], %[y] \n"
- "movs %[lo], %[lo], lsr %[rshift] \n"
- "adc %[lo], %[lo], %[hi], lsl %[lshift] \n"
- : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
- : "%[x]"(x), [y]"r"(y), [lshift] "r"(32-shift), [rshift] "r"(shift)
- : "cc"
- );
- }
- return result;
-}
-
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) {
- GGLfixed result, t;
- if (__builtin_constant_p(shift)) {
- asm("smull %[lo], %[hi], %[x], %[y] \n"
- "add %[lo], %[a], %[lo], lsr %[rshift] \n"
- "add %[lo], %[lo], %[hi], lsl %[lshift] \n"
- : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
- : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "I"(32-shift), [rshift] "I"(shift)
- );
- } else {
- asm("smull %[lo], %[hi], %[x], %[y] \n"
- "add %[lo], %[a], %[lo], lsr %[rshift] \n"
- "add %[lo], %[lo], %[hi], lsl %[lshift] \n"
- : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
- : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "r"(32-shift), [rshift] "r"(shift)
- );
- }
- return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) {
- GGLfixed result, t;
- if (__builtin_constant_p(shift)) {
- asm("smull %[lo], %[hi], %[x], %[y] \n"
- "rsb %[lo], %[a], %[lo], lsr %[rshift] \n"
- "add %[lo], %[lo], %[hi], lsl %[lshift] \n"
- : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
- : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "I"(32-shift), [rshift] "I"(shift)
- );
- } else {
- asm("smull %[lo], %[hi], %[x], %[y] \n"
- "rsb %[lo], %[a], %[lo], lsr %[rshift] \n"
- "add %[lo], %[lo], %[hi], lsl %[lshift] \n"
- : [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
- : "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "r"(32-shift), [rshift] "r"(shift)
- );
- }
- return result;
-}
-
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y)
-{
- // 64-bits result: r0=low, r1=high
- union {
- struct {
- int32_t lo;
- int32_t hi;
- } s;
- int64_t res;
- };
- asm("smull %0, %1, %2, %3 \n"
- : "=r"(s.lo), "=&r"(s.hi)
- : "%r"(x), "r"(y)
- :
- );
- return res;
-}
-#elif defined(__mips__)
-
-/*inline MIPS implementations*/
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) {
- GGLfixed result,tmp,tmp1,tmp2;
-
- if (__builtin_constant_p(shift)) {
- if (shift == 0) {
- asm ("mult %[a], %[b] \t\n"
- "mflo %[res] \t\n"
- : [res]"=&r"(result),[tmp]"=&r"(tmp)
- : [a]"r"(a),[b]"r"(b)
- : "%hi","%lo"
- );
- } else if (shift == 32)
- {
- asm ("mult %[a], %[b] \t\n"
- "li %[tmp],1\t\n"
- "sll %[tmp],%[tmp],0x1f\t\n"
- "mflo %[res] \t\n"
- "addu %[tmp1],%[tmp],%[res] \t\n"
- "sltu %[tmp1],%[tmp1],%[tmp]\t\n" /*obit*/
- "sra %[tmp],%[tmp],0x1f \t\n"
- "mfhi %[res] \t\n"
- "addu %[res],%[res],%[tmp]\t\n"
- "addu %[res],%[res],%[tmp1]\t\n"
- : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1)
- : [a]"r"(a),[b]"r"(b),[shift]"I"(shift)
- : "%hi","%lo"
- );
- } else if ((shift >0) && (shift < 32))
- {
- asm ("mult %[a], %[b] \t\n"
- "li %[tmp],1 \t\n"
- "sll %[tmp],%[tmp],%[shiftm1] \t\n"
- "mflo %[res] \t\n"
- "addu %[tmp1],%[tmp],%[res] \t\n"
- "sltu %[tmp1],%[tmp1],%[tmp] \t\n" /*obit?*/
- "addu %[res],%[res],%[tmp] \t\n"
- "mfhi %[tmp] \t\n"
- "addu %[tmp],%[tmp],%[tmp1] \t\n"
- "sll %[tmp],%[tmp],%[lshift] \t\n"
- "srl %[res],%[res],%[rshift] \t\n"
- "or %[res],%[res],%[tmp] \t\n"
- : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[lshift]"I"(32-shift),[rshift]"I"(shift),[shiftm1]"I"(shift-1)
- : "%hi","%lo"
- );
- } else {
- asm ("mult %[a], %[b] \t\n"
- "li %[tmp],1 \t\n"
- "sll %[tmp],%[tmp],%[shiftm1] \t\n"
- "mflo %[res] \t\n"
- "addu %[tmp1],%[tmp],%[res] \t\n"
- "sltu %[tmp1],%[tmp1],%[tmp] \t\n" /*obit?*/
- "sra %[tmp2],%[tmp],0x1f \t\n"
- "addu %[res],%[res],%[tmp] \t\n"
- "mfhi %[tmp] \t\n"
- "addu %[tmp],%[tmp],%[tmp2] \t\n"
- "addu %[tmp],%[tmp],%[tmp1] \t\n" /*tmp=hi*/
- "srl %[tmp2],%[res],%[rshift] \t\n"
- "srav %[res], %[tmp],%[rshift]\t\n"
- "sll %[tmp],%[tmp],1 \t\n"
- "sll %[tmp],%[tmp],%[norbits] \t\n"
- "or %[tmp],%[tmp],%[tmp2] \t\n"
- "movz %[res],%[tmp],%[bit5] \t\n"
- : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[norbits]"I"(~(shift)),[rshift]"I"(shift),[shiftm1] "I"(shift-1),[bit5]"I"(shift & 0x20)
- : "%hi","%lo"
- );
- }
- } else {
- asm ("mult %[a], %[b] \t\n"
- "li %[tmp],1 \t\n"
- "sll %[tmp],%[tmp],%[shiftm1] \t\n"
- "mflo %[res] \t\n"
- "addu %[tmp1],%[tmp],%[res] \t\n"
- "sltu %[tmp1],%[tmp1],%[tmp] \t\n" /*obit?*/
- "sra %[tmp2],%[tmp],0x1f \t\n"
- "addu %[res],%[res],%[tmp] \t\n"
- "mfhi %[tmp] \t\n"
- "addu %[tmp],%[tmp],%[tmp2] \t\n"
- "addu %[tmp],%[tmp],%[tmp1] \t\n" /*tmp=hi*/
- "srl %[tmp2],%[res],%[rshift] \t\n"
- "srav %[res], %[tmp],%[rshift]\t\n"
- "sll %[tmp],%[tmp],1 \t\n"
- "sll %[tmp],%[tmp],%[norbits] \t\n"
- "or %[tmp],%[tmp],%[tmp2] \t\n"
- "movz %[res],%[tmp],%[bit5] \t\n"
- : [res]"=&r"(result),[tmp]"=&r"(tmp),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[norbits]"r"(~(shift)),[rshift] "r"(shift),[shiftm1]"r"(shift-1),[bit5] "r"(shift & 0x20)
- : "%hi","%lo"
- );
- }
-
- return result;
-}
-
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
- GGLfixed result,t,tmp1,tmp2;
-
- if (__builtin_constant_p(shift)) {
- if (shift == 0) {
- asm ("mult %[a], %[b] \t\n"
- "mflo %[lo] \t\n"
- "addu %[lo],%[lo],%[c] \t\n"
- : [lo]"=&r"(result)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c)
- : "%hi","%lo"
- );
- } else if (shift == 32) {
- asm ("mult %[a], %[b] \t\n"
- "mfhi %[lo] \t\n"
- "addu %[lo],%[lo],%[c] \t\n"
- : [lo]"=&r"(result)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c)
- : "%hi","%lo"
- );
- } else if ((shift>0) && (shift<32)) {
- asm ("mult %[a], %[b] \t\n"
- "mflo %[res] \t\n"
- "mfhi %[t] \t\n"
- "srl %[res],%[res],%[rshift] \t\n"
- "sll %[t],%[t],%[lshift] \t\n"
- "or %[res],%[res],%[t] \t\n"
- "addu %[res],%[res],%[c] \t\n"
- : [res]"=&r"(result),[t]"=&r"(t)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c),[lshift]"I"(32-shift),[rshift]"I"(shift)
- : "%hi","%lo"
- );
- } else {
- asm ("mult %[a], %[b] \t\n"
- "nor %[tmp1],$zero,%[shift]\t\n"
- "mflo %[res] \t\n"
- "mfhi %[t] \t\n"
- "srl %[res],%[res],%[shift] \t\n"
- "sll %[tmp2],%[t],1 \t\n"
- "sllv %[tmp2],%[tmp2],%[tmp1] \t\n"
- "or %[tmp1],%[tmp2],%[res] \t\n"
- "srav %[res],%[t],%[shift] \t\n"
- "andi %[tmp2],%[shift],0x20\t\n"
- "movz %[res],%[tmp1],%[tmp2]\t\n"
- "addu %[res],%[res],%[c] \t\n"
- : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"I"(shift)
- : "%hi","%lo"
- );
- }
- } else {
- asm ("mult %[a], %[b] \t\n"
- "nor %[tmp1],$zero,%[shift]\t\n"
- "mflo %[res] \t\n"
- "mfhi %[t] \t\n"
- "srl %[res],%[res],%[shift] \t\n"
- "sll %[tmp2],%[t],1 \t\n"
- "sllv %[tmp2],%[tmp2],%[tmp1] \t\n"
- "or %[tmp1],%[tmp2],%[res] \t\n"
- "srav %[res],%[t],%[shift] \t\n"
- "andi %[tmp2],%[shift],0x20\t\n"
- "movz %[res],%[tmp1],%[tmp2]\t\n"
- "addu %[res],%[res],%[c] \t\n"
- : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"r"(shift)
- : "%hi","%lo"
- );
- }
- return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
- GGLfixed result,t,tmp1,tmp2;
-
- if (__builtin_constant_p(shift)) {
- if (shift == 0) {
- asm ("mult %[a], %[b] \t\n"
- "mflo %[lo] \t\n"
- "subu %[lo],%[lo],%[c] \t\n"
- : [lo]"=&r"(result)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c)
- : "%hi","%lo"
- );
- } else if (shift == 32) {
- asm ("mult %[a], %[b] \t\n"
- "mfhi %[lo] \t\n"
- "subu %[lo],%[lo],%[c] \t\n"
- : [lo]"=&r"(result)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c)
- : "%hi","%lo"
- );
- } else if ((shift>0) && (shift<32)) {
- asm ("mult %[a], %[b] \t\n"
- "mflo %[res] \t\n"
- "mfhi %[t] \t\n"
- "srl %[res],%[res],%[rshift] \t\n"
- "sll %[t],%[t],%[lshift] \t\n"
- "or %[res],%[res],%[t] \t\n"
- "subu %[res],%[res],%[c] \t\n"
- : [res]"=&r"(result),[t]"=&r"(t)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c),[lshift]"I"(32-shift),[rshift]"I"(shift)
- : "%hi","%lo"
- );
- } else {
- asm ("mult %[a], %[b] \t\n"
- "nor %[tmp1],$zero,%[shift]\t\n"
- "mflo %[res] \t\n"
- "mfhi %[t] \t\n"
- "srl %[res],%[res],%[shift] \t\n"
- "sll %[tmp2],%[t],1 \t\n"
- "sllv %[tmp2],%[tmp2],%[tmp1] \t\n"
- "or %[tmp1],%[tmp2],%[res] \t\n"
- "srav %[res],%[t],%[shift] \t\n"
- "andi %[tmp2],%[shift],0x20\t\n"
- "movz %[res],%[tmp1],%[tmp2]\t\n"
- "subu %[res],%[res],%[c] \t\n"
- : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"I"(shift)
- : "%hi","%lo"
- );
- }
- } else {
- asm ("mult %[a], %[b] \t\n"
- "nor %[tmp1],$zero,%[shift]\t\n"
- "mflo %[res] \t\n"
- "mfhi %[t] \t\n"
- "srl %[res],%[res],%[shift] \t\n"
- "sll %[tmp2],%[t],1 \t\n"
- "sllv %[tmp2],%[tmp2],%[tmp1] \t\n"
- "or %[tmp1],%[tmp2],%[res] \t\n"
- "srav %[res],%[t],%[shift] \t\n"
- "andi %[tmp2],%[shift],0x20\t\n"
- "movz %[res],%[tmp1],%[tmp2]\t\n"
- "subu %[res],%[res],%[c] \t\n"
- : [res]"=&r"(result),[t]"=&r"(t),[tmp1]"=&r"(tmp1),[tmp2]"=&r"(tmp2)
- : [a]"r"(a),[b]"r"(b),[c]"r"(c),[shift]"r"(shift)
- : "%hi","%lo"
- );
- }
- return result;
-}
-
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y) {
- union {
- struct {
-#if defined(__MIPSEL__)
- int32_t lo;
- int32_t hi;
-#elif defined(__MIPSEB__)
- int32_t hi;
- int32_t lo;
-#endif
- } s;
- int64_t res;
- }u;
- asm("mult %2, %3 \t\n"
- "mfhi %1 \t\n"
- "mflo %0 \t\n"
- : "=r"(u.s.lo), "=&r"(u.s.hi)
- : "%r"(x), "r"(y)
- : "%hi","%lo"
- );
- return u.res;
-}
-
-#elif defined(__aarch64__)
-
-// inline AArch64 implementations
-
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift)
-{
- GGLfixed result;
- GGLfixed round;
-
- asm("mov %x[round], #1 \n"
- "lsl %x[round], %x[round], %x[shift] \n"
- "lsr %x[round], %x[round], #1 \n"
- "smaddl %x[result], %w[x], %w[y],%x[round] \n"
- "lsr %x[result], %x[result], %x[shift] \n"
- : [round]"=&r"(round), [result]"=&r"(result) \
- : [x]"r"(x), [y]"r"(y), [shift] "r"(shift) \
- :
- );
- return result;
-}
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift)
-{
- GGLfixed result;
- asm("smull %x[result], %w[x], %w[y] \n"
- "lsr %x[result], %x[result], %x[shift] \n"
- "add %w[result], %w[result], %w[a] \n"
- : [result]"=&r"(result) \
- : [x]"r"(x), [y]"r"(y), [a]"r"(a), [shift] "r"(shift) \
- :
- );
- return result;
-}
-
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift)
-{
-
- GGLfixed result;
- int rshift;
-
- asm("smull %x[result], %w[x], %w[y] \n"
- "lsr %x[result], %x[result], %x[shift] \n"
- "sub %w[result], %w[result], %w[a] \n"
- : [result]"=&r"(result) \
- : [x]"r"(x), [y]"r"(y), [a]"r"(a), [shift] "r"(shift) \
- :
- );
- return result;
-}
-inline int64_t gglMulii(int32_t x, int32_t y) CONST;
-inline int64_t gglMulii(int32_t x, int32_t y)
-{
- int64_t res;
- asm("smull %x0, %w1, %w2 \n"
- : "=r"(res)
- : "%r"(x), "r"(y)
- :
- );
- return res;
-}
-
-#else // ----------------------------------------------------------------------
-
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) {
- return GGLfixed((int64_t(a)*b + (1<<(shift-1)))>>shift);
-}
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
- return GGLfixed((int64_t(a)*b)>>shift) + c;
-}
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
- return GGLfixed((int64_t(a)*b)>>shift) - c;
-}
-inline int64_t gglMulii(int32_t a, int32_t b) CONST;
-inline int64_t gglMulii(int32_t a, int32_t b) {
- return int64_t(a)*b;
-}
-
-#endif
-
-// ------------------------------------------------------------------------
-
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b) CONST;
-inline GGLfixed gglMulx(GGLfixed a, GGLfixed b) {
- return gglMulx(a, b, 16);
-}
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c) CONST;
-inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c) {
- return gglMulAddx(a, b, c, 16);
-}
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) CONST;
-inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) {
- return gglMulSubx(a, b, c, 16);
-}
-
-// ------------------------------------------------------------------------
-
-inline int32_t gglClz(int32_t x) CONST;
-inline int32_t gglClz(int32_t x)
-{
-#if (defined(__arm__) && !defined(__thumb__)) || defined(__mips__) || defined(__aarch64__)
- return __builtin_clz(x);
-#else
- if (!x) return 32;
- int32_t exp = 31;
- if (x & 0xFFFF0000) { exp -=16; x >>= 16; }
- if (x & 0x0000ff00) { exp -= 8; x >>= 8; }
- if (x & 0x000000f0) { exp -= 4; x >>= 4; }
- if (x & 0x0000000c) { exp -= 2; x >>= 2; }
- if (x & 0x00000002) { exp -= 1; }
- return exp;
-#endif
-}
-
-// ------------------------------------------------------------------------
-
-int32_t gglDivQ(GGLfixed n, GGLfixed d, int32_t i) CONST;
-
-inline int32_t gglDivQ16(GGLfixed n, GGLfixed d) CONST;
-inline int32_t gglDivQ16(GGLfixed n, GGLfixed d) {
- return gglDivQ(n, d, 16);
-}
-
-inline int32_t gglDivx(GGLfixed n, GGLfixed d) CONST;
-inline int32_t gglDivx(GGLfixed n, GGLfixed d) {
- return gglDivQ(n, d, 16);
-}
-
-// ------------------------------------------------------------------------
-
-inline GGLfixed gglRecipFast(GGLfixed x) CONST;
-inline GGLfixed gglRecipFast(GGLfixed x)
-{
- // This is a really bad approximation of 1/x, but it's also
- // very fast. x must be strictly positive.
- // if x between [0.5, 1[ , then 1/x = 3-2*x
- // (we use 2.30 fixed-point)
- const int32_t lz = gglClz(x);
- return (0xC0000000 - (x << (lz - 1))) >> (30-lz);
-}
-
-// ------------------------------------------------------------------------
-
-inline GGLfixed gglClampx(GGLfixed c) CONST;
-inline GGLfixed gglClampx(GGLfixed c)
-{
-#if defined(__thumb__)
- // clamp without branches
- c &= ~(c>>31); c = FIXED_ONE - c;
- c &= ~(c>>31); c = FIXED_ONE - c;
-#else
-#if defined(__arm__)
- // I don't know why gcc thinks its smarter than me! The code below
- // clamps to zero in one instruction, but gcc won't generate it and
- // replace it by a cmp + movlt (it's quite amazing actually).
- asm("bic %0, %1, %1, asr #31\n" : "=r"(c) : "r"(c));
-#elif defined(__aarch64__)
- asm("bic %w0, %w1, %w1, asr #31\n" : "=r"(c) : "r"(c));
-#else
- c &= ~(c>>31);
-#endif
- if (c>FIXED_ONE)
- c = FIXED_ONE;
-#endif
- return c;
-}
-
-// ------------------------------------------------------------------------
-
-#endif // ANDROID_GGL_FIXED_H
diff --git a/include/system/graphics.h b/include/system/graphics.h
index c3fca97..efd48cb 100644
--- a/include/system/graphics.h
+++ b/include/system/graphics.h
@@ -45,9 +45,12 @@ enum {
/*
* "linear" color pixel formats:
*
- * The pixel formats below contain sRGB data but are otherwise treated
- * as linear formats, i.e.: no special operation is performed when
- * reading or writing into a buffer in one of these formats
+ * When used with ANativeWindow, the dataSpace field describes the color
+ * space of the buffer.
+ *
+ * The color space determines, for example, if the formats are linear or
+ * gamma-corrected; or whether any special operations are performed when
+ * reading or writing into a buffer in one of these formats.
*/
HAL_PIXEL_FORMAT_RGBA_8888 = 1,
HAL_PIXEL_FORMAT_RGBX_8888 = 2,
@@ -55,25 +58,8 @@ enum {
HAL_PIXEL_FORMAT_RGB_565 = 4,
HAL_PIXEL_FORMAT_BGRA_8888 = 5,
- /*
- * sRGB color pixel formats:
- *
- * The red, green and blue components are stored in sRGB space, and converted
- * to linear space when read, using the standard sRGB to linear equation:
- *
- * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045
- * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045
- *
- * When written the inverse transformation is performed:
- *
- * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308
- * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308
- *
- *
- * The alpha component, if present, is always stored in linear space and
- * is left unmodified when read or written.
- *
- */
+ // Deprecated sRGB formats for source code compatibility
+ // Not for use in new code
HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC,
HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD,
@@ -111,6 +97,8 @@ enum {
* cr_offset = y_size
* cb_offset = y_size + c_size
*
+ * When used with ANativeWindow, the dataSpace field describes the color
+ * space of the buffer.
*/
HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
@@ -135,6 +123,8 @@ enum {
*
* size = stride * height
*
+ * When used with ANativeWindow, the dataSpace field describes the color
+ * space of the buffer.
*/
HAL_PIXEL_FORMAT_Y8 = 0x20203859,
@@ -159,6 +149,10 @@ enum {
*
* size = stride * height * 2
*
+ * When used with ANativeWindow, the dataSpace field describes the color
+ * space of the buffer, except that dataSpace field
+ * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth
+ * image where each sample is a distance value measured by a depth camera.
*/
HAL_PIXEL_FORMAT_Y16 = 0x20363159,
@@ -167,7 +161,7 @@ enum {
*
* This format is exposed outside of the camera HAL to applications.
*
- * RAW_SENSOR is a single-channel, 16-bit, little endian format, typically
+ * RAW16 is a single-channel, 16-bit, little endian format, typically
* representing raw Bayer-pattern images from an image sensor, with minimal
* processing.
*
@@ -193,9 +187,15 @@ enum {
* - GRALLOC_USAGE_HW_CAMERA_*
* - GRALLOC_USAGE_SW_*
* - GRALLOC_USAGE_RENDERSCRIPT
+ *
+ * When used with ANativeWindow, the dataSpace should be
+ * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
+ * extra metadata to define.
*/
HAL_PIXEL_FORMAT_RAW16 = 0x20,
- HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, // TODO(rubenbrunk): Remove RAW_SENSOR.
+
+ // Temporary alias for source code compatibility; do not use in new code
+ HAL_PIXEL_FORMAT_RAW_SENSOR = HAL_PIXEL_FORMAT_RAW16,
/*
* Android RAW10 format:
@@ -244,6 +244,10 @@ enum {
* - GRALLOC_USAGE_HW_CAMERA_*
* - GRALLOC_USAGE_SW_*
* - GRALLOC_USAGE_RENDERSCRIPT
+ *
+ * When used with ANativeWindow, the dataSpace field should be
+ * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
+ * extra metadata to define.
*/
HAL_PIXEL_FORMAT_RAW10 = 0x25,
@@ -261,6 +265,10 @@ enum {
* - GRALLOC_USAGE_HW_CAMERA_*
* - GRALLOC_USAGE_SW_*
* - GRALLOC_USAGE_RENDERSCRIPT
+ *
+ * When used with ANativeWindow, the dataSpace field should be
+ * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial
+ * extra metadata to define.
*/
HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24,
@@ -276,6 +284,16 @@ enum {
*
* Buffers of this format must have a height of 1, and width equal to their
* size in bytes.
+ *
+ * When used with ANativeWindow, the mapping of the dataSpace field to
+ * buffer contents for BLOB is as follows:
+ *
+ * dataSpace value | Buffer contents
+ * -------------------------------+-----------------------------------------
+ * HAL_DATASPACE_JFIF | An encoded JPEG image
+ * HAL_DATASPACE_DEPTH | An android_depth_points buffer
+ * Other | Unsupported
+ *
*/
HAL_PIXEL_FORMAT_BLOB = 0x21,
@@ -292,6 +310,8 @@ enum {
* framework will assume that sampling the texture will always return an
* alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
*
+ * When used with ANativeWindow, the dataSpace field describes the color
+ * space of the buffer.
*/
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22,
@@ -311,6 +331,9 @@ enum {
*
* This format is locked for use by gralloc's (*lock_ycbcr) method, and
* locking with the (*lock) method will return an error.
+ *
+ * When used with ANativeWindow, the dataSpace field describes the color
+ * space of the buffer.
*/
HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
@@ -355,6 +378,42 @@ struct android_ycbcr {
};
/**
+ * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB
+ * with dataSpace value of HAL_DATASPACE_DEPTH.
+ * When locking a native buffer of the above format and dataSpace value,
+ * the vaddr pointer can be cast to this structure.
+ *
+ * A variable-length list of (x,y,z) 3D points, as floats.
+ *
+ * @num_points is the number of points in the list
+ *
+ * @xyz_points is the flexible array of floating-point values.
+ * It contains (num_points) * 3 floats.
+ *
+ * For example:
+ * android_depth_points d = get_depth_buffer();
+ * struct {
+ * float x; float y; float z;
+ * } firstPoint, lastPoint;
+ *
+ * firstPoint.x = d.xyz_points[0];
+ * firstPoint.y = d.xyz_points[1];
+ * firstPoint.z = d.xyz_points[2];
+ * lastPoint.x = d.xyz_points[(d.num_points - 1) * 3 + 0];
+ * lastPoint.y = d.xyz_points[(d.num_points - 1) * 3 + 1];
+ * lastPoint.z = d.xyz_points[(d.num_points - 1) * 3 + 2];
+ */
+
+struct android_depth_points {
+ uint32_t num_points;
+
+ /** reserved for future use, set to 0 by gralloc's (*lock)() */
+ uint32_t reserved[8];
+
+ float xyz_points[];
+};
+
+/**
* Transformation definitions
*
* IMPORTANT NOTE:
@@ -378,19 +437,33 @@ enum {
};
/**
- * Colorspace Definitions
+ * Dataspace Definitions
* ======================
*
- * Colorspace is the definition of how pixel values should be interpreted.
- * It includes primaries (including white point) and the transfer
- * characteristic function, which describes both gamma curve and numeric
- * range (within the bit depth).
+ * Dataspace is the definition of how pixel values should be interpreted.
+ *
+ * For many formats, this is the colorspace of the image data, which includes
+ * primaries (including white point) and the transfer characteristic function,
+ * which describes both gamma curve and numeric range (within the bit depth).
+ *
+ * Other dataspaces include depth measurement data from a depth camera.
*/
-enum {
+typedef enum android_dataspace {
+ /*
+ * Default-assumption data space, when not explicitly specified.
+ *
+ * It is safest to assume the buffer is an image with sRGB primaries and
+ * encoding ranges, but the consumer and/or the producer of the data may
+ * simply be using defaults. No automatic gamma transform should be
+ * expected, except for a possible display gamma transform when drawn to a
+ * screen.
+ */
+ HAL_DATASPACE_UNKNOWN = 0x0,
+
/*
- * Arbitrary colorspace with manually defined characteristics.
- * Colorspace definition must be communicated separately.
+ * Arbitrary dataspace with manually defined characteristics. Definition
+ * for colorspaces or other meaning must be communicated separately.
*
* This is used when specifying primaries, transfer characteristics,
* etc. separately.
@@ -399,7 +472,57 @@ enum {
* where a colorspace can have separately defined primaries, transfer
* characteristics, etc.
*/
- HAL_COLORSPACE_ARBITRARY = 0x1,
+ HAL_DATASPACE_ARBITRARY = 0x1,
+
+ /*
+ * RGB Colorspaces
+ * -----------------
+ *
+ * Primaries are given using (x,y) coordinates in the CIE 1931 definition
+ * of x and y specified by ISO 11664-1.
+ *
+ * Transfer characteristics are the opto-electronic transfer characteristic
+ * at the source as a function of linear optical intensity (luminance).
+ */
+
+ /*
+ * sRGB linear encoding:
+ *
+ * The red, green, and blue components are stored in sRGB space, but
+ * are linear, not gamma-encoded.
+ * The RGB primaries and the white point are the same as BT.709.
+ *
+ * The values are encoded using the full range ([0,255] for 8-bit) for all
+ * components.
+ */
+ HAL_DATASPACE_SRGB_LINEAR = 0x200,
+
+ /*
+ * sRGB gamma encoding:
+ *
+ * The red, green and blue components are stored in sRGB space, and
+ * converted to linear space when read, using the standard sRGB to linear
+ * equation:
+ *
+ * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045
+ * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045
+ *
+ * When written the inverse transformation is performed:
+ *
+ * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308
+ * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308
+ *
+ *
+ * The alpha component, if present, is always stored in linear space and
+ * is left unmodified when read or written.
+ *
+ * The RGB primaries and the white point are the same as BT.709.
+ *
+ * The values are encoded using the full range ([0,255] for 8-bit) for all
+ * components.
+ *
+ */
+ HAL_DATASPACE_SRGB = 0x201,
/*
* YCbCr Colorspaces
@@ -429,7 +552,7 @@ enum {
* red 0.640 0.330
* white (D65) 0.3127 0.3290
*/
- HAL_COLORSPACE_JFIF = 0x101,
+ HAL_DATASPACE_JFIF = 0x101,
/*
* ITU-R Recommendation 601 (BT.601) - 625-line
@@ -456,7 +579,7 @@ enum {
* red 0.640 0.330
* white (D65) 0.3127 0.3290
*/
- HAL_COLORSPACE_BT601_625 = 0x102,
+ HAL_DATASPACE_BT601_625 = 0x102,
/*
* ITU-R Recommendation 601 (BT.601) - 525-line
@@ -483,7 +606,7 @@ enum {
* red 0.630 0.340
* white (D65) 0.3127 0.3290
*/
- HAL_COLORSPACE_BT601_525 = 0x103,
+ HAL_DATASPACE_BT601_525 = 0x103,
/*
* ITU-R Recommendation 709 (BT.709)
@@ -504,8 +627,20 @@ enum {
* red 0.640 0.330
* white (D65) 0.3127 0.3290
*/
- HAL_COLORSPACE_BT709 = 0x104,
-};
+ HAL_DATASPACE_BT709 = 0x104,
+
+ /*
+ * The buffer contains depth ranging measurements from a depth camera.
+ * This value is valid with formats:
+ * HAL_PIXEL_FORMAT_Y16: 16-bit single channel depth image.
+ * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as
+ * a variable-length float (x,y,z) coordinate point list.
+ * The point cloud will be represented with the android_depth_points
+ * structure.
+ */
+ HAL_DATASPACE_DEPTH = 0x1000
+
+} android_dataspace_t;
#ifdef __cplusplus
}
diff --git a/include/system/window.h b/include/system/window.h
index bf93b79..a875427 100644
--- a/include/system/window.h
+++ b/include/system/window.h
@@ -262,6 +262,12 @@ enum {
* the aspect ratio of the buffers produced.
*/
NATIVE_WINDOW_STICKY_TRANSFORM = 11,
+
+ /**
+ * The default data space for the buffers as set by the consumer.
+ * The values are defined in graphics.h.
+ */
+ NATIVE_WINDOW_DEFAULT_DATASPACE = 12
};
/* Valid operations for the (*perform)() hook.
@@ -294,6 +300,8 @@ enum {
NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */
NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */
NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18,
+ NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19,
+ NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */
};
/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */
@@ -486,30 +494,12 @@ struct ANativeWindow
* DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions
* defined below.
*
- * (*perform)() returns -ENOENT if the 'what' parameter is not supported
- * by the surface's implementation.
- *
- * The valid operations are:
- * NATIVE_WINDOW_SET_USAGE
- * NATIVE_WINDOW_CONNECT (deprecated)
- * NATIVE_WINDOW_DISCONNECT (deprecated)
- * NATIVE_WINDOW_SET_CROP (private)
- * NATIVE_WINDOW_SET_BUFFER_COUNT
- * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated)
- * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM
- * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP
- * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS
- * NATIVE_WINDOW_SET_BUFFERS_FORMAT
- * NATIVE_WINDOW_SET_SCALING_MODE (private)
- * NATIVE_WINDOW_LOCK (private)
- * NATIVE_WINDOW_UNLOCK_AND_POST (private)
- * NATIVE_WINDOW_API_CONNECT (private)
- * NATIVE_WINDOW_API_DISCONNECT (private)
- * NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS (private)
- * NATIVE_WINDOW_SET_POST_TRANSFORM_CROP (private)
+ * (*perform)() returns -ENOENT if the 'what' parameter is not supported
+ * by the surface's implementation.
*
+ * See above for a list of valid operations, such as
+ * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT
*/
-
int (*perform)(struct ANativeWindow* window,
int operation, ... );
@@ -799,6 +789,26 @@ static inline int native_window_set_buffers_format(
}
/*
+ * native_window_set_buffers_data_space(..., int dataSpace)
+ * All buffers queued after this call will be associated with the dataSpace
+ * parameter specified.
+ *
+ * dataSpace specifies additional information about the buffer that's dependent
+ * on the buffer format and the endpoints. For example, it can be used to convey
+ * the color space of the image data in the buffer, or it can be used to
+ * indicate that the buffers contain depth measurement data instead of color
+ * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been
+ * overridden by the consumer.
+ */
+static inline int native_window_set_buffers_data_space(
+ struct ANativeWindow* window,
+ android_dataspace_t dataSpace)
+{
+ return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE,
+ dataSpace);
+}
+
+/*
* native_window_set_buffers_transform(..., int transform)
* All buffers queued after this call will be displayed transformed according
* to the transform parameter specified.
@@ -906,6 +916,30 @@ static inline int native_window_set_sideband_stream(
sidebandHandle);
}
+/*
+ * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects)
+ * Set the surface damage (i.e., the region of the surface that has changed
+ * since the previous frame). The damage set by this call will be reset (to the
+ * default of full-surface damage) after calling queue, so this must be called
+ * prior to every frame with damage that does not cover the whole surface if the
+ * caller desires downstream consumers to use this optimization.
+ *
+ * The damage region is specified as an array of rectangles, with the important
+ * caveat that the origin of the surface is considered to be the bottom-left
+ * corner, as in OpenGL ES.
+ *
+ * If numRects is set to 0, rects may be NULL, and the surface damage will be
+ * set to the full surface (the same as if this function had not been called for
+ * this frame).
+ */
+static inline int native_window_set_surface_damage(
+ struct ANativeWindow* window,
+ const android_native_rect_t* rects, size_t numRects)
+{
+ return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE,
+ rects, numRects);
+}
+
__END_DECLS
#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */
diff --git a/include/sysutils/NetlinkEvent.h b/include/sysutils/NetlinkEvent.h
index c345cdb..4fa49c5 100644
--- a/include/sysutils/NetlinkEvent.h
+++ b/include/sysutils/NetlinkEvent.h
@@ -57,6 +57,7 @@ public:
bool parseIfInfoMessage(const struct nlmsghdr *nh);
bool parseIfAddrMessage(const struct nlmsghdr *nh);
bool parseUlogPacketMessage(const struct nlmsghdr *nh);
+ bool parseNfPacketMessage(struct nlmsghdr *nh);
bool parseRtMessage(const struct nlmsghdr *nh);
bool parseNdUserOptMessage(const struct nlmsghdr *nh);
};
diff --git a/include/sysutils/NetlinkListener.h b/include/sysutils/NetlinkListener.h
index 6e52c3b..82465d6 100644
--- a/include/sysutils/NetlinkListener.h
+++ b/include/sysutils/NetlinkListener.h
@@ -27,6 +27,7 @@ class NetlinkListener : public SocketListener {
public:
static const int NETLINK_FORMAT_ASCII = 0;
static const int NETLINK_FORMAT_BINARY = 1;
+ static const int NETLINK_FORMAT_BINARY_UNICAST = 2;
#if 1
/* temporary version until we can get Motorola to update their
diff --git a/include/utils/AndroidThreads.h b/include/utils/AndroidThreads.h
index 4eee14d..aad1e82 100644
--- a/include/utils/AndroidThreads.h
+++ b/include/utils/AndroidThreads.h
@@ -20,7 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
# include <pthread.h>
#endif
@@ -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..7d96310 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,20 +29,35 @@ 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 defined(_WIN32)
+#define O_CLOEXEC O_NOINHERIT
+#define O_NOFOLLOW 0
+#define DEFFILEMODE 0666
+#endif /* _WIN32 */
+
+#if defined(_WIN32)
+#define ZD "%ld"
+#define ZD_TYPE long
+#else
+#define ZD "%zd"
+#define ZD_TYPE ssize_t
+#endif
-#if HAVE_PRINTF_ZD
-# define ZD "%zd"
-# define ZD_TYPE ssize_t
+/*
+ * Needed for cases where something should be constexpr if possible, but not
+ * being constexpr is fine if in pre-C++11 code (such as a const static float
+ * member variable).
+ */
+#if __cplusplus >= 201103L
+#define CONSTEXPR constexpr
#else
-# define ZD "%ld"
-# define ZD_TYPE long
+#define CONSTEXPR
#endif
/*
diff --git a/include/utils/Condition.h b/include/utils/Condition.h
index 1c99d1a..5a72519 100644
--- a/include/utils/Condition.h
+++ b/include/utils/Condition.h
@@ -21,7 +21,7 @@
#include <sys/types.h>
#include <time.h>
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
# include <pthread.h>
#endif
@@ -74,7 +74,7 @@ public:
void broadcast();
private:
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
pthread_cond_t mCond;
#else
void* mState;
@@ -83,7 +83,7 @@ private:
// ---------------------------------------------------------------------------
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
inline Condition::Condition() {
pthread_cond_init(&mCond, NULL);
@@ -113,15 +113,15 @@ inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) {
return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts);
#else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
struct timespec ts;
-#if defined(HAVE_POSIX_CLOCKS)
+#if defined(__linux__)
clock_gettime(CLOCK_REALTIME, &ts);
-#else // HAVE_POSIX_CLOCKS
+#else // __APPLE__
// we don't support the clocks here.
struct timeval t;
gettimeofday(&t, NULL);
ts.tv_sec = t.tv_sec;
ts.tv_nsec= t.tv_usec*1000;
-#endif // HAVE_POSIX_CLOCKS
+#endif
ts.tv_sec += reltime/1000000000;
ts.tv_nsec+= reltime%1000000000;
if (ts.tv_nsec >= 1000000000) {
@@ -149,7 +149,7 @@ inline void Condition::broadcast() {
pthread_cond_broadcast(&mCond);
}
-#endif // HAVE_PTHREADS
+#endif // !defined(_WIN32)
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/include/utils/Endian.h b/include/utils/Endian.h
index 19f2504..591cae0 100644
--- a/include/utils/Endian.h
+++ b/include/utils/Endian.h
@@ -20,21 +20,16 @@
#ifndef _LIBS_UTILS_ENDIAN_H
#define _LIBS_UTILS_ENDIAN_H
-#if defined(HAVE_ENDIAN_H)
-
-#include <endian.h>
-
-#else /*not HAVE_ENDIAN_H*/
+#if defined(__APPLE__) || defined(_WIN32)
#define __BIG_ENDIAN 0x1000
#define __LITTLE_ENDIAN 0x0001
+#define __BYTE_ORDER __LITTLE_ENDIAN
-#if defined(HAVE_LITTLE_ENDIAN)
-# define __BYTE_ORDER __LITTLE_ENDIAN
#else
-# define __BYTE_ORDER __BIG_ENDIAN
-#endif
-#endif /*not HAVE_ENDIAN_H*/
+#include <endian.h>
+
+#endif
#endif /*_LIBS_UTILS_ENDIAN_H*/
diff --git a/include/utils/FileMap.h b/include/utils/FileMap.h
index dfe6d51..f70fc92 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
@@ -59,6 +63,8 @@ public:
bool create(const char* origFileName, int fd,
off64_t offset, size_t length, bool readOnly);
+ ~FileMap(void);
+
/*
* Return the name of the file this map came from, if known.
*/
@@ -80,19 +86,6 @@ public:
off64_t getDataOffset(void) const { return mDataOffset; }
/*
- * Get a "copy" of the object.
- */
- FileMap* acquire(void) { mRefCount++; return this; }
-
- /*
- * Call this when mapping is no longer needed.
- */
- void release(void) {
- if (--mRefCount <= 0)
- delete this;
- }
-
- /*
* This maps directly to madvise() values, but allows us to avoid
* including <sys/mman.h> everywhere.
*/
@@ -108,22 +101,19 @@ public:
int advise(MapAdvice advice);
protected:
- // don't delete objects; call release()
- ~FileMap(void);
private:
// these are not implemented
FileMap(const FileMap& src);
const FileMap& operator=(const FileMap& src);
- int mRefCount; // reference count
char* mFileName; // original file name, if known
void* mBasePtr; // base of mmap area; page aligned
size_t mBaseLength; // length, measured from "mBasePtr"
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/Mutex.h b/include/utils/Mutex.h
index dd201c8..757519b 100644
--- a/include/utils/Mutex.h
+++ b/include/utils/Mutex.h
@@ -21,11 +21,12 @@
#include <sys/types.h>
#include <time.h>
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
# include <pthread.h>
#endif
#include <utils/Errors.h>
+#include <utils/Timers.h>
// ---------------------------------------------------------------------------
namespace android {
@@ -45,7 +46,7 @@ public:
PRIVATE = 0,
SHARED = 1
};
-
+
Mutex();
Mutex(const char* name);
Mutex(int type, const char* name = NULL);
@@ -58,6 +59,16 @@ public:
// lock if possible; returns 0 on success, error otherwise
status_t tryLock();
+#if HAVE_ANDROID_OS
+ // lock the mutex, but don't wait longer than timeoutMilliseconds.
+ // Returns 0 on success, TIMED_OUT for failure due to timeout expiration.
+ //
+ // OSX doesn't have pthread_mutex_timedlock() or equivalent. To keep
+ // capabilities consistent across host OSes, this method is only available
+ // when building Android binaries.
+ status_t timedLock(nsecs_t timeoutMilliseconds);
+#endif
+
// Manages the mutex automatically. It'll be locked when Autolock is
// constructed and released when Autolock goes out of scope.
class Autolock {
@@ -71,12 +82,12 @@ public:
private:
friend class Condition;
-
+
// A mutex cannot be copied
Mutex(const Mutex&);
Mutex& operator = (const Mutex&);
-
-#if defined(HAVE_PTHREADS)
+
+#if !defined(_WIN32)
pthread_mutex_t mMutex;
#else
void _init();
@@ -86,7 +97,7 @@ private:
// ---------------------------------------------------------------------------
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
inline Mutex::Mutex() {
pthread_mutex_init(&mMutex, NULL);
@@ -117,8 +128,17 @@ inline void Mutex::unlock() {
inline status_t Mutex::tryLock() {
return -pthread_mutex_trylock(&mMutex);
}
+#if HAVE_ANDROID_OS
+inline status_t Mutex::timedLock(nsecs_t timeoutNs) {
+ const struct timespec ts = {
+ /* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
+ /* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
+ };
+ return -pthread_mutex_timedlock(&mMutex, &ts);
+}
+#endif
-#endif // HAVE_PTHREADS
+#endif // !defined(_WIN32)
// ---------------------------------------------------------------------------
@@ -127,7 +147,7 @@ inline status_t Mutex::tryLock() {
* When the function returns, it will go out of scope, and release the
* mutex.
*/
-
+
typedef Mutex::Autolock AutoMutex;
// ---------------------------------------------------------------------------
diff --git a/include/utils/RWLock.h b/include/utils/RWLock.h
index 90beb5f..e743b1c 100644
--- a/include/utils/RWLock.h
+++ b/include/utils/RWLock.h
@@ -20,7 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
# include <pthread.h>
#endif
@@ -31,7 +31,7 @@
namespace android {
// ---------------------------------------------------------------------------
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
/*
* Simple mutex class. The implementation is system-dependent.
@@ -117,7 +117,7 @@ inline void RWLock::unlock() {
pthread_rwlock_unlock(&mRWLock);
}
-#endif // HAVE_PTHREADS
+#endif // !defined(_WIN32)
// ---------------------------------------------------------------------------
}; // namespace android
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/Singleton.h b/include/utils/Singleton.h
index c60680e..ffc03cb 100644
--- a/include/utils/Singleton.h
+++ b/include/utils/Singleton.h
@@ -65,9 +65,10 @@ private:
*/
#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \
- template<> Mutex Singleton< TYPE >::sLock(Mutex::PRIVATE); \
- template<> TYPE* Singleton< TYPE >::sInstance(0); \
- template class Singleton< TYPE >;
+ template<> ::android::Mutex \
+ (::android::Singleton< TYPE >::sLock)(::android::Mutex::PRIVATE); \
+ template<> TYPE* ::android::Singleton< TYPE >::sInstance(0); \
+ template class ::android::Singleton< TYPE >;
// ---------------------------------------------------------------------------
diff --git a/include/utils/Thread.h b/include/utils/Thread.h
index df30611..28839fd 100644
--- a/include/utils/Thread.h
+++ b/include/utils/Thread.h
@@ -21,7 +21,7 @@
#include <sys/types.h>
#include <time.h>
-#if defined(HAVE_PTHREADS)
+#if !defined(_WIN32)
# include <pthread.h>
#endif
@@ -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/Timers.h b/include/utils/Timers.h
index d015421..54ec474 100644
--- a/include/utils/Timers.h
+++ b/include/utils/Timers.h
@@ -24,6 +24,8 @@
#include <sys/types.h>
#include <sys/time.h>
+#include <utils/Compat.h>
+
// ------------------------------------------------------------------
// C API
@@ -33,46 +35,46 @@ extern "C" {
typedef int64_t nsecs_t; // nano-seconds
-static inline nsecs_t seconds_to_nanoseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t seconds_to_nanoseconds(nsecs_t secs)
{
return secs*1000000000;
}
-static inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs)
{
return secs*1000000;
}
-static inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs)
{
return secs*1000;
}
-static inline nsecs_t nanoseconds_to_seconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t nanoseconds_to_seconds(nsecs_t secs)
{
return secs/1000000000;
}
-static inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs)
{
return secs/1000000;
}
-static inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs)
{
return secs/1000;
}
-static inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);}
-static inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);}
-static inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);}
-static inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);}
-static inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);}
-static inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);}
+static CONSTEXPR inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);}
+static CONSTEXPR inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);}
+static CONSTEXPR inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);}
+static CONSTEXPR inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);}
+static CONSTEXPR inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);}
+static CONSTEXPR inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);}
-static inline nsecs_t seconds(nsecs_t v) { return s2ns(v); }
-static inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); }
-static inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); }
+static CONSTEXPR inline nsecs_t seconds(nsecs_t v) { return s2ns(v); }
+static CONSTEXPR inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); }
+static CONSTEXPR inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); }
enum {
SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock
diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h
index 5b98de2..b76a5e2 100644
--- a/include/utils/Unicode.h
+++ b/include/utils/Unicode.h
@@ -22,12 +22,6 @@
extern "C" {
-// Definitions exist in C++11
-#if defined __cplusplus && __cplusplus < 201103L
-typedef uint32_t char32_t;
-typedef uint16_t char16_t;
-#endif
-
// Standard string functions on char16_t strings.
int strcmp16(const char16_t *, const char16_t *);
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);
diff --git a/include/ziparchive/zip_archive.h b/include/ziparchive/zip_archive.h
index 1877494..386a390 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)) {}
};
/*
@@ -92,6 +101,9 @@ int32_t OpenArchive(const char* fileName, ZipArchiveHandle* handle);
* Sets handle to the value of the opaque handle for this file descriptor.
* This handle must be released by calling CloseArchive with this handle.
*
+ * If assume_ownership parameter is 'true' calling CloseArchive will close
+ * the file.
+ *
* This function maps and scans the central directory and builds a table
* of entries for future lookups.
*
@@ -100,7 +112,7 @@ int32_t OpenArchive(const char* fileName, ZipArchiveHandle* handle);
* Returns 0 on success, and negative values on failure.
*/
int32_t OpenArchiveFd(const int fd, const char* debugFileName,
- ZipArchiveHandle *handle);
+ ZipArchiveHandle *handle, bool assume_ownership = true);
/*
* Close archive, releasing resources associated with it. This will
@@ -124,24 +136,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 +164,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
diff --git a/include/zipfile/zipfile.h b/include/zipfile/zipfile.h
deleted file mode 100644
index 0ae4ee4..0000000
--- a/include/zipfile/zipfile.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 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 _ZIPFILE_ZIPFILE_H
-#define _ZIPFILE_ZIPFILE_H
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void* zipfile_t;
-typedef void* zipentry_t;
-
-// Provide a buffer. Returns NULL on failure.
-zipfile_t init_zipfile(const void* data, size_t size);
-
-// Release the zipfile resources.
-void release_zipfile(zipfile_t file);
-
-// Get a named entry object. Returns NULL if it doesn't exist
-// or if we won't be able to decompress it. The zipentry_t is
-// freed by release_zipfile()
-zipentry_t lookup_zipentry(zipfile_t file, const char* entryName);
-
-// Return the size of the entry.
-size_t get_zipentry_size(zipentry_t entry);
-
-// return the filename of this entry, you own the memory returned
-char* get_zipentry_name(zipentry_t entry);
-
-// The buffer must be 1.001 times the buffer size returned
-// by get_zipentry_size. Returns nonzero on failure.
-int decompress_zipentry(zipentry_t entry, void* buf, int bufsize);
-
-// iterate through the entries in the zip file. pass a pointer to
-// a void* initialized to NULL to start. Returns NULL when done
-zipentry_t iterate_zipfile(zipfile_t file, void** cookie);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _ZIPFILE_ZIPFILE_H