Merge "libasync_safe: stop clobbering other folks' identifiers."
This commit is contained in:
commit
f84d0a95bd
8 changed files with 73 additions and 40 deletions
|
@ -12,7 +12,19 @@ cc_library_static {
|
|||
recovery_available: true,
|
||||
|
||||
include_dirs: ["bionic/libc"],
|
||||
header_libs: ["libc_headers"],
|
||||
header_libs: ["libc_headers", "liblog_headers"],
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
export_header_lib_headers: ["liblog_headers"],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
cc_library_headers {
|
||||
name: "libasync_safe_headers",
|
||||
recovery_available: true,
|
||||
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
|
|
47
libc/async_safe/include/async_safe/CHECK.h
Normal file
47
libc/async_safe/include/async_safe/CHECK.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <async_safe/log.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
// TODO: replace this with something more like <android-base/logging.h>'s family of macros.
|
||||
|
||||
#define CHECK(predicate) \
|
||||
do { \
|
||||
if (!(predicate)) { \
|
||||
async_safe_fatal("%s:%d: %s CHECK '" #predicate "' failed", \
|
||||
__FILE__, __LINE__, __FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
__END_DECLS
|
|
@ -34,36 +34,14 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// This file is an alternative to <android/log.h>, but reuses
|
||||
// `android_LogPriority` and should not have conflicting identifiers.
|
||||
#include <android/log.h>
|
||||
|
||||
// These functions do not allocate memory to send data to the log.
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
enum {
|
||||
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 */
|
||||
};
|
||||
|
||||
enum {
|
||||
LOG_ID_MIN = 0,
|
||||
|
||||
LOG_ID_MAIN = 0,
|
||||
LOG_ID_RADIO = 1,
|
||||
LOG_ID_EVENTS = 2,
|
||||
LOG_ID_SYSTEM = 3,
|
||||
LOG_ID_CRASH = 4,
|
||||
|
||||
LOG_ID_MAX
|
||||
};
|
||||
|
||||
// Formats a message to the log (priority 'fatal'), then aborts.
|
||||
// Implemented as a macro so that async_safe_fatal isn't on the stack when we crash:
|
||||
// we appear to go straight from the caller to abort, saving an uninteresting stack
|
||||
|
@ -91,16 +69,8 @@ int async_safe_format_buffer_va_list(char* buffer, size_t buffer_size, const cha
|
|||
|
||||
int async_safe_format_fd(int fd, const char* format , ...) __printflike(2, 3);
|
||||
int async_safe_format_fd_va_list(int fd, const char* format, va_list args);
|
||||
int async_safe_format_log(int pri, const char* tag, const char* fmt, ...) __printflike(3, 4);
|
||||
int async_safe_format_log_va_list(int pri, const char* tag, const char* fmt, va_list ap);
|
||||
int async_safe_write_log(int pri, const char* tag, const char* msg);
|
||||
|
||||
#define CHECK(predicate) \
|
||||
do { \
|
||||
if (!(predicate)) { \
|
||||
async_safe_fatal("%s:%d: %s CHECK '" #predicate "' failed", \
|
||||
__FILE__, __LINE__, __FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
int async_safe_format_log(int priority, const char* tag, const char* fmt, ...) __printflike(3, 4);
|
||||
int async_safe_format_log_va_list(int priority, const char* tag, const char* fmt, va_list ap);
|
||||
int async_safe_write_log(int priority, const char* tag, const char* msg);
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <new>
|
||||
|
||||
#include <async_safe/log.h>
|
||||
#include <async_safe/CHECK.h>
|
||||
|
||||
#include "private/bionic_macros.h"
|
||||
#include "private/bionic_page.h"
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <async_safe/log.h>
|
||||
#include <async_safe/CHECK.h>
|
||||
|
||||
#include "private/bionic_defs.h"
|
||||
#include "private/bionic_macros.h"
|
||||
|
|
|
@ -12,8 +12,8 @@ cc_library_static {
|
|||
whole_static_libs: [
|
||||
"libpropertyinfoparser",
|
||||
],
|
||||
static_libs: [
|
||||
"libasync_safe",
|
||||
header_libs: [
|
||||
"libasync_safe_headers",
|
||||
],
|
||||
|
||||
include_dirs: [
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <async_safe/log.h>
|
||||
#include <async_safe/CHECK.h>
|
||||
|
||||
__LIBC_HIDDEN__ extern int g_ld_debug_verbosity;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "async_safe/CHECK.h"
|
||||
#include "private/ScopedRWLock.h"
|
||||
#include "private/ScopedSignalBlocker.h"
|
||||
#include "private/bionic_defs.h"
|
||||
|
|
Loading…
Reference in a new issue