diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:29:04 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:29:04 -0800 |
commit | e54eebbf1a908d65ee8cf80bab62821c05666d70 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /include/cutils | |
parent | a1e1c1b106423de09bc918502e7a51d4ffe5a4ae (diff) | |
download | system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.zip system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.tar.gz system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'include/cutils')
29 files changed, 0 insertions, 2304 deletions
diff --git a/include/cutils/adb_networking.h b/include/cutils/adb_networking.h deleted file mode 100755 index 409d577..0000000 --- a/include/cutils/adb_networking.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _ADB_NETWORKING_H -#define _ADB_NETWORKING_H 1 -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/socket.h> - -#ifdef __cplusplus -extern "C" { -#endif - -extern int adb_networking_connect_fd(int fd, struct sockaddr_in *p_address); -extern int adb_networking_gethostbyname(const char *name, struct in_addr *p_out_addr); - -#ifdef __cplusplus -} -#endif - -#endif /*_ADB_NETWORKING_H*/ - diff --git a/include/cutils/array.h b/include/cutils/array.h deleted file mode 100644 index c97ff34..0000000 --- a/include/cutils/array.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * 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 */ diff --git a/include/cutils/ashmem.h b/include/cutils/ashmem.h deleted file mode 100644 index fd71352..0000000 --- a/include/cutils/ashmem.h +++ /dev/null @@ -1,42 +0,0 @@ -/* 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 - -#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); - -#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 - -#endif /* ! __ASHMEMIOC */ - -#endif /* _CUTILS_ASHMEM_H */ diff --git a/include/cutils/atomic.h b/include/cutils/atomic.h deleted file mode 100644 index 5694d66..0000000 --- a/include/cutils/atomic.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_H -#define ANDROID_CUTILS_ATOMIC_H - -#include <stdint.h> -#include <sys/types.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * NOTE: memory shared between threads is synchronized by all atomic operations - * below, this means that no explicit memory barrier is required: all reads or - * writes issued before android_atomic_* operations are guaranteed to complete - * before the atomic operation takes place. - */ - -void android_atomic_write(int32_t value, volatile int32_t* addr); - -/* - * all these atomic operations return the previous value - */ - - -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); - -int32_t android_atomic_swap(int32_t value, volatile int32_t* addr); - -/* - * NOTE: Two "quasiatomic" operations on the exact same memory address - * are guaranteed to operate atomically with respect to each other, - * but no guarantees are made about quasiatomic operations mixed with - * non-quasiatomic operations on the same address, nor about - * quasiatomic operations that are performed on partially-overlapping - * memory. - */ - -int64_t android_quasiatomic_swap_64(int64_t value, volatile int64_t* addr); -int64_t android_quasiatomic_read_64(volatile int64_t* addr); - -/* - * cmpxchg return a non zero value if the exchange was NOT performed, - * in other words if oldvalue != *addr - */ - -int android_atomic_cmpxchg(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr); - -int android_quasiatomic_cmpxchg_64(int64_t oldvalue, int64_t newvalue, - volatile int64_t* addr); - - - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // ANDROID_CUTILS_ATOMIC_H diff --git a/include/cutils/config_utils.h b/include/cutils/config_utils.h deleted file mode 100644 index f3fb370..0000000 --- a/include/cutils/config_utils.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __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 diff --git a/include/cutils/cpu_info.h b/include/cutils/cpu_info.h deleted file mode 100644 index 78c1884..0000000 --- a/include/cutils/cpu_info.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CUTILS_CPU_INFO_H -#define __CUTILS_CPU_INFO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* returns a string contiaining an ASCII representation of the CPU serial number, -** or NULL if cpu info not available. -** The string is a static variable, so don't call free() on it. -*/ -extern const char* get_cpu_serial_number(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_CPU_INFO_H */ diff --git a/include/cutils/dir_hash.h b/include/cutils/dir_hash.h deleted file mode 100644 index fbb4d02..0000000 --- a/include/cutils/dir_hash.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -typedef enum { - SHA_1, -} HashAlgorithm; - -int get_file_hash(HashAlgorithm algorithm, const char *path, - char *output_string, size_t max_output_string); - -int get_recursive_hash_manifest(HashAlgorithm algorithm, - const char *directory_path, - char **output_string); diff --git a/include/cutils/event_tag_map.h b/include/cutils/event_tag_map.h deleted file mode 100644 index 1653c61..0000000 --- a/include/cutils/event_tag_map.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _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*/ diff --git a/include/cutils/fdevent.h b/include/cutils/fdevent.h deleted file mode 100644 index 7a442d4..0000000 --- a/include/cutils/fdevent.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __FDEVENT_H -#define __FDEVENT_H - -/* events that may be observed */ -#define FDE_READ 0x0001 -#define FDE_WRITE 0x0002 -#define FDE_ERROR 0x0004 - -/* features that may be set (via the events set/add/del interface) */ -#define FDE_DONT_CLOSE 0x0080 - -typedef struct fdevent fdevent; - -typedef void (*fd_func)(int fd, unsigned events, void *userdata); - -/* Allocate and initialize a new fdevent object -*/ -fdevent *fdevent_create(int fd, fd_func func, void *arg); - -/* Uninitialize and deallocate an fdevent object that was -** created by fdevent_create() -*/ -void fdevent_destroy(fdevent *fde); - -/* Initialize an fdevent object that was externally allocated -*/ -void fdevent_install(fdevent *fde, int fd, fd_func func, void *arg); - -/* Uninitialize an fdevent object that was initialized by -** fdevent_install() -*/ -void fdevent_remove(fdevent *item); - -/* Change which events should cause notifications -*/ -void fdevent_set(fdevent *fde, unsigned events); -void fdevent_add(fdevent *fde, unsigned events); -void fdevent_del(fdevent *fde, unsigned events); - -/* loop forever, handling events. -*/ -void fdevent_loop(); - -struct fdevent -{ - fdevent *next; - fdevent *prev; - - int fd; - unsigned short state; - unsigned short events; - - fd_func func; - void *arg; -}; - - -#endif diff --git a/include/cutils/hashmap.h b/include/cutils/hashmap.h deleted file mode 100644 index 5cb344c..0000000 --- a/include/cutils/hashmap.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * 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 */ diff --git a/include/cutils/jstring.h b/include/cutils/jstring.h deleted file mode 100644 index ee0018f..0000000 --- a/include/cutils/jstring.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __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 */ diff --git a/include/cutils/log.h b/include/cutils/log.h deleted file mode 100644 index ec3cac8..0000000 --- a/include/cutils/log.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -// 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 - -/* - * 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 - -// --------------------------------------------------------------------- - -/* - * 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(...) ((void)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)) \ - ? ((void)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(...) ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef LOGD_IF -#define LOGD_IF(cond, ...) \ - ( (CONDITION(cond)) \ - ? ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info log message using the current LOG_TAG. - */ -#ifndef LOGI -#define LOGI(...) ((void)LOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef LOGI_IF -#define LOGI_IF(cond, ...) \ - ( (CONDITION(cond)) \ - ? ((void)LOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning log message using the current LOG_TAG. - */ -#ifndef LOGW -#define LOGW(...) ((void)LOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef LOGW_IF -#define LOGW_IF(cond, ...) \ - ( (CONDITION(cond)) \ - ? ((void)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(...) ((void)LOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef LOGE_IF -#define LOGE_IF(cond, ...) \ - ( (CONDITION(cond)) \ - ? ((void)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 - -// --------------------------------------------------------------------- - -/* - * 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_PRI(ANDROID_##priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to specify a number for the priority. - */ -#ifndef LOG_PRI -#define LOG_PRI(priority, tag, ...) \ - 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) - - -#ifdef __cplusplus -} -#endif - -#endif // _LIBS_CUTILS_LOG_H diff --git a/include/cutils/logd.h b/include/cutils/logd.h deleted file mode 100644 index a1cb012..0000000 --- a/include/cutils/logd.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _ANDROID_CUTILS_LOGD_H -#define _ANDROID_CUTILS_LOGD_H - -#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 - -/* - * 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; - -int __android_log_write(int prio, const char *tag, const char *text); - -int __android_log_vprint(int prio, const char *tag, - const char *fmt, va_list ap); - -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); - -int __android_log_print(int prio, const char *tag, const char *fmt, ...) -#if defined(__GNUC__) - __attribute__ ((format(printf, 3, 4))) -#endif - ; - - -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 /* _LOGD_H */ diff --git a/include/cutils/logger.h b/include/cutils/logger.h deleted file mode 100644 index 3a08019..0000000 --- a/include/cutils/logger.h +++ /dev/null @@ -1,46 +0,0 @@ -/* 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_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 */ diff --git a/include/cutils/logprint.h b/include/cutils/logprint.h deleted file mode 100644 index d6ec480..0000000 --- a/include/cutils/logprint.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _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); - -/** - * 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_filterAndPrintLogLine( - AndroidLogFormat *p_format, - int fd, - const AndroidLogEntry *entry); - - -#ifdef __cplusplus -} -#endif - - -#endif /*_LOGPRINT_H*/ diff --git a/include/cutils/memory.h b/include/cutils/memory.h deleted file mode 100644 index e725cdd..0000000 --- a/include/cutils/memory.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_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 diff --git a/include/cutils/misc.h b/include/cutils/misc.h deleted file mode 100644 index 2c48dfa..0000000 --- a/include/cutils/misc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __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 */ diff --git a/include/cutils/mq.h b/include/cutils/mq.h deleted file mode 100644 index b27456d..0000000 --- a/include/cutils/mq.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * 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 */ diff --git a/include/cutils/mspace.h b/include/cutils/mspace.h deleted file mode 100644 index 33410c1..0000000 --- a/include/cutils/mspace.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* A wrapper file for dlmalloc.h that defines prototypes for the - * mspace_*() functions, which provide an interface for creating - * multiple heaps. - */ - -#ifndef MSPACE_H_ -#define MSPACE_H_ - -/* It's a pain getting the mallinfo stuff to work - * with Linux, OSX, and klibc, so just turn it off - * for now. - * TODO: make mallinfo work - */ -#define NO_MALLINFO 1 - -/* Allow setting the maximum heap footprint. - */ -#define USE_MAX_ALLOWED_FOOTPRINT 1 - -#define USE_CONTIGUOUS_MSPACES 1 -#if USE_CONTIGUOUS_MSPACES -#define HAVE_MMAP 0 -#define HAVE_MORECORE 1 -#define MORECORE_CONTIGUOUS 0 -#endif - -#define MSPACES 1 -#define ONLY_MSPACES 1 -#include "../../../../bionic/libc/bionic/dlmalloc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - mspace_usable_size(void* p); - - Returns the number of bytes you can actually use in - an allocated chunk, which may be more than you requested (although - often not) due to alignment and minimum size constraints. - You can use this many bytes without worrying about - overwriting other allocated objects. This is not a particularly great - programming practice. mspace_usable_size can be more useful in - debugging and assertions, for example: - - p = mspace_malloc(msp, n); - assert(mspace_usable_size(msp, p) >= 256); -*/ -size_t mspace_usable_size(mspace, const void*); - -#if USE_CONTIGUOUS_MSPACES -/* - Similar to create_mspace(), but the underlying memory is - guaranteed to be contiguous. No more than max_capacity - bytes is ever allocated to the mspace. - */ -mspace create_contiguous_mspace(size_t starting_capacity, size_t max_capacity, - int locked); - -/* - Identical to create_contiguous_mspace, but labels the mapping 'mspace/name' - instead of 'mspace' -*/ -mspace create_contiguous_mspace_with_name(size_t starting_capacity, - size_t max_capacity, int locked, const char *name); - -size_t destroy_contiguous_mspace(mspace msp); -#endif - -/* - Call the handler for each block in the specified mspace. - chunkptr and chunklen refer to the heap-level chunk including - the chunk overhead, and userptr and userlen refer to the - user-usable part of the chunk. If the chunk is free, userptr - will be NULL and userlen will be 0. userlen is not guaranteed - to be the same value passed into malloc() for a given chunk; - it is >= the requested size. - */ -void mspace_walk_heap(mspace msp, - void(*handler)(const void *chunkptr, size_t chunklen, - const void *userptr, size_t userlen, void *arg), void *harg); - -/* - mspace_walk_free_pages(handler, harg) - - Calls the provided handler on each free region in the specified - mspace. The memory between start and end are guaranteed not to - contain any important data, so the handler is free to alter the - contents in any way. This can be used to advise the OS that large - free regions may be swapped out. - - The value in harg will be passed to each call of the handler. - */ -void mspace_walk_free_pages(mspace msp, - void(*handler)(void *start, void *end, void *arg), void *harg); - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - -#endif /* MSPACE_H_ */ diff --git a/include/cutils/native_handle.h b/include/cutils/native_handle.h deleted file mode 100644 index 2b64893..0000000 --- a/include/cutils/native_handle.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NATIVE_HANDLE_H_ -#define NATIVE_HANDLE_H_ - -typedef struct -{ - int version; /* sizeof(native_handle) */ - 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; - -#endif /* NATIVE_HANDLE_H_ */ diff --git a/include/cutils/process_name.h b/include/cutils/process_name.h deleted file mode 100644 index 1e72e5c..0000000 --- a/include/cutils/process_name.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * 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 */ diff --git a/include/cutils/properties.h b/include/cutils/properties.h deleted file mode 100644 index 25fd67a..0000000 --- a/include/cutils/properties.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __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 diff --git a/include/cutils/record_stream.h b/include/cutils/record_stream.h deleted file mode 100644 index bfac87a..0000000 --- a/include/cutils/record_stream.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * A 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*/ - diff --git a/include/cutils/selector.h b/include/cutils/selector.h deleted file mode 100644 index dfc2a9d..0000000 --- a/include/cutils/selector.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * 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 */ diff --git a/include/cutils/sockets.h b/include/cutils/sockets.h deleted file mode 100644 index aa8682e..0000000 --- a/include/cutils/sockets.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __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 */ diff --git a/include/cutils/threads.h b/include/cutils/threads.h deleted file mode 100644 index acf8f48..0000000 --- a/include/cutils/threads.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _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 */ diff --git a/include/cutils/tztime.h b/include/cutils/tztime.h deleted file mode 100644 index 9b3ece8..0000000 --- a/include/cutils/tztime.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _CUTILS_TZTIME_H -#define _CUTILS_TZTIME_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); - -struct strftime_locale { - const char *mon[12]; /* short names */ - const char *month[12]; /* long 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); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_TZTIME_H */ - diff --git a/include/cutils/uio.h b/include/cutils/uio.h deleted file mode 100644 index 01a74d2..0000000 --- a/include/cutils/uio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// -// 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> - -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 ); - -#ifdef __cplusplus -} -#endif - -#endif /* !HAVE_SYS_UIO_H */ - -#endif /* _LIBS_UTILS_UIO_H */ - diff --git a/include/cutils/zygote.h b/include/cutils/zygote.h deleted file mode 100644 index 22721a6..0000000 --- a/include/cutils/zygote.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CUTILS_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 */ |