4 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef __CALENDAR_SERVICE_INTERNAL_H__
20 #define __CALENDAR_SERVICE_INTERNAL_H__
26 #define API __attribute__ ((visibility("default")))
29 #define SAFE_STRDUP(src) (src) ? strdup((char *)src) : NULL
33 #define LOG_TAG "CALENDAR_SVC"
36 #define COLOR_RED "\033[0;31m"
37 #define COLOR_GREEN "\033[0;32m"
38 #define COLOR_BROWN "\033[0;33m"
39 #define COLOR_BLUE "\033[0;34m"
40 #define COLOR_PURPLE "\033[0;35m"
41 #define COLOR_CYAN "\033[0;36m"
42 #define COLOR_END "\033[0;m"
44 #if defined(CAL_IPC_SERVER)
45 #define IPC_ROLE COLOR_BLUE"[SERVER]"COLOR_END
46 #elif defined(CAL_IPC_CLIENT)
47 #define IPC_ROLE COLOR_BROWN"[CLIENT]"COLOR_END
49 #define IPC_ROLE COLOR_GREEN"[LIB]"COLOR_END
53 #define INFO(fmt, arg...) SLOGI(IPC_ROLE" "fmt, ##arg)
54 #define ERR(fmt, arg...) SLOGE(IPC_ROLE" "fmt, ##arg)
55 #define DBG(fmt, arg...) SLOGD(IPC_ROLE" "fmt, ##arg)
56 #define WARN(fmt, arg...) SLOGD(IPC_ROLE" "fmt, ##arg)
57 #define VERBOSE(fmt, arg...) SLOGV(IPC_ROLE" "fmt, ##arg)
58 #else /* CAL_DEBUGGING */
59 #define INFO(fmt, arg...)
60 #define ERR(fmt, arg...)
61 #define DBG(fmt, arg...)
62 #define WARN(fmt, arg...)
63 #define VERBOSE(fmt, arg...)
64 #endif /* CAL_DEBUGGING */
66 #define SEC_INFO(fmt, arg...) SECURE_LOGI(fmt, ##arg)
67 #define SEC_ERR(fmt, arg...) SECURE_LOGE(fmt, ##arg)
68 #define SEC_DBG(fmt, arg...) SECURE_LOGD(fmt, ##arg)
69 #define SECURE(fmt, arg...) SECURE_LOGD(fmt, ##arg)
71 #define CAL_FN_CALL() DBG(">>>>>>>> called")
72 #define CAL_FN_END() DBG("<<<<<<<< ended")
73 #define CAL_DBG(fmt, arg...) DBG(fmt, ##arg)
74 #define CAL_WARN(fmt, arg...) WARN(fmt, ##arg)
75 #define CAL_ERR(fmt, arg...) ERR(fmt, ##arg)
76 #define CAL_INFO(fmt, arg...) INFO(fmt, ##arg)
77 #define CAL_VERBOSE(fmt, arg...) VERBOSE(fmt, ##arg)
79 #define WARN_IF(expr, fmt, arg...) do { \
84 #define RET_IF(expr) do { \
90 #define RETV_IF(expr, val) do { \
96 #define RETM_IF(expr, fmt, arg...) do { \
102 #define RETVM_IF(expr, val, fmt, arg...) do { \
108 #define BREAK_IF(expr, fmt, arg...) do { \
115 #define CAL_START_TIMESTAMP struct timeval timeval_s = {0}; \
116 struct timeval timeval_e = {0}; \
117 struct timeval timeval_d = {0}; \
118 DBG(COLOR_PURPLE">>>>>"COLOR_END); \
119 gettimeofday(&timeval_s, NULL);
121 #define CAL_PRINT_TIMESTAMP gettimeofday(&timeval_e, NULL); \
122 timersub(&timeval_e, &timeval_s, &timeval_d); \
123 timeval_s = timeval_e; \
124 DBG(COLOR_PURPLE"<<<<< (%03d.%03dsec)"COLOR_END, timeval_d.tv_sec % 1000, timeval_d.tv_usec/1000);
128 #define CAL_PROFILE_GET_TIME() (clock() / (CLOCKS_PER_SEC / 1000));
129 #define CAL_PROFILE_PRINT(starttime, endtime) ERR("%ld ~ %ld : %ld(%d sec) msec", starttime, endtime, endtime-starttime, (endtime-starttime)/1000);
131 #define CAL_PROFILE_GET_TIME(input_time) 0
132 #define CAL_PROFILE_PRINT(starttime, endtime)
135 #define CAL_FREE(ptr) \
143 /* Thread-local storage */
144 #if defined(CAL_IPC_SERVER)
146 #elif defined(CAL_IPC_CLIENT)
148 #else /* CAL_NATIVE */
152 #endif /* __CALENDAR_SERVICE_INTERNAL_H__ */