summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-01-09 14:44:13 -0600
committerMark Salyzyn2017-01-25 17:41:43 -0600
commit5c967da341c9395a4c378c149f326505224ec66e (patch)
tree0e1de2d192d55de6300d99269441882ccbb0b2bd
parent01678a0c84e1f94420630709fe7aea7b4357f019 (diff)
downloadplatform-system-core-5c967da341c9395a4c378c149f326505224ec66e.tar.gz
platform-system-core-5c967da341c9395a4c378c149f326505224ec66e.tar.xz
platform-system-core-5c967da341c9395a4c378c149f326505224ec66e.zip
ndk: reverse course on android/log.h
move LOG macros to log/log_main.h move include/android/log.h to liblog/include/android/log.h Test: compile of all components and gTest liblog-unit-tests Bug: 34250038 Bug: 30465923 Change-Id: If182dd9b83689e8b7bc1a44b2f5d913c7ee5eeee
l---------include/android1
-rw-r--r--liblog/include/android/log.h156
-rw-r--r--liblog/include/log/log.h17
-rw-r--r--liblog/include/log/log_main.h (renamed from include/android/log.h)174
l---------liblog/include_vndk/android2
-rw-r--r--liblog/include_vndk/log/log.h1
l---------liblog/include_vndk/log/log_main.h1
7 files changed, 198 insertions, 154 deletions
diff --git a/include/android b/include/android
new file mode 120000
index 000000000..487239387
--- /dev/null
+++ b/include/android
@@ -0,0 +1 @@
../liblog/include/android \ No newline at end of file
diff --git a/liblog/include/android/log.h b/liblog/include/android/log.h
new file mode 100644
index 000000000..9f198fe87
--- /dev/null
+++ b/liblog/include/android/log.h
@@ -0,0 +1,156 @@
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROID_LOG_H
18#define _ANDROID_LOG_H
19
20/******************************************************************
21 *
22 * IMPORTANT NOTICE:
23 *
24 * This file is part of Android's set of stable system headers
25 * exposed by the Android NDK (Native Development Kit) since
26 * platform release 1.5
27 *
28 * Third-party source AND binary code relies on the definitions
29 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
30 *
31 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
32 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
33 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
34 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
35 */
36
37/*
38 * Support routines to send messages to the Android in-kernel log buffer,
39 * which can later be accessed through the 'logcat' utility.
40 *
41 * Each log message must have
42 * - a priority
43 * - a log tag
44 * - some text
45 *
46 * The tag normally corresponds to the component that emits the log message,
47 * and should be reasonably small.
48 *
49 * Log message text may be truncated to less than an implementation-specific
50 * limit (e.g. 1023 characters max).
51 *
52 * Note that a newline character ("\n") will be appended automatically to your
53 * log message, if not already there. It is not possible to send several messages
54 * and have them appear on a single line in logcat.
55 *
56 * PLEASE USE LOGS WITH MODERATION:
57 *
58 * - Sending log messages eats CPU and slow down your application and the
59 * system.
60 *
61 * - The circular log buffer is pretty small (<64KB), sending many messages
62 * might push off other important log messages from the rest of the system.
63 *
64 * - In release builds, only send log messages to account for exceptional
65 * conditions.
66 *
67 * NOTE: These functions MUST be implemented by /system/lib/liblog.so
68 */
69
70#include <stdarg.h>
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
76/*
77 * Android log priority values, in ascending priority order.
78 */
79typedef enum android_LogPriority {
80 ANDROID_LOG_UNKNOWN = 0,
81 ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
82 ANDROID_LOG_VERBOSE,
83 ANDROID_LOG_DEBUG,
84 ANDROID_LOG_INFO,
85 ANDROID_LOG_WARN,
86 ANDROID_LOG_ERROR,
87 ANDROID_LOG_FATAL,
88 ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
89} android_LogPriority;
90
91/*
92 * Send a simple string to the log.
93 */
94int __android_log_write(int prio, const char* tag, const char* text);
95
96/*
97 * Send a formatted string to the log, used like printf(fmt,...)
98 */
99int __android_log_print(int prio, const char* tag, const char* fmt, ...)
100#if defined(__GNUC__)
101#ifdef __USE_MINGW_ANSI_STDIO
102#if __USE_MINGW_ANSI_STDIO
103 __attribute__ ((__format__(gnu_printf, 3, 4)))
104#else
105 __attribute__ ((__format__(printf, 3, 4)))
106#endif
107#else
108 __attribute__ ((__format__(printf, 3, 4)))
109#endif
110#endif
111 ;
112
113/*
114 * A variant of __android_log_print() that takes a va_list to list
115 * additional parameters.
116 */
117int __android_log_vprint(int prio, const char* tag,
118 const char* fmt, va_list ap)
119#if defined(__GNUC__)
120#ifdef __USE_MINGW_ANSI_STDIO
121#if __USE_MINGW_ANSI_STDIO
122 __attribute__ ((__format__(gnu_printf, 3, 0)))
123#else
124 __attribute__ ((__format__(printf, 3, 0)))
125#endif
126#else
127 __attribute__ ((__format__(printf, 3, 0)))
128#endif
129#endif
130 ;
131
132/*
133 * Log an assertion failure and abort the process to have a chance
134 * to inspect it if a debugger is attached. This uses the FATAL priority.
135 */
136void __android_log_assert(const char* cond, const char* tag,
137 const char* fmt, ...)
138#if defined(__GNUC__)
139 __attribute__ ((__noreturn__))
140#ifdef __USE_MINGW_ANSI_STDIO
141#if __USE_MINGW_ANSI_STDIO
142 __attribute__ ((__format__(gnu_printf, 3, 4)))
143#else
144 __attribute__ ((__format__(printf, 3, 4)))
145#endif
146#else
147 __attribute__ ((__format__(printf, 3, 4)))
148#endif
149#endif
150 ;
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif /* _ANDROID_LOG_H */
diff --git a/liblog/include/log/log.h b/liblog/include/log/log.h
index ece9ea6d1..37d30bc73 100644
--- a/liblog/include/log/log.h
+++ b/liblog/include/log/log.h
@@ -28,6 +28,7 @@
28#include <unistd.h> 28#include <unistd.h>
29 29
30#include <android/log.h> 30#include <android/log.h>
31#include <log/log_main.h>
31#include <log/uio.h> /* helper to define iovec for portability */ 32#include <log/uio.h> /* helper to define iovec for portability */
32 33
33#ifdef __cplusplus 34#ifdef __cplusplus
@@ -44,6 +45,22 @@ extern "C" {
44#define LOG_TAG NULL 45#define LOG_TAG NULL
45#endif 46#endif
46 47
48/*
49 * Normally we strip the effects of ALOGV (VERBOSE messages),
50 * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
51 * release builds be defining NDEBUG. You can modify this (for
52 * example with "#define LOG_NDEBUG 0" at the top of your source
53 * file) to change that behavior.
54 */
55
56#ifndef LOG_NDEBUG
57#ifdef NDEBUG
58#define LOG_NDEBUG 1
59#else
60#define LOG_NDEBUG 0
61#endif
62#endif
63
47/* --------------------------------------------------------------------- */ 64/* --------------------------------------------------------------------- */
48 65
49/* 66/*
diff --git a/include/android/log.h b/liblog/include/log/log_main.h
index 567335786..f45397ab8 100644
--- a/include/android/log.h
+++ b/liblog/include/log/log_main.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2009 The Android Open Source Project 2 * Copyright (C) 2005-2017 The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
@@ -14,88 +14,16 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17#ifndef _ANDROID_LOG_H 17#ifndef _LIBS_LOG_LOG_MAIN_H
18#define _ANDROID_LOG_H 18#define _LIBS_LOG_LOG_MAIN_H
19 19
20/****************************************************************** 20#include <android/log.h>
21 *
22 * IMPORTANT NOTICE:
23 *
24 * This file is part of Android's set of stable system headers
25 * exposed by the Android NDK (Native Development Kit) since
26 * platform release 1.5
27 *
28 * Third-party source AND binary code relies on the definitions
29 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
30 *
31 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
32 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
33 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
34 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
35 */
36
37/*
38 * Support routines to send messages to the Android in-kernel log buffer,
39 * which can later be accessed through the 'logcat' utility.
40 *
41 * Each log message must have
42 * - a priority
43 * - a log tag
44 * - some text
45 *
46 * The tag normally corresponds to the component that emits the log message,
47 * and should be reasonably small.
48 *
49 * Log message text may be truncated to less than an implementation-specific
50 * limit (e.g. 1023 characters max).
51 *
52 * Note that a newline character ("\n") will be appended automatically to your
53 * log message, if not already there. It is not possible to send several messages
54 * and have them appear on a single line in logcat.
55 *
56 * PLEASE USE LOGS WITH MODERATION:
57 *
58 * - Sending log messages eats CPU and slow down your application and the
59 * system.
60 *
61 * - The circular log buffer is pretty small (<64KB), sending many messages
62 * might push off other important log messages from the rest of the system.
63 *
64 * - In release builds, only send log messages to account for exceptional
65 * conditions.
66 *
67 * NOTE: These functions MUST be implemented by /system/lib/liblog.so
68 */
69
70#include <stdarg.h>
71 21
72#ifdef __cplusplus 22#ifdef __cplusplus
73extern "C" { 23extern "C" {
74#endif 24#endif
75 25
76/* 26/*
77 * This file uses ", ## __VA_ARGS__" zero-argument token pasting to
78 * work around issues with debug-only syntax errors in assertions
79 * that are missing format strings. See commit
80 * 19299904343daf191267564fe32e6cd5c165cd42
81 */
82#if defined(__clang__)
83#pragma clang diagnostic push
84#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
85#endif
86
87#ifndef __predict_false
88#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
89#endif
90
91/*
92 * LOG_TAG is the local tag used for the following simplified
93 * logging macros. You must set this preprocessor definition,
94 * or more tenuously supply a variable definition, before using
95 * the macros.
96 */
97
98/*
99 * Normally we strip the effects of ALOGV (VERBOSE messages), 27 * Normally we strip the effects of ALOGV (VERBOSE messages),
100 * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the 28 * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
101 * release builds be defining NDEBUG. You can modify this (for 29 * release builds be defining NDEBUG. You can modify this (for
@@ -111,52 +39,32 @@ extern "C" {
111#endif 39#endif
112#endif 40#endif
113 41
42/* --------------------------------------------------------------------- */
43
114/* 44/*
115 * Android log priority values, in ascending priority order. 45 * This file uses ", ## __VA_ARGS__" zero-argument token pasting to
46 * work around issues with debug-only syntax errors in assertions
47 * that are missing format strings. See commit
48 * 19299904343daf191267564fe32e6cd5c165cd42
116 */ 49 */
117#ifndef __android_LogPriority_defined 50#if defined(__clang__)
118#define __android_LogPriority_defined 51#pragma clang diagnostic push
119typedef enum android_LogPriority { 52#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
120 ANDROID_LOG_UNKNOWN = 0,
121 ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
122 ANDROID_LOG_VERBOSE,
123 ANDROID_LOG_DEBUG,
124 ANDROID_LOG_INFO,
125 ANDROID_LOG_WARN,
126 ANDROID_LOG_ERROR,
127 ANDROID_LOG_FATAL,
128 ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
129} android_LogPriority;
130#endif 53#endif
131 54
132/* 55#ifndef __predict_false
133 * Send a simple string to the log. 56#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
134 */ 57#endif
135int __android_log_write(int prio, const char* tag, const char* text);
136 58
137#define android_writeLog(prio, tag, text) \ 59#define android_writeLog(prio, tag, text) \
138 __android_log_write(prio, tag, text) 60 __android_log_write(prio, tag, text)
139 61
140/*
141 * Send a formatted string to the log, used like printf(fmt,...)
142 */
143int __android_log_print(int prio, const char* tag, const char* fmt, ...)
144#if defined(__GNUC__)
145#ifdef __USE_MINGW_ANSI_STDIO
146#if __USE_MINGW_ANSI_STDIO
147 __attribute__ ((format(gnu_printf, 3, 4)))
148#else
149 __attribute__ ((format(printf, 3, 4)))
150#endif
151#else
152 __attribute__ ((format(printf, 3, 4)))
153#endif
154#endif
155 ;
156
157#define android_printLog(prio, tag, ...) \ 62#define android_printLog(prio, tag, ...) \
158 __android_log_print(prio, tag, __VA_ARGS__) 63 __android_log_print(prio, tag, __VA_ARGS__)
159 64
65#define android_vprintLog(prio, cond, tag, ...) \
66 __android_log_vprint(prio, tag, __VA_ARGS__)
67
160/* 68/*
161 * Log macro that allows you to specify a number for the priority. 69 * Log macro that allows you to specify a number for the priority.
162 */ 70 */
@@ -166,28 +74,6 @@ int __android_log_print(int prio, const char* tag, const char* fmt, ...)
166#endif 74#endif
167 75
168/* 76/*
169 * A variant of __android_log_print() that takes a va_list to list
170 * additional parameters.
171 */
172int __android_log_vprint(int prio, const char* tag,
173 const char* fmt, va_list ap)
174#if defined(__GNUC__)
175#ifdef __USE_MINGW_ANSI_STDIO
176#if __USE_MINGW_ANSI_STDIO
177 __attribute__ ((format(gnu_printf, 3, 0)))
178#else
179 __attribute__ ((format(printf, 3, 0)))
180#endif
181#else
182 __attribute__ ((format(printf, 3, 0)))
183#endif
184#endif
185 ;
186
187#define android_vprintLog(prio, cond, tag, ...) \
188 __android_log_vprint(prio, tag, __VA_ARGS__)
189
190/*
191 * Log macro that allows you to pass in a varargs ("args" is a va_list). 77 * Log macro that allows you to pass in a varargs ("args" is a va_list).
192 */ 78 */
193#ifndef LOG_PRI_VA 79#ifndef LOG_PRI_VA
@@ -195,25 +81,7 @@ int __android_log_vprint(int prio, const char* tag,
195 android_vprintLog(priority, NULL, tag, fmt, args) 81 android_vprintLog(priority, NULL, tag, fmt, args)
196#endif 82#endif
197 83
198/* 84/* --------------------------------------------------------------------- */
199 * Log an assertion failure and abort the process to have a chance
200 * to inspect it if a debugger is attached. This uses the FATAL priority.
201 */
202void __android_log_assert(const char* cond, const char* tag,
203 const char* fmt, ...)
204#if defined(__GNUC__)
205 __attribute__ ((__noreturn__))
206#ifdef __USE_MINGW_ANSI_STDIO
207#if __USE_MINGW_ANSI_STDIO
208 __attribute__ ((format(gnu_printf, 3, 4)))
209#else
210 __attribute__ ((format(printf, 3, 4)))
211#endif
212#else
213 __attribute__ ((format(printf, 3, 4)))
214#endif
215#endif
216 ;
217 85
218/* XXX Macros to work around syntax errors in places where format string 86/* XXX Macros to work around syntax errors in places where format string
219 * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF 87 * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
@@ -524,4 +392,4 @@ int __android_log_is_loggable_len(int prio, const char* tag, size_t len,
524} 392}
525#endif 393#endif
526 394
527#endif /* _ANDROID_LOG_H */ 395#endif /* _LIBS_LOG_LOG_MAIN_H */
diff --git a/liblog/include_vndk/android b/liblog/include_vndk/android
index 69fbc0947..a3c0320f9 120000
--- a/liblog/include_vndk/android
+++ b/liblog/include_vndk/android
@@ -1 +1 @@
../../include/android/ \ No newline at end of file ../include/android \ No newline at end of file
diff --git a/liblog/include_vndk/log/log.h b/liblog/include_vndk/log/log.h
index f3eb3fe14..5d720f6d1 100644
--- a/liblog/include_vndk/log/log.h
+++ b/liblog/include_vndk/log/log.h
@@ -4,6 +4,7 @@
4#define _LIBS_LOG_LOG_H 4#define _LIBS_LOG_LOG_H
5 5
6#include <android/log.h> 6#include <android/log.h>
7#include <log/log_main.h>
7 8
8/*The following files will be included once they are available*/ 9/*The following files will be included once they are available*/
9/*#include <log/log_id.h>*/ 10/*#include <log/log_id.h>*/
diff --git a/liblog/include_vndk/log/log_main.h b/liblog/include_vndk/log/log_main.h
new file mode 120000
index 000000000..f2ec01835
--- /dev/null
+++ b/liblog/include_vndk/log/log_main.h
@@ -0,0 +1 @@
../../include/log/log_main.h \ No newline at end of file