M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
/*
* 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.
*/
#ifndef ANDROID_ACC_ACC_H
#define ANDROID_ACC_ACC_H
#include <stdint.h>
#include <sys/types.h>
typedef char ACCchar;
typedef int32_t ACCint;
typedef uint32_t ACCuint;
typedef ssize_t ACCsizei;
typedef unsigned int ACCenum;
typedef void ACCvoid;
typedef struct ACCscript ACCscript;
#define ACC_NO_ERROR 0x0000
#define ACC_INVALID_ENUM 0x0500
#define ACC_INVALID_OPERATION 0x0502
#define ACC_INVALID_VALUE 0x0501
#define ACC_OUT_OF_MEMORY 0x0505
#define ACC_COMPILE_STATUS 0x8B81
#define ACC_INFO_LOG_LENGTH 0x8B84
// ----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
ACCscript* accCreateScript();
void accDeleteScript(ACCscript* script);
typedef ACCvoid* (*ACCSymbolLookupFn)(ACCvoid* pContext, const ACCchar * name);
void accRegisterSymbolCallback(ACCscript* script, ACCSymbolLookupFn pFn,
ACCvoid* pContext);
ACCenum accGetError( ACCscript* script );
void accScriptSource(ACCscript* script,
ACCsizei count,
const ACCchar** string,
const ACCint* length);
void accCompileScript(ACCscript* script);
void accGetScriptiv(ACCscript* script,
ACCenum pname,
ACCint* params);
void accGetScriptInfoLog(ACCscript* script,
ACCsizei maxLength,
ACCsizei* length,
ACCchar* infoLog);
void accGetScriptLabel(ACCscript* script, const ACCchar * name,
ACCvoid** address);
void accGetPragmas(ACCscript* script, ACCsizei* actualStringCount,
ACCsizei maxStringCount, ACCchar** strings);
/* Used to implement disassembly */
void accGetProgramBinary(ACCscript* script,
ACCvoid** base,
ACCsizei* length);
#ifdef __cplusplus
};
#endif
// ----------------------------------------------------------------------------
#endif

View File

@@ -0,0 +1,128 @@
/*
* 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.
*/
#ifndef _ANDROID_LOG_H
#define _ANDROID_LOG_H
/******************************************************************
*
* IMPORTANT NOTICE:
*
* This file is part of Android's set of stable system headers
* exposed by the Android NDK (Native Development Kit) since
* platform release 1.5
*
* Third-party source AND binary code relies on the definitions
* here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
*
* - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
* - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
* - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
* - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
*/
/*
* Support routines to send messages to the Android in-kernel log buffer,
* which can later be accessed through the 'logcat' utility.
*
* Each log message must have
* - a priority
* - a log tag
* - some text
*
* The tag normally corresponds to the component that emits the log message,
* and should be reasonably small.
*
* Log message text may be truncated to less than an implementation-specific
* limit (e.g. 1023 characters max).
*
* Note that a newline character ("\n") will be appended automatically to your
* log message, if not already there. It is not possible to send several messages
* and have them appear on a single line in logcat.
*
* PLEASE USE LOGS WITH MODERATION:
*
* - Sending log messages eats CPU and slow down your application and the
* system.
*
* - The circular log buffer is pretty small (<64KB), sending many messages
* might push off other important log messages from the rest of the system.
*
* - In release builds, only send log messages to account for exceptional
* conditions.
*
* NOTE: These functions MUST be implemented by /system/lib/liblog.so
*/
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Android log priority values, in ascending priority order.
*/
typedef enum android_LogPriority {
ANDROID_LOG_UNKNOWN = 0,
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
ANDROID_LOG_VERBOSE,
ANDROID_LOG_DEBUG,
ANDROID_LOG_INFO,
ANDROID_LOG_WARN,
ANDROID_LOG_ERROR,
ANDROID_LOG_FATAL,
ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
} android_LogPriority;
/*
* Send a simple string to the log.
*/
int __android_log_write(int prio, const char *tag, const char *text);
/*
* Send a formatted string to the log, used like printf(fmt,...)
*/
int __android_log_print(int prio, const char *tag, const char *fmt, ...)
#if defined(__GNUC__)
__attribute__ ((format(printf, 3, 4)))
#endif
;
/*
* A variant of __android_log_print() that takes a va_list to list
* additional parameters.
*/
int __android_log_vprint(int prio, const char *tag,
const char *fmt, va_list ap);
/*
* Log an assertion failure and SIGTRAP the process to have a chance
* to inspect it, if a debugger is attached. This uses the FATAL priority.
*/
void __android_log_assert(const char *cond, const char *tag,
const char *fmt, ...)
#if defined(__GNUC__)
__attribute__ ((noreturn))
__attribute__ ((format(printf, 3, 4)))
#endif
;
#ifdef __cplusplus
}
#endif
#endif /* _ANDROID_LOG_H */

View File

@@ -0,0 +1,303 @@
/*
* 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
/*
* 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*/

View File

@@ -0,0 +1,361 @@
/*
* 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
/*
* 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*/

View File

@@ -0,0 +1,357 @@
/*
* 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 */
/*
* 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__
/*
* 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 */

View File

@@ -0,0 +1,358 @@
/*
* 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.
*/
/*
* OE config -- "oe-arm". Used for ARM device non-Android builds.
*/
#ifndef _OE_CONFIG_H
#define _OE_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, or the new /proc/<pid>/oom_score_adj.
*/
// #define HAVE_OOM_ADJ
#define HAVE_OOM_SCORE_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 */
/*
* 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__
/*
* 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 /* _OE_CONFIG_H */

View File

@@ -0,0 +1,364 @@
/*
* 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 */
/*
* 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 */

View File

@@ -0,0 +1,331 @@
/*
* 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
/*
* 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*/

View File

@@ -0,0 +1,348 @@
/*
* 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
*/
/*
* 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 */

View File

@@ -0,0 +1,336 @@
/*
* 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
/*
* 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*/

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Very simple unit testing framework.
*/
#ifndef __CUTILS_TEST_H
#define __CUTILS_TEST_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* Adds a test to the test suite.
*/
#define addTest(test) addNamedTest(#test, &test)
/**
* Asserts that a condition is true. The test fails if it isn't.
*/
#define assertTrue(value, message) assertTrueWithSource(value, __FILE__, __LINE__, message);
/**
* Asserts that a condition is false. The test fails if the value is true.
*/
#define assertFalse(value, message) assertTrueWithSource(!value, __FILE__, __LINE__, message);
/** Fails a test with the given message. */
#define fail(message) assertTrueWithSource(0, __FILE__, __LINE__, message);
/**
* Asserts that two values are ==.
*/
#define assertSame(a, b) assertTrueWithSource(a == b, __FILE__, __LINE__, "Expected same value.");
/**
* Asserts that two values are !=.
*/
#define assertNotSame(a, b) assertTrueWithSource(a != b, __FILE__, __LINE__,\
"Expected different values");
/**
* Runs a test suite.
*/
void runTests(void);
// Do not call these functions directly. Use macros above instead.
void addNamedTest(const char* name, void (*test)(void));
void assertTrueWithSource(int value, const char* file, int line, char* message);
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_TEST_H */

View File

@@ -0,0 +1,103 @@
/*
* Copyright 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.
*/
/* Helper to perform abortable blocking operations on a socket:
* asocket_connect()
* asocket_accept()
* asocket_read()
* asocket_write()
* These calls are similar to the regular syscalls, but can be aborted with:
* asocket_abort()
*
* Calling close() on a regular POSIX socket does not abort blocked syscalls on
* that socket in other threads.
*
* After calling asocket_abort() the socket cannot be reused.
*
* Call asocket_destory() *after* all threads have finished with the socket to
* finish closing the socket and free the asocket structure.
*
* The helper is implemented by setting the socket non-blocking to initiate
* syscalls connect(), accept(), read(), write(), then using a blocking poll()
* on both the primary socket and a local pipe. This makes the poll() abortable
* by writing a byte to the local pipe in asocket_abort().
*
* asocket_create() sets the fd to non-blocking mode. It must not be changed to
* blocking mode.
*
* Using asocket will triple the number of file descriptors required per
* socket, due to the local pipe. It may be possible to use a global pipe per
* process rather than per socket, but we have not been able to come up with a
* race-free implementation yet.
*
* All functions except asocket_init() and asocket_destroy() are thread safe.
*/
#include <stdlib.h>
#include <sys/socket.h>
#ifndef __CUTILS_ABORT_SOCKET_H__
#define __CUTILS_ABORT_SOCKET_H__
#ifdef __cplusplus
extern "C" {
#endif
struct asocket {
int fd; /* primary socket fd */
int abort_fd[2]; /* pipe used to abort */
};
/* Create an asocket from fd.
* Sets the socket to non-blocking mode.
* Returns NULL on error with errno set.
*/
struct asocket *asocket_init(int fd);
/* Blocking socket I/O with timeout.
* Calling asocket_abort() from another thread will cause each of these
* functions to immediately return with value -1 and errno ECANCELED.
* timeout is in ms, use -1 to indicate no timeout. On timeout -1 is returned
* with errno ETIMEDOUT.
* EINTR is handled in-call.
* Other semantics are identical to the regular syscalls.
*/
int asocket_connect(struct asocket *s, const struct sockaddr *addr,
socklen_t addrlen, int timeout);
int asocket_accept(struct asocket *s, struct sockaddr *addr,
socklen_t *addrlen, int timeout);
int asocket_read(struct asocket *s, void *buf, size_t count, int timeout);
int asocket_write(struct asocket *s, const void *buf, size_t count,
int timeout);
/* Abort above calls and shutdown socket.
* Further I/O operations on this socket will immediately fail after this call.
* asocket_destroy() should be used to release resources once all threads
* have returned from blocking calls on the socket.
*/
void asocket_abort(struct asocket *s);
/* Close socket and free asocket structure.
* Must not be called until all calls on this structure have completed.
*/
void asocket_destroy(struct asocket *s);
#ifdef __cplusplus
}
#endif
#endif //__CUTILS_ABORT_SOCKET__H__

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A pointer array which intelligently expands its capacity ad needed.
*/
#ifndef __ARRAY_H
#define __ARRAY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
/** An array. */
typedef struct Array Array;
/** Constructs a new array. Returns NULL if we ran out of memory. */
Array* arrayCreate();
/** Frees an array. Does not free elements themselves. */
void arrayFree(Array* array);
/** Adds a pointer. Returns 0 is successful, < 0 otherwise. */
int arrayAdd(Array* array, void* pointer);
/** Gets the pointer at the specified index. */
void* arrayGet(Array* array, int index);
/** Removes the pointer at the given index and returns it. */
void* arrayRemove(Array* array, int index);
/** Sets pointer at the given index. Returns old pointer. */
void* arraySet(Array* array, int index, void* pointer);
/** Sets the array size. Sets new pointers to NULL. Returns 0 if successful, < 0 otherwise . */
int arraySetSize(Array* array, int size);
/** Returns the size of the given array. */
int arraySize(Array* array);
/**
* Returns a pointer to a C-style array which will be valid until this array
* changes.
*/
const void** arrayUnwrap(Array* array);
#ifdef __cplusplus
}
#endif
#endif /* __ARRAY_H */

View File

@@ -0,0 +1,71 @@
/* cutils/ashmem.h
**
** Copyright 2008 The Android Open Source Project
**
** This file is dual licensed. It may be redistributed and/or modified
** under the terms of the Apache 2.0 License OR version 2 of the GNU
** General Public License.
*/
#ifndef _CUTILS_ASHMEM_H
#define _CUTILS_ASHMEM_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
int ashmem_create_region(const char *name, size_t size);
int ashmem_set_prot_region(int fd, int prot);
int ashmem_pin_region(int fd, size_t offset, size_t len);
int ashmem_unpin_region(int fd, size_t offset, size_t len);
int ashmem_get_size_region(int fd);
#ifdef __cplusplus
}
#endif
#ifndef __ASHMEMIOC /* in case someone included <linux/ashmem.h> too */
#define ASHMEM_NAME_LEN 256
#define ASHMEM_NAME_DEF "dev/ashmem"
/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */
#define ASHMEM_NOT_PURGED 0
#define ASHMEM_WAS_PURGED 1
/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */
#define ASHMEM_IS_UNPINNED 0
#define ASHMEM_IS_PINNED 1
#if LINUX_ENABLED
#include <linux/limits.h>
#include <linux/ioctl.h>
#include <linux/types.h>
struct ashmem_pin {
__u32 offset;
__u32 len;
};
#define __ASHMEMIOC 0x77
#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN])
#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN])
#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t)
#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4)
#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long)
#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6)
#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin)
#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
#endif /* LINUX_ENABLED */
#endif /* ! __ASHMEMIOC */
#endif /* _CUTILS_ASHMEM_H */

View File

@@ -0,0 +1,271 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_CUTILS_ATOMIC_ARM_H
#define ANDROID_CUTILS_ATOMIC_ARM_H
#include <stdint.h>
#include <machine/cpu-features.h>
extern inline void android_compiler_barrier(void)
{
__asm__ __volatile__ ("" : : : "memory");
}
#if ANDROID_SMP == 0
extern inline void android_memory_barrier(void)
{
android_compiler_barrier();
}
#elif defined(__ARM_HAVE_DMB)
extern inline void android_memory_barrier(void)
{
__asm__ __volatile__ ("dmb" : : : "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");
}
#else
extern inline void android_memory_barrier(void)
{
typedef void (kuser_memory_barrier)(void);
(*(kuser_memory_barrier *)0xffff0fa0)();
}
#endif
extern 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)
{
android_memory_barrier();
return *ptr;
}
extern 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)
{
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)
{
int32_t prev, status;
do {
__asm__ __volatile__ ("ldrex %0, [%3]\n"
"mov %1, #0\n"
"teq %0, %4\n"
"strexeq %1, %5, [%3]"
: "=&r" (prev), "=&r" (status), "+m"(*ptr)
: "r" (ptr), "Ir" (old_value), "r" (new_value)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prev != old_value;
}
#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)
{
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)
{
android_memory_barrier();
return android_atomic_cas(old_value, new_value, ptr);
}
#if defined(__thumb__)
extern int32_t android_atomic_swap(int32_t new_value,
volatile int32_t *ptr);
#elif defined(__ARM_HAVE_LDREX_STREX)
extern inline int32_t android_atomic_swap(int32_t new_value,
volatile int32_t *ptr)
{
int32_t prev, status;
do {
__asm__ __volatile__ ("ldrex %0, [%3]\n"
"strex %1, %4, [%3]"
: "=&r" (prev), "=&r" (status), "+m" (*ptr)
: "r" (ptr), "r" (new_value)
: "cc");
} while (__builtin_expect(status != 0, 0));
android_memory_barrier();
return prev;
}
#else
extern inline int32_t android_atomic_swap(int32_t new_value,
volatile int32_t *ptr)
{
int32_t prev;
__asm__ __volatile__ ("swp %0, %2, [%3]"
: "=&r" (prev), "+m" (*ptr)
: "r" (new_value), "r" (ptr)
: "cc");
android_memory_barrier();
return prev;
}
#endif
#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)
{
int32_t prev, tmp, status;
android_memory_barrier();
do {
__asm__ __volatile__ ("ldrex %0, [%4]\n"
"add %1, %0, %5\n"
"strex %2, %1, [%4]"
: "=&r" (prev), "=&r" (tmp),
"=&r" (status), "+m" (*ptr)
: "r" (ptr), "Ir" (increment)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prev;
}
#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)
{
return android_atomic_add(1, addr);
}
extern 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)
{
int32_t prev, tmp, status;
android_memory_barrier();
do {
__asm__ __volatile__ ("ldrex %0, [%4]\n"
"and %1, %0, %5\n"
"strex %2, %1, [%4]"
: "=&r" (prev), "=&r" (tmp),
"=&r" (status), "+m" (*ptr)
: "r" (ptr), "Ir" (value)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prev;
}
#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)
{
int32_t prev, tmp, status;
android_memory_barrier();
do {
__asm__ __volatile__ ("ldrex %0, [%4]\n"
"orr %1, %0, %5\n"
"strex %2, %1, [%4]"
: "=&r" (prev), "=&r" (tmp),
"=&r" (status), "+m" (*ptr)
: "r" (ptr), "Ir" (value)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prev;
}
#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 */

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_CUTILS_ATOMIC_INLINE_H
#define ANDROID_CUTILS_ATOMIC_INLINE_H
/*
* Inline declarations and macros for some special-purpose atomic
* operations. These are intended for rare circumstances where a
* memory barrier needs to be issued inline rather than as a function
* call.
*
* Most code should not use these.
*
* Anything that does include this file must set ANDROID_SMP to either
* 0 or 1, indicating compilation for UP or SMP, respectively.
*
* Macros defined in this header:
*
* void ANDROID_MEMBAR_FULL(void)
* Full memory barrier. Provides a compiler reordering barrier, and
* on SMP systems emits an appropriate instruction.
*/
#if !defined(ANDROID_SMP)
# error "Must define ANDROID_SMP before including atomic-inline.h"
#endif
#if defined(__arm__)
#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 */
#else
#error atomic operations are unsupported
#endif
#if ANDROID_SMP == 0
#define ANDROID_MEMBAR_FULL android_compiler_barrier
#else
#define ANDROID_MEMBAR_FULL android_memory_barrier
#endif
#endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */

View File

@@ -0,0 +1,145 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_CUTILS_ATOMIC_X86_H
#define ANDROID_CUTILS_ATOMIC_X86_H
#include <stdint.h>
extern inline void android_compiler_barrier(void)
{
__asm__ __volatile__ ("" : : : "memory");
}
#if ANDROID_SMP == 0
extern inline void android_memory_barrier(void)
{
android_compiler_barrier();
}
#else
extern inline void android_memory_barrier(void)
{
__asm__ __volatile__ ("mfence" : : : "memory");
}
#endif
extern 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)
{
android_memory_barrier();
return *ptr;
}
extern 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)
{
android_compiler_barrier();
*ptr = value;
}
extern inline int android_atomic_cas(int32_t old_value, int32_t new_value,
volatile int32_t *ptr)
{
int32_t prev;
__asm__ __volatile__ ("lock; cmpxchgl %1, %2"
: "=a" (prev)
: "q" (new_value), "m" (*ptr), "0" (old_value)
: "memory");
return prev != old_value;
}
extern 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)
{
/* Stores are not reordered with other stores. */
return android_atomic_cas(old_value, new_value, ptr);
}
extern inline int32_t android_atomic_swap(int32_t new_value,
volatile int32_t *ptr)
{
__asm__ __volatile__ ("xchgl %1, %0"
: "=r" (new_value)
: "m" (*ptr), "0" (new_value)
: "memory");
/* new_value now holds the old value of *ptr */
return new_value;
}
extern inline int32_t android_atomic_add(int32_t increment,
volatile int32_t *ptr)
{
__asm__ __volatile__ ("lock; xaddl %0, %1"
: "+r" (increment), "+m" (*ptr)
: : "memory");
/* increment now holds the old value of *ptr */
return increment;
}
extern 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)
{
return android_atomic_add(-1, addr);
}
extern inline int32_t android_atomic_and(int32_t value,
volatile int32_t *ptr)
{
int32_t prev, status;
do {
prev = *ptr;
status = android_atomic_cas(prev, prev & value, ptr);
} while (__builtin_expect(status != 0, 0));
return prev;
}
extern inline int32_t android_atomic_or(int32_t value, volatile int32_t *ptr)
{
int32_t prev, status;
do {
prev = *ptr;
status = android_atomic_cas(prev, prev | value, ptr);
} while (__builtin_expect(status != 0, 0));
return prev;
}
#endif /* ANDROID_CUTILS_ATOMIC_X86_H */

View File

@@ -0,0 +1,128 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_CUTILS_ATOMIC_H
#define ANDROID_CUTILS_ATOMIC_H
#include <stdint.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* A handful of basic atomic operations. The appropriate pthread
* functions should be used instead of these whenever possible.
*
* The "acquire" and "release" terms can be defined intuitively in terms
* of the placement of memory barriers in a simple lock implementation:
* - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds
* - barrier
* - [do work]
* - barrier
* - store(lock-is-free)
* In very crude terms, the initial (acquire) barrier prevents any of the
* "work" from happening before the lock is held, and the later (release)
* barrier ensures that all of the work happens before the lock is released.
* (Think of cached writes, cache read-ahead, and instruction reordering
* around the CAS and store instructions.)
*
* The barriers must apply to both the compiler and the CPU. Note it is
* legal for instructions that occur before an "acquire" barrier to be
* moved down below it, and for instructions that occur after a "release"
* barrier to be moved up above it.
*
* The ARM-driven implementation we use here is short on subtlety,
* and actually requests a full barrier from the compiler and the CPU.
* The only difference between acquire and release is in whether they
* are issued before or after the atomic operation with which they
* are associated. To ease the transition to C/C++ atomic intrinsics,
* you should not rely on this, and instead assume that only the minimal
* acquire/release protection is provided.
*
* NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries.
* If they are not, atomicity is not guaranteed.
*/
/*
* Basic arithmetic and bitwise operations. These all provide a
* barrier with "release" ordering, and return the previous value.
*
* These have the same characteristics (e.g. what happens on overflow)
* as the equivalent non-atomic C operations.
*/
int32_t android_atomic_inc(volatile int32_t* addr);
int32_t android_atomic_dec(volatile int32_t* addr);
int32_t android_atomic_add(int32_t value, volatile int32_t* addr);
int32_t android_atomic_and(int32_t value, volatile int32_t* addr);
int32_t android_atomic_or(int32_t value, volatile int32_t* addr);
/*
* Perform an atomic load with "acquire" or "release" ordering.
*
* This is only necessary if you need the memory barrier. A 32-bit read
* from a 32-bit aligned address is atomic on all supported platforms.
*/
int32_t android_atomic_acquire_load(volatile const int32_t* addr);
int32_t android_atomic_release_load(volatile const int32_t* addr);
/*
* Perform an atomic store with "acquire" or "release" ordering.
*
* This is only necessary if you need the memory barrier. A 32-bit write
* to a 32-bit aligned address is atomic on all supported platforms.
*/
void android_atomic_acquire_store(int32_t value, volatile int32_t* addr);
void android_atomic_release_store(int32_t value, volatile int32_t* addr);
/*
* Unconditional swap operation with release ordering.
*
* Stores the new value at *addr, and returns the previous value.
*/
int32_t android_atomic_swap(int32_t value, volatile int32_t* addr);
/*
* Compare-and-set operation with "acquire" or "release" ordering.
*
* This returns zero if the new value was successfully stored, which will
* only happen when *addr == oldvalue.
*
* (The return value is inverted from implementations on other platforms,
* but matches the ARM ldrex/strex result.)
*
* Implementations that use the release CAS in a loop may be less efficient
* than possible, because we re-issue the memory barrier on each iteration.
*/
int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue,
volatile int32_t* addr);
int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue,
volatile int32_t* addr);
/*
* Aliases for code using an older version of this header. These are now
* deprecated and should not be used. The definitions will be removed
* in a future release.
*/
#define android_atomic_write android_atomic_release_store
#define android_atomic_cmpxchg android_atomic_release_cas
#ifdef __cplusplus
} // extern "C"
#endif
#endif // ANDROID_CUTILS_ATOMIC_H

View File

@@ -0,0 +1,32 @@
/*
* 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.
*/
#ifndef ANDROID_CUTILS_COMPILER_H
#define ANDROID_CUTILS_COMPILER_H
/*
* helps the compiler's optimizer predicting branches
*/
#ifdef __cplusplus
# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true ))
# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false ))
#else
# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 ))
# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 ))
#endif
#endif // ANDROID_CUTILS_COMPILER_H

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_CONFIG_UTILS_H
#define __CUTILS_CONFIG_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct cnode cnode;
struct cnode
{
cnode *next;
cnode *first_child;
cnode *last_child;
const char *name;
const char *value;
};
/* parse a text string into a config node tree */
void config_load(cnode *root, char *data);
/* parse a file into a config node tree */
void config_load_file(cnode *root, const char *fn);
/* create a single config node */
cnode* config_node(const char *name, const char *value);
/* locate a named child of a config node */
cnode* config_find(cnode *root, const char *name);
/* look up a child by name and return the boolean value */
int config_bool(cnode *root, const char *name, int _default);
/* look up a child by name and return the string value */
const char* config_str(cnode *root, const char *name, const char *_default);
/* add a named child to a config node (or modify it if it already exists) */
void config_set(cnode *root, const char *name, const char *value);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_CPU_INFO_H
#define __CUTILS_CPU_INFO_H
#ifdef __cplusplus
extern "C" {
#endif
/* returns a string contiaining an ASCII representation of the CPU serial number,
** or NULL if cpu info not available.
** The string is a static variable, so don't call free() on it.
*/
extern const char* get_cpu_serial_number(void);
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_CPU_INFO_H */

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
typedef enum {
SHA_1,
} HashAlgorithm;
int get_file_hash(HashAlgorithm algorithm, const char *path,
char *output_string, size_t max_output_string);
int get_recursive_hash_manifest(HashAlgorithm algorithm,
const char *directory_path,
char **output_string);

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBS_CUTILS_EVENTTAGMAP_H
#define _LIBS_CUTILS_EVENTTAGMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags"
struct EventTagMap;
typedef struct EventTagMap EventTagMap;
/*
* Open the specified file as an event log tag map.
*
* Returns NULL on failure.
*/
EventTagMap* android_openEventTagMap(const char* fileName);
/*
* Close the map.
*/
void android_closeEventTagMap(EventTagMap* map);
/*
* Look up a tag by index. Returns the tag string, or NULL if not found.
*/
const char* android_lookupEventTag(const EventTagMap* map, int tag);
#ifdef __cplusplus
}
#endif
#endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/

View File

@@ -0,0 +1,150 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Hash map.
*/
#ifndef __HASHMAP_H
#define __HASHMAP_H
#include <stdbool.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/** A hash map. */
typedef struct Hashmap Hashmap;
/**
* Creates a new hash map. Returns NULL if memory allocation fails.
*
* @param initialCapacity number of expected entries
* @param hash function which hashes keys
* @param equals function which compares keys for equality
*/
Hashmap* hashmapCreate(size_t initialCapacity,
int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB));
/**
* Frees the hash map. Does not free the keys or values themselves.
*/
void hashmapFree(Hashmap* map);
/**
* Hashes the memory pointed to by key with the given size. Useful for
* implementing hash functions.
*/
int hashmapHash(void* key, size_t keySize);
/**
* Puts value for the given key in the map. Returns pre-existing value if
* any.
*
* If memory allocation fails, this function returns NULL, the map's size
* does not increase, and errno is set to ENOMEM.
*/
void* hashmapPut(Hashmap* map, void* key, void* value);
/**
* Gets a value from the map. Returns NULL if no entry for the given key is
* found or if the value itself is NULL.
*/
void* hashmapGet(Hashmap* map, void* key);
/**
* Returns true if the map contains an entry for the given key.
*/
bool hashmapContainsKey(Hashmap* map, void* key);
/**
* Gets the value for a key. If a value is not found, this function gets a
* value and creates an entry using the given callback.
*
* If memory allocation fails, the callback is not called, this function
* returns NULL, and errno is set to ENOMEM.
*/
void* hashmapMemoize(Hashmap* map, void* key,
void* (*initialValue)(void* key, void* context), void* context);
/**
* Removes an entry from the map. Returns the removed value or NULL if no
* entry was present.
*/
void* hashmapRemove(Hashmap* map, void* key);
/**
* Gets the number of entries in this map.
*/
size_t hashmapSize(Hashmap* map);
/**
* Invokes the given callback on each entry in the map. Stops iterating if
* the callback returns false.
*/
void hashmapForEach(Hashmap* map,
bool (*callback)(void* key, void* value, void* context),
void* context);
/**
* Concurrency support.
*/
/**
* Locks the hash map so only the current thread can access it.
*/
void hashmapLock(Hashmap* map);
/**
* Unlocks the hash map so other threads can access it.
*/
void hashmapUnlock(Hashmap* map);
/**
* Key utilities.
*/
/**
* Hashes int keys. 'key' is a pointer to int.
*/
int hashmapIntHash(void* key);
/**
* Compares two int keys for equality.
*/
bool hashmapIntEquals(void* keyA, void* keyB);
/**
* For debugging.
*/
/**
* Gets current capacity.
*/
size_t hashmapCurrentCapacity(Hashmap* map);
/**
* Counts the number of entry collisions.
*/
size_t hashmapCountCollisions(Hashmap* map);
#ifdef __cplusplus
}
#endif
#endif /* __HASHMAP_H */

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_IOSCHED_POLICY_H
#define __CUTILS_IOSCHED_POLICY_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
IoSchedClass_NONE,
IoSchedClass_RT,
IoSchedClass_BE,
IoSchedClass_IDLE,
} IoSchedClass;
extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio);
extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio);
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_IOSCHED_POLICY_H */

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_STRING16_H
#define __CUTILS_STRING16_H
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint16_t char16_t;
extern char * strndup16to8 (const char16_t* s, size_t n);
extern size_t strnlen16to8 (const char16_t* s, size_t n);
extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n);
extern char16_t * strdup8to16 (const char* s, size_t *out_len);
extern size_t strlen8to16 (const char* utf8Str);
extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len);
extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length,
size_t *out_len);
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_STRING16_H */

View File

@@ -0,0 +1,524 @@
/*
* Copyright (C) 2005 The Android Open Source Project
* Copyright (c) 2009, The Linux Foundation. All rights reserved.
*
* 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/C++ logging functions. See the logging documentation for API details.
//
// We'd like these to be available from C code (in case we import some from
// somewhere), so this has a C interface.
//
// The output will be correct when the log file is shared between multiple
// threads and/or multiple processes so long as the operating system
// supports O_APPEND. These calls have mutex-protected data structures
// and so are NOT reentrant. Do not use LOG in a signal handler.
//
#ifndef _LIBS_CUTILS_LOG_H
#define _LIBS_CUTILS_LOG_H
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef HAVE_PTHREADS
#include <pthread.h>
#endif
#include <stdarg.h>
#include <cutils/uio.h>
#include <cutils/logd.h>
#ifdef __cplusplus
extern "C" {
#endif
// ---------------------------------------------------------------------
/*
* Normally we strip LOGV (VERBOSE messages) from release builds.
* You can modify this (for example with "#define LOG_NDEBUG 0"
* at the top of your source file) to change that behavior.
*/
#ifndef LOG_NDEBUG
#ifdef NDEBUG
#define LOG_NDEBUG 1
#else
#define LOG_NDEBUG 0
#endif
#endif
#ifndef LOG_NIDEBUG
#ifdef NDEBUG
#define LOG_NIDEBUG 1
#else
#define LOG_NIDEBUG 0
#endif
#endif
#ifndef LOG_NDDEBUG
#ifdef NDEBUG
#define LOG_NDDEBUG 1
#else
#define LOG_NDDEBUG 0
#endif
#endif
/*
* This is the local tag used for the following simplified
* logging macros. You can change this preprocessor definition
* before using the other macros to change the tag.
*/
#ifndef LOG_TAG
#define LOG_TAG NULL
#endif
/* basic log macros for each level
*/
#ifndef LOGLOG_VERBOSE
#if LOG_NDEBUG
#define LOGLOG_VERBOSE(tag, ...) ((void)0)
#else
#define LOGLOG_VERBOSE(tag, ...) \
(void)android_printLog(ANDROID_LOG_VERBOSE, tag, __VA_ARGS__)
#endif
#endif
#ifndef LOGLOG_DEBUG
#if LOG_NDDEBUG
#define LOGLOG_DEBUG(tag, ...) ((void)0)
#else
#define LOGLOG_DEBUG(tag, ...) \
(void)android_printLog(ANDROID_LOG_DEBUG, tag, __VA_ARGS__)
#endif
#endif
#ifndef LOGLOG_INFO
#if LOG_NIDEBUG
#define LOGLOG_INFO(tag, ...) ((void)0)
#else
#define LOGLOG_INFO(tag, ...) \
(void)android_printLog(ANDROID_LOG_INFO, tag, __VA_ARGS__)
#endif
#endif
#ifndef LOGLOG_WARN
#define LOGLOG_WARN(tag, ...) \
(void)android_printLog(ANDROID_LOG_WARN, tag, __VA_ARGS__)
#endif
#ifndef LOGLOG_ERROR
#define LOGLOG_ERROR(tag, ...) \
(void)android_printLog(ANDROID_LOG_ERROR, tag, __VA_ARGS__)
#endif
// ---------------------------------------------------------------------
/*
* Simplified macro to send a verbose log message using the current LOG_TAG.
*/
#ifndef LOGV
#if LOG_NDEBUG
#define LOGV(...) ((void)0)
#else
#define LOGV(...) LOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#endif
#endif
#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
#ifndef LOGV_IF
#if LOG_NDEBUG
#define LOGV_IF(cond, ...) ((void)0)
#else
#define LOGV_IF(cond, ...) \
( (CONDITION(cond)) \
? LOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__) \
: (void)0 )
#endif
#endif
/*
* Simplified macro to send a debug log message using the current LOG_TAG.
*/
#ifndef LOGD
#define LOGD(...) LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#endif
#ifndef LOGD_IF
#if LOG_NDDEBUG
#define LOGD_IF(cond, ...) ((void)0)
#else
#define LOGD_IF(cond, ...) \
( (CONDITION(cond)) \
? LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__) \
: (void)0 )
#endif
#endif
/*
* Simplified macro to send an info log message using the current LOG_TAG.
*/
#ifndef LOGI
#define LOGI(...) LOG(LOG_INFO, LOG_TAG, __VA_ARGS__)
#endif
#ifndef LOGI_IF
#if LOG_NIDEBUG
#define LOGI_IF(cond, ...) ((void)0)
#else
#define LOGI_IF(cond, ...) \
( (CONDITION(cond)) \
? LOG(LOG_INFO, LOG_TAG, __VA_ARGS__) \
: (void)0 )
#endif
#endif
/*
* Simplified macro to send a warning log message using the current LOG_TAG.
*/
#ifndef LOGW
#define LOGW(...) LOG(LOG_WARN, LOG_TAG, __VA_ARGS__)
#endif
#ifndef LOGW_IF
#define LOGW_IF(cond, ...) \
( (CONDITION(cond)) \
? LOG(LOG_WARN, LOG_TAG, __VA_ARGS__) \
: (void)0 )
#endif
/*
* Simplified macro to send an error log message using the current LOG_TAG.
*/
#ifndef LOGE
#define LOGE(...) LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)
#endif
#ifndef LOGE_IF
#define LOGE_IF(cond, ...) \
( (CONDITION(cond)) \
? LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__) \
: (void)0 )
#endif
// ---------------------------------------------------------------------
/*
* Conditional based on whether the current LOG_TAG is enabled at
* verbose priority.
*/
#ifndef IF_LOGV
#if LOG_NDEBUG
#define IF_LOGV() if (false)
#else
#define IF_LOGV() IF_LOG(LOG_VERBOSE, LOG_TAG)
#endif
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* debug priority.
*/
#ifndef IF_LOGD
#define IF_LOGD() IF_LOG(LOG_DEBUG, LOG_TAG)
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* info priority.
*/
#ifndef IF_LOGI
#define IF_LOGI() IF_LOG(LOG_INFO, LOG_TAG)
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* warn priority.
*/
#ifndef IF_LOGW
#define IF_LOGW() IF_LOG(LOG_WARN, LOG_TAG)
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* error priority.
*/
#ifndef IF_LOGE
#define IF_LOGE() IF_LOG(LOG_ERROR, LOG_TAG)
#endif
// ---------------------------------------------------------------------
/*
* Simplified macro to send a verbose system log message using the current LOG_TAG.
*/
#ifndef SLOGV
#if LOG_NDEBUG
#define SLOGV(...) ((void)0)
#else
#define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#endif
#endif
#define CONDITION(cond) (__builtin_expect((cond)!=0, 0))
#ifndef SLOGV_IF
#if LOG_NDEBUG
#define SLOGV_IF(cond, ...) ((void)0)
#else
#define SLOGV_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
#endif
/*
* Simplified macro to send a debug system log message using the current LOG_TAG.
*/
#ifndef SLOGD
#define SLOGD(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGD_IF
#define SLOGD_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
/*
* Simplified macro to send an info system log message using the current LOG_TAG.
*/
#ifndef SLOGI
#define SLOGI(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGI_IF
#define SLOGI_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
/*
* Simplified macro to send a warning system log message using the current LOG_TAG.
*/
#ifndef SLOGW
#define SLOGW(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGW_IF
#define SLOGW_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
/*
* Simplified macro to send an error system log message using the current LOG_TAG.
*/
#ifndef SLOGE
#define SLOGE(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef SLOGE_IF
#define SLOGE_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#endif
// ---------------------------------------------------------------------
/*
* Log a fatal error. If the given condition fails, this stops program
* execution like a normal assertion, but also generating the given message.
* It is NOT stripped from release builds. Note that the condition test
* is -inverted- from the normal assert() semantics.
*/
#define LOG_ALWAYS_FATAL_IF(cond, ...) \
( (CONDITION(cond)) \
? ((void)android_printAssert(#cond, LOG_TAG, __VA_ARGS__)) \
: (void)0 )
#define LOG_ALWAYS_FATAL(...) \
( ((void)android_printAssert(NULL, LOG_TAG, __VA_ARGS__)) )
/*
* Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
* are stripped out of release builds.
*/
#if LOG_NDEBUG
#define LOG_FATAL_IF(cond, ...) ((void)0)
#define LOG_FATAL(...) ((void)0)
#else
#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, __VA_ARGS__)
#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
#endif
/*
* Assertion that generates a log message when the assertion fails.
* Stripped out of release builds. Uses the current LOG_TAG.
*/
#define LOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), __VA_ARGS__)
//#define LOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond)
// ---------------------------------------------------------------------
/*
* Basic log message macro.
*
* Example:
* LOG(LOG_WARN, NULL, "Failed with error %d", errno);
*
* The second argument may be NULL or "" to indicate the "global" tag.
*/
#ifndef LOG
#define LOG(priority, tag, ...) \
LOG##priority(tag, __VA_ARGS__)
#endif
/*
* Log macro that allows you to specify a number for the priority.
*
* Since all of the above variations end up here, this is where the lower
* priority messages can be filtered out. The if statement below can be
* optimizaed out by the compiler since all of the expressions are
* constant.
*/
#ifndef LOG_PRI
#define LOG_PRI(priority, tag, ...) \
({ \
if (((priority == ANDROID_LOG_VERBOSE) && (LOG_NDEBUG == 0)) || \
((priority == ANDROID_LOG_DEBUG) && (LOG_NDDEBUG == 0)) || \
((priority == ANDROID_LOG_INFO) && (LOG_NIDEBUG == 0)) || \
(priority == ANDROID_LOG_WARN) || \
(priority == ANDROID_LOG_ERROR) || \
(priority == ANDROID_LOG_FATAL)) \
(void)android_printLog(priority, tag, __VA_ARGS__); \
})
#endif
/*
* Log macro that allows you to pass in a varargs ("args" is a va_list).
*/
#ifndef LOG_PRI_VA
#define LOG_PRI_VA(priority, tag, fmt, args) \
android_vprintLog(priority, NULL, tag, fmt, args)
#endif
/*
* Conditional given a desired logging priority and tag.
*/
#ifndef IF_LOG
#define IF_LOG(priority, tag) \
if (android_testLog(ANDROID_##priority, tag))
#endif
// ---------------------------------------------------------------------
/*
* Event logging.
*/
/*
* Event log entry types. These must match up with the declarations in
* java/android/android/util/EventLog.java.
*/
typedef enum {
EVENT_TYPE_INT = 0,
EVENT_TYPE_LONG = 1,
EVENT_TYPE_STRING = 2,
EVENT_TYPE_LIST = 3,
} AndroidEventLogType;
#define LOG_EVENT_INT(_tag, _value) { \
int intBuf = _value; \
(void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \
sizeof(intBuf)); \
}
#define LOG_EVENT_LONG(_tag, _value) { \
long long longBuf = _value; \
(void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \
sizeof(longBuf)); \
}
#define LOG_EVENT_STRING(_tag, _value) \
((void) 0) /* not implemented -- must combine len with string */
/* TODO: something for LIST */
/*
* ===========================================================================
*
* The stuff in the rest of this file should not be used directly.
*/
#define android_printLog(prio, tag, fmt...) \
__android_log_print(prio, tag, fmt)
#define android_vprintLog(prio, cond, tag, fmt...) \
__android_log_vprint(prio, tag, fmt)
#define android_printAssert(cond, tag, fmt...) \
__android_log_assert(cond, tag, fmt)
#define android_writeLog(prio, tag, text) \
__android_log_write(prio, tag, text)
#define android_bWriteLog(tag, payload, len) \
__android_log_bwrite(tag, payload, len)
#define android_btWriteLog(tag, type, payload, len) \
__android_log_btwrite(tag, type, payload, len)
// TODO: remove these prototypes and their users
#define android_testLog(prio, tag) (1)
#define android_writevLog(vec,num) do{}while(0)
#define android_write1Log(str,len) do{}while (0)
#define android_setMinPriority(tag, prio) do{}while(0)
//#define android_logToCallback(func) do{}while(0)
#define android_logToFile(tag, file) (0)
#define android_logToFd(tag, fd) (0)
typedef enum {
LOG_ID_MAIN = 0,
LOG_ID_RADIO = 1,
LOG_ID_EVENTS = 2,
LOG_ID_SYSTEM = 3,
LOG_ID_MAX
} log_id_t;
/*
* Send a simple string to the log.
*/
int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text);
int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif // _LIBS_CUTILS_LOG_H

View File

@@ -0,0 +1,49 @@
/*
* 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.
*/
#ifndef _ANDROID_CUTILS_LOGD_H
#define _ANDROID_CUTILS_LOGD_H
/* the stable/frozen log-related definitions have been
* moved to this header, which is exposed by the NDK
*/
#include <android/log.h>
/* the rest is only used internally by the system */
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/types.h>
#ifdef HAVE_PTHREADS
#include <pthread.h>
#endif
#include <cutils/uio.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
int __android_log_bwrite(int32_t tag, const void *payload, size_t len);
int __android_log_btwrite(int32_t tag, char type, const void *payload,
size_t len);
#ifdef __cplusplus
}
#endif
#endif /* _LOGD_H */

View File

@@ -0,0 +1,47 @@
/* utils/logger.h
**
** Copyright 2007, The Android Open Source Project
**
** This file is dual licensed. It may be redistributed and/or modified
** under the terms of the Apache 2.0 License OR version 2 of the GNU
** General Public License.
*/
#ifndef _UTILS_LOGGER_H
#define _UTILS_LOGGER_H
#include <stdint.h>
struct logger_entry {
uint16_t len; /* length of the payload */
uint16_t __pad; /* no matter what, we get 2 bytes of padding */
int32_t pid; /* generating process's pid */
int32_t tid; /* generating process's tid */
int32_t sec; /* seconds since Epoch */
int32_t nsec; /* nanoseconds */
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))
#ifdef HAVE_IOCTL
#include <sys/ioctl.h>
#define __LOGGERIO 0xAE
#define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */
#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 */
#endif // HAVE_IOCTL
#endif /* _UTILS_LOGGER_H */

View File

@@ -0,0 +1,158 @@
/*
* Copyright (C) 2006 The Android Open Source Project
* Copyright (c) 2009, The Linux Foundation. All rights reserved.
*
* 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 _LOGPRINT_H
#define _LOGPRINT_H
#include <cutils/log.h>
#include <cutils/logger.h>
#include <cutils/event_tag_map.h>
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
FORMAT_OFF = 0,
FORMAT_BRIEF,
FORMAT_PROCESS,
FORMAT_TAG,
FORMAT_THREAD,
FORMAT_RAW,
FORMAT_TIME,
FORMAT_THREADTIME,
FORMAT_LONG,
} AndroidLogPrintFormat;
typedef struct AndroidLogFormat_t AndroidLogFormat;
typedef struct AndroidLogEntry_t {
time_t tv_sec;
long tv_nsec;
android_LogPriority priority;
pid_t pid;
pthread_t tid;
const char * tag;
size_t messageLen;
const char * message;
} AndroidLogEntry;
AndroidLogFormat *android_log_format_new();
void android_log_format_free(AndroidLogFormat *p_format);
void android_log_setPrintFormat(AndroidLogFormat *p_format,
AndroidLogPrintFormat format);
char filterPriToChar (android_LogPriority pri);
/**
* Returns FORMAT_OFF on invalid string
*/
AndroidLogPrintFormat android_log_formatFromString(const char *s);
/**
* filterExpression: a single filter expression
* eg "AT:d"
*
* returns 0 on success and -1 on invalid expression
*
* Assumes single threaded execution
*
*/
int android_log_addFilterRule(AndroidLogFormat *p_format,
const char *filterExpression);
/**
* filterString: a whitespace-separated set of filter expressions
* eg "AT:d *:i"
*
* returns 0 on success and -1 on invalid expression
*
* Assumes single threaded execution
*
*/
int android_log_addFilterString(AndroidLogFormat *p_format,
const char *filterString);
/**
* returns 1 if this log line should be printed based on its priority
* and tag, and 0 if it should not
*/
int android_log_shouldPrintLine (
AndroidLogFormat *p_format, const char *tag, android_LogPriority pri);
/**
* Splits a wire-format buffer into an AndroidLogEntry
* entry allocated by caller. Pointers will point directly into buf
*
* Returns 0 on success and -1 on invalid wire format (entry will be
* in unspecified state)
*/
int android_log_processLogBuffer(struct logger_entry *buf,
AndroidLogEntry *entry);
/**
* Like android_log_processLogBuffer, but for binary logs.
*
* If "map" is non-NULL, it will be used to convert the log tag number
* into a string.
*/
int android_log_processBinaryLogBuffer(struct logger_entry *buf,
AndroidLogEntry *entry, const EventTagMap* map, char* messageBuf,
int messageBufLen);
/**
* Formats a log message into a buffer
*
* Uses defaultBuffer if it can, otherwise malloc()'s a new buffer
* If return value != defaultBuffer, caller must call free()
* Returns NULL on malloc error
*/
char *android_log_formatLogLine (
AndroidLogFormat *p_format,
char *defaultBuffer,
size_t defaultBufferSize,
const AndroidLogEntry *p_line,
size_t *p_outLength);
/**
* Either print or do not print log line, based on filter
*
* Assumes single threaded execution
*
*/
int android_log_printLogLine(
AndroidLogFormat *p_format,
int fd,
const AndroidLogEntry *entry);
#ifdef __cplusplus
}
#endif
#endif /*_LOGPRINT_H*/

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_CUTILS_MEMORY_H
#define ANDROID_CUTILS_MEMORY_H
#include <stdint.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* size is given in bytes and must be multiple of 2 */
void android_memset16(uint16_t* dst, uint16_t value, size_t size);
/* size is given in bytes and must be multiple of 4 */
void android_memset32(uint32_t* dst, uint32_t value, size_t size);
#if !HAVE_STRLCPY
/* Declaration of strlcpy() for platforms that don't already have it. */
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // ANDROID_CUTILS_MEMORY_H

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_MISC_H
#define __CUTILS_MISC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Load an entire file into a malloc'd chunk of memory
* that is length_of_file + 1 (null terminator). If
* sz is non-zero, return the size of the file via sz.
* Returns 0 on failure.
*/
extern void *load_file(const char *fn, unsigned *sz);
/* Connects your process to the system debugger daemon
* so that on a crash it may be logged or interactively
* debugged (depending on system settings).
*/
extern void debuggerd_connect(void);
/* This is the range of UIDs (and GIDs) that are reserved
* for assigning to applications.
*/
#define FIRST_APPLICATION_UID 10000
#define LAST_APPLICATION_UID 99999
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_MISC_H */

View File

@@ -0,0 +1,124 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* IPC messaging library.
*/
#ifndef __MQ_H
#define __MQ_H
#ifdef __cplusplus
extern "C" {
#endif
/** A message. */
typedef struct MqMessage MqMessage;
/** A destination to which messages can be sent. */
typedef struct MqDestination MqDestination;
/* Array of bytes. */
typedef struct MqBytes MqBytes;
/**
* Hears messages.
*
* @param destination to which the message was sent
* @param message the message to hear
*/
typedef void MqMessageListener(MqDestination* destination, MqMessage* message);
/**
* Hears a destination close.
*
* @param destination that closed
*/
typedef void MqCloseListener(MqDestination* destination);
/** Message functions. */
/**
* Creates a new Message.
*
* @param header as defined by user
* @param body as defined by user
* @param replyTo destination to which replies should be sent, NULL if none
*/
MqMessage* mqCreateMessage(MqBytes header, MqBytes body,
MqDestination* replyTo);
/** Sends a message to a destination. */
void mqSendMessage(MqMessage* message, MqDestination* destination);
/** Destination functions. */
/**
* Creates a new destination. Acquires a reference implicitly.
*
* @param messageListener function to call when a message is recieved
* @param closeListener function to call when the destination closes
* @param userData user-specific data to associate with the destination.
* Retrieve using mqGetDestinationUserData().
*/
MqDestination* mqCreateDestination(MqMessageListener* messageListener,
MqCloseListener* closeListener, void* userData);
/**
* Gets user data which was associated with the given destination at
* construction time.
*
* It is only valid to call this function in the same process that the
* given destination was created in.
* This function returns a null pointer if you call it on a destination
* created in a remote process.
*/
void* mqGetUserData(MqDestination* destination);
/**
* Returns 1 if the destination was created in this process, or 0 if
* the destination was created in a different process, in which case you have
* a remote stub.
*/
int mqIsDestinationLocal(MqDestination* destination);
/**
* Increments the destination's reference count.
*/
void mqKeepDestination(MqDesintation* destination);
/**
* Decrements the destination's reference count.
*/
void mqFreeDestination(MqDestination* desintation);
/** Registry API. */
/**
* Gets the destination bound to a name.
*/
MqDestination* mqGetDestination(char* name);
/**
* Binds a destination to a name.
*/
void mqPutDestination(char* name, MqDestination* desintation);
#ifdef __cplusplus
}
#endif
#endif /* __MQ_H */

View File

@@ -0,0 +1,128 @@
/*
* 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_ */

View File

@@ -0,0 +1,73 @@
/*
* 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.
*/
#ifndef NATIVE_HANDLE_H_
#define NATIVE_HANDLE_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
int version; /* sizeof(native_handle_t) */
int numFds; /* number of file-descriptors at &data[0] */
int numInts; /* number of ints at &data[numFds] */
int data[0]; /* numFds + numInts ints */
} native_handle_t;
/* keep the old definition for backward source-compatibility */
typedef native_handle_t native_handle;
/*
* native_handle_close
*
* closes the file descriptors contained in this native_handle_t
*
* return 0 on success, or a negative error code on failure
*
*/
int native_handle_close(const native_handle_t* h);
/*
* native_handle_create
*
* creates a native_handle_t and initializes it. must be destroyed with
* native_handle_delete().
*
*/
native_handle_t* native_handle_create(int numFds, int numInts);
/*
* native_handle_delete
*
* frees a native_handle_t allocated with native_handle_create().
* This ONLY frees the memory allocated for the native_handle_t, but doesn't
* close the file descriptors; which can be achieved with native_handle_close().
*
* return 0 on success, or a negative error code on failure
*
*/
int native_handle_delete(native_handle_t* h);
#ifdef __cplusplus
}
#endif
#endif /* NATIVE_HANDLE_H_ */

View File

@@ -0,0 +1,36 @@
/*
* 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 __CUTILS_OPEN_MEMSTREAM_H__
#define __CUTILS_OPEN_MEMSTREAM_H__
#include <stdio.h>
#ifndef HAVE_OPEN_MEMSTREAM
#ifdef __cplusplus
extern "C" {
#endif
FILE* open_memstream(char** bufp, size_t* sizep);
#ifdef __cplusplus
}
#endif
#endif /*!HAVE_OPEN_MEMSTREAM*/
#endif /*__CUTILS_OPEN_MEMSTREAM_H__*/

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Gives the current process a name.
*/
#ifndef __PROCESS_NAME_H
#define __PROCESS_NAME_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* Sets the current process name.
*
* Warning: This leaks a string every time you call it. Use judiciously!
*/
void set_process_name(const char* process_name);
/** Gets the current process name. */
const char* get_process_name(void);
#ifdef __cplusplus
}
#endif
#endif /* __PROCESS_NAME_H */

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_PROPERTIES_H
#define __CUTILS_PROPERTIES_H
#ifdef __cplusplus
extern "C" {
#endif
/* System properties are *small* name value pairs managed by the
** property service. If your data doesn't fit in the provided
** space it is not appropriate for a system property.
**
** WARNING: system/bionic/include/sys/system_properties.h also defines
** these, but with different names. (TODO: fix that)
*/
#define PROPERTY_KEY_MAX 32
#define PROPERTY_VALUE_MAX 92
/* property_get: returns the length of the value which will never be
** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated.
** (the length does not include the terminating zero).
**
** If the property read fails or returns an empty value, the default
** value is used (if nonnull).
*/
int property_get(const char *key, char *value, const char *default_value);
/* property_set: returns 0 on success, < 0 on failure
*/
int property_set(const char *key, const char *value);
int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie);
#ifdef HAVE_SYSTEM_PROPERTY_SERVER
/*
* We have an external property server instead of built-in libc support.
* Used by the simulator.
*/
#define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop"
enum {
kSystemPropertyUnknown = 0,
kSystemPropertyGet,
kSystemPropertySet,
kSystemPropertyList
};
#endif /*HAVE_SYSTEM_PROPERTY_SERVER*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,43 @@
/*
* 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 simple utility for reading fixed records out of a stream fd
*/
#ifndef _CUTILS_RECORD_STREAM_H
#define _CUTILS_RECORD_STREAM_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct RecordStream RecordStream;
extern RecordStream *record_stream_new(int fd, size_t maxRecordLen);
extern void record_stream_free(RecordStream *p_rs);
extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord,
size_t *p_outRecordLen);
#ifdef __cplusplus
}
#endif
#endif /*_CUTILS_RECORD_STREAM_H*/

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_SCHED_POLICY_H
#define __CUTILS_SCHED_POLICY_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SP_BACKGROUND = 0,
SP_FOREGROUND = 1,
} SchedPolicy;
extern int set_sched_policy(int tid, SchedPolicy policy);
extern int get_sched_policy(int tid, SchedPolicy *policy);
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_SCHED_POLICY_H */

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Framework for multiplexing I/O. A selector manages a set of file
* descriptors and calls out to user-provided callback functions to read and
* write data and handle errors.
*/
#ifndef __SELECTOR_H
#define __SELECTOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
/**
* Manages SelectableFds and invokes their callbacks at appropriate times.
*/
typedef struct Selector Selector;
/**
* A selectable descriptor. Contains callbacks which the selector can invoke
* before calling select(), when the descriptor is readable or writable, and
* when the descriptor contains out-of-band data. Simply set a callback to
* NULL if you're not interested in that particular event.
*
* A selectable descriptor can indicate that it needs to be removed from the
* selector by setting the 'remove' flag. The selector will remove the
* descriptor at a later time and invoke the onRemove() callback.
*
* SelectableFd fields should only be modified from the selector loop.
*/
typedef struct SelectableFd SelectableFd;
struct SelectableFd {
/** The file descriptor itself. */
int fd;
/** Pointer to user-specific data. Can be NULL. */
void* data;
/**
* Set this flag when you no longer wish to be selected. The selector
* will invoke onRemove() when the descriptor is actually removed.
*/
bool remove;
/**
* Invoked by the selector before calling select. You can set up other
* callbacks from here as necessary.
*/
void (*beforeSelect)(SelectableFd* self);
/**
* Invoked by the selector when the descriptor has data available. Set to
* NULL to indicate that you're not interested in reading.
*/
void (*onReadable)(SelectableFd* self);
/**
* Invoked by the selector when the descriptor can accept data. Set to
* NULL to indicate that you're not interested in writing.
*/
void (*onWritable)(SelectableFd* self);
/**
* Invoked by the selector when out-of-band (OOB) data is available. Set to
* NULL to indicate that you're not interested in OOB data.
*/
void (*onExcept)(SelectableFd* self);
/**
* Invoked by the selector after the descriptor is removed from the
* selector but before the selector frees the SelectableFd memory.
*/
void (*onRemove)(SelectableFd* self);
/**
* The selector which selected this fd. Set by the selector itself.
*/
Selector* selector;
};
/**
* Creates a new selector.
*/
Selector* selectorCreate(void);
/**
* Creates a new selectable fd, adds it to the given selector and returns a
* pointer. Outside of 'selector' and 'fd', all fields are set to 0 or NULL
* by default.
*
* The selectable fd should only be modified from the selector loop thread.
*/
SelectableFd* selectorAdd(Selector* selector, int fd);
/**
* Wakes up the selector even though no I/O events occurred. Use this
* to indicate that you're ready to write to a descriptor.
*/
void selectorWakeUp(Selector* selector);
/**
* Loops continuously selecting file descriptors and firing events.
* Does not return.
*/
void selectorLoop(Selector* selector);
#ifdef __cplusplus
}
#endif
#endif /* __SELECTOR_H */

View File

@@ -0,0 +1,100 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_SOCKETS_H
#define __CUTILS_SOCKETS_H
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_WINSOCK
#include <winsock2.h>
typedef int socklen_t;
#elif HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_"
#define ANDROID_SOCKET_DIR "/dev/socket"
#ifdef __cplusplus
extern "C" {
#endif
/*
* android_get_control_socket - simple helper function to get the file
* descriptor of our init-managed Unix domain socket. `name' is the name of the
* socket, as given in init.rc. Returns -1 on error.
*
* This is inline and not in libcutils proper because we want to use this in
* third-party daemons with minimal modification.
*/
static inline int android_get_control_socket(const char *name)
{
char key[64] = ANDROID_SOCKET_ENV_PREFIX;
const char *val;
int fd;
/* build our environment variable, counting cycles like a wolf ... */
#if HAVE_STRLCPY
strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
name,
sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
#else /* for the host, which may lack the almightly strncpy ... */
strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
name,
sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
key[sizeof(key)-1] = '\0';
#endif
val = getenv(key);
if (!val)
return -1;
errno = 0;
fd = strtol(val, NULL, 10);
if (errno)
return -1;
return fd;
}
/*
* See also android.os.LocalSocketAddress.Namespace
*/
// Linux "abstract" (non-filesystem) namespace
#define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0
// Android "reserved" (/dev/socket) namespace
#define ANDROID_SOCKET_NAMESPACE_RESERVED 1
// Normal filesystem namespace
#define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2
extern int socket_loopback_client(int port, int type);
extern int socket_network_client(const char *host, int port, int type);
extern int socket_loopback_server(int port, int type);
extern int socket_local_server(const char *name, int namespaceId, int type);
extern int socket_local_server_bind(int s, const char *name, int namespaceId);
extern int socket_local_client_connect(int fd,
const char *name, int namespaceId, int type);
extern int socket_local_client(const char *name, int namespaceId, int type);
extern int socket_inaddr_any_server(int port, int type);
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_SOCKETS_H */

View File

@@ -0,0 +1,146 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBS_CUTILS_THREADS_H
#define _LIBS_CUTILS_THREADS_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************************/
/***********************************************************************/
/***** *****/
/***** local thread storage *****/
/***** *****/
/***********************************************************************/
/***********************************************************************/
#ifdef HAVE_PTHREADS
#include <pthread.h>
typedef struct {
pthread_mutex_t lock;
int has_tls;
pthread_key_t tls;
} thread_store_t;
#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 }
#elif defined HAVE_WIN32_THREADS
#include <windows.h>
typedef struct {
int lock_init;
int has_tls;
DWORD tls;
CRITICAL_SECTION lock;
} thread_store_t;
#define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} }
#else
# error "no thread_store_t implementation for your platform !!"
#endif
typedef void (*thread_store_destruct_t)(void* value);
extern void* thread_store_get(thread_store_t* store);
extern void thread_store_set(thread_store_t* store,
void* value,
thread_store_destruct_t destroy);
/***********************************************************************/
/***********************************************************************/
/***** *****/
/***** mutexes *****/
/***** *****/
/***********************************************************************/
/***********************************************************************/
#ifdef HAVE_PTHREADS
typedef pthread_mutex_t mutex_t;
#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
static __inline__ void mutex_lock(mutex_t* lock)
{
pthread_mutex_lock(lock);
}
static __inline__ void mutex_unlock(mutex_t* lock)
{
pthread_mutex_unlock(lock);
}
static __inline__ int mutex_init(mutex_t* lock)
{
return pthread_mutex_init(lock, NULL);
}
static __inline__ void mutex_destroy(mutex_t* lock)
{
pthread_mutex_destroy(lock);
}
#endif
#ifdef HAVE_WIN32_THREADS
typedef struct {
int init;
CRITICAL_SECTION lock[1];
} mutex_t;
#define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} }
static __inline__ void mutex_lock(mutex_t* lock)
{
if (!lock->init) {
lock->init = 1;
InitializeCriticalSection( lock->lock );
lock->init = 2;
} else while (lock->init != 2)
Sleep(10);
EnterCriticalSection(lock->lock);
}
static __inline__ void mutex_unlock(mutex_t* lock)
{
LeaveCriticalSection(lock->lock);
}
static __inline__ int mutex_init(mutex_t* lock)
{
InitializeCriticalSection(lock->lock);
lock->init = 2;
return 0;
}
static __inline__ void mutex_destroy(mutex_t* lock)
{
if (lock->init) {
lock->init = 0;
DeleteCriticalSection(lock->lock);
}
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LIBS_CUTILS_THREADS_H */

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _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
#endif /* __CUTILS_TZTIME_H */

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// implementation of sys/uio.h for platforms that don't have it (Win32)
//
#ifndef _LIBS_CUTILS_UIO_H
#define _LIBS_CUTILS_UIO_H
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#else
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#if !LINUX_ENABLED
struct iovec {
const void* iov_base;
size_t iov_len;
};
extern int readv( int fd, struct iovec* vecs, int count );
extern int writev( int fd, const struct iovec* vecs, int count );
#endif /* !LINUX_ENABLED */
#ifdef __cplusplus
}
#endif
#endif /* !HAVE_SYS_UIO_H */
#endif /* _LIBS_UTILS_UIO_H */

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CUTILS_ZYGOTE_H
#define __CUTILS_ZYGOTE_H
#ifdef __cplusplus
extern "C" {
#endif
int zygote_run_oneshot(int sendStdio, int argc, const char **argv);
int zygote_run(int argc, const char **argv);
int zygote_run_wait(int argc, const char **argv, void (*post_run_func)(int));
#ifdef __cplusplus
}
#endif
#endif /* __CUTILS_ZYGOTE_H */

View File

@@ -0,0 +1,129 @@
/* system/core/include/diskconfig/diskconfig.h
*
* Copyright 2008, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __LIBS_DISKCONFIG_H
#define __LIBS_DISKCONFIG_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_NAME_LEN 512
#define MAX_NUM_PARTS 16
/* known partition schemes */
#define PART_SCHEME_MBR 0x1
#define PART_SCHEME_GPT 0x2
/* PC Bios partition status */
#define PC_PART_ACTIVE 0x80
#define PC_PART_NORMAL 0x0
/* Known (rather, used by us) partition types */
#define PC_PART_TYPE_LINUX 0x83
#define PC_PART_TYPE_EXTENDED 0x05
#define PC_PART_TYPE_FAT32 0x0c
#define PC_NUM_BOOT_RECORD_PARTS 4
#define PC_EBR_LOGICAL_PART 0
#define PC_EBR_NEXT_PTR_PART 1
#define PC_BIOS_BOOT_SIG 0xAA55
#define PC_MBR_DISK_OFFSET 0
#define PC_MBR_SIZE 512
#define PART_ACTIVE_FLAG 0x1
struct chs {
uint8_t head;
uint8_t sector;
uint8_t cylinder;
} __attribute__((__packed__));
/* 16 byte pc partition descriptor that sits in MBR and EPBR.
* Note: multi-byte entities have little-endian layout on disk */
struct pc_partition {
uint8_t status; /* byte 0 */
struct chs start; /* bytes 1-3 */
uint8_t type; /* byte 4 */
struct chs end; /* bytes 5-7 */
uint32_t start_lba; /* bytes 8-11 */
uint32_t len_lba; /* bytes 12-15 */
} __attribute__((__packed__));
struct pc_boot_record {
uint8_t code[440]; /* bytes 0-439 */
uint32_t disk_sig; /* bytes 440-443 */
uint16_t pad; /* bytes 444-445 */
struct pc_partition ptable[PC_NUM_BOOT_RECORD_PARTS]; /* bytes 446-509 */
uint16_t mbr_sig; /* bytes 510-511 */
} __attribute__((__packed__));
struct part_info {
char *name;
uint8_t flags;
uint8_t type;
uint32_t len_kb; /* in 1K-bytes */
uint32_t start_lba; /* the LBA where this partition begins */
};
struct disk_info {
char *device;
uint8_t scheme;
int sect_size; /* expected sector size in bytes. MUST BE POWER OF 2 */
uint32_t skip_lba; /* in sectors (1 unit of LBA) */
uint32_t num_lba; /* the size of the disk in LBA units */
struct part_info *part_lst;
int num_parts;
};
struct write_list {
struct write_list *next;
loff_t offset;
uint32_t len;
uint8_t data[0];
};
struct write_list *alloc_wl(uint32_t data_len);
void free_wl(struct write_list *item);
struct write_list *wlist_add(struct write_list **lst, struct write_list *item);
void wlist_free(struct write_list *lst);
int wlist_commit(int fd, struct write_list *lst, int test);
struct disk_info *load_diskconfig(const char *fn, char *path_override);
int dump_disk_config(struct disk_info *dinfo);
int apply_disk_config(struct disk_info *dinfo, int test);
char *find_part_device(struct disk_info *dinfo, const char *name);
int process_disk_config(struct disk_info *dinfo);
struct part_info *find_part(struct disk_info *dinfo, const char *name);
int write_raw_image(const char *dst, const char *src, loff_t offset, int test);
/* For MBR partition schemes */
struct write_list *config_mbr(struct disk_info *dinfo);
char *find_mbr_part(struct disk_info *dinfo, const char *name);
#ifdef __cplusplus
}
#endif
#endif /* __LIBS_DISKCONFIG_H */

View File

@@ -0,0 +1,198 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _ARM_MACHINE_CPU_FEATURES_H
#define _ARM_MACHINE_CPU_FEATURES_H
/* The purpose of this file is to define several macros corresponding
* to CPU features that may or may not be available at build time on
* on the target CPU.
*
* This is done to abstract us from the various ARM Architecture
* quirks and alphabet soup.
*
* IMPORTANT: We have no intention to support anything below an ARMv4T !
*/
/* __ARM_ARCH__ is a number corresponding to the ARM revision
* we're going to support
*
* it looks like our toolchain doesn't define __ARM_ARCH__
* so try to guess it.
*
*
*
*/
#ifndef __ARM_ARCH__
# if defined __ARM_ARCH_7__ || defined __ARM_ARCH_7A__ || \
defined __ARM_ARCH_7R__ || defined __ARM_ARCH_7M__
# define __ARM_ARCH__ 7
# elif defined __ARM_ARCH_6__ || defined __ARM_ARCH_6J__ || \
defined __ARM_ARCH_6K__ || defined __ARM_ARCH_6Z__ || \
defined __ARM_ARCH_6KZ__ || defined __ARM_ARCH_6T2__
#
# define __ARM_ARCH__ 6
#
# elif defined __ARM_ARCH_5__ || defined __ARM_ARCH_5T__ || \
defined __ARM_ARCH_5TE__ || defined __ARM_ARCH_5TEJ__
#
# define __ARM_ARCH__ 5
#
# elif defined __ARM_ARCH_4T__
#
# define __ARM_ARCH__ 4
#
# elif defined __ARM_ARCH_4__
# error ARMv4 is not supported, please use ARMv4T at a minimum
# else
# error Unknown or unsupported ARM architecture
# endif
#endif
/* experimental feature used to check that our ARMv4 workarounds
* work correctly without a real ARMv4 machine */
#ifdef BIONIC_EXPERIMENTAL_FORCE_ARMV4
# undef __ARM_ARCH__
# define __ARM_ARCH__ 4
#endif
/* define __ARM_HAVE_5TE if we have the ARMv5TE instructions */
#if __ARM_ARCH__ > 5
# define __ARM_HAVE_5TE 1
#elif __ARM_ARCH__ == 5
# if defined __ARM_ARCH_5TE__ || defined __ARM_ARCH_5TEJ__
# define __ARM_HAVE_5TE 1
# endif
#endif
/* instructions introduced in ARMv5 */
#if __ARM_ARCH__ >= 5
# define __ARM_HAVE_BLX 1
# define __ARM_HAVE_CLZ 1
# define __ARM_HAVE_LDC2 1
# define __ARM_HAVE_MCR2 1
# define __ARM_HAVE_MRC2 1
# define __ARM_HAVE_STC2 1
#endif
/* ARMv5TE introduces a few instructions */
#if __ARM_HAVE_5TE
# define __ARM_HAVE_PLD 1
# define __ARM_HAVE_MCRR 1
# define __ARM_HAVE_MRRC 1
#endif
/* define __ARM_HAVE_HALFWORD_MULTIPLY when half-word multiply instructions
* this means variants of: smul, smulw, smla, smlaw, smlal
*/
#if __ARM_HAVE_5TE
# define __ARM_HAVE_HALFWORD_MULTIPLY 1
#endif
/* define __ARM_HAVE_PAIR_LOAD_STORE when 64-bit memory loads and stored
* into/from a pair of 32-bit registers is supported throuhg 'ldrd' and 'strd'
*/
#if __ARM_HAVE_5TE
# define __ARM_HAVE_PAIR_LOAD_STORE 1
#endif
/* define __ARM_HAVE_SATURATED_ARITHMETIC is you have the saturated integer
* arithmetic instructions: qdd, qdadd, qsub, qdsub
*/
#if __ARM_HAVE_5TE
# define __ARM_HAVE_SATURATED_ARITHMETIC 1
#endif
/* define __ARM_HAVE_PC_INTERWORK when a direct assignment to the
* pc register will switch into thumb/ARM mode depending on bit 0
* of the new instruction address. Before ARMv5, this was not the
* case, and you have to write:
*
* mov r0, [<some address>]
* bx r0
*
* instead of:
*
* ldr pc, [<some address>]
*
* note that this affects any instruction that explicitly changes the
* value of the pc register, including ldm { ...,pc } or 'add pc, #offset'
*/
#if __ARM_ARCH__ >= 5
# define __ARM_HAVE_PC_INTERWORK
#endif
/* define __ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecture to be
* used in replacement of deprecated swp instruction
*/
#if __ARM_ARCH__ >= 6
# define __ARM_HAVE_LDREX_STREX
#endif
/* define __ARM_HAVE_DMB for ARMv7 architecture
*/
#if __ARM_ARCH__ >= 7
# define __ARM_HAVE_DMB
#endif
/* define __ARM_HAVE_LDREXD for ARMv7 architecture
* (also present in ARMv6K, but not implemented in ARMv7-M, neither of which
* we care about)
*/
#if __ARM_ARCH__ >= 7
# define __ARM_HAVE_LDREXD
#endif
/* define _ARM_HAVE_VFP if we have VFPv3
*/
#if __ARM_ARCH__ >= 7 && defined __VFP_FP__
# define __ARM_HAVE_VFP
#endif
/* define _ARM_HAVE_NEON for ARMv7 architecture if we support the
* Neon SIMD instruction set extensions. This also implies
* that VFPv3-D32 is supported.
*/
#if __ARM_ARCH__ >= 7 && defined __ARM_NEON__
# define __ARM_HAVE_NEON
#endif
/* Assembly-only macros */
/* define a handy PLD(address) macro since the cache preload
* is an optional opcode
*/
#if __ARM_HAVE_PLD
# define PLD(reg,offset) pld [reg, offset]
#else
# define PLD(reg,offset) /* nothing */
#endif
#endif /* _ARM_MACHINE_CPU_FEATURES_H */

View File

@@ -0,0 +1,56 @@
/* rsa.h
**
** Copyright 2008, The Android Open Source Project
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of Google Inc. nor the names of its contributors may
** 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
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** 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
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _EMBEDDED_RSA_H_
#define _EMBEDDED_RSA_H_
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
#define RSANUMBYTES 256 /* 2048 bit key length */
#define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t))
typedef struct RSAPublicKey {
int len; /* Length of n[] in number of uint32_t */
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 */
} RSAPublicKey;
int RSA_verify(const RSAPublicKey *key,
const uint8_t* signature,
const int len,
const uint8_t* sha);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,63 @@
/* sha.h
**
** Copyright 2008, The Android Open Source Project
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of Google Inc. nor the names of its contributors may
** 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
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** 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
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _EMBEDDED_SHA_H_
#define _EMBEDDED_SHA_H_
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct SHA_CTX {
uint64_t count;
uint32_t state[5];
#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN)
union {
uint8_t b[64];
uint32_t w[16];
} buf;
#else
uint8_t buf[64];
#endif
} SHA_CTX;
void SHA_init(SHA_CTX* ctx);
void SHA_update(SHA_CTX* ctx, const void* data, int len);
const uint8_t* SHA_final(SHA_CTX* ctx);
/* Convenience method. Returns digest parameter value. */
const uint8_t* SHA(const void* data, int len, uint8_t* digest);
#define SHA_DIGEST_SIZE 20
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,136 @@
/*
* Copyright (C) 2005 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_PIXELFLINGER_FORMAT_H
#define ANDROID_PIXELFLINGER_FORMAT_H
#include <stdint.h>
#include <sys/types.h>
enum GGLPixelFormat {
// these constants need to match those
// in graphics/PixelFormat.java, ui/PixelFormat.h, BlitHardware.h
GGL_PIXEL_FORMAT_UNKNOWN = 0,
GGL_PIXEL_FORMAT_NONE = 0,
GGL_PIXEL_FORMAT_RGBA_8888 = 1, // 4x8-bit ARGB
GGL_PIXEL_FORMAT_RGBX_8888 = 2, // 3x8-bit RGB stored in 32-bit chunks
GGL_PIXEL_FORMAT_RGB_888 = 3, // 3x8-bit RGB
GGL_PIXEL_FORMAT_RGB_565 = 4, // 16-bit RGB
GGL_PIXEL_FORMAT_BGRA_8888 = 5, // 4x8-bit BGRA
GGL_PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit RGBA
GGL_PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit RGBA
GGL_PIXEL_FORMAT_A_8 = 8, // 8-bit A
GGL_PIXEL_FORMAT_L_8 = 9, // 8-bit L (R=G=B = L)
GGL_PIXEL_FORMAT_LA_88 = 0xA, // 16-bit LA
GGL_PIXEL_FORMAT_RGB_332 = 0xB, // 8-bit RGB (non paletted)
// reserved range. don't use.
GGL_PIXEL_FORMAT_RESERVED_10 = 0x10,
GGL_PIXEL_FORMAT_RESERVED_11 = 0x11,
GGL_PIXEL_FORMAT_RESERVED_12 = 0x12,
GGL_PIXEL_FORMAT_RESERVED_13 = 0x13,
GGL_PIXEL_FORMAT_RESERVED_14 = 0x14,
GGL_PIXEL_FORMAT_RESERVED_15 = 0x15,
GGL_PIXEL_FORMAT_RESERVED_16 = 0x16,
GGL_PIXEL_FORMAT_RESERVED_17 = 0x17,
// reserved/special formats
GGL_PIXEL_FORMAT_Z_16 = 0x18,
GGL_PIXEL_FORMAT_S_8 = 0x19,
GGL_PIXEL_FORMAT_SZ_24 = 0x1A,
GGL_PIXEL_FORMAT_SZ_8 = 0x1B,
// reserved range. don't use.
GGL_PIXEL_FORMAT_RESERVED_20 = 0x20,
GGL_PIXEL_FORMAT_RESERVED_21 = 0x21,
};
enum GGLFormatComponents {
GGL_STENCIL_INDEX = 0x1901,
GGL_DEPTH_COMPONENT = 0x1902,
GGL_ALPHA = 0x1906,
GGL_RGB = 0x1907,
GGL_RGBA = 0x1908,
GGL_LUMINANCE = 0x1909,
GGL_LUMINANCE_ALPHA = 0x190A,
};
enum GGLFormatComponentIndex {
GGL_INDEX_ALPHA = 0,
GGL_INDEX_RED = 1,
GGL_INDEX_GREEN = 2,
GGL_INDEX_BLUE = 3,
GGL_INDEX_STENCIL = 0,
GGL_INDEX_DEPTH = 1,
GGL_INDEX_Y = 0,
GGL_INDEX_CB = 1,
GGL_INDEX_CR = 2,
};
typedef struct {
#ifdef __cplusplus
enum {
ALPHA = GGL_INDEX_ALPHA,
RED = GGL_INDEX_RED,
GREEN = GGL_INDEX_GREEN,
BLUE = GGL_INDEX_BLUE,
STENCIL = GGL_INDEX_STENCIL,
DEPTH = GGL_INDEX_DEPTH,
LUMA = GGL_INDEX_Y,
CHROMAB = GGL_INDEX_CB,
CHROMAR = GGL_INDEX_CR,
};
inline uint32_t mask(int i) const {
return ((1<<(c[i].h-c[i].l))-1)<<c[i].l;
}
inline uint32_t bits(int i) const {
return c[i].h - c[i].l;
}
#endif
uint8_t size; // bytes per pixel
uint8_t bitsPerPixel;
union {
struct {
uint8_t ah; // alpha high bit position + 1
uint8_t al; // alpha low bit position
uint8_t rh; // red high bit position + 1
uint8_t rl; // red low bit position
uint8_t gh; // green high bit position + 1
uint8_t gl; // green low bit position
uint8_t bh; // blue high bit position + 1
uint8_t bl; // blue low bit position
};
struct {
uint8_t h;
uint8_t l;
} __attribute__((__packed__)) c[4];
} __attribute__((__packed__));
uint16_t components; // GGLFormatComponents
} GGLFormat;
#ifdef __cplusplus
extern "C" const GGLFormat* gglGetPixelFormatTable(size_t* numEntries = 0);
#else
const GGLFormat* gglGetPixelFormatTable(size_t* numEntries);
#endif
// ----------------------------------------------------------------------------
#endif // ANDROID_PIXELFLINGER_FORMAT_H

View File

@@ -0,0 +1,330 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_PIXELFLINGER_H
#define ANDROID_PIXELFLINGER_H
#include <stdint.h>
#include <sys/types.h>
#include <pixelflinger/format.h>
// GGL types
typedef int8_t GGLbyte; // b
typedef int16_t GGLshort; // s
typedef int32_t GGLint; // i
typedef ssize_t GGLsizei; // i
typedef int32_t GGLfixed; // x
typedef int32_t GGLclampx; // x
typedef float GGLfloat; // f
typedef float GGLclampf; // f
typedef double GGLdouble; // d
typedef double GGLclampd; // d
typedef uint8_t GGLubyte; // ub
typedef uint8_t GGLboolean; // ub
typedef uint16_t GGLushort; // us
typedef uint32_t GGLuint; // ui
typedef unsigned int GGLenum; // ui
typedef unsigned int GGLbitfield; // ui
typedef void GGLvoid;
typedef int32_t GGLfixed32;
typedef int32_t GGLcolor;
typedef int32_t GGLcoord;
// ----------------------------------------------------------------------------
#define GGL_MAX_VIEWPORT_DIMS 4096
#define GGL_MAX_TEXTURE_SIZE 4096
#define GGL_MAX_ALIASED_POINT_SIZE 0x7FFFFFF
#define GGL_MAX_SMOOTH_POINT_SIZE 2048
#define GGL_MAX_SMOOTH_LINE_WIDTH 2048
// ----------------------------------------------------------------------------
// All these names are compatible with their OpenGL equivalents
// some of them are listed only for completeness
enum GGLNames {
GGL_FALSE = 0,
GGL_TRUE = 1,
// enable/disable
GGL_SCISSOR_TEST = 0x0C11,
GGL_TEXTURE_2D = 0x0DE1,
GGL_ALPHA_TEST = 0x0BC0,
GGL_BLEND = 0x0BE2,
GGL_COLOR_LOGIC_OP = 0x0BF2,
GGL_DITHER = 0x0BD0,
GGL_STENCIL_TEST = 0x0B90,
GGL_DEPTH_TEST = 0x0B71,
GGL_AA = 0x80000001,
GGL_W_LERP = 0x80000004,
GGL_POINT_SMOOTH_NICE = 0x80000005,
// buffers, pixel drawing/reading
GGL_COLOR = 0x1800,
// fog
GGL_FOG = 0x0B60,
// shade model
GGL_FLAT = 0x1D00,
GGL_SMOOTH = 0x1D01,
// Texture parameter name
GGL_TEXTURE_MIN_FILTER = 0x2801,
GGL_TEXTURE_MAG_FILTER = 0x2800,
GGL_TEXTURE_WRAP_S = 0x2802,
GGL_TEXTURE_WRAP_T = 0x2803,
GGL_TEXTURE_WRAP_R = 0x2804,
// Texture Filter
GGL_NEAREST = 0x2600,
GGL_LINEAR = 0x2601,
GGL_NEAREST_MIPMAP_NEAREST = 0x2700,
GGL_LINEAR_MIPMAP_NEAREST = 0x2701,
GGL_NEAREST_MIPMAP_LINEAR = 0x2702,
GGL_LINEAR_MIPMAP_LINEAR = 0x2703,
// Texture Wrap Mode
GGL_CLAMP = 0x2900,
GGL_REPEAT = 0x2901,
GGL_CLAMP_TO_EDGE = 0x812F,
// Texture Env Mode
GGL_REPLACE = 0x1E01,
GGL_MODULATE = 0x2100,
GGL_DECAL = 0x2101,
GGL_ADD = 0x0104,
// Texture Env Parameter
GGL_TEXTURE_ENV_MODE = 0x2200,
GGL_TEXTURE_ENV_COLOR = 0x2201,
// Texture Env Target
GGL_TEXTURE_ENV = 0x2300,
// Texture coord generation
GGL_TEXTURE_GEN_MODE = 0x2500,
GGL_S = 0x2000,
GGL_T = 0x2001,
GGL_R = 0x2002,
GGL_Q = 0x2003,
GGL_ONE_TO_ONE = 0x80000002,
GGL_AUTOMATIC = 0x80000003,
// AlphaFunction
GGL_NEVER = 0x0200,
GGL_LESS = 0x0201,
GGL_EQUAL = 0x0202,
GGL_LEQUAL = 0x0203,
GGL_GREATER = 0x0204,
GGL_NOTEQUAL = 0x0205,
GGL_GEQUAL = 0x0206,
GGL_ALWAYS = 0x0207,
// LogicOp
GGL_CLEAR = 0x1500, // 0
GGL_AND = 0x1501, // s & d
GGL_AND_REVERSE = 0x1502, // s & ~d
GGL_COPY = 0x1503, // s
GGL_AND_INVERTED = 0x1504, // ~s & d
GGL_NOOP = 0x1505, // d
GGL_XOR = 0x1506, // s ^ d
GGL_OR = 0x1507, // s | d
GGL_NOR = 0x1508, // ~(s | d)
GGL_EQUIV = 0x1509, // ~(s ^ d)
GGL_INVERT = 0x150A, // ~d
GGL_OR_REVERSE = 0x150B, // s | ~d
GGL_COPY_INVERTED = 0x150C, // ~s
GGL_OR_INVERTED = 0x150D, // ~s | d
GGL_NAND = 0x150E, // ~(s & d)
GGL_SET = 0x150F, // 1
// blending equation & function
GGL_ZERO = 0, // SD
GGL_ONE = 1, // SD
GGL_SRC_COLOR = 0x0300, // D
GGL_ONE_MINUS_SRC_COLOR = 0x0301, // D
GGL_SRC_ALPHA = 0x0302, // SD
GGL_ONE_MINUS_SRC_ALPHA = 0x0303, // SD
GGL_DST_ALPHA = 0x0304, // SD
GGL_ONE_MINUS_DST_ALPHA = 0x0305, // SD
GGL_DST_COLOR = 0x0306, // S
GGL_ONE_MINUS_DST_COLOR = 0x0307, // S
GGL_SRC_ALPHA_SATURATE = 0x0308, // S
// clear bits
GGL_DEPTH_BUFFER_BIT = 0x00000100,
GGL_STENCIL_BUFFER_BIT = 0x00000400,
GGL_COLOR_BUFFER_BIT = 0x00004000,
// errors
GGL_NO_ERROR = 0,
GGL_INVALID_ENUM = 0x0500,
GGL_INVALID_VALUE = 0x0501,
GGL_INVALID_OPERATION = 0x0502,
GGL_STACK_OVERFLOW = 0x0503,
GGL_STACK_UNDERFLOW = 0x0504,
GGL_OUT_OF_MEMORY = 0x0505
};
// ----------------------------------------------------------------------------
typedef struct {
GGLsizei version; // always set to sizeof(GGLSurface)
GGLuint width; // width in pixels
GGLuint height; // height in pixels
GGLint stride; // stride in pixels
GGLubyte* data; // pointer to the bits
GGLubyte format; // pixel format
GGLubyte rfu[3]; // must be zero
// these values are dependent on the used format
union {
GGLint compressedFormat;
GGLint vstride;
};
void* reserved;
} GGLSurface;
typedef struct {
// immediate rendering
void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
void (*linex)(void *con,
const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b);
void (*trianglex)(void* c,
GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
// scissor
void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
// Set the textures and color buffers
void (*activeTexture)(void* c, GGLuint tmu);
void (*bindTexture)(void* c, const GGLSurface* surface);
void (*colorBuffer)(void* c, const GGLSurface* surface);
void (*readBuffer)(void* c, const GGLSurface* surface);
void (*depthBuffer)(void* c, const GGLSurface* surface);
void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
// enable/disable features
void (*enable)(void* c, GGLenum name);
void (*disable)(void* c, GGLenum name);
void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
// specify the fragment's color
void (*shadeModel)(void* c, GGLenum mode);
void (*color4xv)(void* c, const GGLclampx* color);
// specify color iterators (16.16)
void (*colorGrad12xv)(void* c, const GGLcolor* grad);
// specify Z coordinate iterators (0.32)
void (*zGrad3xv)(void* c, const GGLfixed32* grad);
// specify W coordinate iterators (16.16)
void (*wGrad3xv)(void* c, const GGLfixed* grad);
// specify fog iterator & color (16.16)
void (*fogGrad3xv)(void* c, const GGLfixed* grad);
void (*fogColor3xv)(void* c, const GGLclampx* color);
// specify blending parameters
void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
void (*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,
GGLenum srcAlpha, GGLenum dstAplha);
// texture environnement (REPLACE / MODULATE / DECAL / BLEND)
void (*texEnvi)(void* c, GGLenum target,
GGLenum pname,
GGLint param);
void (*texEnvxv)(void* c, GGLenum target,
GGLenum pname, const GGLfixed* params);
// texture parameters (Wrapping, filter)
void (*texParameteri)(void* c, GGLenum target,
GGLenum pname,
GGLint param);
// texture iterators (16.16)
void (*texCoord2i)(void* c, GGLint s, GGLint t);
void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
// s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
// This api uses block floating-point for S and T texture coordinates.
// All values are given in 16.16, scaled by 'scale'. In other words,
// set scale to 0, for 16.16 values.
void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
// masking
void (*colorMask)(void* c, GGLboolean red,
GGLboolean green,
GGLboolean blue,
GGLboolean alpha);
void (*depthMask)(void* c, GGLboolean flag);
void (*stencilMask)(void* c, GGLuint mask);
// alpha func
void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
// depth func
void (*depthFunc)(void* c, GGLenum func);
// logic op
void (*logicOp)(void* c, GGLenum opcode);
// clear
void (*clear)(void* c, GGLbitfield mask);
void (*clearColorx)(void* c,
GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
void (*clearDepthx)(void* c, GGLclampx depth);
void (*clearStencil)(void* c, GGLint s);
// framebuffer operations
void (*copyPixels)(void* c, GGLint x, GGLint y,
GGLsizei width, GGLsizei height, GGLenum type);
void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
void (*rasterPos2i)(void* c, GGLint x, GGLint y);
} GGLContext;
// ----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
// construct / destroy the context
ssize_t gglInit(GGLContext** context);
ssize_t gglUninit(GGLContext* context);
GGLint gglBitBlti(
GGLContext* c,
int tmu,
GGLint crop[4],
GGLint where[4]);
#ifdef __cplusplus
};
#endif
// ----------------------------------------------------------------------------
#endif // ANDROID_PIXELFLINGER_H

View File

@@ -0,0 +1,257 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (c) 2009, The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* This file is used to define the properties of the filesystem
** images generated by build tools (mkbootfs and mkyaffs2image) and
** by the device side of adb.
*/
#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
#define _ANDROID_FILESYSTEM_CONFIG_H_
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
/* This is the master Users and Groups config for the platform.
** DO NOT EVER RENUMBER.
*/
#define AID_ROOT 0 /* traditional unix root user */
#define AID_SYSTEM 1000 /* system server */
#define AID_RADIO 1001 /* telephony subsystem, RIL */
#define AID_BLUETOOTH 1002 /* bluetooth subsystem */
#define AID_GRAPHICS 1003 /* graphics devices */
#define AID_INPUT 1004 /* input devices */
#define AID_AUDIO 1005 /* audio devices */
#define AID_CAMERA 1006 /* camera devices */
#define AID_LOG 1007 /* log devices */
#define AID_COMPASS 1008 /* compass device */
#define AID_MOUNT 1009 /* mountd socket */
#define AID_WIFI 1010 /* wifi subsystem */
#define AID_ADB 1011 /* android debug bridge (adbd) */
#define AID_INSTALL 1012 /* group for installing packages */
#define AID_MEDIA 1013 /* mediaserver process */
#define AID_DHCP 1014 /* dhcp client */
#define AID_SDCARD_RW 1015 /* external storage write access */
#define AID_VPN 1016 /* vpn system */
#define AID_KEYSTORE 1017 /* keystore subsystem */
#define AID_USB 1018 /* USB devices */
#define AID_FM_RADIO 1019 /* FM radio */
#define AID_GPS 1021 /* GPS daemon */
#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */
#define AID_RFU1 1023 /* RFU */
#define AID_RFU2 1024 /* RFU */
#define AID_NFC 1025 /* nfc subsystem */
#define AID_SHELL 2000 /* adb and debug shell user */
#define AID_CACHE 2001 /* cache access */
#define AID_DIAG 2002 /* access to diagnostic resources */
/* The 3000 series are intended for use as supplemental group id's only.
* They indicate special Android capabilities that the kernel is aware of. */
#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
#define AID_NET_RAW 3004 /* can create raw INET sockets */
#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
#define AID_QCOM_ONCRPC 3006 /* can read/write /dev/oncrpc files */
#define AID_MISC 9998 /* access to misc storage */
#define AID_NOBODY 9999
#define AID_APP 10000 /* first app user */
#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
struct android_id_info {
const char *name;
unsigned aid;
};
static const struct android_id_info android_ids[] = {
{ "root", AID_ROOT, },
{ "system", AID_SYSTEM, },
{ "radio", AID_RADIO, },
{ "bluetooth", AID_BLUETOOTH, },
{ "graphics", AID_GRAPHICS, },
{ "input", AID_INPUT, },
{ "audio", AID_AUDIO, },
{ "camera", AID_CAMERA, },
{ "log", AID_LOG, },
{ "compass", AID_COMPASS, },
{ "mount", AID_MOUNT, },
{ "wifi", AID_WIFI, },
{ "dhcp", AID_DHCP, },
{ "adb", AID_ADB, },
{ "install", AID_INSTALL, },
{ "media", AID_MEDIA, },
{ "nfc", AID_NFC, },
{ "shell", AID_SHELL, },
{ "cache", AID_CACHE, },
{ "diag", AID_DIAG, },
{ "net_bt_admin", AID_NET_BT_ADMIN, },
{ "net_bt", AID_NET_BT, },
{ "sdcard_rw", AID_SDCARD_RW, },
{ "vpn", AID_VPN, },
{ "keystore", AID_KEYSTORE, },
{ "usb", AID_USB, },
{ "gps", AID_GPS, },
{ "inet", AID_INET, },
{ "net_raw", AID_NET_RAW, },
{ "net_admin", AID_NET_ADMIN, },
{ "qcom_oncrpc", AID_QCOM_ONCRPC, },
{ "misc", AID_MISC, },
{ "fm_radio", AID_FM_RADIO, },
{ "nobody", AID_NOBODY, },
};
#define android_id_count \
(sizeof(android_ids) / sizeof(android_ids[0]))
struct fs_path_config {
unsigned mode;
unsigned uid;
unsigned gid;
const char *prefix;
};
/* Rules for directories.
** These rules are applied based on "first match", so they
** should start with the most specific path and work their
** way up to the root.
*/
static 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" },
{ 00771, AID_SYSTEM, AID_SYSTEM, "data" },
{ 00750, AID_ROOT, AID_SHELL, "sbin" },
{ 00755, AID_ROOT, AID_ROOT, "system/sbin" },
{ 00750, AID_ROOT, AID_SHELL, "userdata/sbin" },
{ 00755, AID_ROOT, AID_SHELL, "system/bin" },
{ 00755, AID_ROOT, AID_SHELL, "userdata/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 },
};
/* Rules for files.
** These rules are applied based on "first match", so they
** should start with the most specific path and work their
** way up to the root. Prefixes ending in * denotes wildcard
** and will allow partial matches.
*/
static struct fs_path_config android_files[] = {
{ 00755, AID_ROOT, AID_ROOT, "system/etc/init.d/*" },
{ 00755, AID_ROOT, AID_ROOT, "system/lib/*" },
{ 00440, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.rc" },
{ 00550, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.sh" },
{ 00777, AID_SYSTEM, AID_SYSTEM, "system/etc/init.qcom.sdio.sh" },
{ 00440, AID_ROOT, AID_SHELL, "system/etc/init.trout.rc" },
{ 00440, AID_ROOT, AID_SHELL, "system/etc/init.qcom.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" },
{ 00755, AID_ROOT, AID_ROOT, "system/etc/udev/scripts/*" },
{ 00755, AID_ROOT, AID_ROOT, "system/etc/udhcpc.d/udhcpc.script"},
{ 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" },
{ 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/*" },
{ 00644, AID_SYSTEM, AID_SYSTEM, "data/app/*" },
{ 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" },
{ 04750, AID_ROOT, AID_SYSTEM, "system/bin/diag_mdlog" },
/* 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" },
{ 04755, AID_ROOT, AID_SHELL, "system/bin/btwlancoex" },
{ 04750, AID_ROOT, AID_SYSTEM, "system/bin/tc" },
{ 04750, AID_ROOT, AID_SYSTEM, "system/bin/iptables" },
{ 00755, AID_ROOT, AID_SHELL, "system/bin/*" },
{ 00755, AID_ROOT, AID_SHELL, "userdata/bin/*" },
{ 00750, AID_ROOT, AID_SHELL, "system/sbin/*" },
{ 00755, AID_ROOT, AID_SHELL, "system/xbin/*" },
{ 00755, AID_ROOT, AID_SHELL, "system/vendor/bin/*" },
{ 00750, AID_ROOT, AID_SHELL, "sbin/*" },
{ 00750, AID_ROOT, AID_SHELL, "userdata/sbin/*" },
{ 00755, AID_ROOT, AID_ROOT, "bin/*" },
{ 00750, AID_ROOT, AID_SHELL, "init*" },
{ 00644, AID_ROOT, AID_ROOT, 0 },
};
static inline void fs_config(const char *path, int dir,
unsigned *uid, unsigned *gid, unsigned *mode)
{
struct fs_path_config *pc;
int plen;
pc = dir ? android_dirs : android_files;
plen = strlen(path);
for(; pc->prefix; pc++){
int len = strlen(pc->prefix);
if (dir) {
if(plen < len) continue;
if(!strncmp(pc->prefix, path, len)) break;
continue;
}
/* If name ends in * then allow partial matches. */
if (pc->prefix[len -1] == '*') {
if(!strncmp(pc->prefix, path, len - 1)) break;
} else if (plen == len){
if(!strncmp(pc->prefix, path, len)) break;
}
}
*uid = pc->uid;
*gid = pc->gid;
*mode = (*mode & (~07777)) | pc->mode;
#if 0
fprintf(stderr,"< '%s' '%s' %d %d %o >\n",
path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode);
#endif
}
#endif
#endif

View File

@@ -0,0 +1,543 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_GGL_CONTEXT_H
#define ANDROID_GGL_CONTEXT_H
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <endian.h>
#include <pixelflinger/pixelflinger.h>
#include <private/pixelflinger/ggl_fixed.h>
namespace android {
// ----------------------------------------------------------------------------
#if BYTE_ORDER == LITTLE_ENDIAN
inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
return v;
}
inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
return v;
}
#else
inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
}
inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
}
#endif
// ----------------------------------------------------------------------------
const int GGL_DITHER_BITS = 6; // dither weights stored on 6 bits
const int GGL_DITHER_ORDER_SHIFT= 3;
const int GGL_DITHER_ORDER = (1<<GGL_DITHER_ORDER_SHIFT);
const int GGL_DITHER_SIZE = GGL_DITHER_ORDER * GGL_DITHER_ORDER;
const int GGL_DITHER_MASK = GGL_DITHER_ORDER-1;
// ----------------------------------------------------------------------------
const int GGL_SUBPIXEL_BITS = 4;
// TRI_FRACTION_BITS defines the number of bits we want to use
// for the sub-pixel coordinates during the edge stepping, the
// value shouldn't be more than 7, or bad things are going to
// happen when drawing large triangles (8 doesn't work because
// 32 bit muls will loose the sign bit)
#define TRI_FRACTION_BITS (GGL_SUBPIXEL_BITS)
#define TRI_ONE (1 << TRI_FRACTION_BITS)
#define TRI_HALF (1 << (TRI_FRACTION_BITS-1))
#define TRI_FROM_INT(x) ((x) << TRI_FRACTION_BITS)
#define TRI_FRAC(x) ((x) & (TRI_ONE-1))
#define TRI_FLOOR(x) ((x) & ~(TRI_ONE-1))
#define TRI_CEIL(x) (((x) + (TRI_ONE-1)) & ~(TRI_ONE-1))
#define TRI_ROUND(x) (((x) + TRI_HALF ) & ~(TRI_ONE-1))
#define TRI_ROUDNING (1 << (16 - TRI_FRACTION_BITS - 1))
#define TRI_FROM_FIXED(x) (((x)+TRI_ROUDNING) >> (16-TRI_FRACTION_BITS))
#define TRI_SNAP_NEXT_HALF(x) (TRI_CEIL((x)+TRI_HALF) - TRI_HALF)
#define TRI_SNAP_PREV_HALF(x) (TRI_CEIL((x)-TRI_HALF) - TRI_HALF)
// ----------------------------------------------------------------------------
const int GGL_COLOR_BITS = 24;
// To maintain 8-bits color chanels, with a maximum GGLSurface
// size of 4096 and GGL_SUBPIXEL_BITS=4, we need 8 + 12 + 4 = 24 bits
// for encoding the color iterators
inline GGLcolor gglFixedToIteratedColor(GGLfixed c) {
return (c << 8) - c;
}
// ----------------------------------------------------------------------------
template<bool> struct CTA;
template<> struct CTA<true> { };
#define GGL_CONTEXT(con, c) context_t *con = static_cast<context_t *>(c)
#define GGL_OFFSETOF(field) int(&(((context_t*)0)->field))
#define GGL_INIT_PROC(p, f) p.f = ggl_ ## f;
#define GGL_BETWEEN(x, L, H) (uint32_t((x)-(L)) <= ((H)-(L)))
#define ggl_likely(x) __builtin_expect(!!(x), 1)
#define ggl_unlikely(x) __builtin_expect(!!(x), 0)
const int GGL_TEXTURE_UNIT_COUNT = 2;
const int GGL_TMU_STATE = 0x00000001;
const int GGL_CB_STATE = 0x00000002;
const int GGL_PIXEL_PIPELINE_STATE = 0x00000004;
// ----------------------------------------------------------------------------
#define GGL_RESERVE_NEEDS(name, l, s) \
const uint32_t GGL_NEEDS_##name##_MASK = (((1LU<<(s))-1)<<l); \
const uint32_t GGL_NEEDS_##name##_SHIFT = (l);
#define GGL_BUILD_NEEDS(val, name) \
(((val)<<(GGL_NEEDS_##name##_SHIFT)) & GGL_NEEDS_##name##_MASK)
#define GGL_READ_NEEDS(name, n) \
(uint32_t(n & GGL_NEEDS_##name##_MASK) >> GGL_NEEDS_##name##_SHIFT)
#define GGL_NEED_MASK(name) (uint32_t(GGL_NEEDS_##name##_MASK))
#define GGL_NEED(name, val) GGL_BUILD_NEEDS(val, name)
GGL_RESERVE_NEEDS( CB_FORMAT, 0, 6 )
GGL_RESERVE_NEEDS( SHADE, 6, 1 )
GGL_RESERVE_NEEDS( W, 7, 1 )
GGL_RESERVE_NEEDS( BLEND_SRC, 8, 4 )
GGL_RESERVE_NEEDS( BLEND_DST, 12, 4 )
GGL_RESERVE_NEEDS( BLEND_SRCA, 16, 4 )
GGL_RESERVE_NEEDS( BLEND_DSTA, 20, 4 )
GGL_RESERVE_NEEDS( LOGIC_OP, 24, 4 )
GGL_RESERVE_NEEDS( MASK_ARGB, 28, 4 )
GGL_RESERVE_NEEDS( P_ALPHA_TEST, 0, 3 )
GGL_RESERVE_NEEDS( P_AA, 3, 1 )
GGL_RESERVE_NEEDS( P_DEPTH_TEST, 4, 3 )
GGL_RESERVE_NEEDS( P_MASK_Z, 7, 1 )
GGL_RESERVE_NEEDS( P_DITHER, 8, 1 )
GGL_RESERVE_NEEDS( P_FOG, 9, 1 )
GGL_RESERVE_NEEDS( P_RESERVED1, 10,22 )
GGL_RESERVE_NEEDS( T_FORMAT, 0, 6 )
GGL_RESERVE_NEEDS( T_RESERVED0, 6, 1 )
GGL_RESERVE_NEEDS( T_POT, 7, 1 )
GGL_RESERVE_NEEDS( T_S_WRAP, 8, 2 )
GGL_RESERVE_NEEDS( T_T_WRAP, 10, 2 )
GGL_RESERVE_NEEDS( T_ENV, 12, 3 )
GGL_RESERVE_NEEDS( T_LINEAR, 15, 1 )
const int GGL_NEEDS_WRAP_CLAMP_TO_EDGE = 0;
const int GGL_NEEDS_WRAP_REPEAT = 1;
const int GGL_NEEDS_WRAP_11 = 2;
inline uint32_t ggl_wrap_to_needs(uint32_t e) {
switch (e) {
case GGL_CLAMP: return GGL_NEEDS_WRAP_CLAMP_TO_EDGE;
case GGL_REPEAT: return GGL_NEEDS_WRAP_REPEAT;
}
return 0;
}
inline uint32_t ggl_blendfactor_to_needs(uint32_t b) {
if (b <= 1) return b;
return (b & 0xF)+2;
}
inline uint32_t ggl_needs_to_blendfactor(uint32_t n) {
if (n <= 1) return n;
return (n - 2) + 0x300;
}
inline uint32_t ggl_env_to_needs(uint32_t e) {
switch (e) {
case GGL_REPLACE: return 0;
case GGL_MODULATE: return 1;
case GGL_DECAL: return 2;
case GGL_BLEND: return 3;
case GGL_ADD: return 4;
}
return 0;
}
inline uint32_t ggl_needs_to_env(uint32_t n) {
const uint32_t envs[] = { GGL_REPLACE, GGL_MODULATE,
GGL_DECAL, GGL_BLEND, GGL_ADD };
return envs[n];
}
// ----------------------------------------------------------------------------
enum {
GGL_ENABLE_BLENDING = 0x00000001,
GGL_ENABLE_SMOOTH = 0x00000002,
GGL_ENABLE_AA = 0x00000004,
GGL_ENABLE_LOGIC_OP = 0x00000008,
GGL_ENABLE_ALPHA_TEST = 0x00000010,
GGL_ENABLE_SCISSOR_TEST = 0x00000020,
GGL_ENABLE_TMUS = 0x00000040,
GGL_ENABLE_DEPTH_TEST = 0x00000080,
GGL_ENABLE_STENCIL_TEST = 0x00000100,
GGL_ENABLE_W = 0x00000200,
GGL_ENABLE_DITHER = 0x00000400,
GGL_ENABLE_FOG = 0x00000800,
GGL_ENABLE_POINT_AA_NICE= 0x00001000
};
// ----------------------------------------------------------------------------
class needs_filter_t;
struct needs_t {
inline int match(const needs_filter_t& filter);
inline bool operator == (const needs_t& rhs) const {
return (n==rhs.n) &&
(p==rhs.p) &&
(t[0]==rhs.t[0]) &&
(t[1]==rhs.t[1]);
}
inline bool operator != (const needs_t& rhs) const {
return !operator == (rhs);
}
uint32_t n;
uint32_t p;
uint32_t t[GGL_TEXTURE_UNIT_COUNT];
};
inline int compare_type(const needs_t& lhs, const needs_t& rhs) {
return memcmp(&lhs, &rhs, sizeof(needs_t));
}
struct needs_filter_t {
needs_t value;
needs_t mask;
};
int needs_t::match(const needs_filter_t& filter) {
uint32_t result =
((filter.value.n ^ n) & filter.mask.n) |
((filter.value.p ^ p) & filter.mask.p) |
((filter.value.t[0] ^ t[0]) & filter.mask.t[0]) |
((filter.value.t[1] ^ t[1]) & filter.mask.t[1]);
return (result == 0);
}
// ----------------------------------------------------------------------------
struct context_t;
class Assembly;
struct blend_state_t {
uint32_t src;
uint32_t dst;
uint32_t src_alpha;
uint32_t dst_alpha;
uint8_t reserved;
uint8_t alpha_separate;
uint8_t operation;
uint8_t equation;
};
struct mask_state_t {
uint8_t color;
uint8_t depth;
uint32_t stencil;
};
struct clear_state_t {
GGLclampx r;
GGLclampx g;
GGLclampx b;
GGLclampx a;
GGLclampx depth;
GGLint stencil;
uint32_t colorPacked;
uint32_t depthPacked;
uint32_t stencilPacked;
uint32_t dirty;
};
struct fog_state_t {
uint8_t color[4];
};
struct logic_op_state_t {
uint16_t opcode;
};
struct alpha_test_state_t {
uint16_t func;
GGLcolor ref;
};
struct depth_test_state_t {
uint16_t func;
GGLclampx clearValue;
};
struct scissor_t {
uint32_t user_left;
uint32_t user_right;
uint32_t user_top;
uint32_t user_bottom;
uint32_t left;
uint32_t right;
uint32_t top;
uint32_t bottom;
};
struct pixel_t {
uint32_t c[4];
uint8_t s[4];
};
struct surface_t {
union {
GGLSurface s;
struct {
uint32_t reserved;
uint32_t width;
uint32_t height;
int32_t stride;
uint8_t* data;
uint8_t format;
uint8_t dirty;
uint8_t pad[2];
};
};
void (*read) (const surface_t* s, context_t* c,
uint32_t x, uint32_t y, pixel_t* pixel);
void (*write)(const surface_t* s, context_t* c,
uint32_t x, uint32_t y, const pixel_t* pixel);
};
// ----------------------------------------------------------------------------
struct texture_shade_t {
union {
struct {
int32_t is0;
int32_t idsdx;
int32_t idsdy;
int sscale;
int32_t it0;
int32_t idtdx;
int32_t idtdy;
int tscale;
};
struct {
int32_t v;
int32_t dx;
int32_t dy;
int scale;
} st[2];
};
};
struct texture_iterators_t {
// these are not encoded in the same way than in the
// texture_shade_t structure
union {
struct {
GGLfixed ydsdy;
GGLfixed dsdx;
GGLfixed dsdy;
int sscale;
GGLfixed ydtdy;
GGLfixed dtdx;
GGLfixed dtdy;
int tscale;
};
struct {
GGLfixed ydvdy;
GGLfixed dvdx;
GGLfixed dvdy;
int scale;
} st[2];
};
};
struct texture_t {
surface_t surface;
texture_iterators_t iterators;
texture_shade_t shade;
uint32_t s_coord;
uint32_t t_coord;
uint16_t s_wrap;
uint16_t t_wrap;
uint16_t min_filter;
uint16_t mag_filter;
uint16_t env;
uint8_t env_color[4];
uint8_t enable;
uint8_t dirty;
};
struct raster_t {
GGLfixed x;
GGLfixed y;
};
struct framebuffer_t {
surface_t color;
surface_t read;
surface_t depth;
surface_t stencil;
int16_t *coverage;
size_t coverageBufferSize;
};
// ----------------------------------------------------------------------------
struct iterators_t {
int32_t xl;
int32_t xr;
int32_t y;
GGLcolor ydady;
GGLcolor ydrdy;
GGLcolor ydgdy;
GGLcolor ydbdy;
GGLfixed ydzdy;
GGLfixed ydwdy;
GGLfixed ydfdy;
};
struct shade_t {
GGLcolor a0;
GGLcolor dadx;
GGLcolor dady;
GGLcolor r0;
GGLcolor drdx;
GGLcolor drdy;
GGLcolor g0;
GGLcolor dgdx;
GGLcolor dgdy;
GGLcolor b0;
GGLcolor dbdx;
GGLcolor dbdy;
uint32_t z0;
GGLfixed32 dzdx;
GGLfixed32 dzdy;
GGLfixed w0;
GGLfixed dwdx;
GGLfixed dwdy;
uint32_t f0;
GGLfixed dfdx;
GGLfixed dfdy;
};
// these are used in the generated code
// we use this mirror structure to improve
// data locality in the pixel pipeline
struct generated_tex_vars_t {
uint32_t width;
uint32_t height;
uint32_t stride;
int32_t data;
int32_t dsdx;
int32_t dtdx;
int32_t spill[2];
};
struct generated_vars_t {
struct {
int32_t c;
int32_t dx;
} argb[4];
int32_t aref;
int32_t dzdx;
int32_t zbase;
int32_t f;
int32_t dfdx;
int32_t spill[3];
generated_tex_vars_t texture[GGL_TEXTURE_UNIT_COUNT];
int32_t rt;
int32_t lb;
};
// ----------------------------------------------------------------------------
struct state_t {
framebuffer_t buffers;
texture_t texture[GGL_TEXTURE_UNIT_COUNT];
scissor_t scissor;
raster_t raster;
blend_state_t blend;
alpha_test_state_t alpha_test;
depth_test_state_t depth_test;
mask_state_t mask;
clear_state_t clear;
fog_state_t fog;
logic_op_state_t logic_op;
uint32_t enables;
uint32_t enabled_tmu;
needs_t needs;
};
// ----------------------------------------------------------------------------
struct context_t {
GGLContext procs;
state_t state;
shade_t shade;
iterators_t iterators;
generated_vars_t generated_vars __attribute__((aligned(32)));
uint8_t ditherMatrix[GGL_DITHER_SIZE] __attribute__((aligned(32)));
uint32_t packed;
uint32_t packed8888;
const GGLFormat* formats;
uint32_t dirty;
texture_t* activeTMU;
uint32_t activeTMUIndex;
void (*init_y)(context_t* c, int32_t y);
void (*step_y)(context_t* c);
void (*scanline)(context_t* c);
void (*span)(context_t* c);
void (*rect)(context_t* c, size_t yc);
void* base;
Assembly* scanline_as;
GGLenum error;
};
// ----------------------------------------------------------------------------
void ggl_init_context(context_t* context);
void ggl_uninit_context(context_t* context);
void ggl_error(context_t* c, GGLenum error);
int64_t ggl_system_time();
// ----------------------------------------------------------------------------
};
#endif // ANDROID_GGL_CONTEXT_H

View File

@@ -0,0 +1,302 @@
/*
* Copyright (C) 2005 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_GGL_FIXED_H
#define ANDROID_GGL_FIXED_H
#include <math.h>
#include <pixelflinger/pixelflinger.h>
// ----------------------------------------------------------------------------
#define CONST __attribute__((const))
#define ALWAYS_INLINE __attribute__((always_inline))
const GGLfixed FIXED_BITS = 16;
const GGLfixed FIXED_EPSILON = 1;
const GGLfixed FIXED_ONE = 1L<<FIXED_BITS;
const GGLfixed FIXED_HALF = 1L<<(FIXED_BITS-1);
const GGLfixed FIXED_MIN = 0x80000000L;
const GGLfixed FIXED_MAX = 0x7FFFFFFFL;
inline GGLfixed gglIntToFixed(GGLfixed i) ALWAYS_INLINE ;
inline GGLfixed gglFixedToIntRound(GGLfixed f) ALWAYS_INLINE ;
inline GGLfixed gglFixedToIntFloor(GGLfixed f) ALWAYS_INLINE ;
inline GGLfixed gglFixedToIntCeil(GGLfixed f) ALWAYS_INLINE ;
inline GGLfixed gglFracx(GGLfixed v) ALWAYS_INLINE ;
inline GGLfixed gglFloorx(GGLfixed v) ALWAYS_INLINE ;
inline GGLfixed gglCeilx(GGLfixed v) ALWAYS_INLINE ;
inline GGLfixed gglCenterx(GGLfixed v) ALWAYS_INLINE ;
inline GGLfixed gglRoundx(GGLfixed v) ALWAYS_INLINE ;
GGLfixed gglIntToFixed(GGLfixed i) {
return i<<FIXED_BITS;
}
GGLfixed gglFixedToIntRound(GGLfixed f) {
return (f + FIXED_HALF)>>FIXED_BITS;
}
GGLfixed gglFixedToIntFloor(GGLfixed f) {
return f>>FIXED_BITS;
}
GGLfixed gglFixedToIntCeil(GGLfixed f) {
return (f + ((1<<FIXED_BITS) - 1))>>FIXED_BITS;
}
GGLfixed gglFracx(GGLfixed v) {
return v & ((1<<FIXED_BITS)-1);
}
GGLfixed gglFloorx(GGLfixed v) {
return gglFixedToIntFloor(v)<<FIXED_BITS;
}
GGLfixed gglCeilx(GGLfixed v) {
return gglFixedToIntCeil(v)<<FIXED_BITS;
}
GGLfixed gglCenterx(GGLfixed v) {
return gglFloorx(v + FIXED_HALF) | FIXED_HALF;
}
GGLfixed gglRoundx(GGLfixed v) {
return gglFixedToIntRound(v)<<FIXED_BITS;
}
// conversion from (unsigned) int, short, byte to fixed...
#define GGL_B_TO_X(_x) GGLfixed( ((int32_t(_x)+1)>>1)<<10 )
#define GGL_S_TO_X(_x) GGLfixed( ((int32_t(_x)+1)>>1)<<2 )
#define GGL_I_TO_X(_x) GGLfixed( ((int32_t(_x)>>1)+1)>>14 )
#define GGL_UB_TO_X(_x) GGLfixed( uint32_t(_x) + \
(uint32_t(_x)<<8) + \
(uint32_t(_x)>>7) )
#define GGL_US_TO_X(_x) GGLfixed( (_x) + ((_x)>>15) )
#define GGL_UI_TO_X(_x) GGLfixed( (((_x)>>1)+1)>>15 )
// ----------------------------------------------------------------------------
GGLfixed gglPowx(GGLfixed x, GGLfixed y) CONST;
GGLfixed gglSqrtx(GGLfixed a) CONST;
GGLfixed gglSqrtRecipx(GGLfixed x) CONST;
GGLfixed gglFastDivx(GGLfixed n, GGLfixed d) CONST;
int32_t gglMulDivi(int32_t a, int32_t b, int32_t c);
int32_t gglRecipQNormalized(int32_t x, int* exponent);
int32_t gglRecipQ(GGLfixed x, int q) CONST;
inline GGLfixed gglRecip(GGLfixed x) CONST;
inline GGLfixed gglRecip(GGLfixed x) {
return gglRecipQ(x, 16);
}
inline GGLfixed gglRecip28(GGLfixed x) CONST;
int32_t gglRecip28(GGLfixed x) {
return gglRecipQ(x, 28);
}
// ----------------------------------------------------------------------------
#if defined(__arm__) && !defined(__thumb__)
// inline ARM implementations
inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) CONST;
inline GGLfixed gglMulx(GGLfixed x, GGLfixed y, int shift) {
GGLfixed result, t;
if (__builtin_constant_p(shift)) {
asm("smull %[lo], %[hi], %[x], %[y] \n"
"movs %[lo], %[lo], lsr %[rshift] \n"
"adc %[lo], %[lo], %[hi], lsl %[lshift] \n"
: [lo]"=r"(result), [hi]"=r"(t), [x]"=r"(x)
: "%[x]"(x), [y]"r"(y), [lshift] "I"(32-shift), [rshift] "I"(shift)
: "cc"
);
} else {
asm("smull %[lo], %[hi], %[x], %[y] \n"
"movs %[lo], %[lo], lsr %[rshift] \n"
"adc %[lo], %[lo], %[hi], lsl %[lshift] \n"
: [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
: "%[x]"(x), [y]"r"(y), [lshift] "r"(32-shift), [rshift] "r"(shift)
: "cc"
);
}
return result;
}
inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
inline GGLfixed gglMulAddx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) {
GGLfixed result, t;
if (__builtin_constant_p(shift)) {
asm("smull %[lo], %[hi], %[x], %[y] \n"
"add %[lo], %[a], %[lo], lsr %[rshift] \n"
"add %[lo], %[lo], %[hi], lsl %[lshift] \n"
: [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
: "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "I"(32-shift), [rshift] "I"(shift)
);
} else {
asm("smull %[lo], %[hi], %[x], %[y] \n"
"add %[lo], %[a], %[lo], lsr %[rshift] \n"
"add %[lo], %[lo], %[hi], lsl %[lshift] \n"
: [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
: "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "r"(32-shift), [rshift] "r"(shift)
);
}
return result;
}
inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) CONST;
inline GGLfixed gglMulSubx(GGLfixed x, GGLfixed y, GGLfixed a, int shift) {
GGLfixed result, t;
if (__builtin_constant_p(shift)) {
asm("smull %[lo], %[hi], %[x], %[y] \n"
"rsb %[lo], %[a], %[lo], lsr %[rshift] \n"
"add %[lo], %[lo], %[hi], lsl %[lshift] \n"
: [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
: "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "I"(32-shift), [rshift] "I"(shift)
);
} else {
asm("smull %[lo], %[hi], %[x], %[y] \n"
"rsb %[lo], %[a], %[lo], lsr %[rshift] \n"
"add %[lo], %[lo], %[hi], lsl %[lshift] \n"
: [lo]"=&r"(result), [hi]"=&r"(t), [x]"=&r"(x)
: "%[x]"(x), [y]"r"(y), [a]"r"(a), [lshift] "r"(32-shift), [rshift] "r"(shift)
);
}
return result;
}
inline int64_t gglMulii(int32_t x, int32_t y) CONST;
inline int64_t gglMulii(int32_t x, int32_t y)
{
// 64-bits result: r0=low, r1=high
union {
struct {
int32_t lo;
int32_t hi;
} s;
int64_t res;
};
asm("smull %0, %1, %2, %3 \n"
: "=r"(s.lo), "=&r"(s.hi)
: "%r"(x), "r"(y)
:
);
return res;
}
#else // ----------------------------------------------------------------------
inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) CONST;
inline GGLfixed gglMulx(GGLfixed a, GGLfixed b, int shift) {
return GGLfixed((int64_t(a)*b + (1<<(shift-1)))>>shift);
}
inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
return GGLfixed((int64_t(a)*b)>>shift) + c;
}
inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) CONST;
inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c, int shift) {
return GGLfixed((int64_t(a)*b)>>shift) - c;
}
inline int64_t gglMulii(int32_t a, int32_t b) CONST;
inline int64_t gglMulii(int32_t a, int32_t b) {
return int64_t(a)*b;
}
#endif
// ------------------------------------------------------------------------
inline GGLfixed gglMulx(GGLfixed a, GGLfixed b) CONST;
inline GGLfixed gglMulx(GGLfixed a, GGLfixed b) {
return gglMulx(a, b, 16);
}
inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c) CONST;
inline GGLfixed gglMulAddx(GGLfixed a, GGLfixed b, GGLfixed c) {
return gglMulAddx(a, b, c, 16);
}
inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) CONST;
inline GGLfixed gglMulSubx(GGLfixed a, GGLfixed b, GGLfixed c) {
return gglMulSubx(a, b, c, 16);
}
// ------------------------------------------------------------------------
inline int32_t gglClz(int32_t x) CONST;
inline int32_t gglClz(int32_t x)
{
#if defined(__arm__) && !defined(__thumb__)
return __builtin_clz(x);
#else
if (!x) return 32;
int32_t exp = 31;
if (x & 0xFFFF0000) { exp -=16; x >>= 16; }
if (x & 0x0000ff00) { exp -= 8; x >>= 8; }
if (x & 0x000000f0) { exp -= 4; x >>= 4; }
if (x & 0x0000000c) { exp -= 2; x >>= 2; }
if (x & 0x00000002) { exp -= 1; }
return exp;
#endif
}
// ------------------------------------------------------------------------
int32_t gglDivQ(GGLfixed n, GGLfixed d, int32_t i) CONST;
inline int32_t gglDivQ16(GGLfixed n, GGLfixed d) CONST;
inline int32_t gglDivQ16(GGLfixed n, GGLfixed d) {
return gglDivQ(n, d, 16);
}
inline int32_t gglDivx(GGLfixed n, GGLfixed d) CONST;
inline int32_t gglDivx(GGLfixed n, GGLfixed d) {
return gglDivQ(n, d, 16);
}
// ------------------------------------------------------------------------
inline GGLfixed gglRecipFast(GGLfixed x) CONST;
inline GGLfixed gglRecipFast(GGLfixed x)
{
// This is a really bad approximation of 1/x, but it's also
// very fast. x must be strictly positive.
// if x between [0.5, 1[ , then 1/x = 3-2*x
// (we use 2.30 fixed-point)
const int32_t lz = gglClz(x);
return (0xC0000000 - (x << (lz - 1))) >> (30-lz);
}
// ------------------------------------------------------------------------
inline GGLfixed gglClampx(GGLfixed c) CONST;
inline GGLfixed gglClampx(GGLfixed c)
{
#if defined(__thumb__)
// clamp without branches
c &= ~(c>>31); c = FIXED_ONE - c;
c &= ~(c>>31); c = FIXED_ONE - c;
#else
#if defined(__arm__)
// I don't know why gcc thinks its smarter than me! The code below
// clamps to zero in one instruction, but gcc won't generate it and
// replace it by a cmp + movlt (it's quite amazing actually).
asm("bic %0, %1, %1, asr #31\n" : "=r"(c) : "r"(c));
#else
c &= ~(c>>31);
#endif
if (c>FIXED_ONE)
c = FIXED_ONE;
#endif
return c;
}
// ------------------------------------------------------------------------
#endif // ANDROID_GGL_FIXED_H

View File

@@ -0,0 +1,21 @@
#ifndef _FRAMEWORK_CLIENT_H
#define _FRAMEWORK_CLIENT_H
#include "../../../frameworks/base/include/utils/List.h"
#include <pthread.h>
class FrameworkClient {
int mSocket;
pthread_mutex_t mWriteMutex;
public:
FrameworkClient(int sock);
virtual ~FrameworkClient() {}
int sendMsg(const char *msg);
int sendMsg(const char *msg, const char *data);
};
typedef android::List<FrameworkClient *> FrameworkClientCollection;
#endif

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __FRAMEWORK_CMD_HANDLER_H
#define __FRAMEWORK_CMD_HANDLER_H
#include "../../../frameworks/base/include/utils/List.h"
class SocketClient;
class FrameworkCommand {
private:
const char *mCommand;
public:
FrameworkCommand(const char *cmd);
virtual ~FrameworkCommand() { }
virtual int runCommand(SocketClient *c, int argc, char **argv) = 0;
const char *getCommand() { return mCommand; }
};
typedef android::List<FrameworkCommand *> FrameworkCommandCollection;
#endif

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _FRAMEWORKSOCKETLISTENER_H
#define _FRAMEWORKSOCKETLISTENER_H
#include "SocketListener.h"
#include "FrameworkCommand.h"
class SocketClient;
class FrameworkListener : public SocketListener {
public:
static const int CMD_ARGS_MAX = 16;
private:
FrameworkCommandCollection *mCommands;
public:
FrameworkListener(const char *socketName);
virtual ~FrameworkListener() {}
protected:
void registerCmd(FrameworkCommand *cmd);
virtual bool onDataAvailable(SocketClient *c);
private:
void dispatchCommand(SocketClient *c, char *data);
};
#endif

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _NETLINKEVENT_H
#define _NETLINKEVENT_H
#define NL_PARAMS_MAX 32
class NetlinkEvent {
int mSeq;
char *mPath;
int mAction;
char *mSubsystem;
char *mParams[NL_PARAMS_MAX];
public:
const static int NlActionUnknown;
const static int NlActionAdd;
const static int NlActionRemove;
const static int NlActionChange;
NetlinkEvent();
virtual ~NetlinkEvent();
bool decode(char *buffer, int size);
const char *findParam(const char *paramName);
const char *getSubsystem() { return mSubsystem; }
int getAction() { return mAction; }
void dump();
};
#endif

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _NETLINKLISTENER_H
#define _NETLINKLISTENER_H
#include "SocketListener.h"
class NetlinkEvent;
class NetlinkListener : public SocketListener {
char mBuffer[64 * 1024];
public:
NetlinkListener(int socket);
virtual ~NetlinkListener() {}
protected:
virtual bool onDataAvailable(SocketClient *cli);
virtual void onEvent(NetlinkEvent *evt) = 0;
};
#endif

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SERVICE_MANAGER_H
#define _SERVICE_MANAGER_H
class ServiceManager {
public:
ServiceManager();
virtual ~ServiceManager() {}
int start(const char *name);
int stop(const char *name);
bool isRunning(const char *name);
};
#endif

View File

@@ -0,0 +1,36 @@
#ifndef _SOCKET_CLIENT_H
#define _SOCKET_CLIENT_H
#include "../../../frameworks/base/include/utils/List.h"
#include <pthread.h>
#include <sys/types.h>
class SocketClient {
int mSocket;
pthread_mutex_t mWriteMutex;
/* Peer process ID */
pid_t mPid;
/* Peer user ID */
uid_t mUid;
/* Peer group ID */
gid_t mGid;
public:
SocketClient(int sock);
virtual ~SocketClient() {}
int getSocket() { return mSocket; }
pid_t getPid() const { return mPid; }
uid_t getUid() const { return mUid; }
gid_t getGid() const { return mGid; }
int sendMsg(int code, const char *msg, bool addErrno);
int sendMsg(const char *msg);
};
typedef android::List<SocketClient *> SocketClientCollection;
#endif

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SOCKETLISTENER_H
#define _SOCKETLISTENER_H
#include <pthread.h>
#include <sysutils/SocketClient.h>
class SocketListener {
int mSock;
const char *mSocketName;
SocketClientCollection *mClients;
pthread_mutex_t mClientsLock;
bool mListen;
int mCtrlPipe[2];
pthread_t mThread;
public:
SocketListener(const char *socketNames, bool listen);
SocketListener(int socketFd, bool listen);
virtual ~SocketListener();
int startListener();
int stopListener();
void sendBroadcast(int code, const char *msg, bool addErrno);
void sendBroadcast(const char *msg);
protected:
virtual bool onDataAvailable(SocketClient *c) = 0;
private:
static void *threadStart(void *obj);
void runListener();
};
#endif

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _ZIPFILE_ZIPFILE_H
#define _ZIPFILE_ZIPFILE_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void* zipfile_t;
typedef void* zipentry_t;
// Provide a buffer. Returns NULL on failure.
zipfile_t init_zipfile(const void* data, size_t size);
// Release the zipfile resources.
void release_zipfile(zipfile_t file);
// Get a named entry object. Returns NULL if it doesn't exist
// or if we won't be able to decompress it. The zipentry_t is
// freed by release_zipfile()
zipentry_t lookup_zipentry(zipfile_t file, const char* entryName);
// Return the size of the entry.
size_t get_zipentry_size(zipentry_t entry);
// return the filename of this entry, you own the memory returned
char* get_zipentry_name(zipentry_t entry);
// The buffer must be 1.001 times the buffer size returned
// by get_zipentry_size. Returns nonzero on failure.
int decompress_zipentry(zipentry_t entry, void* buf, int bufsize);
// iterate through the entries in the zip file. pass a pointer to
// a void* initialized to NULL to start. Returns NULL when done
zipentry_t iterate_zipfile(zipfile_t file, void** cookie);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _ZIPFILE_ZIPFILE_H