Merge "Move libcutils source to C++." am: d2ce2f4f45

am: ba3b6a2851

Change-Id: Ifa80cbb1767cd54883e801963631bb7ddd5614c7
This commit is contained in:
Elliott Hughes 2017-11-11 00:41:29 +00:00 committed by android-build-merger
commit 4320727b68
40 changed files with 150 additions and 126 deletions

View file

@ -19,14 +19,14 @@
// which are also hard or even impossible to port to native Win32
libcutils_nonwindows_sources = [
"android_get_control_file.cpp",
"fs.c",
"fs.cpp",
"multiuser.c",
"socket_inaddr_any_server_unix.c",
"socket_local_client_unix.c",
"socket_local_server_unix.c",
"socket_network_client_unix.c",
"socket_inaddr_any_server_unix.cpp",
"socket_local_client_unix.cpp",
"socket_local_server_unix.cpp",
"socket_network_client_unix.cpp",
"sockets_unix.cpp",
"str_parms.c",
"str_parms.cpp",
]
cc_library_headers {
@ -56,21 +56,21 @@ cc_library {
},
host_supported: true,
srcs: [
"config_utils.c",
"config_utils.cpp",
"fs_config.cpp",
"canned_fs_config.c",
"hashmap.c",
"iosched_policy.c",
"load_file.c",
"native_handle.c",
"canned_fs_config.cpp",
"hashmap.cpp",
"iosched_policy.cpp",
"load_file.cpp",
"native_handle.cpp",
"open_memstream.c",
"record_stream.c",
"record_stream.cpp",
"sched_policy.cpp",
"sockets.cpp",
"strdup16to8.c",
"strdup8to16.c",
"strdup16to8.cpp",
"strdup8to16.cpp",
"strlcpy.c",
"threads.c",
"threads.cpp",
],
target: {
@ -83,14 +83,14 @@ cc_library {
},
not_windows: {
srcs: libcutils_nonwindows_sources + [
"ashmem-host.c",
"trace-host.c",
"ashmem-host.cpp",
"trace-host.cpp",
],
},
windows: {
srcs: [
"socket_inaddr_any_server_windows.c",
"socket_network_client_windows.c",
"socket_inaddr_any_server_windows.cpp",
"socket_network_client_windows.cpp",
"sockets_windows.cpp",
],
@ -105,13 +105,13 @@ cc_library {
android: {
srcs: libcutils_nonwindows_sources + [
"android_reboot.c",
"ashmem-dev.c",
"android_reboot.cpp",
"ashmem-dev.cpp",
"klog.cpp",
"partition_utils.c",
"partition_utils.cpp",
"properties.cpp",
"qtaguid.cpp",
"trace-dev.c",
"trace-dev.cpp",
"uevent.cpp",
],
},

View file

@ -25,6 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <cutils/android_get_control_file.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@ -36,8 +39,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <cutils/android_get_control_file.h>
#include "android_get_control_env.h"
#ifndef TEMP_FAILURE_RETRY

View file

@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cutils/android_reboot.h>
#include <stdio.h>
#include <stdlib.h>
#include <cutils/android_reboot.h>
#include <cutils/properties.h>
#define TAG "android_reboot"
@ -26,7 +28,7 @@ int android_reboot(int cmd, int flags __unused, const char* arg) {
const char* restart_cmd = NULL;
char* prop_value;
switch (cmd) {
switch (static_cast<unsigned>(cmd)) {
case ANDROID_RB_RESTART: // deprecated
case ANDROID_RB_RESTART2:
restart_cmd = "reboot";

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/ashmem.h>
/*
* Implementation of the user-space ashmem API for devices, which have our
* ashmem-enabled kernel. See ashmem-sim.c for the "fake" tmp-based version,
@ -31,8 +33,6 @@
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <unistd.h>
#include <cutils/ashmem.h>
#include <log/log.h>
#define ASHMEM_DEVICE "/dev/ashmem"
@ -192,7 +192,8 @@ int ashmem_set_prot_region(int fd, int prot)
int ashmem_pin_region(int fd, size_t offset, size_t len)
{
struct ashmem_pin pin = { offset, len };
// TODO: should LP64 reject too-large offset/len?
ashmem_pin pin = { static_cast<uint32_t>(offset), static_cast<uint32_t>(len) };
int ret = __ashmem_is_ashmem(fd, 1);
if (ret < 0) {
@ -204,7 +205,8 @@ int ashmem_pin_region(int fd, size_t offset, size_t len)
int ashmem_unpin_region(int fd, size_t offset, size_t len)
{
struct ashmem_pin pin = { offset, len };
// TODO: should LP64 reject too-large offset/len?
ashmem_pin pin = { static_cast<uint32_t>(offset), static_cast<uint32_t>(len) };
int ret = __ashmem_is_ashmem(fd, 1);
if (ret < 0) {

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/ashmem.h>
/*
* Implementation of the user-space ashmem API for the simulator, which lacks
* an ashmem-enabled kernel. See ashmem-dev.c for the real ashmem-based version.
@ -31,7 +33,6 @@
#include <time.h>
#include <unistd.h>
#include <cutils/ashmem.h>
#include <utils/Compat.h>
#ifndef __unused
@ -40,12 +41,12 @@
int ashmem_create_region(const char *ignored __unused, size_t size)
{
char template[PATH_MAX];
snprintf(template, sizeof(template), "/tmp/android-ashmem-%d-XXXXXXXXX", getpid());
int fd = mkstemp(template);
char pattern[PATH_MAX];
snprintf(pattern, sizeof(pattern), "/tmp/android-ashmem-%d-XXXXXXXXX", getpid());
int fd = mkstemp(pattern);
if (fd == -1) return -1;
unlink(template);
unlink(pattern);
if (TEMP_FAILURE_RETRY(ftruncate(fd, size)) == -1) {
close(fd);

View file

@ -14,6 +14,10 @@
* limitations under the License.
*/
#include <private/android_filesystem_config.h>
#include <private/canned_fs_config.h>
#include <private/fs_config.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
@ -22,10 +26,6 @@
#include <stdlib.h>
#include <string.h>
#include <private/android_filesystem_config.h>
#include <private/fs_config.h>
#include <private/canned_fs_config.h>
typedef struct {
const char* path;
unsigned uid;

View file

@ -14,20 +14,19 @@
* limitations under the License.
*/
#include <cutils/config_utils.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <cutils/config_utils.h>
#include <cutils/misc.h>
cnode* config_node(const char *name, const char *value)
{
cnode *node;
node = calloc(sizeof(cnode), 1);
cnode* node = static_cast<cnode*>(calloc(sizeof(cnode), 1));
if(node) {
node->name = name ? name : "";
node->value = value ? value : "";
@ -311,9 +310,9 @@ void config_load(cnode *root, char *data)
void config_load_file(cnode *root, const char *fn)
{
char *data;
data = load_file(fn, 0);
char* data = static_cast<char*>(load_file(fn, nullptr));
config_load(root, data);
// TODO: deliberate leak :-/
}
void config_free(cnode *root)

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/fs.h>
#define LOG_TAG "cutils"
/* These defines are only needed because prebuilt headers are out of date */
@ -32,7 +34,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <cutils/fs.h>
#include <log/log.h>
#define ALL_PERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
@ -40,6 +41,11 @@
static int fs_prepare_path_impl(const char* path, mode_t mode, uid_t uid, gid_t gid,
int allow_fixup, int prepare_as_dir) {
// TODO: fix the goto hell below.
int type_ok;
int owner_match;
int mode_match;
// Check if path needs to be created
struct stat sb;
int create_result = -1;
@ -53,14 +59,14 @@ static int fs_prepare_path_impl(const char* path, mode_t mode, uid_t uid, gid_t
}
// Exists, verify status
int type_ok = prepare_as_dir ? S_ISDIR(sb.st_mode) : S_ISREG(sb.st_mode);
type_ok = prepare_as_dir ? S_ISDIR(sb.st_mode) : S_ISREG(sb.st_mode);
if (!type_ok) {
ALOGE("Not a %s: %s", (prepare_as_dir ? "directory" : "regular file"), path);
return -1;
}
int owner_match = ((sb.st_uid == uid) && (sb.st_gid == gid));
int mode_match = ((sb.st_mode & ALL_PERMS) == mode);
owner_match = ((sb.st_uid == uid) && (sb.st_gid == gid));
mode_match = ((sb.st_mode & ALL_PERMS) == mode);
if (owner_match && mode_match) {
return 0;
} else if (allow_fixup) {
@ -188,23 +194,20 @@ fail_closed:
#ifndef __APPLE__
int fs_mkdirs(const char* path, mode_t mode) {
int res = 0;
int fd = 0;
struct stat sb;
char* buf = strdup(path);
if (*buf != '/') {
ALOGE("Relative paths are not allowed: %s", buf);
res = -EINVAL;
goto done;
if (*path != '/') {
ALOGE("Relative paths are not allowed: %s", path);
return -EINVAL;
}
if ((fd = open("/", 0)) == -1) {
int fd = open("/", 0);
if (fd == -1) {
ALOGE("Failed to open(/): %s", strerror(errno));
res = -errno;
goto done;
return -errno;
}
struct stat sb;
int res = 0;
char* buf = strdup(path);
char* segment = buf + 1;
char* p = segment;
while (*p != '\0') {
@ -266,7 +269,6 @@ int fs_mkdirs(const char* path, mode_t mode) {
done_close:
close(fd);
done:
free(buf);
return res;
}

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <private/fs_config.h>
// 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.
@ -31,7 +33,6 @@
#include <log/log.h>
#include <private/android_filesystem_config.h>
#include <private/fs_config.h>
#include <utils/Compat.h>
#ifndef O_BINARY

View file

@ -15,6 +15,7 @@
*/
#include <cutils/hashmap.h>
#include <assert.h>
#include <errno.h>
#include <cutils/threads.h>
@ -45,7 +46,7 @@ Hashmap* hashmapCreate(size_t initialCapacity,
assert(hash != NULL);
assert(equals != NULL);
Hashmap* map = malloc(sizeof(Hashmap));
Hashmap* map = static_cast<Hashmap*>(malloc(sizeof(Hashmap)));
if (map == NULL) {
return NULL;
}
@ -58,7 +59,7 @@ Hashmap* hashmapCreate(size_t initialCapacity,
map->bucketCount <<= 1;
}
map->buckets = calloc(map->bucketCount, sizeof(Entry*));
map->buckets = static_cast<Entry**>(calloc(map->bucketCount, sizeof(Entry*)));
if (map->buckets == NULL) {
free(map);
return NULL;
@ -106,7 +107,7 @@ static void expandIfNecessary(Hashmap* map) {
if (map->size > (map->bucketCount * 3 / 4)) {
// Start off with a 0.33 load factor.
size_t newBucketCount = map->bucketCount << 1;
Entry** newBuckets = calloc(newBucketCount, sizeof(Entry*));
Entry** newBuckets = static_cast<Entry**>(calloc(newBucketCount, sizeof(Entry*)));
if (newBuckets == NULL) {
// Abort expansion.
return;
@ -171,7 +172,7 @@ int hashmapHash(void* key, size_t keySize) {
}
static Entry* createEntry(void* key, int hash, void* value) {
Entry* entry = malloc(sizeof(Entry));
Entry* entry = static_cast<Entry*>(malloc(sizeof(Entry)));
if (entry == NULL) {
return NULL;
}

View file

@ -17,6 +17,7 @@
#ifndef __CUTILS_ANDROID_REBOOT_H__
#define __CUTILS_ANDROID_REBOOT_H__
#include <sys/cdefs.h>
__BEGIN_DECLS

View file

@ -17,6 +17,8 @@
#ifndef __CUTILS_PARTITION_WIPED_H__
#define __CUTILS_PARTITION_WIPED_H__
#include <sys/cdefs.h>
__BEGIN_DECLS
int partition_wiped(char *source);

View file

@ -25,6 +25,7 @@
extern "C" {
#endif
#include <stddef.h>
typedef struct RecordStream RecordStream;

View file

@ -19,8 +19,12 @@
#include <inttypes.h>
__BEGIN_DECLS
int load_canned_fs_config(const char* fn);
void canned_fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid,
unsigned* gid, unsigned* mode, uint64_t* capabilities);
__END_DECLS
#endif

View file

@ -24,6 +24,7 @@
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#if defined(__BIONIC__)
#include <linux/capability.h>

View file

@ -14,6 +14,8 @@
** limitations under the License.
*/
#include <cutils/iosched_policy.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -21,8 +23,6 @@
#include <string.h>
#include <unistd.h>
#include <cutils/iosched_policy.h>
#if defined(__ANDROID__)
#define IOPRIO_WHO_PROCESS (1)
#define IOPRIO_CLASS_SHIFT (13)
@ -49,7 +49,7 @@ int android_get_ioprio(int pid __android_unused, IoSchedClass *clazz, int *iopri
return -1;
}
*clazz = (rc >> IOPRIO_CLASS_SHIFT);
*clazz = static_cast<IoSchedClass>(rc >> IOPRIO_CLASS_SHIFT);
*ioprio = (rc & 0xff);
#else
*clazz = IoSchedClass_NONE;

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/klog.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
@ -25,7 +27,6 @@
#include <unistd.h>
#include <cutils/android_get_control_file.h>
#include <cutils/klog.h>
static int klog_level = KLOG_INFO_LEVEL;

View file

@ -15,6 +15,8 @@
** limitations under the License.
*/
#include <cutils/misc.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

View file

@ -45,7 +45,7 @@ native_handle_t* native_handle_create(int numFds, int numInts) {
}
size_t mallocSize = sizeof(native_handle_t) + (sizeof(int) * (numFds + numInts));
native_handle_t* h = malloc(mallocSize);
native_handle_t* h = static_cast<native_handle_t*>(malloc(mallocSize));
if (h) {
h->version = sizeof(native_handle_t);
h->numFds = numFds;

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/partition_utils.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mount.h> /* for BLKGETSIZE */

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/properties.h>
#define LOG_TAG "properties"
// #define LOG_NDEBUG 0
@ -25,7 +27,6 @@
#include <string.h>
#include <unistd.h>
#include <cutils/properties.h>
#include <cutils/sockets.h>
#include <log/log.h>

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/qtaguid.h>
// #define LOG_NDEBUG 0
#define LOG_TAG "qtaguid"
@ -26,7 +28,6 @@
#include <string.h>
#include <unistd.h>
#include <cutils/qtaguid.h>
#include <log/log.h>
class netdHandler {

View file

@ -15,11 +15,12 @@
** limitations under the License.
*/
#include <cutils/record_stream.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <cutils/record_stream.h>
#include <string.h>
#include <stdint.h>
#if defined(_WIN32)

View file

@ -14,6 +14,8 @@
** limitations under the License.
*/
#include <cutils/sched_policy.h>
#define LOG_TAG "SchedPolicy"
#include <errno.h>
@ -24,7 +26,6 @@
#include <unistd.h>
#include <log/log.h>
#include <cutils/sched_policy.h>
#define UNUSED __attribute__((__unused__))

View file

@ -14,6 +14,8 @@
** limitations under the License.
*/
#include <cutils/sockets.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
@ -25,8 +27,6 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <cutils/sockets.h>
#define LISTEN_BACKLOG 4
/* open listen() port on any interface */

View file

@ -26,10 +26,10 @@
* SUCH DAMAGE.
*/
#include <errno.h>
#include <cutils/sockets.h>
#include <errno.h>
#define LISTEN_BACKLOG 4
extern bool initialize_windows_sockets();

View file

@ -14,14 +14,14 @@
* limitations under the License.
*/
#include <cutils/sockets.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <cutils/sockets.h>
#if defined(_WIN32)
int socket_local_client(const char *name, int namespaceId, int type)

View file

@ -94,7 +94,7 @@ int socket_local_server_bind(int s, const char *name, int namespaceId)
* Returns fd on success, -1 on fail
*/
int socket_local_server(const char *name, int namespace, int type)
int socket_local_server(const char *name, int namespaceId, int type)
{
int err;
int s;
@ -102,7 +102,7 @@ int socket_local_server(const char *name, int namespace, int type)
s = socket(AF_LOCAL, type, 0);
if (s < 0) return -1;
err = socket_local_server_bind(s, name, namespace);
err = socket_local_server_bind(s, name, namespaceId);
if (err < 0) {
close(s);

View file

@ -14,6 +14,8 @@
** limitations under the License.
*/
#include <cutils/sockets.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
@ -27,8 +29,6 @@
#include <netinet/in.h>
#include <netdb.h>
#include <cutils/sockets.h>
static int toggle_O_NONBLOCK(int s) {
int flags = fcntl(s, F_GETFL);
if (flags == -1 || fcntl(s, F_SETFL, flags ^ O_NONBLOCK) == -1) {

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/sockets.h>
#define LOG_TAG "socket-unix"
#include <stdio.h>
@ -26,7 +28,6 @@
#include <unistd.h>
#include <cutils/android_get_control_file.h>
#include <cutils/sockets.h>
#include <log/log.h>
#include "android_get_control_env.h"

View file

@ -37,7 +37,7 @@
// Both adb (1) and Chrome (2) purposefully avoid WSACleanup() with no issues.
// (1) https://android.googlesource.com/platform/system/core.git/+/master/adb/sysdeps_win32.cpp
// (2) https://code.google.com/p/chromium/codesearch#chromium/src/net/base/winsock_init.cc
extern "C" bool initialize_windows_sockets() {
bool initialize_windows_sockets() {
// There's no harm in calling WSAStartup() multiple times but no benefit
// either, we may as well skip it after the first.
static bool init_success = false;

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/str_parms.h>
#define LOG_TAG "str_params"
//#define LOG_NDEBUG 0
@ -26,7 +28,6 @@
#include <cutils/hashmap.h>
#include <cutils/memory.h>
#include <cutils/str_parms.h>
#include <log/log.h>
#define UNUSED __attribute__((unused))
@ -62,30 +63,24 @@ __attribute__((no_sanitize("integer")))
static int str_hash_fn(void *str)
{
uint32_t hash = 5381;
char *p;
for (p = str; p && *p; p++)
for (char* p = static_cast<char*>(str); p && *p; p++)
hash = ((hash << 5) + hash) + *p;
return (int)hash;
}
struct str_parms *str_parms_create(void)
{
struct str_parms *str_parms;
str_parms* s = static_cast<str_parms*>(calloc(1, sizeof(str_parms)));
if (!s) return NULL;
str_parms = calloc(1, sizeof(struct str_parms));
if (!str_parms)
s->map = hashmapCreate(5, str_hash_fn, str_eq);
if (!s->map) {
free(s);
return NULL;
}
str_parms->map = hashmapCreate(5, str_hash_fn, str_eq);
if (!str_parms->map)
goto err;
return str_parms;
err:
free(str_parms);
return NULL;
return s;
}
struct remove_ctxt {
@ -95,7 +90,7 @@ struct remove_ctxt {
static bool remove_pair(void *key, void *value, void *context)
{
struct remove_ctxt *ctxt = context;
remove_ctxt* ctxt = static_cast<remove_ctxt*>(context);
bool should_continue;
/*
@ -109,7 +104,7 @@ static bool remove_pair(void *key, void *value, void *context)
if (!ctxt->key) {
should_continue = true;
goto do_remove;
} else if (!strcmp(ctxt->key, key)) {
} else if (!strcmp(ctxt->key, static_cast<const char*>(key))) {
should_continue = false;
goto do_remove;
}
@ -292,9 +287,8 @@ int str_parms_has_key(struct str_parms *str_parms, const char *key) {
int str_parms_get_str(struct str_parms *str_parms, const char *key, char *val,
int len)
{
char *value;
value = hashmapGet(str_parms->map, (void *)key);
// TODO: hashmapGet should take a const* key.
char* value = static_cast<char*>(hashmapGet(str_parms->map, (void*)key));
if (value)
return strlcpy(val, value, len);
@ -303,10 +297,10 @@ int str_parms_get_str(struct str_parms *str_parms, const char *key, char *val,
int str_parms_get_int(struct str_parms *str_parms, const char *key, int *val)
{
char *value;
char *end;
value = hashmapGet(str_parms->map, (void *)key);
// TODO: hashmapGet should take a const* key.
char* value = static_cast<char*>(hashmapGet(str_parms->map, (void*)key));
if (!value)
return -ENOENT;
@ -321,10 +315,10 @@ int str_parms_get_float(struct str_parms *str_parms, const char *key,
float *val)
{
float out;
char *value;
char *end;
value = hashmapGet(str_parms->map, (void *)key);
// TODO: hashmapGet should take a const* key.
char* value = static_cast<char*>(hashmapGet(str_parms->map, (void*)(key)));
if (!value)
return -ENOENT;
@ -338,7 +332,7 @@ int str_parms_get_float(struct str_parms *str_parms, const char *key,
static bool combine_strings(void *key, void *value, void *context)
{
char **old_str = context;
char** old_str = static_cast<char**>(context);
char *new_str;
int ret;

View file

@ -15,10 +15,10 @@
** limitations under the License.
*/
#include <limits.h> /* for SIZE_MAX */
#include <cutils/jstring.h>
#include <assert.h>
#include <limits.h> /* for SIZE_MAX */
#include <stdlib.h>
@ -145,14 +145,11 @@ extern char* strncpy16to8(char* utf8Str, const char16_t* utf16Str, size_t len)
*/
char * strndup16to8 (const char16_t* s, size_t n)
{
char* ret;
size_t len;
if (s == NULL) {
return NULL;
}
len = strnlen16to8(s, n);
size_t len = strnlen16to8(s, n);
/* We are paranoid, and we check for SIZE_MAX-1
* too since it is an overflow value for our
@ -161,7 +158,7 @@ char * strndup16to8 (const char16_t* s, size_t n)
if (len >= SIZE_MAX-1)
return NULL;
ret = malloc(len + 1);
char* ret = static_cast<char*>(malloc(len + 1));
if (ret == NULL)
return NULL;

View file

@ -16,9 +16,10 @@
*/
#include <cutils/jstring.h>
#include <assert.h>
#include <stdlib.h>
#include <limits.h>
#include <stdlib.h>
/* See http://www.unicode.org/reports/tr22/ for discussion
* on invalid sequences
@ -116,7 +117,7 @@ static inline uint32_t getUtf32FromUtf8(const char** pUtf8Ptr)
int i;
/* Mask for leader byte for lengths 1, 2, 3, and 4 respectively*/
static const char leaderMask[4] = {0xff, 0x1f, 0x0f, 0x07};
static const unsigned char leaderMask[4] = {0xff, 0x1f, 0x0f, 0x07};
/* Bytes that start with bits "10" are not leading characters. */
if (((**pUtf8Ptr) & 0xc0) == 0x80) {

View file

@ -25,7 +25,7 @@
#include <android-base/test_utils.h>
#include <gtest/gtest.h>
#include "../trace-dev.c"
#include "../trace-dev.cpp"
class TraceDevTest : public ::testing::Test {
protected:

View file

@ -14,7 +14,7 @@
** limitations under the License.
*/
#include "cutils/threads.h"
#include <cutils/threads.h>
// For gettid.
#if defined(__APPLE__)

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/trace.h>
#include "trace-dev.inc"
#include <cutils/sockets.h>

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <cutils/trace.h>
#include "trace-dev.inc"
static pthread_once_t atrace_once_control = PTHREAD_ONCE_INIT;