diff options
Diffstat (limited to 'include')
51 files changed, 2563 insertions, 3308 deletions
diff --git a/include/arch/darwin-x86/AndroidConfig.h b/include/arch/darwin-x86/AndroidConfig.h deleted file mode 100644 index c8ccc7e..0000000 --- a/include/arch/darwin-x86/AndroidConfig.h +++ /dev/null @@ -1,308 +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. - */ - -/* - * Android config -- "Darwin". Used for X86 Mac OS X. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have the futex syscall? - */ - -/* #define HAVE_FUTEX */ - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -/* #define HAVE_OOM_ADJ */ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_MACOSX_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP - -/* - * Define this if you have <termio.h> - */ -#define HAVE_TERMIO_H - -/* - * Define this if you have <sys/sendfile.h> - */ -/* #define HAVE_SYS_SENDFILE_H 1 */ - -/* - * Define this if you build against MSVCRT.DLL - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS - -/* - * Define this if we have localtime_r(). - */ -#define HAVE_LOCALTIME_R - -/* - * Define this if we have gethostbyname_r(). - */ -/* #define HAVE_GETHOSTBYNAME_R */ - -/* - * Define this if we have ioctl(). - */ -/* #define HAVE_IOCTL */ - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - */ -/* #define HAVE_POSIX_CLOCKS */ - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -/* #define HAVE_TIMEDWAIT_MONOTONIC */ - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#if (defined(__ppc__) || defined(__ppc64__)) -# define HAVE_BIG_ENDIAN -#elif (defined(__i386__) || defined(__x86_64__)) -# define HAVE_LITTLE_ENDIAN -#endif - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE 1 - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -/* #define HAVE_OFF64_T */ - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 0 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 0 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -/* #define HAVE_GETTID */ - - -/* - * Add any extra platform-specific defines here. - */ -#define _THREAD_SAFE - -/* - * Define if we have <malloc.h> header - */ -/* #define HAVE_MALLOC_H */ - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if we include <sys/mount.h> for statfs() - */ -#define INCLUDE_SYS_MOUNT_FOR_STATFS 1 - -/* - * What CPU architecture does this platform use? - */ -#if (defined(__ppc__) || defined(__ppc64__)) -# define ARCH_PPC -#elif (defined(__i386__) || defined(__x86_64__)) -# define ARCH_X86 -#endif - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.dylib" - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE char * - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - * - * For tools apps, we'll treat is as not case sensitive. - */ -/* #define OS_CASE_SENSITIVE */ - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -#define HAVE_STRLCPY 1 - -/* - * Define if the open_memstream() function exists on the system. - */ -/* #define HAVE_OPEN_MEMSTREAM 1 */ - -/* - * Define if the BSD funopen() function exists on the system. - */ -#define HAVE_FUNOPEN 1 - -/* - * Define if writev() exists - */ -#define HAVE_WRITEV 1 - -/* - * Define if <stdint.h> exists. - */ -#define HAVE_STDINT_H 1 - -/* - * Define if <stdbool.h> exists. - */ -#define HAVE_STDBOOL_H 1 - -/* - * Define if <sched.h> exists. - */ -#define HAVE_SCHED_H 1 - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 - -/* - * Define if we have st_mtim in struct stat - */ -#define HAVE_STAT_ST_MTIM 1 - -/* - * Define if printf() supports %zd for size_t arguments - */ -#define HAVE_PRINTF_ZD 1 - -#endif /*_ANDROID_CONFIG_H*/ diff --git a/include/arch/freebsd-x86/AndroidConfig.h b/include/arch/freebsd-x86/AndroidConfig.h deleted file mode 100644 index d828bd5..0000000 --- a/include/arch/freebsd-x86/AndroidConfig.h +++ /dev/null @@ -1,366 +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. - */ - -/* - * Android config -- "FreeBSD". Used for desktop x86 FreeBSD. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * make sure we are building for FreeBSD - */ -#ifndef OS_FREEBSD -#define OS_FREEBSD -#endif -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have the futex syscall? - */ -/* #define HAVE_FUTEX */ - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -/* #define HAVE_OOM_ADJ */ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_SYSV_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP - -/* - * Define this if you have <termio.h> - */ -/* #define HAVE_TERMIO_H */ - -/* - * Define this if you have <sys/sendfile.h> - */ -/* #define HAVE_SYS_SENDFILE_H 1 */ - -/* - * Define this if you build against MSVCRT.DLL - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS - -/* - * Define this if we have localtime_r(). - */ -#define HAVE_LOCALTIME_R - -/* - * Define this if we have gethostbyname_r(). - */ -/* #define HAVE_GETHOSTBYNAME_R */ - -/* - * Define this if we have ioctl(). - */ -#define HAVE_IOCTL - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - * - * Desktop Linux has this in librt, but it's broken in goobuntu, yielding - * mildly or wildly inaccurate results. - */ -#define HAVE_POSIX_CLOCKS - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -/* #define HAVE_TIMEDWAIT_MONOTONIC */ - -/* - * Define this if we have linux style epoll() - */ -/* #define HAVE_EPOLL */ - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -/* #define HAVE_ENDIAN_H */ -#define HAVE_LITTLE_ENDIAN - -/* - * Define this if you have sys/endian.h - * NOTE: mutually exclusive with HAVE_ENDIAN_H - */ -#define HAVE_SYS_ENDIAN_H - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE 1 - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -/* #define HAVE_OFF64_T */ - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 0 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 1 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -/* #define HAVE_GETTID */ - -/* - * Defined if we have the sched_setscheduler() call - */ -#define HAVE_SCHED_SETSCHEDULER - -/* - * Add any extra platform-specific defines here. - */ - -/* - * Define if we have <malloc.h> header - */ -#define HAVE_MALLOC_H - -/* - * Define if we have Linux-style non-filesystem Unix Domain Sockets - */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_X86 - - -/* - * Define if we have Linux's inotify in <sys/inotify.h>. - */ -/*#define HAVE_INOTIFY 1*/ - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if libc includes Android system properties implementation. - */ -/* #define HAVE_LIBC_SYSTEM_PROPERTIES */ - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -#define HAVE_SYSTEM_PROPERTY_SERVER - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE char * - -/* - * Do we have the sigaction flag SA_NOCLDWAIT? - */ -#define HAVE_SA_NOCLDWAIT - -/* - * Define if we include <sys/mount.h> for statfs() - */ -#define INCLUDE_SYS_MOUNT_FOR_STATFS 1 - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - */ -#define OS_CASE_SENSITIVE - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -#define HAVE_STRLCPY 1 - -/* - * Define if the open_memstream() function exists on the system. - */ -/* #define HAVE_OPEN_MEMSTREAM 1 */ - -/* - * Define if the BSD funopen() function exists on the system. - */ -#define HAVE_FUNOPEN 1 - -/* - * Define if prctl() exists - */ -/* #define HAVE_PRCTL 1 */ - -/* - * Define if writev() exists - */ -#define HAVE_WRITEV 1 - -/* - * Define if <alloca.h> does not exist - * NOTE: <alloca.h> defines alloca() which - * on FreeBSD is defined in <stdlib.h> - */ -#define HAVE_NO_ALLOCA_H - -/* - * Defines CLOCK_PROCESS_CPUTIME_ID for clock_gettime() - * XXX: CLOCK_PROF seems to be commonly used replacement - */ -#ifndef CLOCK_PROCESS_CPUTIME_ID -#define CLOCK_PROCESS_CPUTIME_ID CLOCK_PROF -#endif - -/* - * Define if <stdint.h> exists. - */ -/* #define HAVE_STDINT_H */ - -/* - * Define if <stdbool.h> exists. - */ -/* #define HAVE_STDBOOL_H */ - -/* - * Define if <sched.h> exists. - */ -#define HAVE_SCHED_H 1 - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 -/* - * Define if we have st_mtim in struct stat - */ -#define HAVE_STAT_ST_MTIM 1 - -/* - * Define if printf() supports %zd for size_t arguments - */ -#define HAVE_PRINTF_ZD 1 - -#endif /*_ANDROID_CONFIG_H*/ diff --git a/include/arch/linux-arm/AndroidConfig.h b/include/arch/linux-arm/AndroidConfig.h deleted file mode 100644 index cae112b..0000000 --- a/include/arch/linux-arm/AndroidConfig.h +++ /dev/null @@ -1,364 +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. - */ - -/* - * Android config -- "android-arm". Used for ARM device builds. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have pthread_setname_np()? - * - * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with - * the same name but different parameters, so we can't use that here.) - */ -#define HAVE_ANDROID_PTHREAD_SETNAME_NP - -/* - * Do we have the futex syscall? - */ -#define HAVE_FUTEX - -/* - * Define if we already have the futex wrapper functions defined. Yes if - * compiling against bionic. - */ -#define HAVE_FUTEX_WRAPPERS 1 - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -#define HAVE_OOM_ADJ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_ANDROID_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP - -/* - * Define this if you have <termio.h> - */ -#define HAVE_TERMIO_H - -/* - * Define this if you have <sys/sendfile.h> - */ -#define HAVE_SYS_SENDFILE_H 1 - -/* - * Define this if you build against MSVCRT.DLL - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS - -/* - * Define this if we have localtime_r(). - */ -/* #define HAVE_LOCALTIME_R */ - -/* - * Define this if we have gethostbyname_r(). - */ -/* #define HAVE_GETHOSTBYNAME_R */ - -/* - * Define this if we have ioctl(). - */ -#define HAVE_IOCTL - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - */ -#define HAVE_POSIX_CLOCKS - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -#define HAVE_TIMEDWAIT_MONOTONIC - -/* - * Define this if we have linux style epoll() - */ -#define HAVE_EPOLL - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#define HAVE_ENDIAN_H -#define HAVE_LITTLE_ENDIAN - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -/* #define _FILE_OFFSET_BITS 64 */ -/* #define _LARGEFILE_SOURCE 1 */ - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -#define HAVE_OFF64_T - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 0 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 1 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -#define HAVE_GETTID - -/* - * Defined if we have the sched_setscheduler() call - */ -#define HAVE_SCHED_SETSCHEDULER - -/* - * Add any extra platform-specific defines here. - */ -#ifndef __linux__ -#define __linux__ -#endif - -/* - * Define if we have <malloc.h> header - */ -#define HAVE_MALLOC_H - -/* - * Define if we're running on *our* linux on device or emulator. - */ -#define HAVE_ANDROID_OS 1 - -/* - * Define if we have Linux-style non-filesystem Unix Domain Sockets - */ -#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1 - -/* - * Define if we have Linux's inotify in <sys/inotify.h>. - */ -#define HAVE_INOTIFY 1 - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if libc includes Android system properties implementation. - */ -#define HAVE_LIBC_SYSTEM_PROPERTIES 1 - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -/* #define HAVE_SYSTEM_PROPERTY_SERVER */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_ARM - -/* - * Define if the size of enums is as short as possible, - */ -/* #define HAVE_SHORT_ENUMS */ - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" - -/* - * Do we have __memcmp16()? - */ -#define HAVE__MEMCMP16 1 - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE unsigned char * - -/* - * Do we have the sigaction flag SA_NOCLDWAIT? - */ -#define HAVE_SA_NOCLDWAIT - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - */ -#define OS_CASE_SENSITIVE - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -#define HAVE_STRLCPY 1 - -/* - * Define if the open_memstream() function exists on the system. - */ -/* #define HAVE_OPEN_MEMSTREAM 1 */ - -/* - * Define if the BSD funopen() function exists on the system. - */ -#define HAVE_FUNOPEN 1 - -/* - * Define if prctl() exists - */ -#define HAVE_PRCTL 1 - -/* - * Define if writev() exists - */ -#define HAVE_WRITEV 1 - -/* - * Define if <stdint.h> exists. - */ -#define HAVE_STDINT_H 1 - -/* - * Define if <stdbool.h> exists. - */ -#define HAVE_STDBOOL_H 1 - -/* - * Define if <sched.h> exists. - */ -#define HAVE_SCHED_H 1 - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 - -/* - * Define if we have st_mtim in struct stat - */ -#define HAVE_STAT_ST_MTIM 1 - -/* - * Define if printf() supports %zd for size_t arguments - */ -#define HAVE_PRINTF_ZD 1 - -#endif /* _ANDROID_CONFIG_H */ diff --git a/include/arch/linux-ppc/AndroidConfig.h b/include/arch/linux-ppc/AndroidConfig.h deleted file mode 100644 index 00706dc..0000000 --- a/include/arch/linux-ppc/AndroidConfig.h +++ /dev/null @@ -1,326 +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. - */ - -/* - * Android config -- "Linux". Used for desktop ppc Linux. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have the futex syscall? - */ - -#define HAVE_FUTEX - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -#define HAVE_OOM_ADJ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_SYSV_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP - -/* - * Define this if you have <termio.h> - */ -#define HAVE_TERMIO_H - -/* - * Define this if you have <sys/sendfile.h> - */ -#define HAVE_SYS_SENDFILE_H 1 - -/* - * Define this if you build against MSVCRT.DLL - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS - -/* - * Define this if we have localtime_r(). - */ -#define HAVE_LOCALTIME_R - -/* - * Define this if we have gethostbyname_r(). - */ -#define HAVE_GETHOSTBYNAME_R - -/* - * Define this if we have ioctl(). - */ -#define HAVE_IOCTL - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - * - * Desktop Linux has this in librt, but it's broken in goobuntu, yielding - * mildly or wildly inaccurate results. - */ -/*#define HAVE_POSIX_CLOCKS*/ - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -/* #define HAVE_TIMEDWAIT_MONOTONIC */ - -/* - * Define this if we have linux style epoll() - */ -#define HAVE_EPOLL - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#define HAVE_ENDIAN_H -#define HAVE_BIG_ENDIAN - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE 1 - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -#define HAVE_OFF64_T - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 1 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 1 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -/* #define HAVE_GETTID */ - -/* - * Defined if we have the sched_setscheduler() call - */ -#define HAVE_SCHED_SETSCHEDULER - -/* - * Add any extra platform-specific defines here. - */ - -/* - * Define if we have <malloc.h> header - */ -#define HAVE_MALLOC_H - -/* - * Define if we have Linux-style non-filesystem Unix Domain Sockets - */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_PPC - - -/* - * Define if we have Linux's inotify in <sys/inotify.h>. - */ -/*#define HAVE_INOTIFY 1*/ - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if libc includes Android system properties implementation. - */ -/* #define HAVE_LIBC_SYSTEM_PROPERTIES */ - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -#define HAVE_SYSTEM_PROPERTY_SERVER - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE unsigned char * - -/* - * Do we have the sigaction flag SA_NOCLDWAIT? - */ -#define HAVE_SA_NOCLDWAIT - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - */ -#define OS_CASE_SENSITIVE - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -/* #define HAVE_STRLCPY 1 */ - -/* - * Define if the open_memstream() function exists on the system. - */ -#define HAVE_OPEN_MEMSTREAM 1 - -/* - * Define if the BSD funopen() function exists on the system. - */ -/* #define HAVE_FUNOPEN 1 */ - -/* - * Define if prctl() exists - */ -#define HAVE_PRCTL 1 - -/* - * Define if writev() exists - */ -#define HAVE_WRITEV 1 - -/* - * Define if <stdint.h> exists. - */ -#define HAVE_STDINT_H 1 - -/* - * Define if <stdbool.h> exists. - */ -#define HAVE_STDBOOL_H 1 - -/* - * Define if <sched.h> exists. - */ -#define HAVE_SCHED_H 1 - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 - -#endif /*_ANDROID_CONFIG_H*/ diff --git a/include/arch/linux-sh/AndroidConfig.h b/include/arch/linux-sh/AndroidConfig.h deleted file mode 100644 index 5562eae..0000000 --- a/include/arch/linux-sh/AndroidConfig.h +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -/* - * Android config -- "android-sh". Used for SuperH device builds. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have pthread_setname_np()? - * - * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with - * the same name but different parameters, so we can't use that here.) - */ -#define HAVE_ANDROID_PTHREAD_SETNAME_NP - -/* - * Do we have the futex syscall? - */ -#define HAVE_FUTEX - -/* - * Define if we already have the futex wrapper functions defined. Yes if - * compiling against bionic. - */ -#define HAVE_FUTEX_WRAPPERS 1 - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -#define HAVE_OOM_ADJ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_ANDROID_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP - -/* - * Define this if you have <termio.h> - */ -#define HAVE_TERMIO_H - -/* - * Define this if you have <sys/sendfile.h> - */ -#define HAVE_SYS_SENDFILE_H 1 - -/* - * Define this if you build against MSVCRT.DLL - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS - -/* - * Define this if we have localtime_r(). - */ -/* #define HAVE_LOCALTIME_R */ - -/* - * Define this if we have gethostbyname_r(). - */ -/* #define HAVE_GETHOSTBYNAME_R */ - -/* - * Define this if we have ioctl(). - */ -#define HAVE_IOCTL - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - */ -#define HAVE_POSIX_CLOCKS - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -/* #define HAVE_TIMEDWAIT_MONOTONIC */ - -/* - * Define this if we have linux style epoll() - */ -#define HAVE_EPOLL - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#define HAVE_ENDIAN_H -#define HAVE_LITTLE_ENDIAN - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -/* #define _FILE_OFFSET_BITS 64 */ -/* #define _LARGEFILE_SOURCE 1 */ - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -#define HAVE_OFF64_T - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 0 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 0 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -#define HAVE_GETTID - -/* - * Defined if we have the sched_setscheduler() call - */ -#define HAVE_SCHED_SETSCHEDULER - -/* - * Add any extra platform-specific defines here. - */ -/* #define __linux__ */ /* for SuperH */ - -/* - * Define if we have <malloc.h> header - */ -#define HAVE_MALLOC_H - -/* - * Define if we're running on *our* linux on device or emulator. - */ -#define HAVE_ANDROID_OS 1 - -/* - * Define if we have Linux-style non-filesystem Unix Domain Sockets - */ -#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1 - -/* - * Define if we have Linux's inotify in <sys/inotify.h>. - */ -#define HAVE_INOTIFY 1 - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if libc includes Android system properties implementation. - */ -#define HAVE_LIBC_SYSTEM_PROPERTIES 1 - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -/* #define HAVE_SYSTEM_PROPERTY_SERVER */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_SH - -/* - * Define if the size of enums is as short as possible, - */ -/* #define HAVE_SHORT_ENUMS */ - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" - -/* - * Do we have __memcmp16()? - * - * TODO : Investigate the perfomance impact of __memcmp16() - * and implement it. - * This influences on dalvikVM's string performance. - * See dalvik/vm/InlineNative.c. - */ -/* #define HAVE__MEMCMP16 */ - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE unsigned char * - -/* - * Do we have the sigaction flag SA_NOCLDWAIT? - */ -#define HAVE_SA_NOCLDWAIT - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - */ -#define OS_CASE_SENSITIVE - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -#define HAVE_STRLCPY 1 - -/* - * Define if the open_memstream() function exists on the system. - */ -/* #define HAVE_OPEN_MEMSTREAM 1 */ - -/* - * Define if the BSD funopen() function exists on the system. - */ -#define HAVE_FUNOPEN 1 - -/* - * Define if prctl() exists - */ -#define HAVE_PRCTL 1 - -/* - * Define if writev() exists - */ -#define HAVE_WRITEV 1 - -/* - * For dalvik/libcore - */ -#define CANT_PASS_VALIST_AS_CHARPTR - -/* - * For external/bluez/utils/tools/hciattach.c - * TODO : This definition should be somewhere in bionic/libc/kernel/(*). - * Cosider the place and move it there. - */ -#define N_TTY 0 - -/* - * Whether or not _Unwind_Context is defined as a struct. - */ -#define HAVE_UNWIND_CONTEXT_STRUCT - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 - -/* - * Define if we have st_mtim in struct stat - */ -#define HAVE_STAT_ST_MTIM 1 - -/* - * Define if printf() supports %zd for size_t arguments - */ -#define HAVE_PRINTF_ZD 1 - -#endif /* _ANDROID_CONFIG_H */ diff --git a/include/arch/linux-x86/AndroidConfig.h b/include/arch/linux-x86/AndroidConfig.h deleted file mode 100644 index 7dcaa98..0000000 --- a/include/arch/linux-x86/AndroidConfig.h +++ /dev/null @@ -1,336 +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. - */ - -/* - * Android config -- "Linux". Used for desktop x86 Linux. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have the futex syscall? - */ - -#define HAVE_FUTEX - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -#define HAVE_OOM_ADJ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_SYSV_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP - -/* - * Define this if you have <termio.h> - */ -#define HAVE_TERMIO_H - -/* - * Define this if you have <sys/sendfile.h> - */ -#define HAVE_SYS_SENDFILE_H 1 - -/* - * Define this if you build against MSVCRT.DLL - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS - -/* - * Define this if we have localtime_r(). - */ -#define HAVE_LOCALTIME_R - -/* - * Define this if we have gethostbyname_r(). - */ -#define HAVE_GETHOSTBYNAME_R - -/* - * Define this if we have ioctl(). - */ -#define HAVE_IOCTL - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - * - * Desktop Linux has this in librt, but it's broken in goobuntu, yielding - * mildly or wildly inaccurate results. - */ -/*#define HAVE_POSIX_CLOCKS*/ - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -/* #define HAVE_TIMEDWAIT_MONOTONIC */ - -/* - * Define this if we have linux style epoll() - */ -#define HAVE_EPOLL - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#define HAVE_ENDIAN_H -#define HAVE_LITTLE_ENDIAN - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE 1 - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -#define HAVE_OFF64_T - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 1 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 1 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -/* #define HAVE_GETTID */ - -/* - * Defined if we have the sched_setscheduler() call - */ -#define HAVE_SCHED_SETSCHEDULER - -/* - * Add any extra platform-specific defines here. - */ - -/* - * Define if we have <malloc.h> header - */ -#define HAVE_MALLOC_H - -/* - * Define if we have Linux-style non-filesystem Unix Domain Sockets - */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_X86 - - -/* - * Define if we have Linux's inotify in <sys/inotify.h>. - */ -/*#define HAVE_INOTIFY 1*/ - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if libc includes Android system properties implementation. - */ -/* #define HAVE_LIBC_SYSTEM_PROPERTIES */ - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -#define HAVE_SYSTEM_PROPERTY_SERVER - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE unsigned char * - -/* - * Do we have the sigaction flag SA_NOCLDWAIT? - */ -#define HAVE_SA_NOCLDWAIT - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - */ -#define OS_CASE_SENSITIVE - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -/* #define HAVE_STRLCPY 1 */ - -/* - * Define if the open_memstream() function exists on the system. - */ -#define HAVE_OPEN_MEMSTREAM 1 - -/* - * Define if the BSD funopen() function exists on the system. - */ -/* #define HAVE_FUNOPEN 1 */ - -/* - * Define if prctl() exists - */ -#define HAVE_PRCTL 1 - -/* - * Define if writev() exists - */ -#define HAVE_WRITEV 1 - -/* - * Define if <stdint.h> exists. - */ -#define HAVE_STDINT_H 1 - -/* - * Define if <stdbool.h> exists. - */ -#define HAVE_STDBOOL_H 1 - -/* - * Define if <sched.h> exists. - */ -#define HAVE_SCHED_H 1 - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 - -/* - * Define if we have st_mtim in struct stat - */ -#define HAVE_STAT_ST_MTIM 1 - -/* - * Define if printf() supports %zd for size_t arguments - */ -#define HAVE_PRINTF_ZD 1 - -#endif /*_ANDROID_CONFIG_H*/ diff --git a/include/arch/target_linux-x86/AndroidConfig.h b/include/arch/target_linux-x86/AndroidConfig.h deleted file mode 100644 index 05dd220..0000000 --- a/include/arch/target_linux-x86/AndroidConfig.h +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright 2005 The Android Open Source Project - * - * Android config -- "target_linux-x86". Used for x86 linux target devices. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - * -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX - */ -#define HAVE_PTHREADS - -/* - * Do we have pthread_setname_np()? - * - * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with - * the same name but different parameters, so we can't use that here.) - */ -#define HAVE_ANDROID_PTHREAD_SETNAME_NP - -/* - * Do we have the futex syscall? - */ -#define HAVE_FUTEX - -/* - * Define if we already have the futex wrapper functions defined. Yes if - * compiling against bionic. - */ -#define HAVE_FUTEX_WRAPPERS 1 - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#define HAVE_FORKEXEC - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -#define HAVE_OOM_ADJ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_ANDROID_IPC 1 - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#define HAVE_POSIX_FILEMAP 1 - -/* - * Define this if you have <termio.h> - */ -#define HAVE_TERMIO_H 1 - -/* - * Define this if you have <sys/sendfile.h> - */ -#define HAVE_SYS_SENDFILE_H 1 - -/* - * Define this if you build against have Microsoft C runtime (MSVCRT.DLL) - */ -/* #define HAVE_MS_C_RUNTIME */ - -/* - * Define this if you have sys/uio.h - */ -#define HAVE_SYS_UIO_H 1 - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -#define HAVE_SYMLINKS 1 - -/* - * Define this if we have localtime_r(). - */ -/* #define HAVE_LOCALTIME_R */ - -/* - * Define this if we have gethostbyname_r(). - */ -/* #define HAVE_GETHOSTBYNAME_R */ - -/* - * Define this if we have ioctl(). - */ -#define HAVE_IOCTL - -/* - * Define this if we want to use WinSock. - */ -/* #define HAVE_WINSOCK */ - -/* - * Define this if have clock_gettime() and friends - * - */ -#define HAVE_POSIX_CLOCKS - -/* - * Define this if we have pthread_cond_timedwait_monotonic() and - * clock_gettime(CLOCK_MONOTONIC). - */ -#define HAVE_TIMEDWAIT_MONOTONIC - -/* - * Define this if we have linux style epoll() - */ -#define HAVE_EPOLL - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#define HAVE_ENDIAN_H -#define HAVE_LITTLE_ENDIAN - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -/* - * #define _FILE_OFFSET_BITS 64 - * #define _LARGEFILE_SOURCE 1 - */ - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -#define HAVE_OFF64_T - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 0 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 0 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Defined if we have the gettid() system call. - */ -#define HAVE_GETTID - -/* - * Defined if we have the sched_setscheduler() call - */ -#define HAVE_SCHED_SETSCHEDULER - -/* - * Add any extra platform-specific defines here. - */ -#ifndef __linux__ -#define __linux__ -#endif - -/* - * Define if we have <malloc.h> header - */ -#define HAVE_MALLOC_H - -/* - * Define if we're running on *our* linux on device or emulator. - */ -#define HAVE_ANDROID_OS 1 - -/* - * Define if we have Linux-style non-filesystem Unix Domain Sockets - */ -#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1 - -/* - * Define if we have Linux's inotify in <sys/inotify.h>. - */ -#define HAVE_INOTIFY 1 - -/* - * Define if we have madvise() in <sys/mman.h> - */ -#define HAVE_MADVISE 1 - -/* - * Define if we have Linux's dbus - */ -/* #define HAVE_DBUS 1 */ - -/* - * Define if tm struct has tm_gmtoff field - */ -#define HAVE_TM_GMTOFF 1 - -/* - * Define if dirent struct has d_type field - */ -#define HAVE_DIRENT_D_TYPE 1 - -/* - * Define if libc includes Android system properties implementation. - */ -#define HAVE_LIBC_SYSTEM_PROPERTIES 1 - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -/* #define HAVE_SYSTEM_PROPERTY_SERVER */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_X86 - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.so" - -/* - * Do we have __memcmp16()? - */ -/* #define HAVE__MEMCMP16 1 */ - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE unsigned char * - -/* - * Do we have the sigaction flag SA_NOCLDWAIT? - */ -#define HAVE_SA_NOCLDWAIT - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '/' - -/* - * Is the filesystem case sensitive? - */ -#define OS_CASE_SENSITIVE - -/* - * Define if <sys/socket.h> exists. - */ -#define HAVE_SYS_SOCKET_H 1 - -/* - * Define if the strlcpy() function exists on the system. - */ -#define HAVE_STRLCPY 1 - -/* - * Define if the open_memstream() function exists on the system. - */ -/* #define HAVE_OPEN_MEMSTREAM 1 */ - -/* - * Define if the BSD funopen() function exists on the system. - */ -#define HAVE_FUNOPEN 1 - -/* - * Define if prctl() exists - */ -#define HAVE_PRCTL 1 - -/* - * Whether or not _Unwind_Context is defined as a struct. - */ -#define HAVE_UNWIND_CONTEXT_STRUCT - -/* - * Define if <stdint.h> exists. - */ -#define HAVE_STDINT_H 1 - -/* - * Define if <stdbool.h> exists. - */ -#define HAVE_STDBOOL_H 1 - -/* - * Define if <sched.h> exists. - */ -#define HAVE_SCHED_H 1 - -/* - * Define if pread() exists - */ -#define HAVE_PREAD 1 - -/* - * Define if we have st_mtim in struct stat - */ -#define HAVE_STAT_ST_MTIM 1 - -/* - * Define if printf() supports %zd for size_t arguments - */ -#define HAVE_PRINTF_ZD 1 - -#endif /* _ANDROID_CONFIG_H */ diff --git a/include/arch/windows/AndroidConfig.h b/include/arch/windows/AndroidConfig.h deleted file mode 100644 index ad890b4..0000000 --- a/include/arch/windows/AndroidConfig.h +++ /dev/null @@ -1,341 +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. - */ - -/* - * Android config -- "CYGWIN_NT-5.1". - * - * Cygwin has pthreads, but GDB seems to get confused if you use it to - * create threads. By "confused", I mean it freezes up the first time the - * debugged process creates a thread, even if you use CreateThread. The - * mere presence of pthreads linkage seems to cause problems. - */ -#ifndef _ANDROID_CONFIG_H -#define _ANDROID_CONFIG_H - -/* - * =========================================================================== - * !!! IMPORTANT !!! - * =========================================================================== - * - * This file is included by ALL C/C++ source files. Don't put anything in - * here unless you are absolutely certain it can't go anywhere else. - * - * Any C++ stuff must be wrapped with "#ifdef __cplusplus". Do not use "//" - * comments. - */ - -/* - * Threading model. Choose one: - * - * HAVE_PTHREADS - use the pthreads library. - * HAVE_WIN32_THREADS - use Win32 thread primitives. - */ -#define HAVE_WIN32_THREADS - -/* - * Do we have the futex syscall? - */ - -/* #define HAVE_FUTEX */ - - -/* - * Process creation model. Choose one: - * - * HAVE_FORKEXEC - use fork() and exec() - * HAVE_WIN32_PROC - use CreateProcess() - */ -#ifdef __CYGWIN__ -# define HAVE_FORKEXEC -#else -# define HAVE_WIN32_PROC -#endif - -/* - * Process out-of-memory adjustment. Set if running on Linux, - * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory - * badness adjustment. - */ -/* #define HAVE_OOM_ADJ */ - -/* - * IPC model. Choose one: - * - * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget). - * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap). - * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping). - * HAVE_ANDROID_IPC - use Android versions (?, mmap). - */ -#define HAVE_WIN32_IPC - -/* - * Memory-mapping model. Choose one: - * - * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h - * HAVE_WIN32_FILEMAP - use Win32 filemaps - */ -#ifdef __CYGWIN__ -#define HAVE_POSIX_FILEMAP -#else -#define HAVE_WIN32_FILEMAP -#endif - -/* - * Define this if you have <termio.h> - */ -#ifdef __CYGWIN__ -# define HAVE_TERMIO_H -#endif - -/* - * Define this if you have <sys/sendfile.h> - */ -#ifdef __CYGWIN__ -# define HAVE_SYS_SENDFILE_H 1 -#endif - -/* - * Define this if you build against MSVCRT.DLL - */ -#ifndef __CYGWIN__ -# define HAVE_MS_C_RUNTIME -#endif - -/* - * Define this if you have sys/uio.h - */ -#ifdef __CYGWIN__ -#define HAVE_SYS_UIO_H -#endif - - -/* - * Define this if we have localtime_r(). - */ -/* #define HAVE_LOCALTIME_R */ - -/* - * Define this if we have gethostbyname_r(). - */ -/* #define HAVE_GETHOSTBYNAME_R */ - -/* - * Define this if we have ioctl(). - */ -/* #define HAVE_IOCTL */ - -/* - * Define this if we want to use WinSock. - */ -#ifndef __CYGWIN__ -#define HAVE_WINSOCK -#endif - -/* - * Define this if your platforms implements symbolic links - * in its filesystems - */ -/* #define HAVE_SYMLINKS */ - -/* - * Define this if have clock_gettime() and friends - */ -/* #define HAVE_POSIX_CLOCKS */ - -/* - * Endianness of the target machine. Choose one: - * - * HAVE_ENDIAN_H -- have endian.h header we can include. - * HAVE_LITTLE_ENDIAN -- we are little endian. - * HAVE_BIG_ENDIAN -- we are big endian. - */ -#ifdef __CYGWIN__ -#define HAVE_ENDIAN_H -#endif - -#define HAVE_LITTLE_ENDIAN - -/* - * We need to choose between 32-bit and 64-bit off_t. All of our code should - * agree on the same size. For desktop systems, use 64-bit values, - * because some of our libraries (e.g. wxWidgets) expect to be built that way. - */ -#define _FILE_OFFSET_BITS 64 -#define _LARGEFILE_SOURCE 1 - -/* - * Define if platform has off64_t (and lseek64 and other xxx64 functions) - */ -#define HAVE_OFF64_T - -/* - * Defined if we have the backtrace() call for retrieving a stack trace. - * Needed for CallStack to operate; if not defined, CallStack is - * non-functional. - */ -#define HAVE_BACKTRACE 0 - -/* - * Defined if we have the dladdr() call for retrieving the symbol associated - * with a memory address. If not defined, stack crawls will not have symbolic - * information. - */ -#define HAVE_DLADDR 0 - -/* - * Defined if we have the cxxabi.h header for demangling C++ symbols. If - * not defined, stack crawls will be displayed with raw mangled symbols - */ -#define HAVE_CXXABI 0 - -/* - * Define if tm struct has tm_gmtoff field - */ -/* #define HAVE_TM_GMTOFF 1 */ - -/* - * Define if dirent struct has d_type field - */ -/* #define HAVE_DIRENT_D_TYPE 1 */ - -/* - * Define if libc includes Android system properties implementation. - */ -/* #define HAVE_LIBC_SYSTEM_PROPERTIES */ - -/* - * Define if system provides a system property server (should be - * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES). - */ -/* #define HAVE_SYSTEM_PROPERTY_SERVER */ - -/* - * Define if we have madvise() in <sys/mman.h> - */ -/*#define HAVE_MADVISE 1*/ - -/* - * Add any extra platform-specific defines here. - */ -#define WIN32 1 /* stock Cygwin doesn't define these */ -#define _WIN32 1 -#define _WIN32_WINNT 0x0500 /* admit to using >= Win2K */ - -#define HAVE_WINDOWS_PATHS /* needed by simulator */ - -/* - * What CPU architecture does this platform use? - */ -#define ARCH_X86 - -/* - * sprintf() format string for shared library naming. - */ -#define OS_SHARED_LIB_FORMAT_STR "lib%s.dll" - -/* - * type for the third argument to mincore(). - */ -#define MINCORE_POINTER_TYPE unsigned char * - -/* - * The default path separator for the platform - */ -#define OS_PATH_SEPARATOR '\\' - -/* - * Is the filesystem case sensitive? - */ -/* #define OS_CASE_SENSITIVE */ - -/* - * Define if <sys/socket.h> exists. - * Cygwin has it, but not MinGW. - */ -#ifdef USE_MINGW -/* #define HAVE_SYS_SOCKET_H */ -#else -#define HAVE_SYS_SOCKET_H 1 -#endif - -/* - * Define if the strlcpy() function exists on the system. - */ -/* #define HAVE_STRLCPY 1 */ - -/* - * Define if the open_memstream() function exists on the system. - */ -/* #define HAVE_OPEN_MEMSTREAM 1 */ - -/* - * Define if the BSD funopen() function exists on the system. - */ -/* #define HAVE_FUNOPEN 1 */ - -/* - * Define if <winsock2.h> exists. - * Only MinGW has it. - */ -#ifdef USE_MINGW -#define HAVE_WINSOCK2_H 1 -#else -/* #define HAVE_WINSOCK2_H */ -#endif - -/* - * Various definitions missing in MinGW - */ -#ifdef USE_MINGW -#define S_IRGRP 0 -#endif - -/* - * Define if writev() exists. - */ -/* #define HAVE_WRITEV */ - -/* - * Define if <stdint.h> exists. - */ -/* #define HAVE_STDINT_H */ - -/* - * Define if <stdbool.h> exists. - */ -#define HAVE_STDBOOL_H - -/* - * Define if <sched.h> exists. - */ -/* #define HAVE_SCHED_H */ - -/* - * Define if pread() exists - */ -/* #define HAVE_PREAD 1 */ - -/* - * Define if we have st_mtim in struct stat - */ -/* #define HAVE_STAT_ST_MTIM 1 */ - -/* - * Define if printf() supports %zd for size_t arguments - */ -/* #define HAVE_PRINTF_ZD 1 */ - -#endif /*_ANDROID_CONFIG_H*/ diff --git a/include/corkscrew/backtrace.h b/include/corkscrew/backtrace.h new file mode 100644 index 0000000..556ad04 --- /dev/null +++ b/include/corkscrew/backtrace.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* A stack unwinder. */ + +#ifndef _CORKSCREW_BACKTRACE_H +#define _CORKSCREW_BACKTRACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> +#include <corkscrew/ptrace.h> +#include <corkscrew/map_info.h> +#include <corkscrew/symbol_table.h> + +/* + * Describes a single frame of a backtrace. + */ +typedef struct { + uintptr_t absolute_pc; /* absolute PC offset */ + uintptr_t stack_top; /* top of stack for this frame */ + size_t stack_size; /* size of this stack frame */ +} backtrace_frame_t; + +/* + * Describes the symbols associated with a backtrace frame. + */ +typedef struct { + uintptr_t relative_pc; /* relative frame PC offset from the start of the library, + or the absolute PC if the library is unknown */ + uintptr_t relative_symbol_addr; /* relative offset of the symbol from the start of the + library or 0 if the library is unknown */ + char* map_name; /* executable or library name, or NULL if unknown */ + char* symbol_name; /* symbol name, or NULL if unknown */ + char* demangled_name; /* demangled symbol name, or NULL if unknown */ +} backtrace_symbol_t; + +/* + * Unwinds the call stack for the current thread of execution. + * Populates the backtrace array with the program counters from the call stack. + * Returns the number of frames collected, or -1 if an error occurred. + */ +ssize_t unwind_backtrace(backtrace_frame_t* backtrace, size_t ignore_depth, size_t max_depth); + +/* + * Unwinds the call stack for a thread within this process. + * Populates the backtrace array with the program counters from the call stack. + * Returns the number of frames collected, or -1 if an error occurred. + * + * The task is briefly suspended while the backtrace is being collected. + */ +ssize_t unwind_backtrace_thread(pid_t tid, backtrace_frame_t* backtrace, + size_t ignore_depth, size_t max_depth); + +/* + * Unwinds the call stack of a task within a remote process using ptrace(). + * Populates the backtrace array with the program counters from the call stack. + * Returns the number of frames collected, or -1 if an error occurred. + */ +ssize_t unwind_backtrace_ptrace(pid_t tid, const ptrace_context_t* context, + backtrace_frame_t* backtrace, size_t ignore_depth, size_t max_depth); + +/* + * Gets the symbols for each frame of a backtrace. + * The symbols array must be big enough to hold one symbol record per frame. + * The symbols must later be freed using free_backtrace_symbols. + */ +void get_backtrace_symbols(const backtrace_frame_t* backtrace, size_t frames, + backtrace_symbol_t* backtrace_symbols); + +/* + * Gets the symbols for each frame of a backtrace from a remote process. + * The symbols array must be big enough to hold one symbol record per frame. + * The symbols must later be freed using free_backtrace_symbols. + */ +void get_backtrace_symbols_ptrace(const ptrace_context_t* context, + const backtrace_frame_t* backtrace, size_t frames, + backtrace_symbol_t* backtrace_symbols); + +/* + * Frees the storage associated with backtrace symbols. + */ +void free_backtrace_symbols(backtrace_symbol_t* backtrace_symbols, size_t frames); + +enum { + // A hint for how big to make the line buffer for format_backtrace_line + MAX_BACKTRACE_LINE_LENGTH = 800, +}; + +/** + * Formats a line from a backtrace as a zero-terminated string into the specified buffer. + */ +void format_backtrace_line(unsigned frameNumber, const backtrace_frame_t* frame, + const backtrace_symbol_t* symbol, char* buffer, size_t bufferSize); + +#ifdef __cplusplus +} +#endif + +#endif // _CORKSCREW_BACKTRACE_H diff --git a/include/corkscrew/demangle.h b/include/corkscrew/demangle.h new file mode 100644 index 0000000..04b0225 --- /dev/null +++ b/include/corkscrew/demangle.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* C++ symbol name demangling. */ + +#ifndef _CORKSCREW_DEMANGLE_H +#define _CORKSCREW_DEMANGLE_H + +#include <sys/types.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Demangles a C++ symbol name. + * If name is NULL or if the name cannot be demangled, returns NULL. + * Otherwise, returns a newly allocated string that contains the demangled name. + * + * The caller must free the returned string using free(). + */ +char* demangle_symbol_name(const char* name); + +#ifdef __cplusplus +} +#endif + +#endif // _CORKSCREW_DEMANGLE_H diff --git a/include/corkscrew/map_info.h b/include/corkscrew/map_info.h new file mode 100644 index 0000000..14bfad6 --- /dev/null +++ b/include/corkscrew/map_info.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Process memory map. */ + +#ifndef _CORKSCREW_MAP_INFO_H +#define _CORKSCREW_MAP_INFO_H + +#include <sys/types.h> +#include <stdbool.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct map_info { + struct map_info* next; + uintptr_t start; + uintptr_t end; + bool is_readable; + bool is_writable; + bool is_executable; + void* data; // arbitrary data associated with the map by the user, initially NULL + char name[]; +} map_info_t; + +/* Loads memory map from /proc/<tid>/maps. */ +map_info_t* load_map_info_list(pid_t tid); + +/* Frees memory map. */ +void free_map_info_list(map_info_t* milist); + +/* Finds the memory map that contains the specified address. */ +const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr); + +/* Returns true if the addr is in a readable map. */ +bool is_readable_map(const map_info_t* milist, uintptr_t addr); +/* Returns true if the addr is in a writable map. */ +bool is_writable_map(const map_info_t* milist, uintptr_t addr); +/* Returns true if the addr is in an executable map. */ +bool is_executable_map(const map_info_t* milist, uintptr_t addr); + +/* Acquires a reference to the memory map for this process. + * The result is cached and refreshed automatically. + * Make sure to release the map info when done. */ +map_info_t* acquire_my_map_info_list(); + +/* Releases a reference to the map info for this process that was + * previous acquired using acquire_my_map_info_list(). */ +void release_my_map_info_list(map_info_t* milist); + +/* Flushes the cached memory map so the next call to + * acquire_my_map_info_list() gets fresh data. */ +void flush_my_map_info_list(); + +#ifdef __cplusplus +} +#endif + +#endif // _CORKSCREW_MAP_INFO_H diff --git a/include/corkscrew/ptrace.h b/include/corkscrew/ptrace.h new file mode 100644 index 0000000..76276d8 --- /dev/null +++ b/include/corkscrew/ptrace.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Useful ptrace() utility functions. */ + +#ifndef _CORKSCREW_PTRACE_H +#define _CORKSCREW_PTRACE_H + +#include <corkscrew/map_info.h> +#include <corkscrew/symbol_table.h> + +#include <sys/types.h> +#include <stdbool.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Stores information about a process that is used for several different + * ptrace() based operations. */ +typedef struct { + map_info_t* map_info_list; +} ptrace_context_t; + +/* Describes how to access memory from a process. */ +typedef struct { + pid_t tid; + const map_info_t* map_info_list; +} memory_t; + +#if __i386__ +/* ptrace() register context. */ +typedef struct pt_regs_x86 { + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + uint32_t esi; + uint32_t edi; + uint32_t ebp; + uint32_t eax; + uint32_t xds; + uint32_t xes; + uint32_t xfs; + uint32_t xgs; + uint32_t orig_eax; + uint32_t eip; + uint32_t xcs; + uint32_t eflags; + uint32_t esp; + uint32_t xss; +} pt_regs_x86_t; +#endif + +#if __mips__ +/* ptrace() GET_REGS context. */ +typedef struct pt_regs_mips { + uint64_t regs[32]; + uint64_t lo; + uint64_t hi; + uint64_t cp0_epc; + uint64_t cp0_badvaddr; + uint64_t cp0_status; + uint64_t cp0_cause; +} pt_regs_mips_t; +#endif + +/* + * Initializes a memory structure for accessing memory from this process. + */ +void init_memory(memory_t* memory, const map_info_t* map_info_list); + +/* + * Initializes a memory structure for accessing memory from another process + * using ptrace(). + */ +void init_memory_ptrace(memory_t* memory, pid_t tid); + +/* + * Reads a word of memory safely. + * If the memory is local, ensures that the address is readable before dereferencing it. + * Returns false and a value of 0xffffffff if the word could not be read. + */ +bool try_get_word(const memory_t* memory, uintptr_t ptr, uint32_t* out_value); + +/* + * Reads a word of memory safely using ptrace(). + * Returns false and a value of 0xffffffff if the word could not be read. + */ +bool try_get_word_ptrace(pid_t tid, uintptr_t ptr, uint32_t* out_value); + +/* + * Loads information needed for examining a remote process using ptrace(). + * The caller must already have successfully attached to the process + * using ptrace(). + * + * The context can be used for any threads belonging to that process + * assuming ptrace() is attached to them before performing the actual + * unwinding. The context can continue to be used to decode backtraces + * even after ptrace() has been detached from the process. + */ +ptrace_context_t* load_ptrace_context(pid_t pid); + +/* + * Frees a ptrace context. + */ +void free_ptrace_context(ptrace_context_t* context); + +/* + * Finds a symbol using ptrace. + * Returns the containing map and information about the symbol, or + * NULL if one or the other is not available. + */ +void find_symbol_ptrace(const ptrace_context_t* context, + uintptr_t addr, const map_info_t** out_map_info, const symbol_t** out_symbol); + +#ifdef __cplusplus +} +#endif + +#endif // _CORKSCREW_PTRACE_H diff --git a/include/corkscrew/symbol_table.h b/include/corkscrew/symbol_table.h new file mode 100644 index 0000000..4998750 --- /dev/null +++ b/include/corkscrew/symbol_table.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _CORKSCREW_SYMBOL_TABLE_H +#define _CORKSCREW_SYMBOL_TABLE_H + +#include <stdint.h> +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + uintptr_t start; + uintptr_t end; + char* name; +} symbol_t; + +typedef struct { + symbol_t* symbols; + size_t num_symbols; +} symbol_table_t; + +/* + * Loads a symbol table from a given file. + * Returns NULL on error. + */ +symbol_table_t* load_symbol_table(const char* filename); + +/* + * Frees a symbol table. + */ +void free_symbol_table(symbol_table_t* table); + +/* + * Finds a symbol associated with an address in the symbol table. + * Returns NULL if not found. + */ +const symbol_t* find_symbol(const symbol_table_t* table, uintptr_t addr); + +#ifdef __cplusplus +} +#endif + +#endif // _CORKSCREW_SYMBOL_TABLE_H diff --git a/include/cutils/atomic-arm.h b/include/cutils/atomic-arm.h index 16fe512..172a0cd 100644 --- a/include/cutils/atomic-arm.h +++ b/include/cutils/atomic-arm.h @@ -18,91 +18,75 @@ #define ANDROID_CUTILS_ATOMIC_ARM_H #include <stdint.h> -#include <machine/cpu-features.h> -extern inline void android_compiler_barrier(void) +#ifndef ANDROID_ATOMIC_INLINE +#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) +#endif + +extern ANDROID_ATOMIC_INLINE void android_compiler_barrier() { __asm__ __volatile__ ("" : : : "memory"); } -#if ANDROID_SMP == 0 -extern inline void android_memory_barrier(void) -{ - android_compiler_barrier(); -} -extern inline void android_memory_store_barrier(void) +extern ANDROID_ATOMIC_INLINE void android_memory_barrier() { +#if ANDROID_SMP == 0 android_compiler_barrier(); -} -#elif defined(__ARM_HAVE_DMB) -extern inline void android_memory_barrier(void) -{ +#else __asm__ __volatile__ ("dmb" : : : "memory"); +#endif } -extern inline void android_memory_store_barrier(void) -{ - __asm__ __volatile__ ("dmb st" : : : "memory"); -} -#elif defined(__ARM_HAVE_LDREX_STREX) -extern inline void android_memory_barrier(void) -{ - __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); -} -extern inline void android_memory_store_barrier(void) + +extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier() { - android_memory_barrier(); -} +#if ANDROID_SMP == 0 + android_compiler_barrier(); #else -extern inline void android_memory_barrier(void) -{ - typedef void (kuser_memory_barrier)(void); - (*(kuser_memory_barrier *)0xffff0fa0)(); -} -extern inline void android_memory_store_barrier(void) -{ - android_memory_barrier(); -} + __asm__ __volatile__ ("dmb st" : : : "memory"); #endif +} -extern inline int32_t android_atomic_acquire_load(volatile const int32_t *ptr) +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 inline int32_t android_atomic_release_load(volatile const int32_t *ptr) +extern ANDROID_ATOMIC_INLINE +int32_t android_atomic_release_load(volatile const int32_t *ptr) { android_memory_barrier(); return *ptr; } -extern inline void android_atomic_acquire_store(int32_t value, - volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE +void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) { *ptr = value; android_memory_barrier(); } -extern inline void android_atomic_release_store(int32_t value, - volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE +void android_atomic_release_store(int32_t value, volatile int32_t *ptr) { android_memory_barrier(); *ptr = value; } -#if defined(__thumb__) -extern int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr); -#elif defined(__ARM_HAVE_LDREX_STREX) -extern inline int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) +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) @@ -110,47 +94,26 @@ extern inline int android_atomic_cas(int32_t old_value, int32_t new_value, } while (__builtin_expect(status != 0, 0)); return prev != old_value; } -#else -extern inline int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - typedef int (kuser_cmpxchg)(int32_t, int32_t, volatile int32_t *); - int32_t prev, status; - prev = *ptr; - do { - status = (*(kuser_cmpxchg *)0xffff0fc0)(old_value, new_value, ptr); - if (__builtin_expect(status == 0, 1)) - return 0; - prev = *ptr; - } while (prev == old_value); - return 1; -} -#endif -extern inline int android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) +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 inline int android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) +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); } - -#if defined(__thumb__) -extern int32_t android_atomic_add(int32_t increment, - volatile int32_t *ptr); -#elif defined(__ARM_HAVE_LDREX_STREX) -extern inline int32_t android_atomic_add(int32_t increment, - volatile int32_t *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(); @@ -165,34 +128,19 @@ extern inline int32_t android_atomic_add(int32_t increment, } while (__builtin_expect(status != 0, 0)); return prev; } -#else -extern 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; -} -#endif -extern inline int32_t android_atomic_inc(volatile int32_t *addr) +extern ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t *addr) { return android_atomic_add(1, addr); } -extern inline int32_t android_atomic_dec(volatile int32_t *addr) +extern ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t *addr) { return android_atomic_add(-1, addr); } -#if defined(__thumb__) -extern int32_t android_atomic_and(int32_t value, volatile int32_t *ptr); -#elif defined(__ARM_HAVE_LDREX_STREX) -extern inline int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE +int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) { int32_t prev, tmp, status; android_memory_barrier(); @@ -207,23 +155,9 @@ extern inline int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) } while (__builtin_expect(status != 0, 0)); return prev; } -#else -extern 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; -} -#endif -#if defined(__thumb__) -extern int32_t android_atomic_or(int32_t value, volatile int32_t *ptr); -#elif defined(__ARM_HAVE_LDREX_STREX) -extern inline int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE +int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) { int32_t prev, tmp, status; android_memory_barrier(); @@ -238,17 +172,5 @@ extern inline int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) } while (__builtin_expect(status != 0, 0)); return prev; } -#else -extern 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 #endif /* ANDROID_CUTILS_ATOMIC_ARM_H */ diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h index 49f3e70..0b13138 100644 --- a/include/cutils/atomic-inline.h +++ b/include/cutils/atomic-inline.h @@ -47,8 +47,8 @@ extern "C" { #include <cutils/atomic-arm.h> #elif defined(__i386__) || defined(__x86_64__) #include <cutils/atomic-x86.h> -#elif defined(__sh__) -/* implementation is in atomic-android-sh.c */ +#elif defined(__mips__) +#include <cutils/atomic-mips.h> #else #error atomic operations are unsupported #endif diff --git a/include/cutils/atomic-mips.h b/include/cutils/atomic-mips.h new file mode 100644 index 0000000..f9d3e25 --- /dev/null +++ b/include/cutils/atomic-mips.h @@ -0,0 +1,199 @@ +/* + * 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(); +} +extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) +{ + android_compiler_barrier(); +} +#else +extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) +{ + __asm__ __volatile__ ("sync" : : : "memory"); +} +extern ANDROID_ATOMIC_INLINE void android_memory_store_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_swap(int32_t new_value, volatile int32_t *ptr) +{ + int32_t prev, status; + do { + __asm__ __volatile__ ( + " move %[status], %[new_value]\n" + " ll %[prev], (%[ptr])\n" + " sc %[status], (%[ptr])\n" + : [prev] "=&r" (prev), [status] "=&r" (status) + : [ptr] "r" (ptr), [new_value] "r" (new_value) + ); + } while (__builtin_expect(status == 0, 0)); + android_memory_barrier(); + return prev; +} + +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 index 438012e..9480f57 100644 --- a/include/cutils/atomic-x86.h +++ b/include/cutils/atomic-x86.h @@ -19,60 +19,66 @@ #include <stdint.h> -extern inline void android_compiler_barrier(void) +#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 inline void android_memory_barrier(void) +extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { android_compiler_barrier(); } -extern inline void android_memory_store_barrier(void) +extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) { android_compiler_barrier(); } #else -extern inline void android_memory_barrier(void) +extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { __asm__ __volatile__ ("mfence" : : : "memory"); } -extern inline void android_memory_store_barrier(void) +extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) { android_compiler_barrier(); } #endif -extern inline int32_t android_atomic_acquire_load(volatile const int32_t *ptr) +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 inline int32_t android_atomic_release_load(volatile const int32_t *ptr) +extern ANDROID_ATOMIC_INLINE int32_t +android_atomic_release_load(volatile const int32_t *ptr) { android_memory_barrier(); return *ptr; } -extern inline void android_atomic_acquire_store(int32_t value, - volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE void +android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) { *ptr = value; android_memory_barrier(); } -extern inline void android_atomic_release_store(int32_t value, - volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE void +android_atomic_release_store(int32_t value, volatile int32_t *ptr) { android_compiler_barrier(); *ptr = value; } -extern inline int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) +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" @@ -82,24 +88,26 @@ extern inline int android_atomic_cas(int32_t old_value, int32_t new_value, return prev != old_value; } -extern inline int android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) +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 inline int android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *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 inline int32_t android_atomic_add(int32_t increment, - volatile int32_t *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) @@ -108,18 +116,20 @@ extern inline int32_t android_atomic_add(int32_t increment, return increment; } -extern inline int32_t android_atomic_inc(volatile int32_t *addr) +extern ANDROID_ATOMIC_INLINE int32_t +android_atomic_inc(volatile int32_t *addr) { return android_atomic_add(1, addr); } -extern inline int32_t android_atomic_dec(volatile int32_t *addr) +extern ANDROID_ATOMIC_INLINE int32_t +android_atomic_dec(volatile int32_t *addr) { return android_atomic_add(-1, addr); } -extern inline int32_t android_atomic_and(int32_t value, - volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE int32_t +android_atomic_and(int32_t value, volatile int32_t *ptr) { int32_t prev, status; do { @@ -129,7 +139,8 @@ extern inline int32_t android_atomic_and(int32_t value, return prev; } -extern inline int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) +extern ANDROID_ATOMIC_INLINE int32_t +android_atomic_or(int32_t value, volatile int32_t *ptr) { int32_t prev, status; do { diff --git a/include/cutils/debugger.h b/include/cutils/debugger.h new file mode 100644 index 0000000..4eda523 --- /dev/null +++ b/include/cutils/debugger.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2012 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_DEBUGGER_H +#define __CUTILS_DEBUGGER_H + +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEBUGGER_SOCKET_NAME "android:debuggerd" + +typedef enum { + // dump a crash + DEBUGGER_ACTION_CRASH, + // dump a tombstone file + DEBUGGER_ACTION_DUMP_TOMBSTONE, + // dump a backtrace only back to the socket + DEBUGGER_ACTION_DUMP_BACKTRACE, +} debugger_action_t; + +typedef struct { + debugger_action_t action; + pid_t tid; + uintptr_t abort_msg_address; +} debugger_msg_t; + +/* 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. + */ +int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); + +/* Dumps a process backtrace only to the specified file (requires root). + * Returns 0 on success, -1 on error. + */ +int dump_backtrace_to_file(pid_t tid, int fd); + +#ifdef __cplusplus +} +#endif + +#endif /* __CUTILS_DEBUGGER_H */ diff --git a/include/cutils/fs.h b/include/cutils/fs.h new file mode 100644 index 0000000..fd5296b --- /dev/null +++ b/include/cutils/fs.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2012 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_FS_H +#define __CUTILS_FS_H + +#include <sys/types.h> + +/* + * TEMP_FAILURE_RETRY is defined by some, but not all, versions of + * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's + * not already defined, then define it here. + */ +#ifndef TEMP_FAILURE_RETRY +/* Used to retry syscalls that can return EINTR. */ +#define TEMP_FAILURE_RETRY(exp) ({ \ + typeof (exp) _rc; \ + do { \ + _rc = (exp); \ + } while (_rc == -1 && errno == EINTR); \ + _rc; }) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Ensure that directory exists with given mode and owners. + */ +extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); + +/* + * Read single plaintext integer from given file, correctly handling files + * partially written with fs_write_atomic_int(). + */ +extern int fs_read_atomic_int(const char* path, int* value); + +/* + * Write single plaintext integer to given file, creating backup while + * in progress. + */ +extern int fs_write_atomic_int(const char* path, int value); + +#ifdef __cplusplus +} +#endif + +#endif /* __CUTILS_FS_H */ diff --git a/include/cutils/list.h b/include/cutils/list.h index eb5a3c8..3881fc9 100644 --- a/include/cutils/list.h +++ b/include/cutils/list.h @@ -19,6 +19,10 @@ #include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + struct listnode { struct listnode *next; @@ -48,4 +52,8 @@ void list_remove(struct listnode *item); #define list_head(list) ((list)->next) #define list_tail(list) ((list)->prev) +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + #endif diff --git a/include/cutils/log.h b/include/cutils/log.h index 2997a0c..8b045c7 100644 --- a/include/cutils/log.h +++ b/include/cutils/log.h @@ -79,10 +79,6 @@ extern "C" { #else #define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #endif -// Temporary measure for code still using old LOG macros. -#ifndef LOGV -#define LOGV ALOGV -#endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) @@ -96,10 +92,6 @@ extern "C" { ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif -// Temporary measure for code still using old LOG macros. -#ifndef LOGV_IF -#define LOGV_IF ALOGV_IF -#endif #endif /* @@ -107,10 +99,6 @@ extern "C" { */ #ifndef ALOGD #define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -// Temporary measure for code still using old LOG macros. -#ifndef LOGD -#define LOGD ALOGD -#endif #endif #ifndef ALOGD_IF @@ -118,10 +106,6 @@ extern "C" { ( (CONDITION(cond)) \ ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) -// Temporary measure for code still using old LOG macros. -#ifndef LOGD_IF -#define LOGD_IF ALOGD_IF -#endif #endif /* @@ -129,10 +113,6 @@ extern "C" { */ #ifndef ALOGI #define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -// Temporary measure for code still using old LOG macros. -#ifndef LOGI -#define LOGI ALOGI -#endif #endif #ifndef ALOGI_IF @@ -140,10 +120,6 @@ extern "C" { ( (CONDITION(cond)) \ ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) -// Temporary measure for code still using old LOG macros. -#ifndef LOGI_IF -#define LOGI_IF ALOGI_IF -#endif #endif /* @@ -151,10 +127,6 @@ extern "C" { */ #ifndef ALOGW #define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) -// Temporary measure for code still using old LOG macros. -#ifndef LOGW -#define LOGW ALOGW -#endif #endif #ifndef ALOGW_IF @@ -162,10 +134,6 @@ extern "C" { ( (CONDITION(cond)) \ ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) -// Temporary measure for code still using old LOG macros. -#ifndef LOGW_IF -#define LOGW_IF ALOGW_IF -#endif #endif /* @@ -173,10 +141,6 @@ extern "C" { */ #ifndef ALOGE #define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) -// Temporary measure for code still using old LOG macros. -#ifndef LOGE -#define LOGE ALOGE -#endif #endif #ifndef ALOGE_IF @@ -184,10 +148,6 @@ extern "C" { ( (CONDITION(cond)) \ ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) -// Temporary measure for code still using old LOG macros. -#ifndef LOGE_IF -#define LOGE_IF ALOGE_IF -#endif #endif // --------------------------------------------------------------------- @@ -202,10 +162,6 @@ extern "C" { #else #define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG) #endif -// Temporary measure for code still using old LOG macros. -#ifndef IF_LOGV -#define IF_LOGV IF_ALOGV -#endif #endif /* @@ -214,10 +170,6 @@ extern "C" { */ #ifndef IF_ALOGD #define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG) -// Temporary measure for code still using old LOG macros. -#ifndef IF_LOGD -#define IF_LOGD IF_ALOGD -#endif #endif /* @@ -226,10 +178,6 @@ extern "C" { */ #ifndef IF_ALOGI #define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG) -// Temporary measure for code still using old LOG macros. -#ifndef IF_LOGI -#define IF_LOGI IF_ALOGI -#endif #endif /* @@ -238,10 +186,6 @@ extern "C" { */ #ifndef IF_ALOGW #define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG) -// Temporary measure for code still using old LOG macros. -#ifndef IF_LOGW -#define IF_LOGW IF_ALOGW -#endif #endif /* @@ -250,10 +194,6 @@ extern "C" { */ #ifndef IF_ALOGE #define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG) -// Temporary measure for code still using old LOG macros. -#ifndef IF_LOGE -#define IF_LOGE IF_ALOGE -#endif #endif @@ -339,7 +279,88 @@ extern "C" { : (void)0 ) #endif - +// --------------------------------------------------------------------- + +/* + * Simplified macro to send a verbose radio log message using the current LOG_TAG. + */ +#ifndef RLOGV +#if LOG_NDEBUG +#define RLOGV(...) ((void)0) +#else +#define RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) +#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)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) +#endif +#endif + +/* + * 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__)) +#endif + +#ifndef RLOGD_IF +#define RLOGD_IF(cond, ...) \ + ( (CONDITION(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) +#endif + +/* + * 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__)) +#endif + +#ifndef RLOGI_IF +#define RLOGI_IF(cond, ...) \ + ( (CONDITION(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) +#endif + +/* + * 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__)) +#endif + +#ifndef RLOGW_IF +#define RLOGW_IF(cond, ...) \ + ( (CONDITION(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) +#endif + +/* + * 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__)) +#endif + +#ifndef RLOGE_IF +#define RLOGE_IF(cond, ...) \ + ( (CONDITION(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ + : (void)0 ) +#endif + // --------------------------------------------------------------------- @@ -392,10 +413,6 @@ extern "C" { #ifndef ALOG_ASSERT #define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__) //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) -// Temporary measure for code still using old LOG macros. -#ifndef LOG_ASSERT -#define LOG_ASSERT ALOG_ASSERT -#endif #endif // --------------------------------------------------------------------- @@ -411,10 +428,6 @@ extern "C" { #ifndef ALOG #define ALOG(priority, tag, ...) \ LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) -// Temporary measure for code still using old LOG macros. -#ifndef LOG -#define LOG ALOG -#endif #endif /* @@ -439,10 +452,6 @@ extern "C" { #ifndef IF_ALOG #define IF_ALOG(priority, tag) \ if (android_testLog(ANDROID_##priority, tag)) -// Temporary measure for code still using old LOG macros. -#ifndef IF_LOG -#define IF_LOG IF_ALOG -#endif #endif // --------------------------------------------------------------------- diff --git a/include/cutils/logger.h b/include/cutils/logger.h index b60f7ad..04f3fb0 100644 --- a/include/cutils/logger.h +++ b/include/cutils/logger.h @@ -12,6 +12,11 @@ #include <stdint.h> +/* + * The userspace structure for version 1 of the logger_entry ABI. + * This structure is returned to userspace by the kernel logger + * driver unless an upgrade to a newer ABI version is requested. + */ struct logger_entry { uint16_t len; /* length of the payload */ uint16_t __pad; /* no matter what, we get 2 bytes of padding */ @@ -22,14 +27,41 @@ struct logger_entry { char msg[0]; /* the entry's payload */ }; +/* + * The userspace structure for version 2 of the logger_entry ABI. + * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION) + * is called with version==2 + */ +struct logger_entry_v2 { + uint16_t len; /* length of the payload */ + uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */ + int32_t pid; /* generating process's pid */ + int32_t tid; /* generating process's tid */ + int32_t sec; /* seconds since Epoch */ + int32_t nsec; /* nanoseconds */ + uint32_t euid; /* effective UID of logger */ + char msg[0]; /* the entry's payload */ +}; + #define LOGGER_LOG_MAIN "log/main" #define LOGGER_LOG_RADIO "log/radio" #define LOGGER_LOG_EVENTS "log/events" #define LOGGER_LOG_SYSTEM "log/system" -#define LOGGER_ENTRY_MAX_LEN (4*1024) -#define LOGGER_ENTRY_MAX_PAYLOAD \ - (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry)) +/* + * The maximum size of the log entry payload that can be + * written to the kernel logger driver. An attempt to write + * more than this amount to /dev/log/* will result in a + * truncated log entry. + */ +#define LOGGER_ENTRY_MAX_PAYLOAD 4076 + +/* + * The maximum size of a log entry which can be read from the + * kernel logger driver. An attempt to read less than this amount + * may result in read() returning EINVAL. + */ +#define LOGGER_ENTRY_MAX_LEN (5*1024) #ifdef HAVE_IOCTL @@ -41,6 +73,8 @@ struct logger_entry { #define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */ #define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */ #define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */ +#define LOGGER_GET_VERSION _IO(__LOGGERIO, 5) /* abi version */ +#define LOGGER_SET_VERSION _IO(__LOGGERIO, 6) /* abi version */ #endif // HAVE_IOCTL diff --git a/include/cutils/logprint.h b/include/cutils/logprint.h index 769c8a7..2b1e1c5 100644 --- a/include/cutils/logprint.h +++ b/include/cutils/logprint.h @@ -44,8 +44,8 @@ typedef struct AndroidLogEntry_t { time_t tv_sec; long tv_nsec; android_LogPriority priority; - pid_t pid; - pthread_t tid; + int32_t pid; + int32_t tid; const char * tag; size_t messageLen; const char * message; diff --git a/include/cutils/mspace.h b/include/cutils/mspace.h deleted file mode 100644 index 93fe48e..0000000 --- a/include/cutils/mspace.h +++ /dev/null @@ -1,128 +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. - */ - -/* A wrapper file for dlmalloc.h that defines prototypes for the - * mspace_*() functions, which provide an interface for creating - * multiple heaps. - */ - -#ifndef MSPACE_H_ -#define MSPACE_H_ - -/* It's a pain getting the mallinfo stuff to work - * with Linux, OSX, and klibc, so just turn it off - * for now. - * TODO: make mallinfo work - */ -#define NO_MALLINFO 1 - -/* Allow setting the maximum heap footprint. - */ -#define USE_MAX_ALLOWED_FOOTPRINT 1 - -#define USE_CONTIGUOUS_MSPACES 1 -#if USE_CONTIGUOUS_MSPACES -#define HAVE_MMAP 0 -#define HAVE_MORECORE 1 -#define MORECORE_CONTIGUOUS 0 -#endif - -#define MSPACES 1 -#define ONLY_MSPACES 1 -#include "../../../../bionic/libc/bionic/dlmalloc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - mspace_usable_size(void* p); - - Returns the number of bytes you can actually use in - an allocated chunk, which may be more than you requested (although - often not) due to alignment and minimum size constraints. - You can use this many bytes without worrying about - overwriting other allocated objects. This is not a particularly great - programming practice. mspace_usable_size can be more useful in - debugging and assertions, for example: - - p = mspace_malloc(msp, n); - assert(mspace_usable_size(msp, p) >= 256); -*/ -size_t mspace_usable_size(mspace, const void*); - -#if USE_CONTIGUOUS_MSPACES -/* - Similar to create_mspace(), but the underlying memory is - guaranteed to be contiguous. No more than max_capacity - bytes is ever allocated to the mspace. - */ -mspace create_contiguous_mspace(size_t starting_capacity, size_t max_capacity, - int locked); - -/* - Identical to create_contiguous_mspace, but labels the mapping 'mspace/name' - instead of 'mspace' -*/ -mspace create_contiguous_mspace_with_name(size_t starting_capacity, - size_t max_capacity, int locked, const char *name); - -/* - Identical to create_contiguous_mspace, but uses previously mapped memory. -*/ -mspace create_contiguous_mspace_with_base(size_t starting_capacity, - size_t max_capacity, int locked, void *base); - -size_t destroy_contiguous_mspace(mspace msp); - -/* - Returns the position of the "break" within the given mspace. -*/ -void *contiguous_mspace_sbrk0(mspace msp); -#endif - -/* - Call the handler for each block in the specified mspace. - chunkptr and chunklen refer to the heap-level chunk including - the chunk overhead, and userptr and userlen refer to the - user-usable part of the chunk. If the chunk is free, userptr - will be NULL and userlen will be 0. userlen is not guaranteed - to be the same value passed into malloc() for a given chunk; - it is >= the requested size. - */ -void mspace_walk_heap(mspace msp, - void(*handler)(const void *chunkptr, size_t chunklen, - const void *userptr, size_t userlen, void *arg), void *harg); - -/* - mspace_walk_free_pages(handler, harg) - - Calls the provided handler on each free region in the specified - mspace. The memory between start and end are guaranteed not to - contain any important data, so the handler is free to alter the - contents in any way. This can be used to advise the OS that large - free regions may be swapped out. - - The value in harg will be passed to each call of the handler. - */ -void mspace_walk_free_pages(mspace msp, - void(*handler)(void *start, void *end, void *arg), void *harg); - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - -#endif /* MSPACE_H_ */ diff --git a/include/cutils/multiuser.h b/include/cutils/multiuser.h new file mode 100644 index 0000000..635ddb1 --- /dev/null +++ b/include/cutils/multiuser.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 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_MULTIUSER_H +#define __CUTILS_MULTIUSER_H + +#include <sys/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// NOTE: keep in sync with android.os.UserId + +#define MULTIUSER_APP_PER_USER_RANGE 100000 + +typedef uid_t userid_t; +typedef uid_t appid_t; + +extern userid_t multiuser_get_user_id(uid_t uid); +extern appid_t multiuser_get_app_id(uid_t uid); +extern uid_t multiuser_get_uid(userid_t userId, appid_t appId); + +#ifdef __cplusplus +} +#endif + +#endif /* __CUTILS_MULTIUSER_H */ diff --git a/include/cutils/qsort_r_compat.h b/include/cutils/qsort_r_compat.h new file mode 100644 index 0000000..479a1ab --- /dev/null +++ b/include/cutils/qsort_r_compat.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2012 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. + */ + +/* + * Provides a portable version of qsort_r, called qsort_r_compat, which is a + * reentrant variant of qsort that passes a user data pointer to its comparator. + * This implementation follows the BSD parameter convention. + */ + +#ifndef _LIBS_CUTILS_QSORT_R_COMPAT_H +#define _LIBS_CUTILS_QSORT_R_COMPAT_H + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, + int (*compar)(void*, const void* , const void* )); + +#ifdef __cplusplus +} +#endif + +#endif // _LIBS_CUTILS_QSORT_R_COMPAT_H diff --git a/include/cutils/sched_policy.h b/include/cutils/sched_policy.h index eaf3993..ba84ce3 100644 --- a/include/cutils/sched_policy.h +++ b/include/cutils/sched_policy.h @@ -21,14 +21,39 @@ extern "C" { #endif +/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { + SP_DEFAULT = -1, SP_BACKGROUND = 0, SP_FOREGROUND = 1, + SP_SYSTEM = 2, // can't be used with set_sched_policy() + SP_AUDIO_APP = 3, + SP_AUDIO_SYS = 4, + SP_CNT, + SP_MAX = SP_CNT - 1, + SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; +/* Assign thread tid to the cgroup associated with the specified policy. + * If the thread is a thread group leader, that is it's gettid() == getpid(), + * then the other threads in the same thread group are _not_ affected. + * On platforms which support gettid(), zero tid means current thread. + * Return value: 0 for success, or -errno for error. + */ extern int set_sched_policy(int tid, SchedPolicy policy); + +/* Return the policy associated with the cgroup of thread tid via policy pointer. + * On platforms which support gettid(), zero tid means current thread. + * Return value: 0 for success, or -1 for error and set errno. + */ extern int get_sched_policy(int tid, SchedPolicy *policy); +/* Return a displayable string corresponding to policy. + * Return value: non-NULL NUL-terminated name of unspecified length; + * the caller is responsible for displaying the useful part of the string. + */ +extern const char *get_sched_policy_name(SchedPolicy policy); + #ifdef __cplusplus } #endif diff --git a/include/cutils/tztime.h b/include/cutils/tztime.h index cf103ca..dbdbd60 100644 --- a/include/cutils/tztime.h +++ b/include/cutils/tztime.h @@ -17,39 +17,8 @@ #ifndef _CUTILS_TZTIME_H #define _CUTILS_TZTIME_H -#include <time.h> - -#ifdef __cplusplus -extern "C" { -#endif - -time_t mktime_tz(struct tm * const tmp, char const * tz); -void localtime_tz(const time_t * const timep, struct tm * tmp, const char* tz); - -#ifndef HAVE_ANDROID_OS -/* the following is defined in <time.h> in Bionic */ - -struct strftime_locale { - const char *mon[12]; /* short names */ - const char *month[12]; /* long names */ - const char *standalone_month[12]; /* long standalone names */ - const char *wday[7]; /* short names */ - const char *weekday[7]; /* long names */ - const char *X_fmt; - const char *x_fmt; - const char *c_fmt; - const char *am; - const char *pm; - const char *date_fmt; -}; - -size_t strftime_tz(char *s, size_t max, const char *format, const struct tm *tm, const struct strftime_locale *locale); - -#endif /* !HAVE_ANDROID_OS */ - -#ifdef __cplusplus -} -#endif +// TODO: fix both callers to just include <bionic_time.h> themselves. +#include <bionic_time.h> #endif /* __CUTILS_TZTIME_H */ diff --git a/include/cutils/uevent.h b/include/cutils/uevent.h index 4ebc300..4cca7e5 100644 --- a/include/cutils/uevent.h +++ b/include/cutils/uevent.h @@ -26,6 +26,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); #ifdef __cplusplus } diff --git a/include/diskconfig/diskconfig.h b/include/diskconfig/diskconfig.h index d4f468c..d45b99e 100644 --- a/include/diskconfig/diskconfig.h +++ b/include/diskconfig/diskconfig.h @@ -19,6 +19,7 @@ #define __LIBS_DISKCONFIG_H #include <stdint.h> +#include <sys/types.h> #ifdef __cplusplus extern "C" { diff --git a/include/ion/ion.h b/include/ion/ion.h new file mode 100644 index 0000000..018c0a1 --- /dev/null +++ b/include/ion/ion.h @@ -0,0 +1,43 @@ +/* + * ion.c + * + * Memory Allocator functions for ion + * + * Copyright 2011 Google, Inc + * + * 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 __SYS_CORE_ION_H +#define __SYS_CORE_ION_H + +#include <linux/ion.h> + +__BEGIN_DECLS + +int ion_open(); +int ion_close(int fd); +int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, + unsigned int flags, struct ion_handle **handle); +int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, + unsigned int flags, int *handle_fd); +int ion_sync_fd(int fd, int handle_fd); +int ion_free(int fd, struct ion_handle *handle); +int ion_map(int fd, struct ion_handle *handle, size_t length, int prot, + int flags, off_t offset, unsigned char **ptr, int *map_fd); +int ion_share(int fd, struct ion_handle *handle, int *share_fd); +int ion_import(int fd, int share_fd, struct ion_handle **handle); + +__END_DECLS + +#endif /* __SYS_CORE_ION_H */ diff --git a/include/mincrypt/rsa.h b/include/mincrypt/rsa.h index 7d7d571..d7429fc 100644 --- a/include/mincrypt/rsa.h +++ b/include/mincrypt/rsa.h @@ -13,14 +13,14 @@ ** be used to endorse or promote products derived from this software ** without specific prior written permission. ** -** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR +** THIS SOFTWARE IS PROVIDED BY Google Inc. ``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 +** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO ** EVENT SHALL Google Inc. 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 +** 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. */ @@ -42,6 +42,7 @@ typedef struct RSAPublicKey { uint32_t n0inv; /* -1 / n[0] mod 2^32 */ uint32_t n[RSANUMWORDS]; /* modulus as little endian array */ uint32_t rr[RSANUMWORDS]; /* R^2 as little endian array */ + int exponent; /* 3 or 65537 */ } RSAPublicKey; int RSA_verify(const RSAPublicKey *key, diff --git a/include/netutils/dhcp.h b/include/netutils/dhcp.h index bd16240..d25e58f 100644 --- a/include/netutils/dhcp.h +++ b/include/netutils/dhcp.h @@ -30,7 +30,8 @@ extern int dhcp_do_request(const char *ifname, char *dns1, char *dns2, char *server, - uint32_t *lease); + uint32_t *lease, + char *vendorInfo); extern int dhcp_stop(const char *ifname); extern int dhcp_release_lease(const char *ifname); extern char *dhcp_get_errmsg(); diff --git a/include/netutils/ifc.h b/include/netutils/ifc.h index 67a4a45..1f5421d 100644 --- a/include/netutils/ifc.h +++ b/include/netutils/ifc.h @@ -34,6 +34,9 @@ extern int ifc_down(const char *name); extern int ifc_enable(const char *ifname); extern int ifc_disable(const char *ifname); +#define RESET_IPV4_ADDRESSES 0x01 +#define RESET_IPV6_ADDRESSES 0x02 +#define RESET_ALL_ADDRESSES (RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES) extern int ifc_reset_connections(const char *ifname, const int reset_mask); extern int ifc_get_addr(const char *name, in_addr_t *addr); @@ -66,6 +69,8 @@ extern int ifc_configure(const char *ifname, in_addr_t address, uint32_t prefixLength, in_addr_t gateway, in_addr_t dns1, in_addr_t dns2); +extern in_addr_t prefixLengthToIpv4Netmask(int prefix_length); + __END_DECLS #endif /* _NETUTILS_IFC_H_ */ diff --git a/include/private/android_filesystem_capability.h b/include/private/android_filesystem_capability.h new file mode 100644 index 0000000..0505cda --- /dev/null +++ b/include/private/android_filesystem_capability.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2013 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. + */ + +/* + * Taken from linux/capability.h, with minor modifications + */ + +#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H +#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H + +#include <stdint.h> + +#define __user +#define __u32 uint32_t +#define __le32 uint32_t + +#define _LINUX_CAPABILITY_VERSION_1 0x19980330 +#define _LINUX_CAPABILITY_U32S_1 1 +#define _LINUX_CAPABILITY_VERSION_2 0x20071026 +#define _LINUX_CAPABILITY_U32S_2 2 +#define _LINUX_CAPABILITY_VERSION_3 0x20080522 +#define _LINUX_CAPABILITY_U32S_3 2 + +typedef struct __user_cap_header_struct { + __u32 version; + int pid; +} __user *cap_user_header_t; + +typedef struct __user_cap_data_struct { + __u32 effective; + __u32 permitted; + __u32 inheritable; +} __user *cap_user_data_t; + +#define VFS_CAP_REVISION_MASK 0xFF000000 +#define VFS_CAP_REVISION_SHIFT 24 +#define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK +#define VFS_CAP_FLAGS_EFFECTIVE 0x000001 +#define VFS_CAP_REVISION_1 0x01000000 +#define VFS_CAP_U32_1 1 +#define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1)) +#define VFS_CAP_REVISION_2 0x02000000 +#define VFS_CAP_U32_2 2 +#define XATTR_CAPS_SZ_2 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_2)) +#define XATTR_CAPS_SZ XATTR_CAPS_SZ_2 +#define VFS_CAP_U32 VFS_CAP_U32_2 +#define VFS_CAP_REVISION VFS_CAP_REVISION_2 + +struct vfs_cap_data { + __le32 magic_etc; + struct { + __le32 permitted; + __le32 inheritable; + } data[VFS_CAP_U32]; +}; + +#define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1 +#define _LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1 +#define CAP_CHOWN 0 +#define CAP_DAC_OVERRIDE 1 +#define CAP_DAC_READ_SEARCH 2 +#define CAP_FOWNER 3 +#define CAP_FSETID 4 +#define CAP_KILL 5 +#define CAP_SETGID 6 +#define CAP_SETUID 7 +#define CAP_SETPCAP 8 +#define CAP_LINUX_IMMUTABLE 9 +#define CAP_NET_BIND_SERVICE 10 +#define CAP_NET_BROADCAST 11 +#define CAP_NET_ADMIN 12 +#define CAP_NET_RAW 13 +#define CAP_IPC_LOCK 14 +#define CAP_IPC_OWNER 15 +#define CAP_SYS_MODULE 16 +#define CAP_SYS_RAWIO 17 +#define CAP_SYS_CHROOT 18 +#define CAP_SYS_PTRACE 19 +#define CAP_SYS_PACCT 20 +#define CAP_SYS_ADMIN 21 +#define CAP_SYS_BOOT 22 +#define CAP_SYS_NICE 23 +#define CAP_SYS_RESOURCE 24 +#define CAP_SYS_TIME 25 +#define CAP_SYS_TTY_CONFIG 26 +#define CAP_MKNOD 27 +#define CAP_LEASE 28 +#define CAP_AUDIT_WRITE 29 +#define CAP_AUDIT_CONTROL 30 +#define CAP_SETFCAP 31 +#define CAP_MAC_OVERRIDE 32 +#define CAP_MAC_ADMIN 33 +#define CAP_SYSLOG 34 +#define CAP_WAKE_ALARM 35 +#define CAP_LAST_CAP CAP_WAKE_ALARM +#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)) + +#undef __user +#undef __u32 +#undef __le32 + +#endif diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index ce1e55d..53bd166 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -25,6 +25,13 @@ #include <string.h> #include <sys/stat.h> #include <sys/types.h> +#include <stdint.h> + +#ifdef HAVE_ANDROID_OS +#include <linux/capability.h> +#else +#include "android_filesystem_capability.h" +#endif /* This is the master Users and Groups config for the platform. ** DO NOT EVER RENUMBER. @@ -53,7 +60,7 @@ #define AID_KEYSTORE 1017 /* keystore subsystem */ #define AID_USB 1018 /* USB devices */ #define AID_DRM 1019 /* DRM server */ -#define AID_AVAILABLE 1020 /* available for use */ +#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */ #define AID_GPS 1021 /* GPS daemon */ #define AID_UNUSED1 1022 /* deprecated, DO NOT USE */ #define AID_MEDIA_RW 1023 /* internal media storage write access */ @@ -61,6 +68,9 @@ #define AID_UNUSED2 1025 /* deprecated, DO NOT USE */ #define AID_DRMRPC 1026 /* group for drm rpc */ #define AID_NFC 1027 /* nfc subsystem */ +#define AID_SDCARD_R 1028 /* external storage read access */ +#define AID_CLAT 1029 /* clat part of nat464 */ +#define AID_LOOP_RADIO 1030 /* loop radio devices */ #define AID_SHELL 2000 /* adb and debug shell user */ #define AID_CACHE 2001 /* cache access */ @@ -75,11 +85,20 @@ #define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */ #define AID_NET_BW_STATS 3006 /* read bandwidth statistics */ #define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */ +#define AID_NET_BT_STACK 3008 /* bluetooth: access config files */ #define AID_MISC 9998 /* access to misc storage */ #define AID_NOBODY 9999 -#define AID_APP 10000 /* first app user */ +#define AID_APP 10000 /* first app user */ + +#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */ +#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */ + +#define AID_USER 100000 /* offset for uid ranges for each user */ + +#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */ +#define AID_SHARED_GID_END 59999 /* start of gids for apps in each user to share */ #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES) struct android_id_info { @@ -105,7 +124,7 @@ static const struct android_id_info android_ids[] = { { "install", AID_INSTALL, }, { "media", AID_MEDIA, }, { "drm", AID_DRM, }, - { "available", AID_AVAILABLE, }, + { "mdnsr", AID_MDNSR, }, { "nfc", AID_NFC, }, { "drmrpc", AID_DRMRPC, }, { "shell", AID_SHELL, }, @@ -113,6 +132,8 @@ static const struct android_id_info android_ids[] = { { "diag", AID_DIAG, }, { "net_bt_admin", AID_NET_BT_ADMIN, }, { "net_bt", AID_NET_BT, }, + { "net_bt_stack", AID_NET_BT_STACK, }, + { "sdcard_r", AID_SDCARD_R, }, { "sdcard_rw", AID_SDCARD_RW, }, { "media_rw", AID_MEDIA_RW, }, { "vpn", AID_VPN, }, @@ -125,17 +146,20 @@ static const struct android_id_info android_ids[] = { { "net_admin", AID_NET_ADMIN, }, { "net_bw_stats", AID_NET_BW_STATS, }, { "net_bw_acct", AID_NET_BW_ACCT, }, + { "loop_radio", AID_LOOP_RADIO, }, { "misc", AID_MISC, }, { "nobody", AID_NOBODY, }, + { "clat", AID_CLAT, }, }; #define android_id_count \ (sizeof(android_ids) / sizeof(android_ids[0])) - + struct fs_path_config { unsigned mode; unsigned uid; unsigned gid; + uint64_t capabilities; const char *prefix; }; @@ -145,26 +169,26 @@ struct fs_path_config { ** way up to the root. */ -static struct fs_path_config android_dirs[] = { - { 00770, AID_SYSTEM, AID_CACHE, "cache" }, - { 00771, AID_SYSTEM, AID_SYSTEM, "data/app" }, - { 00771, AID_SYSTEM, AID_SYSTEM, "data/app-private" }, - { 00771, AID_SYSTEM, AID_SYSTEM, "data/dalvik-cache" }, - { 00771, AID_SYSTEM, AID_SYSTEM, "data/data" }, - { 00771, AID_SHELL, AID_SHELL, "data/local/tmp" }, - { 00771, AID_SHELL, AID_SHELL, "data/local" }, - { 01771, AID_SYSTEM, AID_MISC, "data/misc" }, - { 00770, AID_DHCP, AID_DHCP, "data/misc/dhcp" }, - { 00775, AID_MEDIA_RW, AID_MEDIA_RW, "data/media" }, - { 00775, AID_MEDIA_RW, AID_MEDIA_RW, "data/media/Music" }, - { 00771, AID_SYSTEM, AID_SYSTEM, "data" }, - { 00750, AID_ROOT, AID_SHELL, "sbin" }, - { 00755, AID_ROOT, AID_SHELL, "system/bin" }, - { 00755, AID_ROOT, AID_SHELL, "system/vendor" }, - { 00755, AID_ROOT, AID_SHELL, "system/xbin" }, - { 00755, AID_ROOT, AID_ROOT, "system/etc/ppp" }, - { 00777, AID_ROOT, AID_ROOT, "sdcard" }, - { 00755, AID_ROOT, AID_ROOT, 0 }, +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_SYSTEM, AID_SYSTEM, 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" }, + { 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" }, + { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" }, + { 00755, AID_ROOT, AID_ROOT, 0, 0 }, }; /* Rules for files. @@ -173,59 +197,62 @@ static struct fs_path_config android_dirs[] = { ** way up to the root. Prefixes ending in * denotes wildcard ** and will allow partial matches. */ -static struct fs_path_config android_files[] = { - { 00440, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.rc" }, - { 00550, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.sh" }, - { 00440, AID_ROOT, AID_SHELL, "system/etc/init.trout.rc" }, - { 00550, AID_ROOT, AID_SHELL, "system/etc/init.ril" }, - { 00550, AID_ROOT, AID_SHELL, "system/etc/init.testmenu" }, - { 00550, AID_DHCP, AID_SHELL, "system/etc/dhcpcd/dhcpcd-run-hooks" }, - { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/dbus.conf" }, - { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/main.conf" }, - { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/input.conf" }, - { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/audio.conf" }, - { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/network.conf" }, - { 00444, AID_NET_BT, AID_NET_BT, "system/etc/bluetooth/blacklist.conf" }, - { 00640, AID_SYSTEM, AID_SYSTEM, "system/etc/bluetooth/auto_pairing.conf" }, - { 00444, AID_RADIO, AID_AUDIO, "system/etc/AudioPara4.csv" }, - { 00555, AID_ROOT, AID_ROOT, "system/etc/ppp/*" }, - { 00555, AID_ROOT, AID_ROOT, "system/etc/rc.*" }, - { 00644, AID_SYSTEM, AID_SYSTEM, "data/app/*" }, - { 00644, AID_MEDIA_RW, AID_MEDIA_RW, "data/media/*" }, - { 00644, AID_SYSTEM, AID_SYSTEM, "data/app-private/*" }, - { 00644, AID_APP, AID_APP, "data/data/*" }, - /* the following two files are INTENTIONALLY set-gid and not set-uid. - * Do not change. */ - { 02755, AID_ROOT, AID_NET_RAW, "system/bin/ping" }, - { 02750, AID_ROOT, AID_INET, "system/bin/netcfg" }, - /* the following five files are INTENTIONALLY set-uid, but they - * are NOT included on user builds. */ - { 06755, AID_ROOT, AID_ROOT, "system/xbin/su" }, - { 06755, AID_ROOT, AID_ROOT, "system/xbin/librank" }, - { 06755, AID_ROOT, AID_ROOT, "system/xbin/procrank" }, - { 06755, AID_ROOT, AID_ROOT, "system/xbin/procmem" }, - { 06755, AID_ROOT, AID_ROOT, "system/xbin/tcpdump" }, - { 04770, AID_ROOT, AID_RADIO, "system/bin/pppd-ril" }, - /* the following file is INTENTIONALLY set-uid, and IS included - * in user builds. */ - { 06750, AID_ROOT, AID_SHELL, "system/bin/run-as" }, - { 00755, AID_ROOT, AID_SHELL, "system/bin/*" }, - { 00755, AID_ROOT, AID_ROOT, "system/lib/valgrind/*" }, - { 00755, AID_ROOT, AID_SHELL, "system/xbin/*" }, - { 00755, AID_ROOT, AID_SHELL, "system/vendor/bin/*" }, - { 00750, AID_ROOT, AID_SHELL, "sbin/*" }, - { 00755, AID_ROOT, AID_ROOT, "bin/*" }, - { 00750, AID_ROOT, AID_SHELL, "init*" }, - { 00750, AID_ROOT, AID_SHELL, "charger*" }, - { 00644, AID_ROOT, AID_ROOT, 0 }, +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" }, + { 00440, AID_BLUETOOTH, AID_BLUETOOTH, 0, "system/etc/dbus.conf" }, + { 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" }, + + /* the following file is INTENTIONALLY set-gid and not set-uid. + * Do not change. */ + { 02750, AID_ROOT, AID_INET, 0, "system/bin/netcfg" }, + + /* the following five files are INTENTIONALLY set-uid, but they + * are NOT included on user builds. */ + { 06755, AID_ROOT, AID_ROOT, 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" }, + { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/tcpdump" }, + { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" }, + + /* the following file has enhanced capabilities and IS included in user builds. */ + { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" }, + + { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" }, + { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" }, + { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" }, + { 00755, AID_ROOT, AID_SHELL, 0, "system/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, "charger*" }, + { 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) + unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities) { - struct fs_path_config *pc; + const struct fs_path_config *pc; int plen; - + + if (path[0] == '/') { + path++; + } + pc = dir ? android_dirs : android_files; plen = strlen(path); for(; pc->prefix; pc++){ @@ -245,9 +272,10 @@ static inline void fs_config(const char *path, int dir, *uid = pc->uid; *gid = pc->gid; *mode = (*mode & (~07777)) | pc->mode; - + *capabilities = pc->capabilities; + #if 0 - fprintf(stderr,"< '%s' '%s' %d %d %o >\n", + fprintf(stderr,"< '%s' '%s' %d %d %o >\n", path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode); #endif } diff --git a/include/private/pixelflinger/ggl_context.h b/include/private/pixelflinger/ggl_context.h index 2d7fdcf..4864d5a 100644 --- a/include/private/pixelflinger/ggl_context.h +++ b/include/private/pixelflinger/ggl_context.h @@ -42,10 +42,30 @@ inline uint32_t GGL_HOST_TO_RGBA(uint32_t 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 diff --git a/include/private/pixelflinger/ggl_fixed.h b/include/private/pixelflinger/ggl_fixed.h index 96fdb32..217ec04 100644 --- a/include/private/pixelflinger/ggl_fixed.h +++ b/include/private/pixelflinger/ggl_fixed.h @@ -190,6 +190,272 @@ inline int64_t gglMulii(int32_t x, int32_t 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; +} #else // ---------------------------------------------------------------------- @@ -232,7 +498,7 @@ inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) { inline int32_t gglClz(int32_t x) CONST; inline int32_t gglClz(int32_t x) { -#if defined(__arm__) && !defined(__thumb__) +#if (defined(__arm__) && !defined(__thumb__)) || defined(__mips__) return __builtin_clz(x); #else if (!x) return 32; diff --git a/include/sync/sync.h b/include/sync/sync.h new file mode 100644 index 0000000..918acf6 --- /dev/null +++ b/include/sync/sync.h @@ -0,0 +1,62 @@ +/* + * sync.h + * + * Copyright 2012 Google, Inc + * + * 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 __SYS_CORE_SYNC_H +#define __SYS_CORE_SYNC_H + +#include <sys/cdefs.h> +#include <stdint.h> + +__BEGIN_DECLS + +// XXX: These structs are copied from the header "linux/sync.h". +struct sync_fence_info_data { + uint32_t len; + char name[32]; + int32_t status; + uint8_t pt_info[0]; +}; + +struct sync_pt_info { + uint32_t len; + char obj_name[32]; + char driver_name[32]; + int32_t status; + uint64_t timestamp_ns; + uint8_t driver_data[0]; +}; + +/* timeout in msecs */ +int sync_wait(int fd, int timeout); +int sync_merge(const char *name, int fd1, int fd2); +struct sync_fence_info_data *sync_fence_info(int fd); +struct sync_pt_info *sync_pt_info(struct sync_fence_info_data *info, + struct sync_pt_info *itr); +void sync_fence_info_free(struct sync_fence_info_data *info); + +/* sw_sync is mainly inteded for testing and should not be complied into + * production kernels + */ + +int sw_sync_timeline_create(void); +int sw_sync_timeline_inc(int fd, unsigned count); +int sw_sync_fence_create(int fd, const char *name, unsigned value); + +__END_DECLS + +#endif /* __SYS_CORE_SYNC_H */ diff --git a/include/system/audio.h b/include/system/audio.h index 52ba5e7..d246070 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -63,7 +63,10 @@ typedef enum { AUDIO_SOURCE_CAMCORDER = 5, AUDIO_SOURCE_VOICE_RECOGNITION = 6, AUDIO_SOURCE_VOICE_COMMUNICATION = 7, - + AUDIO_SOURCE_REMOTE_SUBMIX = 8, /* Source for the mix to be presented remotely. */ + /* An example of remote presentation is Wifi Display */ + /* where a dongle attached to a TV can be used to */ + /* play the mix captured by this audio source. */ AUDIO_SOURCE_CNT, AUDIO_SOURCE_MAX = AUDIO_SOURCE_CNT - 1, } audio_source_t; @@ -152,7 +155,7 @@ typedef enum { AUDIO_FORMAT_PCM_SUB_8_24_BIT), } audio_format_t; -typedef enum { +enum { /* output channels */ AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1, AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2, @@ -250,7 +253,9 @@ typedef enum { AUDIO_CHANNEL_IN_Z_AXIS | AUDIO_CHANNEL_IN_VOICE_UPLINK | AUDIO_CHANNEL_IN_VOICE_DNLINK), -} audio_channels_t; +}; + +typedef uint32_t audio_channel_mask_t; typedef enum { AUDIO_MODE_INVALID = -2, @@ -273,7 +278,11 @@ typedef enum { AUDIO_IN_ACOUSTICS_TX_DISABLE = 0, } audio_in_acoustics_t; -typedef enum { +enum { + AUDIO_DEVICE_NONE = 0x0, + /* reserved bits */ + AUDIO_DEVICE_BIT_IN = 0x80000000, + AUDIO_DEVICE_BIT_DEFAULT = 0x40000000, /* output devices */ AUDIO_DEVICE_OUT_EARPIECE = 0x1, AUDIO_DEVICE_OUT_SPEAKER = 0x2, @@ -288,7 +297,10 @@ typedef enum { AUDIO_DEVICE_OUT_AUX_DIGITAL = 0x400, AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800, AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000, - AUDIO_DEVICE_OUT_DEFAULT = 0x8000, + AUDIO_DEVICE_OUT_USB_ACCESSORY = 0x2000, + AUDIO_DEVICE_OUT_USB_DEVICE = 0x4000, + AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 0x8000, + AUDIO_DEVICE_OUT_DEFAULT = AUDIO_DEVICE_BIT_DEFAULT, AUDIO_DEVICE_OUT_ALL = (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | AUDIO_DEVICE_OUT_WIRED_HEADSET | @@ -302,6 +314,9 @@ typedef enum { AUDIO_DEVICE_OUT_AUX_DIGITAL | AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET | + AUDIO_DEVICE_OUT_USB_ACCESSORY | + AUDIO_DEVICE_OUT_USB_DEVICE | + AUDIO_DEVICE_OUT_REMOTE_SUBMIX | AUDIO_DEVICE_OUT_DEFAULT), AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | @@ -309,17 +324,24 @@ typedef enum { AUDIO_DEVICE_OUT_ALL_SCO = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT), + AUDIO_DEVICE_OUT_ALL_USB = (AUDIO_DEVICE_OUT_USB_ACCESSORY | + AUDIO_DEVICE_OUT_USB_DEVICE), /* input devices */ - AUDIO_DEVICE_IN_COMMUNICATION = 0x10000, - AUDIO_DEVICE_IN_AMBIENT = 0x20000, - AUDIO_DEVICE_IN_BUILTIN_MIC = 0x40000, - AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000, - AUDIO_DEVICE_IN_WIRED_HEADSET = 0x100000, - AUDIO_DEVICE_IN_AUX_DIGITAL = 0x200000, - AUDIO_DEVICE_IN_VOICE_CALL = 0x400000, - AUDIO_DEVICE_IN_BACK_MIC = 0x800000, - AUDIO_DEVICE_IN_DEFAULT = 0x80000000, + AUDIO_DEVICE_IN_COMMUNICATION = AUDIO_DEVICE_BIT_IN | 0x1, + AUDIO_DEVICE_IN_AMBIENT = AUDIO_DEVICE_BIT_IN | 0x2, + AUDIO_DEVICE_IN_BUILTIN_MIC = AUDIO_DEVICE_BIT_IN | 0x4, + AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN | 0x8, + AUDIO_DEVICE_IN_WIRED_HEADSET = AUDIO_DEVICE_BIT_IN | 0x10, + AUDIO_DEVICE_IN_AUX_DIGITAL = AUDIO_DEVICE_BIT_IN | 0x20, + AUDIO_DEVICE_IN_VOICE_CALL = AUDIO_DEVICE_BIT_IN | 0x40, + AUDIO_DEVICE_IN_BACK_MIC = AUDIO_DEVICE_BIT_IN | 0x80, + AUDIO_DEVICE_IN_REMOTE_SUBMIX = AUDIO_DEVICE_BIT_IN | 0x100, + AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x200, + AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x400, + AUDIO_DEVICE_IN_USB_ACCESSORY = AUDIO_DEVICE_BIT_IN | 0x800, + AUDIO_DEVICE_IN_USB_DEVICE = AUDIO_DEVICE_BIT_IN | 0x1000, + AUDIO_DEVICE_IN_DEFAULT = AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT, AUDIO_DEVICE_IN_ALL = (AUDIO_DEVICE_IN_COMMUNICATION | AUDIO_DEVICE_IN_AMBIENT | @@ -329,13 +351,44 @@ typedef enum { AUDIO_DEVICE_IN_AUX_DIGITAL | AUDIO_DEVICE_IN_VOICE_CALL | AUDIO_DEVICE_IN_BACK_MIC | + AUDIO_DEVICE_IN_REMOTE_SUBMIX | + AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET | + AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET | + AUDIO_DEVICE_IN_USB_ACCESSORY | + AUDIO_DEVICE_IN_USB_DEVICE | AUDIO_DEVICE_IN_DEFAULT), AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, -} audio_devices_t; +}; + +typedef uint32_t audio_devices_t; + +/* the audio output flags serve two purposes: + * - when an AudioTrack is created they indicate a "wish" to be connected to an + * output stream with attributes corresponding to the specified flags + * - when present in an output profile descriptor listed for a particular audio + * hardware module, they indicate that an output stream can be opened that + * supports the attributes indicated by the flags. + * the audio policy manager will try to match the flags in the request + * (when getOuput() is called) to an available output stream. + */ +typedef enum { + AUDIO_OUTPUT_FLAG_NONE = 0x0, // no attributes + AUDIO_OUTPUT_FLAG_DIRECT = 0x1, // this output directly connects a track + // to one output stream: no software mixer + AUDIO_OUTPUT_FLAG_PRIMARY = 0x2, // this output is the primary output of + // the device. It is unique and must be + // present. It is opened by default and + // receives routing, audio mode and volume + // controls related to voice calls. + AUDIO_OUTPUT_FLAG_FAST = 0x4, // output supports "fast tracks", + // defined elsewhere + AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8 // use deep audio buffers +} audio_output_flags_t; static inline bool audio_is_output_device(audio_devices_t device) { - if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0)) + if (((device & AUDIO_DEVICE_BIT_IN) == 0) && + (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0)) return true; else return false; @@ -343,12 +396,20 @@ static inline bool audio_is_output_device(audio_devices_t device) static inline bool audio_is_input_device(audio_devices_t device) { - if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) - return true; - else - return false; + if ((device & AUDIO_DEVICE_BIT_IN) != 0) { + device &= ~AUDIO_DEVICE_BIT_IN; + if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) + return true; + } + return false; } +static inline bool audio_is_output_devices(audio_devices_t device) +{ + return (device & AUDIO_DEVICE_BIT_IN) == 0; +} + + static inline bool audio_is_a2dp_device(audio_devices_t device) { if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP)) @@ -359,6 +420,7 @@ static inline bool audio_is_a2dp_device(audio_devices_t device) static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) { + device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && (device & (AUDIO_DEVICE_OUT_ALL_SCO | AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET))) return true; @@ -366,6 +428,22 @@ static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) return false; } +static inline bool audio_is_usb_device(audio_devices_t device) +{ + if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB)) + return true; + else + return false; +} + +static inline bool audio_is_remote_submix_device(audio_devices_t device) +{ + if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)) + return true; + else + return false; +} + static inline bool audio_is_input_channel(uint32_t channel) { if ((channel & ~AUDIO_CHANNEL_IN_ALL) == 0) @@ -382,7 +460,52 @@ static inline bool audio_is_output_channel(uint32_t channel) return false; } -static inline bool audio_is_valid_format(uint32_t format) +/* Derive an output channel mask from a channel count. + * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel + * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad, + * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC + * for continuity with stereo. + * Returns the matching channel mask, or 0 if the number of channels exceeds that of the + * configurations for which a default channel mask is defined. + */ +static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count) +{ + switch(channel_count) { + case 1: + return AUDIO_CHANNEL_OUT_MONO; + case 2: + return AUDIO_CHANNEL_OUT_STEREO; + case 3: + return (AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER); + case 4: // 4.0 + return AUDIO_CHANNEL_OUT_QUAD; + case 5: // 5.0 + return (AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER); + case 6: // 5.1 + return AUDIO_CHANNEL_OUT_5POINT1; + case 7: // 6.1 + return (AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER); + case 8: + return AUDIO_CHANNEL_OUT_7POINT1; + default: + return 0; + } +} + +/* Similar to above, but for input. Currently handles only mono and stereo. */ +static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count) +{ + switch (channel_count) { + case 1: + return AUDIO_CHANNEL_IN_MONO; + case 2: + return AUDIO_CHANNEL_IN_STEREO; + default: + return 0; + } +} + +static inline bool audio_is_valid_format(audio_format_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { case AUDIO_FORMAT_PCM: @@ -403,28 +526,28 @@ static inline bool audio_is_valid_format(uint32_t format) } } -static inline bool audio_is_linear_pcm(uint32_t format) +static inline bool audio_is_linear_pcm(audio_format_t format) { return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM); } -static inline size_t audio_bytes_per_sample(uint32_t format) +static inline size_t audio_bytes_per_sample(audio_format_t format) { size_t size = 0; switch (format) { - case AUDIO_FORMAT_PCM_32_BIT: - case AUDIO_FORMAT_PCM_8_24_BIT: - size = sizeof(int32_t); - break; - case AUDIO_FORMAT_PCM_16_BIT: - size = sizeof(int16_t); - break; - case AUDIO_FORMAT_PCM_8_BIT: - size = sizeof(uint8_t); - break; - default: - break; + case AUDIO_FORMAT_PCM_32_BIT: + case AUDIO_FORMAT_PCM_8_24_BIT: + size = sizeof(int32_t); + break; + case AUDIO_FORMAT_PCM_16_BIT: + size = sizeof(int16_t); + break; + case AUDIO_FORMAT_PCM_8_BIT: + size = sizeof(uint8_t); + break; + default: + break; } return size; } diff --git a/include/system/audio_policy.h b/include/system/audio_policy.h index 1e0af7d..a6554de 100644 --- a/include/system/audio_policy.h +++ b/include/system/audio_policy.h @@ -30,14 +30,6 @@ __BEGIN_DECLS * frameworks/base/include/media/AudioSystem.h */ -/* request to open a direct output with get_output() (by opposition to - * sharing an output with other AudioTracks) - */ -typedef enum { - AUDIO_POLICY_OUTPUT_FLAG_INDIRECT = 0x0, - AUDIO_POLICY_OUTPUT_FLAG_DIRECT = 0x1 -} audio_policy_output_flags_t; - /* device categories used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_NONE, @@ -50,6 +42,8 @@ typedef enum { AUDIO_POLICY_FORCE_BT_DESK_DOCK, AUDIO_POLICY_FORCE_ANALOG_DOCK, AUDIO_POLICY_FORCE_DIGITAL_DOCK, + AUDIO_POLICY_FORCE_NO_BT_A2DP, /* A2DP sink is not preferred to speaker or wired HS */ + AUDIO_POLICY_FORCE_SYSTEM_ENFORCED, AUDIO_POLICY_FORCE_CFG_CNT, AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, @@ -63,6 +57,7 @@ typedef enum { AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_FOR_RECORD, AUDIO_POLICY_FORCE_FOR_DOCK, + AUDIO_POLICY_FORCE_FOR_SYSTEM, AUDIO_POLICY_FORCE_USE_CNT, AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, diff --git a/include/system/camera.h b/include/system/camera.h index cdfa256..7a4dd53 100644 --- a/include/system/camera.h +++ b/include/system/camera.h @@ -85,6 +85,9 @@ enum { // request FRAME and METADATA. Or the apps can request only FRAME or only // METADATA. CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback + // Notify on autofocus start and stop. This is useful in continuous + // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. + CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback CAMERA_MSG_ALL_MSGS = 0xFFFF }; @@ -134,7 +137,8 @@ enum { * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. * * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or - * CAMERA_FACE_DETECTION_SW. + * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not + * supported, the HAL must return BAD_VALUE. */ CAMERA_CMD_START_FACE_DETECTION = 6, @@ -142,11 +146,47 @@ enum { * Stop the face detection. */ CAMERA_CMD_STOP_FACE_DETECTION = 7, + + /** + * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing + * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. + */ + CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, + + /** + * Ping camera service to see if camera hardware is released. + * + * When any camera method returns error, the client can use ping command + * to see if the camera has been taken away by other clients. If the result + * is NO_ERROR, it means the camera hardware is not released. If the result + * is not NO_ERROR, the camera has been released and the existing client + * can silently finish itself or show a dialog. + */ + CAMERA_CMD_PING = 9, + + /** + * Configure the number of video buffers used for recording. The intended + * video buffer count for recording is passed as arg1, which must be + * greater than 0. This command must be sent before recording is started. + * This command returns INVALID_OPERATION error if it is sent after video + * recording is started, or the command is not supported at all. This + * command also returns a BAD_VALUE error if the intended video buffer + * count is non-positive or too big to be realized. + */ + CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, }; /** camera fatal errors */ enum { CAMERA_ERROR_UNKNOWN = 1, + /** + * Camera was released because another client has connected to the camera. + * The original client should call Camera::disconnect immediately after + * getting this notification. Otherwise, the camera will be released by + * camera service in a short time. The client should not call any method + * (except disconnect and sending CAMERA_CMD_PING) after getting this. + */ + CAMERA_ERROR_RELEASED = 2, CAMERA_ERROR_SERVER_DIED = 100 }; diff --git a/include/system/graphics.h b/include/system/graphics.h index 729e92c..82b5fcc 100644 --- a/include/system/graphics.h +++ b/include/system/graphics.h @@ -78,7 +78,8 @@ enum { * - a vertical stride equal to the height * * y_size = stride * height - * c_size = ALIGN(stride/2, 16) * height/2 + * c_stride = ALIGN(stride/2, 16) + * c_size = c_stride * height/2 * size = y_size + c_size * 2 * cr_offset = y_size * cb_offset = y_size + c_size @@ -86,7 +87,58 @@ enum { */ HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar + /* + * Android RAW sensor format: + * + * This format is exposed outside of the HAL to applications. + * + * RAW_SENSOR is a single-channel 16-bit format, typically representing raw + * Bayer-pattern images from an image sensor, with minimal processing. + * + * The exact pixel layout of the data in the buffer is sensor-dependent, and + * needs to be queried from the camera device. + * + * Generally, not all 16 bits are used; more common values are 10 or 12 + * bits. All parameters to interpret the raw data (black and white points, + * color space, etc) must be queried from the camera device. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels (32 bytes). + */ + HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, + /* + * Android binary blob graphics buffer format: + * + * This format is used to carry task-specific data which does not have a + * standard image structure. The details of the format are left to the two + * endpoints. + * + * A typical use case is for transporting JPEG-compressed images from the + * Camera HAL to the framework or to applications. + * + * Buffers of this format must have a height of 1, and width equal to their + * size in bytes. + */ + HAL_PIXEL_FORMAT_BLOB = 0x21, + + /* + * Android format indicating that the choice of format is entirely up to the + * device-specific Gralloc implementation. + * + * The Gralloc implementation should examine the usage bits passed in when + * allocating a buffer with this format, and it should derive the pixel + * format from those usage flags. This format will never be used with any + * of the GRALLOC_USAGE_SW_* usage flags. + * + * If a buffer of this format is to be used as an OpenGL ES texture, the + * 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). + * + */ + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, /* Legacy formats (deprecated), used by ImageFormat.java */ HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 diff --git a/include/system/window.h b/include/system/window.h index 1cc4a0a..4698fb3 100644 --- a/include/system/window.h +++ b/include/system/window.h @@ -17,10 +17,15 @@ #ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H +#include <cutils/native_handle.h> +#include <errno.h> +#include <limits.h> #include <stdint.h> +#include <string.h> +#include <sync/sync.h> #include <sys/cdefs.h> #include <system/graphics.h> -#include <cutils/native_handle.h> +#include <unistd.h> __BEGIN_DECLS @@ -37,6 +42,14 @@ __BEGIN_DECLS // --------------------------------------------------------------------------- +// This #define may be used to conditionally compile device-specific code to +// support either the prior ANativeWindow interface, which did not pass libsync +// fences around, or the new interface that does. This #define is only present +// when the ANativeWindow interface does include libsync support. +#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 + +// --------------------------------------------------------------------------- + typedef const native_handle_t* buffer_handle_t; // --------------------------------------------------------------------------- @@ -156,9 +169,10 @@ enum { /* - * Default width and height of the ANativeWindow, these are the dimensions - * of the window irrespective of the NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS - * call. + * Default width and height of ANativeWindow buffers, these are the + * dimensions of the window buffers irrespective of the + * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window + * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. */ NATIVE_WINDOW_DEFAULT_WIDTH = 6, NATIVE_WINDOW_DEFAULT_HEIGHT = 7, @@ -211,25 +225,42 @@ enum { * */ NATIVE_WINDOW_TRANSFORM_HINT = 8, + + /* + * Boolean that indicates whether the consumer is running more than + * one buffer behind the producer. + */ + NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9 }; -/* valid operations for the (*perform)() hook */ +/* Valid operations for the (*perform)() hook. + * + * Values marked as 'deprecated' are supported, but have been superceded by + * other functionality. + * + * Values marked as 'private' should be considered private to the framework. + * HAL implementation code with access to an ANativeWindow should not use these, + * as it may not interact properly with the framework's use of the + * ANativeWindow. + */ enum { NATIVE_WINDOW_SET_USAGE = 0, NATIVE_WINDOW_CONNECT = 1, /* deprecated */ NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ - NATIVE_WINDOW_SET_CROP = 3, + NATIVE_WINDOW_SET_CROP = 3, /* private */ NATIVE_WINDOW_SET_BUFFER_COUNT = 4, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, - NATIVE_WINDOW_SET_SCALING_MODE = 10, + NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ NATIVE_WINDOW_LOCK = 11, /* private */ NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ NATIVE_WINDOW_API_CONNECT = 13, /* private */ NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ + NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ + NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ @@ -275,6 +306,15 @@ enum { NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, /* the buffer is scaled in both dimensions to match the window size */ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, + /* the buffer is scaled uniformly such that the smaller dimension + * of the buffer matches the window size (cropping in the process) + */ + NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, + /* the window is clipped to the size of the buffer's crop rectangle; pixels + * outside the crop rectangle are treated as if they are completely + * transparent. + */ + NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, }; /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ @@ -351,8 +391,12 @@ struct ANativeWindow * allowed if a specific buffer count has been set. * * Returns 0 on success or -errno on error. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but the new dequeueBuffer function that + * outputs a fence file descriptor should be used in its place. */ - int (*dequeueBuffer)(struct ANativeWindow* window, + int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer); /* @@ -361,9 +405,14 @@ struct ANativeWindow * dequeueBuffer first. * * Returns 0 on success or -errno on error. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but it is essentially a no-op, and calls + * to it should be removed. */ - int (*lockBuffer)(struct ANativeWindow* window, + int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); + /* * Hook called by EGL when modifications to the render buffer are done. * This unlocks and post the buffer. @@ -377,8 +426,13 @@ struct ANativeWindow * Buffers MUST be queued in the same order than they were dequeued. * * Returns 0 on success or -errno on error. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but the new queueBuffer function that + * takes a fence file descriptor should be used in its place (pass a value + * of -1 for the fence file descriptor if there is no valid one to pass). */ - int (*queueBuffer)(struct ANativeWindow* window, + int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* @@ -404,18 +458,20 @@ struct ANativeWindow * NATIVE_WINDOW_SET_USAGE * NATIVE_WINDOW_CONNECT (deprecated) * NATIVE_WINDOW_DISCONNECT (deprecated) - * NATIVE_WINDOW_SET_CROP + * 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 + * 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) * */ @@ -433,12 +489,86 @@ struct ANativeWindow * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but the new cancelBuffer function that + * takes a fence file descriptor should be used in its place (pass a value + * of -1 for the fence file descriptor if there is no valid one to pass). */ - int (*cancelBuffer)(struct ANativeWindow* window, + int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); + /* + * Hook called by EGL to acquire a buffer. This call may block if no + * buffers are available. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The libsync fence file descriptor returned in the int pointed to by the + * fenceFd argument will refer to the fence that must signal before the + * dequeued buffer may be written to. A value of -1 indicates that the + * caller may access the buffer immediately without waiting on a fence. If + * a valid file descriptor is returned (i.e. any value except -1) then the + * caller is responsible for closing the file descriptor. + * + * Returns 0 on success or -errno on error. + */ + int (*dequeueBuffer)(struct ANativeWindow* window, + struct ANativeWindowBuffer** buffer, int* fenceFd); - void* reserved_proc[2]; + /* + * Hook called by EGL when modifications to the render buffer are done. + * This unlocks and post the buffer. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The fenceFd argument specifies a libsync fence file descriptor for a + * fence that must signal before the buffer can be accessed. If the buffer + * can be accessed immediately then a value of -1 should be used. The + * caller must not use the file descriptor after it is passed to + * queueBuffer, and the ANativeWindow implementation is responsible for + * closing it. + * + * Returns 0 on success or -errno on error. + */ + int (*queueBuffer)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer, int fenceFd); + + /* + * Hook used to cancel a buffer that has been dequeued. + * No synchronization is performed between dequeue() and cancel(), so + * either external synchronization is needed, or these functions must be + * called from the same thread. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The fenceFd argument specifies a libsync fence file decsriptor for a + * fence that must signal before the buffer can be accessed. If the buffer + * can be accessed immediately then a value of -1 should be used. + * + * Note that if the client has not waited on the fence that was returned + * from dequeueBuffer, that same fence should be passed to cancelBuffer to + * ensure that future uses of the buffer are preceded by a wait on that + * fence. The caller must not use the file descriptor after it is passed + * to cancelBuffer, and the ANativeWindow implementation is responsible for + * closing it. + * + * Returns 0 on success or -errno on error. + */ + int (*cancelBuffer)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer, int fenceFd); }; /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). @@ -479,14 +609,16 @@ static inline int native_window_disconnect( /* * native_window_set_crop(..., crop) * Sets which region of the next queued buffers needs to be considered. - * A buffer's crop region is scaled to match the surface's size. + * Depending on the scaling mode, a buffer's crop region is scaled and/or + * cropped to match the surface's size. This function sets the crop in + * pre-transformed buffer pixel coordinates. * * The specified crop region applies to all buffers queued after it is called. * - * if 'crop' is NULL, subsequently queued buffers won't be cropped. + * If 'crop' is NULL, subsequently queued buffers won't be cropped. * - * An error is returned if for instance the crop region is invalid, - * out of the buffer's bound or if the window is invalid. + * An error is returned if for instance the crop region is invalid, out of the + * buffer's bound or if the window is invalid. */ static inline int native_window_set_crop( struct ANativeWindow* window, @@ -496,6 +628,41 @@ static inline int native_window_set_crop( } /* + * native_window_set_post_transform_crop(..., crop) + * Sets which region of the next queued buffers needs to be considered. + * Depending on the scaling mode, a buffer's crop region is scaled and/or + * cropped to match the surface's size. This function sets the crop in + * post-transformed pixel coordinates. + * + * The specified crop region applies to all buffers queued after it is called. + * + * If 'crop' is NULL, subsequently queued buffers won't be cropped. + * + * An error is returned if for instance the crop region is invalid, out of the + * buffer's bound or if the window is invalid. + */ +static inline int native_window_set_post_transform_crop( + struct ANativeWindow* window, + android_native_rect_t const * crop) +{ + return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); +} + +/* + * native_window_set_active_rect(..., active_rect) + * + * This function is deprecated and will be removed soon. For now it simply + * sets the post-transform crop for compatibility while multi-project commits + * get checked. + */ +static inline int native_window_set_active_rect( + struct ANativeWindow* window, + android_native_rect_t const * active_rect) +{ + return native_window_set_post_transform_crop(window, active_rect); +} + +/* * native_window_set_buffer_count(..., count) * Sets the number of buffers associated with this native window. */ @@ -526,7 +693,7 @@ static inline int native_window_set_buffers_geometry( /* * native_window_set_buffers_dimensions(..., int w, int h) * All buffers dequeued after this call will have the dimensions specified. - * In particular, all buffers will have a fixed-size, independent form the + * In particular, all buffers will have a fixed-size, independent from the * native-window size. They will be scaled according to the scaling mode * (see native_window_set_scaling_mode) upon window composition. * @@ -545,6 +712,31 @@ static inline int native_window_set_buffers_dimensions( } /* + * native_window_set_buffers_user_dimensions(..., int w, int h) + * + * Sets the user buffer size for the window, which overrides the + * window's size. All buffers dequeued after this call will have the + * dimensions specified unless overridden by + * native_window_set_buffers_dimensions. All buffers will have a + * fixed-size, independent from the native-window size. They will be + * scaled according to the scaling mode (see + * native_window_set_scaling_mode) upon window composition. + * + * If w and h are 0, the normal behavior is restored. That is, the + * default buffer size will match the windows's size. + * + * Calling this function will reset the window crop to a NULL value, which + * disables cropping of the buffers. + */ +static inline int native_window_set_buffers_user_dimensions( + struct ANativeWindow* window, + int w, int h) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, + w, h); +} + +/* * native_window_set_buffers_format(..., int format) * All buffers dequeued after this call will have the format specified. * @@ -601,7 +793,6 @@ static inline int native_window_set_scaling_mode( mode); } - /* * native_window_api_connect(..., int api) * connects an API to this window. only one API can be connected at a time. @@ -626,6 +817,17 @@ static inline int native_window_api_disconnect( return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); } +/* + * native_window_dequeue_buffer_and_wait(...) + * Dequeue a buffer and wait on the fence associated with that buffer. The + * buffer may safely be accessed immediately upon this function returning. An + * error is returned if either of the dequeue or the wait operations fail. + */ +static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, + struct ANativeWindowBuffer** anb) { + return anw->dequeueBuffer_DEPRECATED(anw, anb); +} + __END_DECLS diff --git a/include/sysutils/FrameworkClient.h b/include/sysutils/FrameworkClient.h index 0ef0753..4a3f0de 100644 --- a/include/sysutils/FrameworkClient.h +++ b/include/sysutils/FrameworkClient.h @@ -1,7 +1,7 @@ #ifndef _FRAMEWORK_CLIENT_H #define _FRAMEWORK_CLIENT_H -#include "../../../frameworks/base/include/utils/List.h" +#include "List.h" #include <pthread.h> @@ -17,5 +17,5 @@ public: int sendMsg(const char *msg, const char *data); }; -typedef android::List<FrameworkClient *> FrameworkClientCollection; +typedef android::sysutils::List<FrameworkClient *> FrameworkClientCollection; #endif diff --git a/include/sysutils/FrameworkCommand.h b/include/sysutils/FrameworkCommand.h index 6c1fca6..3e6264b 100644 --- a/include/sysutils/FrameworkCommand.h +++ b/include/sysutils/FrameworkCommand.h @@ -16,7 +16,7 @@ #ifndef __FRAMEWORK_CMD_HANDLER_H #define __FRAMEWORK_CMD_HANDLER_H -#include "../../../frameworks/base/include/utils/List.h" +#include "List.h" class SocketClient; @@ -34,5 +34,5 @@ public: const char *getCommand() { return mCommand; } }; -typedef android::List<FrameworkCommand *> FrameworkCommandCollection; +typedef android::sysutils::List<FrameworkCommand *> FrameworkCommandCollection; #endif diff --git a/include/sysutils/FrameworkListener.h b/include/sysutils/FrameworkListener.h index 142f50c..f1a4b43 100644 --- a/include/sysutils/FrameworkListener.h +++ b/include/sysutils/FrameworkListener.h @@ -23,12 +23,19 @@ class SocketClient; class FrameworkListener : public SocketListener { public: - static const int CMD_ARGS_MAX = 16; + static const int CMD_ARGS_MAX = 26; + + /* 1 out of errorRate will be dropped */ + int errorRate; + private: + int mCommandCount; + bool mWithSeq; FrameworkCommandCollection *mCommands; public: FrameworkListener(const char *socketName); + FrameworkListener(const char *socketName, bool withSeq); virtual ~FrameworkListener() {} protected: @@ -37,5 +44,6 @@ protected: private: void dispatchCommand(SocketClient *c, char *data); + void init(const char *socketName, bool withSeq); }; #endif diff --git a/include/sysutils/List.h b/include/sysutils/List.h new file mode 100644 index 0000000..31f7b37 --- /dev/null +++ b/include/sysutils/List.h @@ -0,0 +1,334 @@ +/* + * 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. + */ + +// +// Templated list class. Normally we'd use STL, but we don't have that. +// This class mimics STL's interfaces. +// +// Objects are copied into the list with the '=' operator or with copy- +// construction, so if the compiler's auto-generated versions won't work for +// you, define your own. +// +// The only class you want to use from here is "List". +// +#ifndef _SYSUTILS_LIST_H +#define _SYSUTILS_LIST_H + +#include <stddef.h> +#include <stdint.h> + +namespace android { +namespace sysutils { + +/* + * Doubly-linked list. Instantiate with "List<MyClass> myList". + * + * Objects added to the list are copied using the assignment operator, + * so this must be defined. + */ +template<typename T> +class List +{ +protected: + /* + * One element in the list. + */ + class _Node { + public: + explicit _Node(const T& val) : mVal(val) {} + ~_Node() {} + inline T& getRef() { return mVal; } + inline const T& getRef() const { return mVal; } + inline _Node* getPrev() const { return mpPrev; } + inline _Node* getNext() const { return mpNext; } + inline void setVal(const T& val) { mVal = val; } + inline void setPrev(_Node* ptr) { mpPrev = ptr; } + inline void setNext(_Node* ptr) { mpNext = ptr; } + private: + friend class List; + friend class _ListIterator; + T mVal; + _Node* mpPrev; + _Node* mpNext; + }; + + /* + * Iterator for walking through the list. + */ + + template <typename TYPE> + struct CONST_ITERATOR { + typedef _Node const * NodePtr; + typedef const TYPE Type; + }; + + template <typename TYPE> + struct NON_CONST_ITERATOR { + typedef _Node* NodePtr; + typedef TYPE Type; + }; + + template< + typename U, + template <class> class Constness + > + class _ListIterator { + typedef _ListIterator<U, Constness> _Iter; + typedef typename Constness<U>::NodePtr _NodePtr; + typedef typename Constness<U>::Type _Type; + + explicit _ListIterator(_NodePtr ptr) : mpNode(ptr) {} + + public: + _ListIterator() {} + _ListIterator(const _Iter& rhs) : mpNode(rhs.mpNode) {} + ~_ListIterator() {} + + // this will handle conversions from iterator to const_iterator + // (and also all convertible iterators) + // Here, in this implementation, the iterators can be converted + // if the nodes can be converted + template<typename V> explicit + _ListIterator(const V& rhs) : mpNode(rhs.mpNode) {} + + + /* + * Dereference operator. Used to get at the juicy insides. + */ + _Type& operator*() const { return mpNode->getRef(); } + _Type* operator->() const { return &(mpNode->getRef()); } + + /* + * Iterator comparison. + */ + inline bool operator==(const _Iter& right) const { + return mpNode == right.mpNode; } + + inline bool operator!=(const _Iter& right) const { + return mpNode != right.mpNode; } + + /* + * handle comparisons between iterator and const_iterator + */ + template<typename OTHER> + inline bool operator==(const OTHER& right) const { + return mpNode == right.mpNode; } + + template<typename OTHER> + inline bool operator!=(const OTHER& right) const { + return mpNode != right.mpNode; } + + /* + * Incr/decr, used to move through the list. + */ + inline _Iter& operator++() { // pre-increment + mpNode = mpNode->getNext(); + return *this; + } + const _Iter operator++(int) { // post-increment + _Iter tmp(*this); + mpNode = mpNode->getNext(); + return tmp; + } + inline _Iter& operator--() { // pre-increment + mpNode = mpNode->getPrev(); + return *this; + } + const _Iter operator--(int) { // post-increment + _Iter tmp(*this); + mpNode = mpNode->getPrev(); + return tmp; + } + + inline _NodePtr getNode() const { return mpNode; } + + _NodePtr mpNode; /* should be private, but older gcc fails */ + private: + friend class List; + }; + +public: + List() { + prep(); + } + List(const List<T>& src) { // copy-constructor + prep(); + insert(begin(), src.begin(), src.end()); + } + virtual ~List() { + clear(); + delete[] (unsigned char*) mpMiddle; + } + + typedef _ListIterator<T, NON_CONST_ITERATOR> iterator; + typedef _ListIterator<T, CONST_ITERATOR> const_iterator; + + List<T>& operator=(const List<T>& right); + + /* returns true if the list is empty */ + inline bool empty() const { return mpMiddle->getNext() == mpMiddle; } + + /* return #of elements in list */ + size_t size() const { + return size_t(distance(begin(), end())); + } + + /* + * Return the first element or one past the last element. The + * _Node* we're returning is converted to an "iterator" by a + * constructor in _ListIterator. + */ + inline iterator begin() { + return iterator(mpMiddle->getNext()); + } + inline const_iterator begin() const { + return const_iterator(const_cast<_Node const*>(mpMiddle->getNext())); + } + inline iterator end() { + return iterator(mpMiddle); + } + inline const_iterator end() const { + return const_iterator(const_cast<_Node const*>(mpMiddle)); + } + + /* add the object to the head or tail of the list */ + void push_front(const T& val) { insert(begin(), val); } + void push_back(const T& val) { insert(end(), val); } + + /* insert before the current node; returns iterator at new node */ + iterator insert(iterator posn, const T& val) + { + _Node* newNode = new _Node(val); // alloc & copy-construct + newNode->setNext(posn.getNode()); + newNode->setPrev(posn.getNode()->getPrev()); + posn.getNode()->getPrev()->setNext(newNode); + posn.getNode()->setPrev(newNode); + return iterator(newNode); + } + + /* insert a range of elements before the current node */ + void insert(iterator posn, const_iterator first, const_iterator last) { + for ( ; first != last; ++first) + insert(posn, *first); + } + + /* remove one entry; returns iterator at next node */ + iterator erase(iterator posn) { + _Node* pNext = posn.getNode()->getNext(); + _Node* pPrev = posn.getNode()->getPrev(); + pPrev->setNext(pNext); + pNext->setPrev(pPrev); + delete posn.getNode(); + return iterator(pNext); + } + + /* remove a range of elements */ + iterator erase(iterator first, iterator last) { + while (first != last) + erase(first++); // don't erase than incr later! + return iterator(last); + } + + /* remove all contents of the list */ + void clear() { + _Node* pCurrent = mpMiddle->getNext(); + _Node* pNext; + + while (pCurrent != mpMiddle) { + pNext = pCurrent->getNext(); + delete pCurrent; + pCurrent = pNext; + } + mpMiddle->setPrev(mpMiddle); + mpMiddle->setNext(mpMiddle); + } + + /* + * Measure the distance between two iterators. On exist, "first" + * will be equal to "last". The iterators must refer to the same + * list. + * + * FIXME: This is actually a generic iterator function. It should be a + * template function at the top-level with specializations for things like + * vector<>, which can just do pointer math). Here we limit it to + * _ListIterator of the same type but different constness. + */ + template< + typename U, + template <class> class CL, + template <class> class CR + > + ptrdiff_t distance( + _ListIterator<U, CL> first, _ListIterator<U, CR> last) const + { + ptrdiff_t count = 0; + while (first != last) { + ++first; + ++count; + } + return count; + } + +private: + /* + * I want a _Node but don't need it to hold valid data. More + * to the point, I don't want T's constructor to fire, since it + * might have side-effects or require arguments. So, we do this + * slightly uncouth storage alloc. + */ + void prep() { + mpMiddle = (_Node*) new unsigned char[sizeof(_Node)]; + mpMiddle->setPrev(mpMiddle); + mpMiddle->setNext(mpMiddle); + } + + /* + * This node plays the role of "pointer to head" and "pointer to tail". + * It sits in the middle of a circular list of nodes. The iterator + * runs around the circle until it encounters this one. + */ + _Node* mpMiddle; +}; + +/* + * Assignment operator. + * + * The simplest way to do this would be to clear out the target list and + * fill it with the source. However, we can speed things along by + * re-using existing elements. + */ +template<class T> +List<T>& List<T>::operator=(const List<T>& right) +{ + if (this == &right) + return *this; // self-assignment + iterator firstDst = begin(); + iterator lastDst = end(); + const_iterator firstSrc = right.begin(); + const_iterator lastSrc = right.end(); + while (firstSrc != lastSrc && firstDst != lastDst) + *firstDst++ = *firstSrc++; + if (firstSrc == lastSrc) // ran out of elements in source? + erase(firstDst, lastDst); // yes, erase any extras + else + insert(lastDst, firstSrc, lastSrc); // copy remaining over + return *this; +} + +}; // namespace sysutils +}; // namespace android + +#endif // _SYSUTILS_LIST_H diff --git a/include/sysutils/SocketClient.h b/include/sysutils/SocketClient.h index 7d2b1d6..85b58ef 100644 --- a/include/sysutils/SocketClient.h +++ b/include/sysutils/SocketClient.h @@ -1,9 +1,10 @@ #ifndef _SOCKET_CLIENT_H #define _SOCKET_CLIENT_H -#include "../../../frameworks/base/include/utils/List.h" +#include "List.h" #include <pthread.h> +#include <cutils/atomic.h> #include <sys/types.h> class SocketClient { @@ -24,18 +25,34 @@ class SocketClient { pthread_mutex_t mRefCountMutex; int mRefCount; + int mCmdNum; + + bool mUseCmdNum; + public: SocketClient(int sock, bool owned); + SocketClient(int sock, bool owned, bool useCmdNum); virtual ~SocketClient(); int getSocket() { return mSocket; } pid_t getPid() const { return mPid; } uid_t getUid() const { return mUid; } gid_t getGid() const { return mGid; } + void setCmdNum(int cmdNum) { android_atomic_release_store(cmdNum, &mCmdNum); } + int getCmdNum() { return mCmdNum; } // Send null-terminated C strings: int sendMsg(int code, const char *msg, bool addErrno); - int sendMsg(const char *msg); + int sendMsg(int code, const char *msg, bool addErrno, bool useCmdNum); + + // Provides a mechanism to send a response code to the client. + // Sends the code and a null character. + int sendCode(int code); + + // Provides a mechanism to send binary data to client. + // Sends the code and a null character, followed by 4 bytes of + // big-endian length, and the data. + int sendBinaryMsg(int code, const void *data, int len); // Sending binary data: int sendData(const void *data, int len); @@ -46,7 +63,21 @@ public: // decRef() when it's done with the client. void incRef(); bool decRef(); // returns true at 0 (but note: SocketClient already deleted) + + // return a new string in quotes with '\\' and '\"' escaped for "my arg" transmissions + static char *quoteArg(const char *arg); + +private: + // Send null-terminated C strings + int sendMsg(const char *msg); + void init(int socket, bool owned, bool useCmdNum); + + // Sending binary data. The caller should use make sure this is protected + // from multiple threads entering simultaneously. + // returns 0 if successful, -1 if there is a 0 byte write and -2 if any other + // error occurred (use errno to get the error) + int sendDataLocked(const void *data, int len); }; -typedef android::List<SocketClient *> SocketClientCollection; +typedef android::sysutils::List<SocketClient *> SocketClientCollection; #endif diff --git a/include/sysutils/SocketListener.h b/include/sysutils/SocketListener.h index 6592b01..8f56230 100644 --- a/include/sysutils/SocketListener.h +++ b/include/sysutils/SocketListener.h @@ -21,16 +21,18 @@ #include <sysutils/SocketClient.h> class SocketListener { - int mSock; + bool mListen; const char *mSocketName; + int mSock; SocketClientCollection *mClients; pthread_mutex_t mClientsLock; - bool mListen; int mCtrlPipe[2]; pthread_t mThread; + bool mUseCmdNum; public: SocketListener(const char *socketName, bool listen); + SocketListener(const char *socketName, bool listen, bool useCmdNum); SocketListener(int socketFd, bool listen); virtual ~SocketListener(); @@ -38,7 +40,6 @@ public: int stopListener(); void sendBroadcast(int code, const char *msg, bool addErrno); - void sendBroadcast(const char *msg); protected: virtual bool onDataAvailable(SocketClient *c) = 0; @@ -46,5 +47,6 @@ protected: private: static void *threadStart(void *obj); void runListener(); + void init(const char *socketName, int socketFd, bool listen, bool useCmdNum); }; #endif diff --git a/include/usbhost/usbhost.h b/include/usbhost/usbhost.h index 9a6b59c..1d67c12 100644 --- a/include/usbhost/usbhost.h +++ b/include/usbhost/usbhost.h @@ -72,6 +72,19 @@ struct usb_host_context *usb_host_init(void); /* Call this to cleanup the USB host library. */ void usb_host_cleanup(struct usb_host_context *context); +/* Call this to get the inotify file descriptor. */ +int usb_host_get_fd(struct usb_host_context *context); + +/* Call this to initialize the usb host context. */ +int usb_host_load(struct usb_host_context *context, + usb_device_added_cb added_cb, + usb_device_removed_cb removed_cb, + usb_discovery_done_cb discovery_done_cb, + void *client_data); + +/* Call this to read and handle occuring usb event. */ +int usb_host_read_event(struct usb_host_context *context); + /* Call this to monitor the USB bus for new and removed devices. * This is intended to be called from a dedicated thread, * as it will not return until one of the callbacks returns true. |
