1 /* 2 ** Copyright 2008, Google Inc. 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 DEBUG_H 18 #define DEBUG_H 19 20 #include <stdio.h> 21 22 #define LOG_TAG "RPC" 23 #include <utils/Log.h> 24 25 #if 1 26 #define PRINT(x...) do { \ 27 fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \ 28 fprintf(stdout, ##x); \ 29 } while(0) 30 #else 31 #define PRINT(x...) do { \ 32 fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \ 33 fprintf(stdout, ##x); \ 34 LOGI(x); \ 35 } while(0) 36 #endif 37 38 #ifdef DEBUG 39 #define D PRINT 40 #else 41 #define D(x...) do { } while(0) 42 #endif 43 44 #ifdef VERBOSE 45 #define V PRINT 46 #else 47 #define V(x...) do { } while(0) 48 #endif 49 50 #define E(x...) do { \ 51 fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \ 52 fprintf(stderr, ##x); \ 53 LOGE(x); \ 54 } while(0) 55 56 #define FAILIF(cond, msg...) do { \ 57 if (__builtin_expect (cond, 0)) { \ 58 fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \ 59 fprintf(stderr, ##msg); \ 60 } \ 61 } while(0) 62 63 #endif/*DEBUG_H*/ 64