OSDN Git Service

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