tizen 2.3 release
[framework/system/deviced.git] / src / logd / src / shared / macro.h
1 #ifndef _LOGD_MACRO_H_
2 #define _LOGD_MACRO_H_
3
4 #include <time.h>
5 #include "core/common.h"
6
7 #define USEC_PER_SEC 1000000ull
8 #define SEC_PER_DAY 86400
9 #define DAYS_PER_WEEK 7
10 #define time_after(a, b) ((int64_t)(b) - (int64_t)(a) < 0)
11 #define time_after_eq(a, b) ((int64_t)(b) - (int64_t)(a) <= 0)
12
13 //#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
14
15 #define STRINGIZE(x) #x
16 #define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
17
18 #define API __attribute__ ((visibility ("default")))
19
20 #define STATIC_ASSERT(CONDITION,MESSAGE) typedef char static_assert_\
21 ##MESSAGE[(CONDITION)?0:-1]
22
23 #define CHECK_RET(ret, func_name)                                       \
24         do {                                                            \
25                 if (ret < 0) {                                          \
26                         _E(func_name" failed: error code %d", ret);     \
27                         return ret;                                     \
28                 }                                                       \
29         } while (0);
30
31 __attribute__ ((unused)) static time_t getSecTime()
32 {
33         struct timespec ts;
34         clock_gettime(CLOCK_MONOTONIC, &ts);
35         return ts.tv_sec;
36 }
37
38 #endif /* _LOGD_MACRO_H_ */