1 /**************************************************************************
5 * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
7 * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
8 * JinYoung Jeon <jy0.jeon@samsung.com>,
9 * Taeheon Kim <th908.kim@samsung.com>,
10 * YoungJun Cho <yj44.cho@samsung.com>,
11 * SooChan Lim <sc1.lim@samsung.com>,
12 * Boram Park <sc1.lim@samsung.com>
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sub license, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
30 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 **************************************************************************/
42 #include <sys/types.h>
52 #if defined(__GNUC__) && __GNUC__ >= 4
53 #define EXTERN __attribute__ ((visibility("default")))
58 #if defined(__GNUC__) && __GNUC__ >= 4
59 #define INTERN __attribute__ ((visibility("hidden")))
64 #if defined(__GNUC__) && __GNUC__ >= 4
65 #define DEPRECATED __attribute__ ((deprecated))
71 #define TDM_RETURN_IF_FAIL(cond) { \
73 TDM_ERR("'%s' failed", #cond); \
77 #define TDM_RETURN_VAL_IF_FAIL(cond, val) { \
79 TDM_ERR("'%s' failed", #cond); \
83 #define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) { \
85 TDM_ERR("'%s' failed", #cond); \
87 if (error) *error = ret; \
92 #define TDM_WARNING_IF_FAIL(cond) { \
94 TDM_ERR("'%s' failed", #cond); \
96 #define TDM_GOTO_IF_FAIL(cond, dst) { \
98 TDM_ERR("'%s' failed", #cond); \
103 #define TDM_NEVER_GET_HERE() TDM_ERR("** NEVER GET HERE **")
105 #define TDM_SNPRINTF(p, len, fmt, ARG...) \
107 if (p && len && *len > 0) { \
108 int s = snprintf(p, *len, fmt, ##ARG); \
114 #define C(b, m) (((b) >> (m)) & 0xFF)
115 #define B(c, s) ((((unsigned int)(c)) & 0xff) << (s))
116 #define FOURCC(a, b, c, d) (B(d, 24) | B(c, 16) | B(b, 8) | B(a, 0))
117 #define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24)
118 #define FOURCC_ID(str) FOURCC(((char*)str)[0], ((char*)str)[1], ((char*)str)[2], ((char*)str)[3])
124 #endif /* _TDM_MACRO_H_ */