/****************************************************************************** | |
*(C) Copyright 2014 Marvell International Ltd. | |
* All Rights Reserved | |
******************************************************************************/ | |
/* ------------------------------------------------------------------------------------------------------------------- | |
* | |
* Filename: gps_utils.h | |
* | |
* Description: gps interface to ubus | |
* | |
* HISTORY: | |
* Nov 23, 2014 - Initial Version | |
* | |
* Notes: | |
* | |
******************************************************************************/ | |
#ifndef __GPS_UTILS_H__ | |
#define __GPS_UTILS_H__ | |
#ifndef __maybe_unused | |
#define __maybe_unused __attribute__((unused)) | |
#endif | |
#define GPS_LOG_TAG "GPS" | |
#define LOG_BUF_SIZE 1024 | |
#define TRUE (1) | |
#define FALSE (0) | |
#ifndef ARRAY_SIZE | |
#define ARRAY_SIZE(_A) (sizeof(_A) / sizeof((_A)[0])) | |
#endif /* ARRAY_SIZE */ | |
#ifndef MIN | |
#define MIN(x,y) ((x)<(y)?(x):(y)) | |
#endif | |
#ifndef MAX | |
#define MAX(x,y) ((x)>(y)?(x):(y)) | |
#endif | |
#define UNUSED(x) ((void)(x)) | |
#ifdef GPS_LOGCAT | |
#include <include/log.h> | |
#define ENTER() RDBGMSG("libgps ENTER %s:%d", __func__, __LINE__) | |
#define EXIT() RDBGMSG("libgps EXIT %s:%d", __func__, __LINE__) | |
#define TRACE() RDBGMSG("libgps TRACE %s:%d", __func__, __LINE__) | |
#define GPS_DMSG(fmt, args...) RDBGMSG("libgps %s:%d: "fmt, __func__, __LINE__ , ##args) | |
#define GPS_EMSG(fmt, args...) RERRMSG("libgps %s:%d: "fmt, __func__,__LINE__ , ##args) | |
#define GPS_WMSG(fmt, args...) RWARNMSG("libgps %s:%d: "fmt, __func__,__LINE__, ##args) | |
#define GPS_IMSG(fmt, args...) RDPRINTF("libgps %s:%d: "fmt, __func__,__LINE__, ##args) | |
#define MASSERT(cond, args...) \ | |
do {\ | |
if (!(cond)) { \ | |
RERRMSG("libgps %s:%d: ASSERT !!!\n", __FILE__,__LINE__, ##args);\ | |
fprintf(stderr, "libgps %s:%d: ASSERT !!!\n", __FILE__,__LINE__);\ | |
raise(SIGUSR1);\ | |
}\ | |
} while(0); | |
#define GPS_LOG_INIT() set_service_log_tag(GPS_LOG_TAG); | |
#else | |
#define ENTER() __gps_log_print("libgps ENTER %s:%d", __func__, __LINE__) | |
#define EXIT() __gps_log_print("libgps EXIT %s:%d", __func__, __LINE__) | |
#define TRACE() __gps_log_print("libgps TRACE %s:%d", __func__, __LINE__) | |
#define GPS_DMSG(fmt, args...) __gps_log_print("libgps %s:%d: DEBUG: "fmt, __func__, __LINE__, ##args) | |
#define GPS_EMSG(fmt, args...) __gps_log_print("libgps %s:%d: ERROR: "fmt, __func__, __LINE__, ##args) | |
#define GPS_WMSG(fmt, args...) __gps_log_print("libgps %s:%d: WARNING: "fmt, __func__, __LINE__, ##args) | |
#define GPS_IMSG(fmt, args...) __gps_log_print("libgps %s:%d: INFO: "fmt, __func__, __LINE__, ##args) | |
#define MASSERT(cond, args...)\ | |
do { \ | |
if (!(cond)) { \ | |
__gps_log_print("libgps %s:%d: ASSERT !!!\n", __FILE__,__LINE__, ##args); \ | |
raise(SIGUSR1);\ | |
} \ | |
} while (0); | |
#define GPS_LOG_INIT() | |
#endif | |
int __gps_log_print(const char *fmt, ...); | |
#endif //__GPS_UTILS_H__ |