4 * Copyright (c) 2010 - 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.
20 #ifndef __CTSVC_INTERNAL_H__
21 #define __CTSVC_INTERNAL_H__
26 #include "contacts_errors.h"
27 #include "ctsvc_struct.h"
28 #include "ctsvc_view.h"
30 /*#define CONTACTS_DEBUGGING */
31 /*#define CONTACTS_TIMECHECK */
33 #define LOG_TAG "CONTACTS_SERVICE"
36 #if defined(_CONTACTS_IPC_SERVER)
37 #define IPC_ROLE "[SERVER]"
38 #elif defined(_CONTACTS_IPC_CLIENT)
39 #define IPC_ROLE "[CLIENT]"
41 #define IPC_ROLE "[LIB]"
44 #define CTS_LOG_RED "\033[0;31m"
45 #define CTS_LOG_GREEN "\033[0;32m"
46 #define CTS_LOG_BROWN "\033[0;33m"
47 #define CTS_LOG_BLUE "\033[0;34m"
48 #define CTS_LOG_END "\033[0;m"
50 #define _INFO(fmt, arg...) SLOGI(CTS_LOG_GREEN IPC_ROLE CTS_LOG_END fmt, ##arg)
51 #define _ERR(fmt, arg...) SLOGE(CTS_LOG_GREEN IPC_ROLE CTS_LOG_END fmt, ##arg)
52 #define _DBG(fmt, arg...) SLOGD(CTS_LOG_GREEN IPC_ROLE CTS_LOG_END fmt, ##arg)
53 #define _WARN(fmt, arg...) SLOGW(CTS_LOG_GREEN IPC_ROLE CTS_LOG_END fmt, ##arg)
55 #define DEPRECATED_STRING_FORMAT "DEPRECATION WARNING: %s is deprecated and will be removed from next release."
57 #ifdef CONTACTS_DEBUGGING
59 #define CTS_FN_CALL _DBG(">>>>>>>> called")
60 #define CTS_FN_END _DBG("<<<<<<<< ended")
62 #define DBG(fmt, arg...) _DBG(fmt, ##arg)
63 #define WARN(fmt, arg...) _WARN(CTS_LOG_BROWN fmt CTS_LOG_END, ##arg)
64 #define ERR(fmt, arg...) _ERR(CTS_LOG_RED fmt CTS_LOG_END, ##arg)
65 #define INFO(fmt, arg...) _INFO(CTS_LOG_BLUE fmt CTS_LOG_END, ##arg)
67 #else /* CONTACTS_DEBUGGING */
71 #define DBG(fmt, arg...)
72 #define WARN(fmt, arg...) _WARN(fmt, ##arg)
73 #define ERR(fmt, arg...) _ERR(fmt, ##arg)
74 #define INFO(fmt, arg...) _INFO(fmt, ##arg)
76 #define G_DISABLE_ASSERT
77 #endif /* CONTACTS_DEBUGGING */
79 #define RET_IF(expr) \
87 #define RETV_IF(expr, val) \
95 #define RETM_IF(expr, fmt, arg...) \
103 #define RETVM_IF(expr, val, fmt, arg...) \
111 #define WARN_IF(expr, fmt, arg...) \
119 /* TO DISABLE THIS MACRO, DEFINE "G_DISABLE_ASSERT" */
120 #define ASSERT_NOT_REACHED(fmt, arg...) do { \
122 assert(!"DO NOT REACH HERE!"); \
126 /* Thread-local storage */
127 #ifdef _CONTACTS_IPC_SERVER
129 #elif _CONTACTS_IPC_CLIENT
131 #else /* _CONTACTS_NATIVE */
135 #endif /* __CTSVC_INTERNAL_H__ */