Exporting C headers from system/core

Moved headers from include/libcutils and include/liblog to
libcutils/include and liblog/include respectively, so they can be
exported via these libs. They needed to be moved since Soong does
not allow export from external folder.

Added symlink from old locations. They are needed since Soong
includes system/core/include by default. Once all modules are
cleaned up to explicitly add the required libs, the symlinks will be
removed.

Also added liblog_vndk_headers that exports a special log/log.h for
VNDK.

Moved headers of libcutils to libcutils_headers. They should be used
by modules for header-only inlines. Added libcutils_headers as
dependency of libcutils.

Added libcutils_vndk_headers that exports a special cutils/log.h
deprecating usage of the file. A later CL will deprecate the one in
libcutils_headers

Test: Add above libs to shared lib of local module
Change-Id: I6e1f9c5f23d8b6eae13dc3b7e5dfe7fae93b8510
This commit is contained in:
Vijay Venkatraman 2017-01-05 10:22:52 -08:00
parent 41ee55a875
commit 3c6763ca21
75 changed files with 307 additions and 196 deletions

1
include/cutils Symbolic link
View File

@ -0,0 +1 @@
../libcutils/include/cutils/

1
include/log Symbolic link
View File

@ -0,0 +1 @@
../liblog/include/log

View File

@ -1 +0,0 @@
#include <log/log.h>

View File

@ -1 +0,0 @@
#include <log/log.h>

View File

@ -1,194 +0,0 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* This file is used to define the internal protocol for the Android Logger */
#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
/* Android private interfaces */
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#if (defined(__cplusplus) && defined(_USING_LIBCXX))
extern "C++" {
#include <string>
}
#endif
#include <log/log_event_list.h>
#include <log/log.h>
#define LOGGER_MAGIC 'l'
#if defined(__cplusplus)
extern "C" {
#endif
/* Header Structure to pstore */
typedef struct __attribute__((__packed__)) {
uint8_t magic;
uint16_t len;
uint16_t uid;
uint16_t pid;
} android_pmsg_log_header_t;
/* Header Structure to logd, and second header for pstore */
typedef struct __attribute__((__packed__)) {
typeof_log_id_t id;
uint16_t tid;
log_time realtime;
} android_log_header_t;
/* Event Header Structure to logd */
typedef struct __attribute__((__packed__)) {
int32_t tag; // Little Endian Order
} android_event_header_t;
/* Event payload EVENT_TYPE_INT */
typedef struct __attribute__((__packed__)) {
int8_t type; // EVENT_TYPE_INT
int32_t data; // Little Endian Order
} android_event_int_t;
/* Event with single EVENT_TYPE_INT */
typedef struct __attribute__((__packed__)) {
android_event_header_t header;
android_event_int_t payload;
} android_log_event_int_t;
/* Event payload EVENT_TYPE_LONG */
typedef struct __attribute__((__packed__)) {
int8_t type; // EVENT_TYPE_LONG
int64_t data; // Little Endian Order
} android_event_long_t;
/* Event with single EVENT_TYPE_LONG */
typedef struct __attribute__((__packed__)) {
android_event_header_t header;
android_event_long_t payload;
} android_log_event_long_t;
/*
* Event payload EVENT_TYPE_STRING
*
* Danger: do not embed this structure into another structure.
* This structure uses a flexible array member, and when
* compiled using g++, __builtin_object_size(data, 1) returns
* a bad value. This is possibly a g++ bug, or a bug due to
* the fact that flexible array members are not supported
* in C++.
* http://stackoverflow.com/questions/4412749/are-flexible-array-members-valid-in-c
*/
typedef struct __attribute__((__packed__)) {
int8_t type; // EVENT_TYPE_STRING;
int32_t length; // Little Endian Order
char data[];
} android_event_string_t;
/* Event with single EVENT_TYPE_STRING */
typedef struct __attribute__((__packed__)) {
android_event_header_t header;
int8_t type; // EVENT_TYPE_STRING;
int32_t length; // Little Endian Order
char data[];
} android_log_event_string_t;
#define ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE 256 /* 1MB file */
#define ANDROID_LOG_PMSG_FILE_SEQUENCE 1000
ssize_t __android_log_pmsg_file_write(
log_id_t logId,
char prio,
const char* filename,
const char* buf, size_t len);
#define LOG_ID_ANY ((log_id_t)-1)
#define ANDROID_LOG_ANY ANDROID_LOG_UNKNOWN
/* first 5 arguments match __android_log_msg_file_write, a cast is safe */
typedef ssize_t (*__android_log_pmsg_file_read_fn)(
log_id_t logId,
char prio,
const char* filename,
const char* buf, size_t len, void* arg);
ssize_t __android_log_pmsg_file_read(
log_id_t logId, char prio, const char* prefix,
__android_log_pmsg_file_read_fn fn, void* arg);
int __android_log_security_bwrite(int32_t tag, const void* payload, size_t len);
int __android_log_security_bswrite(int32_t tag, const char* payload);
int __android_log_security(); /* Device Owner is present */
int __android_log_is_debuggable();
#define BOOL_DEFAULT_FLAG_TRUE_FALSE 0x1
#define BOOL_DEFAULT_FALSE 0x0 /* false if property not present */
#define BOOL_DEFAULT_TRUE 0x1 /* true if property not present */
#define BOOL_DEFAULT_FLAG_PERSIST 0x2 /* <key>, persist.<key>, ro.<key> */
#define BOOL_DEFAULT_FLAG_ENG 0x4 /* off for user */
#define BOOL_DEFAULT_FLAG_SVELTE 0x8 /* off for low_ram */
bool __android_logger_property_get_bool(const char* key, int flag);
#define LOG_BUFFER_SIZE (256 * 1024) /* Tuned with ro.logd.size per-platform */
#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
#define LOG_BUFFER_MAX_SIZE (256 * 1024 * 1024UL)
unsigned long __android_logger_get_buffer_size(log_id_t logId);
bool __android_logger_valid_buffer_size(unsigned long value);
/* Retrieve the composed event buffer */
int android_log_write_list_buffer(android_log_context ctx, const char** msg);
#ifdef __cplusplus
#ifdef __class_android_log_event_list_defined
#ifndef __class_android_log_event_list_private_defined
#define __class_android_log_event_list_private_defined
/* android_log_context C++ helpers */
extern "C++" {
class __android_log_event_list : public android_log_event_list {
__android_log_event_list(const android_log_event_list&) = delete;
void operator =(const __android_log_event_list&) = delete;
public:
explicit __android_log_event_list(int tag) : android_log_event_list(tag) { }
explicit __android_log_event_list(log_msg& log_msg) : android_log_event_list(log_msg) { }
#if defined(_USING_LIBCXX)
operator std::string() {
if (ret) return std::string("");
const char* cp = NULL;
ssize_t len = android_log_write_list_buffer(ctx, &cp);
if (len < 0) ret = len;
if (!cp || (len <= 0)) return std::string("");
return std::string(cp, len);
}
#endif
};
}
#endif
#endif
#endif
#if defined(__cplusplus)
}
#endif
#endif /* _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ */

View File

@ -0,0 +1 @@
../../liblog/include/private/android_logger.h

View File

@ -30,6 +30,23 @@ libcutils_nonwindows_sources = [
"str_parms.c",
]
cc_library_headers {
name: "libcutils_vndk_headers",
host_supported: true,
export_include_dirs: ["include_vndk"],
}
cc_library_headers {
name: "libcutils_headers",
host_supported: true,
export_include_dirs: ["include"],
target: {
windows: {
enabled: true,
},
},
}
cc_library {
name: "libcutils",
host_supported: true,
@ -51,6 +68,7 @@ cc_library {
"threads.c",
],
target: {
host: {
srcs: ["dlmalloc_stubs.c"],
@ -117,6 +135,9 @@ cc_library {
},
shared_libs: ["liblog"],
header_libs: ["libcutils_headers"],
export_header_lib_headers: ["libcutils_headers"],
product_variables: {
cpusets: {
cflags: ["-DUSE_CPUSETS"],

View File

@ -0,0 +1 @@
../../include/cutils/android_get_control_file.h

View File

@ -0,0 +1 @@
../../include/cutils/android_reboot.h

View File

@ -0,0 +1 @@
../../include/cutils/ashmem.h

View File

@ -0,0 +1 @@
../../include/cutils/atomic.h

View File

@ -0,0 +1 @@
../../include/cutils/bitops.h

View File

@ -0,0 +1 @@
../../include/cutils/compiler.h

View File

@ -0,0 +1 @@
../../include/cutils/config_utils.h

View File

@ -0,0 +1 @@
../../include/cutils/fs.h

View File

@ -0,0 +1 @@
../../include/cutils/hashmap.h

View File

@ -0,0 +1 @@
../../include/cutils/iosched_policy.h

View File

@ -0,0 +1 @@
../../include/cutils/jstring.h

View File

@ -0,0 +1 @@
../../include/cutils/klog.h

View File

@ -0,0 +1 @@
../../include/cutils/list.h

View File

@ -0,0 +1,21 @@
/*Special log.h file for VNDK linking modules*/
/*
* Copyright (C) 2005-2017 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_CUTIL_LOG_H
#define _LIBS_CUTIL_LOG_H
#warning "Deprecated: don't include cutils/log.h, use either android/log.h or log/log.h"
#include <log/log.h>
#endif /* _LIBS_CUTIL_LOG_H */

View File

@ -0,0 +1 @@
../../include/cutils/memory.h

View File

@ -0,0 +1 @@
../../include/cutils/misc.h

View File

@ -0,0 +1 @@
../../include/cutils/multiuser.h

View File

@ -0,0 +1 @@
../../include/cutils/native_handle.h

View File

@ -0,0 +1 @@
../../include/cutils/open_memstream.h

View File

@ -0,0 +1 @@
../../include/cutils/partition_utils.h

View File

@ -0,0 +1 @@
../../include/cutils/properties.h

View File

@ -0,0 +1 @@
../../include/cutils/qtaguid.h

View File

@ -0,0 +1 @@
../../include/cutils/record_stream.h

View File

@ -0,0 +1 @@
../../include/cutils/sched_policy.h

View File

@ -0,0 +1 @@
../../include/cutils/sockets.h

View File

@ -0,0 +1 @@
../../include/cutils/str_parms.h

View File

@ -0,0 +1 @@
../../include/cutils/threads.h

View File

@ -0,0 +1 @@
../../include/cutils/trace.h

View File

@ -0,0 +1 @@
../../include/cutils/uevent.h

View File

@ -79,6 +79,8 @@ cc_library {
},
},
export_include_dirs: ["include"],
cflags: [
"-Werror",
"-fvisibility=hidden",
@ -111,6 +113,11 @@ ndk_headers {
license: "NOTICE",
}
cc_library_headers {
name: "liblog_vndk_headers",
export_include_dirs: ["include_vndk"],
}
ndk_library {
name: "liblog.ndk",
symbol_file: "liblog.map.txt",

View File

@ -0,0 +1,5 @@
#ifndef _LIBS_LOG_LOGD_H
#define _LIBS_LOG_LOGD_H
#include <log/log.h>
#warning "Deprecated: do not include log/logd.h, use log/log.h instead"
#endif /*_LIBS_LOG_LOGD_H*/

View File

@ -0,0 +1,5 @@
#ifndef _LIBS_LOG_LOGGER_H
#define _LIBS_LOG_LOGGER_H
#include <log/log.h>
#warning "Deprecated: do not include log/logger.h, use log/log.h instead"
#endif /*_LIBS_LOG_LOGGER_H*/

View File

@ -0,0 +1,194 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* This file is used to define the internal protocol for the Android Logger */
#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
/* Android private interfaces */
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#if (defined(__cplusplus) && defined(_USING_LIBCXX))
extern "C++" {
#include <string>
}
#endif
#include <log/log_event_list.h>
#include <log/log.h>
#define LOGGER_MAGIC 'l'
#if defined(__cplusplus)
extern "C" {
#endif
/* Header Structure to pstore */
typedef struct __attribute__((__packed__)) {
uint8_t magic;
uint16_t len;
uint16_t uid;
uint16_t pid;
} android_pmsg_log_header_t;
/* Header Structure to logd, and second header for pstore */
typedef struct __attribute__((__packed__)) {
typeof_log_id_t id;
uint16_t tid;
log_time realtime;
} android_log_header_t;
/* Event Header Structure to logd */
typedef struct __attribute__((__packed__)) {
int32_t tag; // Little Endian Order
} android_event_header_t;
/* Event payload EVENT_TYPE_INT */
typedef struct __attribute__((__packed__)) {
int8_t type; // EVENT_TYPE_INT
int32_t data; // Little Endian Order
} android_event_int_t;
/* Event with single EVENT_TYPE_INT */
typedef struct __attribute__((__packed__)) {
android_event_header_t header;
android_event_int_t payload;
} android_log_event_int_t;
/* Event payload EVENT_TYPE_LONG */
typedef struct __attribute__((__packed__)) {
int8_t type; // EVENT_TYPE_LONG
int64_t data; // Little Endian Order
} android_event_long_t;
/* Event with single EVENT_TYPE_LONG */
typedef struct __attribute__((__packed__)) {
android_event_header_t header;
android_event_long_t payload;
} android_log_event_long_t;
/*
* Event payload EVENT_TYPE_STRING
*
* Danger: do not embed this structure into another structure.
* This structure uses a flexible array member, and when
* compiled using g++, __builtin_object_size(data, 1) returns
* a bad value. This is possibly a g++ bug, or a bug due to
* the fact that flexible array members are not supported
* in C++.
* http://stackoverflow.com/questions/4412749/are-flexible-array-members-valid-in-c
*/
typedef struct __attribute__((__packed__)) {
int8_t type; // EVENT_TYPE_STRING;
int32_t length; // Little Endian Order
char data[];
} android_event_string_t;
/* Event with single EVENT_TYPE_STRING */
typedef struct __attribute__((__packed__)) {
android_event_header_t header;
int8_t type; // EVENT_TYPE_STRING;
int32_t length; // Little Endian Order
char data[];
} android_log_event_string_t;
#define ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE 256 /* 1MB file */
#define ANDROID_LOG_PMSG_FILE_SEQUENCE 1000
ssize_t __android_log_pmsg_file_write(
log_id_t logId,
char prio,
const char* filename,
const char* buf, size_t len);
#define LOG_ID_ANY ((log_id_t)-1)
#define ANDROID_LOG_ANY ANDROID_LOG_UNKNOWN
/* first 5 arguments match __android_log_msg_file_write, a cast is safe */
typedef ssize_t (*__android_log_pmsg_file_read_fn)(
log_id_t logId,
char prio,
const char* filename,
const char* buf, size_t len, void* arg);
ssize_t __android_log_pmsg_file_read(
log_id_t logId, char prio, const char* prefix,
__android_log_pmsg_file_read_fn fn, void* arg);
int __android_log_security_bwrite(int32_t tag, const void* payload, size_t len);
int __android_log_security_bswrite(int32_t tag, const char* payload);
int __android_log_security(); /* Device Owner is present */
int __android_log_is_debuggable();
#define BOOL_DEFAULT_FLAG_TRUE_FALSE 0x1
#define BOOL_DEFAULT_FALSE 0x0 /* false if property not present */
#define BOOL_DEFAULT_TRUE 0x1 /* true if property not present */
#define BOOL_DEFAULT_FLAG_PERSIST 0x2 /* <key>, persist.<key>, ro.<key> */
#define BOOL_DEFAULT_FLAG_ENG 0x4 /* off for user */
#define BOOL_DEFAULT_FLAG_SVELTE 0x8 /* off for low_ram */
bool __android_logger_property_get_bool(const char* key, int flag);
#define LOG_BUFFER_SIZE (256 * 1024) /* Tuned with ro.logd.size per-platform */
#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
#define LOG_BUFFER_MAX_SIZE (256 * 1024 * 1024UL)
unsigned long __android_logger_get_buffer_size(log_id_t logId);
bool __android_logger_valid_buffer_size(unsigned long value);
/* Retrieve the composed event buffer */
int android_log_write_list_buffer(android_log_context ctx, const char** msg);
#ifdef __cplusplus
#ifdef __class_android_log_event_list_defined
#ifndef __class_android_log_event_list_private_defined
#define __class_android_log_event_list_private_defined
/* android_log_context C++ helpers */
extern "C++" {
class __android_log_event_list : public android_log_event_list {
__android_log_event_list(const android_log_event_list&) = delete;
void operator =(const __android_log_event_list&) = delete;
public:
explicit __android_log_event_list(int tag) : android_log_event_list(tag) { }
explicit __android_log_event_list(log_msg& log_msg) : android_log_event_list(log_msg) { }
#if defined(_USING_LIBCXX)
operator std::string() {
if (ret) return std::string("");
const char* cp = NULL;
ssize_t len = android_log_write_list_buffer(ctx, &cp);
if (len < 0) ret = len;
if (!cp || (len <= 0)) return std::string("");
return std::string(cp, len);
}
#endif
};
}
#endif
#endif
#endif
#if defined(__cplusplus)
}
#endif
#endif /* _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ */

1
liblog/include_vndk/android Symbolic link
View File

@ -0,0 +1 @@
../../include/android/

View File

@ -0,0 +1,22 @@
/*Special log.h file for VNDK linking modules*/
#ifndef _LIBS_LOG_LOG_H
#define _LIBS_LOG_LOG_H
#include <android/log.h>
/*The following files will be included once they are available*/
/*#include <log/log_id.h>*/
/*#include <log/log_radio.h>*/
/*
* LOG_TAG 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
#endif /*_LIBS_LOG_LOG_H*/