1 /**************************************************************************
5 * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved.
7 * Contact: SooChan Lim <sc1.lim@samsung.com>,
8 * Junkyeong Kim <jk0430.kim@samsung.com>,
9 * Shawn Lee <shiin.lee@samsung.com>,
10 * Changyeon Lee <cyeon.lee@samsung.com>,
11 * Joonbum Ko <joonbum.ko@samsung.com>
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sub license, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
28 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
29 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 **************************************************************************/
38 #include <sys/syscall.h>
43 void hal_tdm_log_print(int level, const char *fmt, ...);
45 #define HAL_TDM_DBG(fmt, args...) \
48 clock_gettime(CLOCK_MONOTONIC, &ts); \
49 hal_tdm_log_print(HAL_TDM_LOG_LEVEL_DBG, "[%5d.%06d][%d][%s %d]"fmt, \
50 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
51 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
54 #define HAL_TDM_INFO(fmt, args...) \
57 clock_gettime(CLOCK_MONOTONIC, &ts); \
58 hal_tdm_log_print(HAL_TDM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \
59 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
60 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
63 #define HAL_TDM_WRN(fmt, args...) \
66 clock_gettime(CLOCK_MONOTONIC, &ts); \
67 hal_tdm_log_print(HAL_TDM_LOG_LEVEL_WRN, "[%5d.%06d][%d][%s %d]"fmt, \
68 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
69 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
72 #define HAL_TDM_ERR(fmt, args...) \
75 clock_gettime(CLOCK_MONOTONIC, &ts); \
76 hal_tdm_log_print(HAL_TDM_LOG_LEVEL_ERR, "[%5d.%06d][%d][%s %d]"fmt, \
77 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
78 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
81 #define HAL_TDM_RETURN_IF_FAIL(cond) {\
83 HAL_TDM_ERR("'%s' failed.\n", #cond);\
87 #define HAL_TDM_RETURN_VAL_IF_FAIL(cond, val) {\
89 HAL_TDM_ERR("'%s' failed.\n", #cond);\
93 #define HAL_TDM_GOTO_VAL_IF_FAIL(cond, val) {\
95 HAL_TDM_ERR("'%s' failed.\n", #cond);\
101 HAL_TDM_LOG_LEVEL_NONE,
102 HAL_TDM_LOG_LEVEL_ERR,
103 HAL_TDM_LOG_LEVEL_WRN,
104 HAL_TDM_LOG_LEVEL_INFO,
105 HAL_TDM_LOG_LEVEL_DBG,
108 #endif /* __COMMON_H__ */