OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / hardware / qcom / gps / loc_api / libloc_api-rpc / inc / debug.h
1 /*
2 Copyright (c) 2009, QUALCOMM USA, INC.
3
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
8 ·         Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
9
10 ·         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. 
11
12 ·         Neither the name of the QUALCOMM USA, INC.  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
13
14 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 HOLDER 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.
15 */
16
17 #ifndef DEBUG_H
18 #define DEBUG_H
19
20 #include <stdio.h>
21
22 #define LOG_TAG "libgps-rpc"
23 #include <utils/Log.h>
24
25 #define PRINT(x...) do {                                    \
26         fprintf(stdout, "%s(%d) ", __FUNCTION__, __LINE__); \
27         fprintf(stdout, ##x);                               \
28         LOGD(x);                               \
29     } while(0)
30
31 #ifdef DEBUG
32 #define D PRINT
33 #else
34 #define D(x...) do { } while(0)
35 #endif
36
37 #ifdef VERBOSE
38 #define V PRINT
39 #else
40 #define V(x...) do { } while(0)
41 #endif
42
43 #define E(x...) do {                                        \
44         fprintf(stderr, "%s(%d) ", __FUNCTION__, __LINE__); \
45         fprintf(stderr, ##x);                               \
46         LOGE(x);                                            \
47     } while(0)
48
49 #define FAILIF(cond, msg...) do {                                              \
50         if (__builtin_expect (cond, 0)) {                                      \
51             fprintf(stderr, "%s:%s:(%d): ", __FILE__, __FUNCTION__, __LINE__); \
52             fprintf(stderr, ##msg);                                            \
53             LOGE(##msg);                                                       \
54         }                                                                      \
55     } while(0)
56
57 #endif/*DEBUG_H*/