1*598139dcSAndroid Build Coastguard Worker /* 2*598139dcSAndroid Build Coastguard Worker * Copyright (C) 2005-2017 The Android Open Source Project 3*598139dcSAndroid Build Coastguard Worker * 4*598139dcSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*598139dcSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*598139dcSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*598139dcSAndroid Build Coastguard Worker * 8*598139dcSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*598139dcSAndroid Build Coastguard Worker * 10*598139dcSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*598139dcSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*598139dcSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*598139dcSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*598139dcSAndroid Build Coastguard Worker * limitations under the License. 15*598139dcSAndroid Build Coastguard Worker */ 16*598139dcSAndroid Build Coastguard Worker 17*598139dcSAndroid Build Coastguard Worker #pragma once 18*598139dcSAndroid Build Coastguard Worker 19*598139dcSAndroid Build Coastguard Worker #include <android/log.h> 20*598139dcSAndroid Build Coastguard Worker 21*598139dcSAndroid Build Coastguard Worker /* 22*598139dcSAndroid Build Coastguard Worker * Normally we strip the effects of ALOGV (VERBOSE messages), 23*598139dcSAndroid Build Coastguard Worker * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the 24*598139dcSAndroid Build Coastguard Worker * release builds be defining NDEBUG. You can modify this (for 25*598139dcSAndroid Build Coastguard Worker * example with "#define LOG_NDEBUG 0" at the top of your source 26*598139dcSAndroid Build Coastguard Worker * file) to change that behavior. 27*598139dcSAndroid Build Coastguard Worker */ 28*598139dcSAndroid Build Coastguard Worker 29*598139dcSAndroid Build Coastguard Worker #ifndef LOG_NDEBUG 30*598139dcSAndroid Build Coastguard Worker #ifdef NDEBUG 31*598139dcSAndroid Build Coastguard Worker #define LOG_NDEBUG 1 32*598139dcSAndroid Build Coastguard Worker #else 33*598139dcSAndroid Build Coastguard Worker #define LOG_NDEBUG 0 34*598139dcSAndroid Build Coastguard Worker #endif 35*598139dcSAndroid Build Coastguard Worker #endif 36*598139dcSAndroid Build Coastguard Worker 37*598139dcSAndroid Build Coastguard Worker /* --------------------------------------------------------------------- */ 38*598139dcSAndroid Build Coastguard Worker 39*598139dcSAndroid Build Coastguard Worker #ifndef __predict_false 40*598139dcSAndroid Build Coastguard Worker #define __predict_false(exp) __builtin_expect((exp) != 0, 0) 41*598139dcSAndroid Build Coastguard Worker #endif 42*598139dcSAndroid Build Coastguard Worker 43*598139dcSAndroid Build Coastguard Worker /* 44*598139dcSAndroid Build Coastguard Worker * Simplified macro to send a verbose radio log message using current LOG_TAG. 45*598139dcSAndroid Build Coastguard Worker */ 46*598139dcSAndroid Build Coastguard Worker #ifndef RLOGV 47*598139dcSAndroid Build Coastguard Worker #define __RLOGV(...) \ 48*598139dcSAndroid Build Coastguard Worker ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, \ 49*598139dcSAndroid Build Coastguard Worker __VA_ARGS__)) 50*598139dcSAndroid Build Coastguard Worker #if LOG_NDEBUG 51*598139dcSAndroid Build Coastguard Worker #define RLOGV(...) \ 52*598139dcSAndroid Build Coastguard Worker do { \ 53*598139dcSAndroid Build Coastguard Worker if (0) { \ 54*598139dcSAndroid Build Coastguard Worker __RLOGV(__VA_ARGS__); \ 55*598139dcSAndroid Build Coastguard Worker } \ 56*598139dcSAndroid Build Coastguard Worker } while (0) 57*598139dcSAndroid Build Coastguard Worker #else 58*598139dcSAndroid Build Coastguard Worker #define RLOGV(...) __RLOGV(__VA_ARGS__) 59*598139dcSAndroid Build Coastguard Worker #endif 60*598139dcSAndroid Build Coastguard Worker #endif 61*598139dcSAndroid Build Coastguard Worker 62*598139dcSAndroid Build Coastguard Worker #ifndef RLOGV_IF 63*598139dcSAndroid Build Coastguard Worker #if LOG_NDEBUG 64*598139dcSAndroid Build Coastguard Worker #define RLOGV_IF(cond, ...) ((void)0) 65*598139dcSAndroid Build Coastguard Worker #else 66*598139dcSAndroid Build Coastguard Worker #define RLOGV_IF(cond, ...) \ 67*598139dcSAndroid Build Coastguard Worker ((__predict_false(cond)) \ 68*598139dcSAndroid Build Coastguard Worker ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, \ 69*598139dcSAndroid Build Coastguard Worker LOG_TAG, __VA_ARGS__)) \ 70*598139dcSAndroid Build Coastguard Worker : (void)0) 71*598139dcSAndroid Build Coastguard Worker #endif 72*598139dcSAndroid Build Coastguard Worker #endif 73*598139dcSAndroid Build Coastguard Worker 74*598139dcSAndroid Build Coastguard Worker /* 75*598139dcSAndroid Build Coastguard Worker * Simplified macro to send a debug radio log message using current LOG_TAG. 76*598139dcSAndroid Build Coastguard Worker */ 77*598139dcSAndroid Build Coastguard Worker #ifndef RLOGD 78*598139dcSAndroid Build Coastguard Worker #define RLOGD(...) \ 79*598139dcSAndroid Build Coastguard Worker ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, \ 80*598139dcSAndroid Build Coastguard Worker __VA_ARGS__)) 81*598139dcSAndroid Build Coastguard Worker #endif 82*598139dcSAndroid Build Coastguard Worker 83*598139dcSAndroid Build Coastguard Worker #ifndef RLOGD_IF 84*598139dcSAndroid Build Coastguard Worker #define RLOGD_IF(cond, ...) \ 85*598139dcSAndroid Build Coastguard Worker ((__predict_false(cond)) \ 86*598139dcSAndroid Build Coastguard Worker ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, \ 87*598139dcSAndroid Build Coastguard Worker LOG_TAG, __VA_ARGS__)) \ 88*598139dcSAndroid Build Coastguard Worker : (void)0) 89*598139dcSAndroid Build Coastguard Worker #endif 90*598139dcSAndroid Build Coastguard Worker 91*598139dcSAndroid Build Coastguard Worker /* 92*598139dcSAndroid Build Coastguard Worker * Simplified macro to send an info radio log message using current LOG_TAG. 93*598139dcSAndroid Build Coastguard Worker */ 94*598139dcSAndroid Build Coastguard Worker #ifndef RLOGI 95*598139dcSAndroid Build Coastguard Worker #define RLOGI(...) \ 96*598139dcSAndroid Build Coastguard Worker ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, \ 97*598139dcSAndroid Build Coastguard Worker __VA_ARGS__)) 98*598139dcSAndroid Build Coastguard Worker #endif 99*598139dcSAndroid Build Coastguard Worker 100*598139dcSAndroid Build Coastguard Worker #ifndef RLOGI_IF 101*598139dcSAndroid Build Coastguard Worker #define RLOGI_IF(cond, ...) \ 102*598139dcSAndroid Build Coastguard Worker ((__predict_false(cond)) \ 103*598139dcSAndroid Build Coastguard Worker ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, \ 104*598139dcSAndroid Build Coastguard Worker LOG_TAG, __VA_ARGS__)) \ 105*598139dcSAndroid Build Coastguard Worker : (void)0) 106*598139dcSAndroid Build Coastguard Worker #endif 107*598139dcSAndroid Build Coastguard Worker 108*598139dcSAndroid Build Coastguard Worker /* 109*598139dcSAndroid Build Coastguard Worker * Simplified macro to send a warning radio log message using current LOG_TAG. 110*598139dcSAndroid Build Coastguard Worker */ 111*598139dcSAndroid Build Coastguard Worker #ifndef RLOGW 112*598139dcSAndroid Build Coastguard Worker #define RLOGW(...) \ 113*598139dcSAndroid Build Coastguard Worker ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, \ 114*598139dcSAndroid Build Coastguard Worker __VA_ARGS__)) 115*598139dcSAndroid Build Coastguard Worker #endif 116*598139dcSAndroid Build Coastguard Worker 117*598139dcSAndroid Build Coastguard Worker #ifndef RLOGW_IF 118*598139dcSAndroid Build Coastguard Worker #define RLOGW_IF(cond, ...) \ 119*598139dcSAndroid Build Coastguard Worker ((__predict_false(cond)) \ 120*598139dcSAndroid Build Coastguard Worker ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, \ 121*598139dcSAndroid Build Coastguard Worker LOG_TAG, __VA_ARGS__)) \ 122*598139dcSAndroid Build Coastguard Worker : (void)0) 123*598139dcSAndroid Build Coastguard Worker #endif 124*598139dcSAndroid Build Coastguard Worker 125*598139dcSAndroid Build Coastguard Worker /* 126*598139dcSAndroid Build Coastguard Worker * Simplified macro to send an error radio log message using current LOG_TAG. 127*598139dcSAndroid Build Coastguard Worker */ 128*598139dcSAndroid Build Coastguard Worker #ifndef RLOGE 129*598139dcSAndroid Build Coastguard Worker #define RLOGE(...) \ 130*598139dcSAndroid Build Coastguard Worker ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, \ 131*598139dcSAndroid Build Coastguard Worker __VA_ARGS__)) 132*598139dcSAndroid Build Coastguard Worker #endif 133*598139dcSAndroid Build Coastguard Worker 134*598139dcSAndroid Build Coastguard Worker #ifndef RLOGE_IF 135*598139dcSAndroid Build Coastguard Worker #define RLOGE_IF(cond, ...) \ 136*598139dcSAndroid Build Coastguard Worker ((__predict_false(cond)) \ 137*598139dcSAndroid Build Coastguard Worker ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, \ 138*598139dcSAndroid Build Coastguard Worker LOG_TAG, __VA_ARGS__)) \ 139*598139dcSAndroid Build Coastguard Worker : (void)0) 140*598139dcSAndroid Build Coastguard Worker #endif 141