b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /******************************************************************************
|
| 2 | *(C) Copyright 2014 Marvell International Ltd.
|
| 3 | * All Rights Reserved
|
| 4 | ******************************************************************************/
|
| 5 | /* -------------------------------------------------------------------------------------------------------------------
|
| 6 | *
|
| 7 | * Filename: gps_utils.h
|
| 8 | *
|
| 9 | * Description: gps interface to ubus
|
| 10 | *
|
| 11 | * HISTORY:
|
| 12 | * Nov 23, 2014 - Initial Version
|
| 13 | *
|
| 14 | * Notes:
|
| 15 | *
|
| 16 | ******************************************************************************/
|
| 17 |
|
| 18 | #ifndef __GPS_UTILS_H__
|
| 19 | #define __GPS_UTILS_H__
|
| 20 |
|
| 21 | #ifndef __maybe_unused
|
| 22 | #define __maybe_unused __attribute__((unused))
|
| 23 | #endif
|
| 24 |
|
| 25 | #define GPS_LOG_TAG "GPS"
|
| 26 | #define LOG_BUF_SIZE 1024
|
| 27 |
|
| 28 | #define TRUE (1)
|
| 29 | #define FALSE (0)
|
| 30 |
|
| 31 | #ifndef ARRAY_SIZE
|
| 32 | #define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0]))
|
| 33 | #endif /* ARRAY_SIZE */
|
| 34 |
|
| 35 | #ifndef MIN
|
| 36 | #define MIN(x,y) ((x)<(y)?(x):(y))
|
| 37 | #endif
|
| 38 |
|
| 39 | #ifndef MAX
|
| 40 | #define MAX(x,y) ((x)>(y)?(x):(y))
|
| 41 | #endif
|
| 42 |
|
| 43 | #define UNUSED(x) ((void)(x))
|
| 44 |
|
| 45 | #ifdef GPS_LOGCAT
|
| 46 | #include <include/log.h>
|
| 47 | #define ENTER() RDBGMSG("libgps ENTER %s:%d", __func__, __LINE__)
|
| 48 | #define EXIT() RDBGMSG("libgps EXIT %s:%d", __func__, __LINE__)
|
| 49 | #define TRACE() RDBGMSG("libgps TRACE %s:%d", __func__, __LINE__)
|
| 50 | #define GPS_DMSG(fmt, args...) RDBGMSG("libgps %s:%d: "fmt, __func__, __LINE__ , ##args)
|
| 51 | #define GPS_EMSG(fmt, args...) RERRMSG("libgps %s:%d: "fmt, __func__,__LINE__ , ##args)
|
| 52 | #define GPS_WMSG(fmt, args...) RWARNMSG("libgps %s:%d: "fmt, __func__,__LINE__, ##args)
|
| 53 | #define GPS_IMSG(fmt, args...) RDPRINTF("libgps %s:%d: "fmt, __func__,__LINE__, ##args)
|
| 54 | #define MASSERT(cond, args...) \
|
| 55 | do {\
|
| 56 | if (!(cond)) { \
|
| 57 | RERRMSG("libgps %s:%d: ASSERT !!!\n", __FILE__,__LINE__, ##args);\
|
| 58 | fprintf(stderr, "libgps %s:%d: ASSERT !!!\n", __FILE__,__LINE__);\
|
| 59 | raise(SIGUSR1);\
|
| 60 | }\
|
| 61 | } while(0);
|
| 62 |
|
| 63 | #define GPS_LOG_INIT() set_service_log_tag(GPS_LOG_TAG);
|
| 64 |
|
| 65 | #else
|
| 66 |
|
| 67 | #define ENTER() __gps_log_print("libgps ENTER %s:%d", __func__, __LINE__)
|
| 68 | #define EXIT() __gps_log_print("libgps EXIT %s:%d", __func__, __LINE__)
|
| 69 | #define TRACE() __gps_log_print("libgps TRACE %s:%d", __func__, __LINE__)
|
| 70 | #define GPS_DMSG(fmt, args...) __gps_log_print("libgps %s:%d: DEBUG: "fmt, __func__, __LINE__, ##args)
|
| 71 | #define GPS_EMSG(fmt, args...) __gps_log_print("libgps %s:%d: ERROR: "fmt, __func__, __LINE__, ##args)
|
| 72 | #define GPS_WMSG(fmt, args...) __gps_log_print("libgps %s:%d: WARNING: "fmt, __func__, __LINE__, ##args)
|
| 73 | #define GPS_IMSG(fmt, args...) __gps_log_print("libgps %s:%d: INFO: "fmt, __func__, __LINE__, ##args)
|
| 74 | #define MASSERT(cond, args...)\
|
| 75 | do { \
|
| 76 | if (!(cond)) { \
|
| 77 | __gps_log_print("libgps %s:%d: ASSERT !!!\n", __FILE__,__LINE__, ##args); \
|
| 78 | raise(SIGUSR1);\
|
| 79 | } \
|
| 80 | } while (0);
|
| 81 | #define GPS_LOG_INIT()
|
| 82 | #endif
|
| 83 |
|
| 84 | int __gps_log_print(const char *fmt, ...);
|
| 85 |
|
| 86 |
|
| 87 | #endif //__GPS_UTILS_H__
|