Utility macros for convenience.
Go to the source code of this file.
Macros | |
#define | UB_SEC_NS 1000000000LL |
one second in unit of nano second More... | |
#define | UB_MSEC_NS 1000000 |
one mili second in unit of nano second More... | |
#define | UB_USEC_NS 1000 |
one micro second in unit of nano second More... | |
#define | UB_SEC_US 1000000LL |
one second in unit of microsecond More... | |
#define | UB_MSEC_US 1000 |
one mili second in unit of microsecond More... | |
#define | UB_SEC_MS 1000 |
one second in unit of milisecond More... | |
#define | UB_CHARS_IN_LINE 384 |
#define | UB_BIT(x) (1U<<(x)) |
bit x More... | |
#define | UB_MAX(x, y) ((x)>(y)?(x):(y)) |
max(x,y) More... | |
#define | UB_MIN(x, y) ((x)<(y)?(x):(y)) |
min(x,y) More... | |
#define | UB_CONSOLE_PRINT(...) |
#define | UB_DEBUGMEM_PRINT(...) |
#define | UB_CONSOLE_DEBUGMEM_PRINT(...) |
#define | UB_SELECT_PRINT(console, debugmem, ...) |
#define | UB_LOG(level, ...) UB_LOG_##level(__VA_ARGS__) |
UB_LOG(level, formt, ...), level is compared to the level in the category which is defined by UB_LOGCAT. More... | |
#define | UB_TLOG(level, ...) UB_TLOG_##level(__VA_ARGS__) |
UB_TLOG add timestamp regardless the timestamp option in the category. More... | |
#define | UB_VLOG(var, ...) |
UB_VLOG allows for flexible logging with a variable log level specified as an argument in the function call. Example Usage: void func(int level, int abc) { UB_VLOG(level, "hello world\n"); } The func can be called as: func(UBL_DEBUGV, abc); In this case UB_LOG and UB_TLOG can not work. More... | |
#define | UB_PRIhexB8 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X" |
use this to print ub_streamid_t More... | |
#define | UB_ARRAY_B8(x) (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7] |
#define | UB_PRIhexB6 "%02X:%02X:%02X:%02X:%02X:%02X" |
use this to print ub_macaddr_t More... | |
#define | UB_ARRAY_B6(x) (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5] |
used with UB_PRIhexB6 More... | |
#define | UB_NON_ZERO_B6(x) (((x)[0]|(x)[1]|(x)[2]|(x)[3]|(x)[4]|(x)[5])!=0u) |
true if 6-byte binaries are not all zero More... | |
#define | UB_NON_ZERO_B8(x) (((x)[0]|(x)[1]|(x)[2]|(x)[3]|(x)[4]|(x)[5]|(x)[6]|(x)[7])!=0u) |
true if 8-byte binaries are not all zero More... | |
#define | UB_ALLFF_B6(x) (((x)[0]&(x)[1]&(x)[2]&(x)[3]&(x)[4]&(x)[5])==0xffu) |
true if 6-byte binaries are all 0xff More... | |
#define | UB_ALLFF_B8(x) (((x)[0]&(x)[1]&(x)[2]&(x)[3]&(x)[4]&(x)[5]&(x)[6]&(x)[7])==0xffu) |
true if 8-byte binaries are all 0xff More... | |
#define | UB_ABIT8_FIELD(name, s, m) |
two of inline functions: name_bit_field, name_set_bit_field are created for bit opperation on a network bit order endian variable. More... | |
#define | UB_ABIT16_FIELD(name, s, m) |
the same like UB_BIT8_FILED, works on 16-bit variable More... | |
#define | UB_ABIT32_FIELD(name, s, m) |
the same like UB_BIT8_FILED, works on 32-bit variable More... | |
#define | UB_ABIT8_TOGGLE_FIELD(name, s, m) |
inline function: name_toggle_bit_field is created for toggling bit opperation on a network bit order variable. More... | |
#define | UB_ABIT16_TOGGLE_FIELD(name, s, m) |
the same like UB_BIT8_TOGGLE_FIELD, works on 16-bit variable More... | |
#define | UB_ABIT32_TOGGLE_FIELD(name, s, m) |
the same like UB_BIT8_TOGGLE_FIELD, works on 32-bit variable More... | |
#define | UB_TS2NSEC(ts) (((int64_t)(ts).tv_sec*1000000000)+(ts).tv_nsec) |
convert 'struct timespec' vaule to nanosecond integer More... | |
#define | UB_TS2USEC(ts) (((int64_t)(ts).tv_sec*1000000)+(ts).tv_nsec/UB_USEC_NS) |
convert 'struct timespec' vaule to microsecond integer More... | |
#define | UB_TS2MSEC(ts) (((int64_t)(ts).tv_sec*UB_SEC_MS)+(ts).tv_nsec/UB_MSEC_NS) |
convert 'struct timespec' vaule to milisecond integer More... | |
#define | UB_TV2NSEC(tv) (((int64_t)(tv).tv_sec*1000000000)+(int64_t)(tv).tv_usec*UB_USEC_NS) |
convert 'struct timeval' vaule to nanosecond integer More... | |
#define | UB_TV2USEC(tv) (((int64_t)(tv).tv_sec*1000000)+(tv).tv_usec) |
convert 'struct timeval' vaule to nanosecond integer More... | |
#define | UB_TV2MSEC(tv) (((int64_t)(tv).tv_sec*UB_SEC_MS)+(tv).tv_usec/UB_MSEC_US) |
convert 'struct timeval' vaule to milisecond integer More... | |
#define | UB_NSEC2TS(ns, ts) {(ts).tv_sec=(ns)/1000000000;(ts).tv_nsec=(ns)%1000000000;} |
convert nanosec value to 'struct timespec' vaule More... | |
#define | UB_USEC2TS(us, ts) {(ts).tv_sec=(us)/1000000;(ts).tv_nsec=((us)%1000000)*UB_USEC_NS;} |
convert microsec value to 'struct timespec' vaule More... | |
#define | UB_MSEC2TS(ms, ts) {(ts).tv_sec=(ms)/UB_SEC_MS;(ts).tv_nsec=((ms)%UB_SEC_MS)*UB_MSEC_NS;} |
convert milisec value to 'struct timespec' vaule More... | |
#define | UB_NSEC2TV(ns, tv) {(tv).tv_sec=(ns)/1000000000;(tv).tv_usec=((ns)%1000000000)/UB_USEC_NS;} |
convert nanosec value to 'struct timeval' vaule More... | |
#define | UB_USEC2TV(us, tv) {(tv).tv_sec=(us)/1000000;(tv).tv_usec=(us)%1000000;} |
convert microsec value to 'struct timeval' vaule More... | |
#define | UB_MSEC2TV(ms, tv) {(tv).tv_sec=(ms)/UB_SEC_MS;(tv).tv_usec=((ms)%UB_SEC_MS)*UB_MSEC_US;} |
convert milisec value to 'struct timeval' vaule More... | |
#define | UB_TV_DIFF64NS(tv1, tv2) (UB_TV2NSEC(tv1)-UB_TV2NSEC(tv2)) |
tv1-tv2 in 64-bit nanosecond unit More... | |
#define | UB_TV_ADD64NS(tv1, tv2) (UB_TV2NSEC(tv1)+UB_TV2NSEC(tv2)) |
tv1+tv2 in 64-bit nanosecond unit More... | |
#define | UB_TS_DIFF64NS(ts1, ts2) (UB_TS2NSEC(ts1)-UB_TS2NSEC(ts2)) |
ts1-ts2 in 64-bit nanosecond unit More... | |
#define | UB_TS_ADD64NS(ts1, ts2) (UB_TS2NSEC(ts1)+UB_TS2NSEC(ts2)) |
ts1+ts2 in 64-bit nanosecond unit More... | |
#define | UB_TV_DIFF_TV(rtv, tv1, tv2) |
rtv=tv1-tv2 in 64-bit nanosecond unit More... | |
#define | UB_TS_DIFF_TS(rts, ts1, ts2) |
rts=ts1-ts2 in 64-bit nanosecond unit More... | |
#define | UB_TV_ADD_TV(rtv, tv1, tv2) |
rtv=tv1+tv2 in 64-bit nanosecond unit More... | |
#define | UB_TS_ADD_TS(rts, ts1, ts2) |
rts=ts1+ts2 in 64-bit nanosecond unit More... | |
#define | UB_HTONLL(x) |
convert values between host and network byte order. which converts the unsigned integer host long long from host byte order to network byte order. More... | |
#define | UB_NTOHLL(x) |
convert values between host and network byte order. converts the unsigned integer netlong from network byte order to host byte order. More... | |
#define | UB_STATIC_ASSERT(cond, error) typedef char type[(cond) ? 1 : -1] |
assert during compilation time. When cond is equal to true, no error. Otherwise, compilation error is raised. e.g. UB_STATIC_ASSERT(uint8_t == 1, Uint8InvalidSize) More... | |
#define | UB_PROTECTED_FUNC(cbfunc, rval, ...) |
call the cbfunc with an internal mutex protection. The ub_func_private_mutex_lock() and ub_func_private_mutex_unlock() are only used privately in this macro. Please do not use them freely elsewhere. More... | |
#define | UB_PROTECTED_FUNC_VOID(cbfunc, ...) |
similar to the UB_PROTECTED_FUNC without return value rval More... | |