![]() |
PDK API Guide for J721E
|
Files | |
file | unibase_macros.h |
Utility macros for convenience. | |
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, formt, ...), level is compared to the level in the category which is defined by UB_LOGCAT. More... | |
#define | UB_TLOG(level, ...) |
UB_TLOG add timestamp regardless the timestamp option in the category. 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) (((ts).tv_sec*1000000000)+(ts).tv_nsec) |
convert 'struct timespec' vaule to nanosecond integer More... | |
#define | UB_TS2USEC(ts) (((ts).tv_sec*1000000)+(ts).tv_nsec/UB_USEC_NS) |
convert 'struct timespec' vaule to microsecond integer More... | |
#define | UB_TS2MSEC(ts) (((ts).tv_sec*UB_SEC_MS)+(ts).tv_nsec/UB_MSEC_NS) |
convert 'struct timespec' vaule to milisecond integer More... | |
#define | UB_TV2NSEC(tv) (((tv).tv_sec*1000000000)+(tv).tv_usec*UB_USEC_NS) |
convert 'struct timeval' vaule to nanosecond integer More... | |
#define | UB_TV2USEC(tv) (((tv).tv_sec*1000000)+(tv).tv_usec) |
convert 'struct timeval' vaule to nanosecond integer More... | |
#define | UB_TV2MSEC(tv) (((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_SEC_NS 1000000000LL |
one second in unit of nano second
#define UB_MSEC_NS 1000000 |
one mili second in unit of nano second
#define UB_USEC_NS 1000 |
one micro second in unit of nano second
#define UB_SEC_US 1000000LL |
one second in unit of microsecond
#define UB_MSEC_US 1000 |
one mili second in unit of microsecond
#define UB_SEC_MS 1000 |
one second in unit of milisecond
#define UB_CHARS_IN_LINE 384 |
#define UB_BIT | ( | x | ) | (1U<<(x)) |
bit x
#define UB_MAX | ( | x, | |
y | |||
) | ((x)>(y)?(x):(y)) |
max(x,y)
#define UB_MIN | ( | x, | |
y | |||
) | ((x)<(y)?(x):(y)) |
min(x,y)
#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, formt, ...), level is compared to the level in the category which is defined by UB_LOGCAT.
UB_LOGCAT must be defined in .c file to indicate the log category index. UB_LOGCAT=0 is reserved as this unibase category. e.g. UB_LOG(UBL_DEBUG, "%s:x=%d\n", func, x); if UBL_DEBUG<="the level in UB_LOGCAT", it is printed
#define UB_TLOG | ( | level, | |
... | |||
) |
UB_TLOG add timestamp regardless the timestamp option in the category.
#define UB_PRIhexB8 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X" |
use this to print ub_streamid_t
used with UB_PRIhexB8
#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
#define UB_ARRAY_B6 | ( | x | ) | (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5] |
used with UB_PRIhexB6
#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
#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
#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
#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
#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.
e.g UB_ABIT8_FIELD(bs, 2, 0x1f),
#define UB_ABIT16_FIELD | ( | name, | |
s, | |||
m | |||
) |
the same like UB_BIT8_FILED, works on 16-bit variable
#define UB_ABIT32_FIELD | ( | name, | |
s, | |||
m | |||
) |
the same like UB_BIT8_FILED, works on 32-bit variable
#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.
e.g UB_ABIT8_TOGGLE_FIELD(bs, 2, 1),
#define UB_ABIT16_TOGGLE_FIELD | ( | name, | |
s, | |||
m | |||
) |
the same like UB_BIT8_TOGGLE_FIELD, works on 16-bit variable
#define UB_ABIT32_TOGGLE_FIELD | ( | name, | |
s, | |||
m | |||
) |
the same like UB_BIT8_TOGGLE_FIELD, works on 32-bit variable
#define UB_TS2NSEC | ( | ts | ) | (((ts).tv_sec*1000000000)+(ts).tv_nsec) |
convert 'struct timespec' vaule to nanosecond integer
#define UB_TS2USEC | ( | ts | ) | (((ts).tv_sec*1000000)+(ts).tv_nsec/UB_USEC_NS) |
convert 'struct timespec' vaule to microsecond integer
#define UB_TS2MSEC | ( | ts | ) | (((ts).tv_sec*UB_SEC_MS)+(ts).tv_nsec/UB_MSEC_NS) |
convert 'struct timespec' vaule to milisecond integer
#define UB_TV2NSEC | ( | tv | ) | (((tv).tv_sec*1000000000)+(tv).tv_usec*UB_USEC_NS) |
convert 'struct timeval' vaule to nanosecond integer
#define UB_TV2USEC | ( | tv | ) | (((tv).tv_sec*1000000)+(tv).tv_usec) |
convert 'struct timeval' vaule to nanosecond integer
#define UB_TV2MSEC | ( | tv | ) | (((tv).tv_sec*UB_SEC_MS)+(tv).tv_usec/UB_MSEC_US) |
convert 'struct timeval' vaule to milisecond integer
#define UB_NSEC2TS | ( | ns, | |
ts | |||
) | {(ts).tv_sec=(ns)/1000000000;(ts).tv_nsec=(ns)%1000000000;} |
convert nanosec value to 'struct timespec' vaule
#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
#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
#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
#define UB_USEC2TV | ( | us, | |
tv | |||
) | {(tv).tv_sec=(us)/1000000;(tv).tv_usec=(us)%1000000;} |
convert microsec value to 'struct timeval' vaule
#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
#define UB_TV_DIFF64NS | ( | tv1, | |
tv2 | |||
) | (UB_TV2NSEC(tv1)-UB_TV2NSEC(tv2)) |
tv1-tv2 in 64-bit nanosecond unit
#define UB_TV_ADD64NS | ( | tv1, | |
tv2 | |||
) | (UB_TV2NSEC(tv1)+UB_TV2NSEC(tv2)) |
tv1+tv2 in 64-bit nanosecond unit
#define UB_TS_DIFF64NS | ( | ts1, | |
ts2 | |||
) | (UB_TS2NSEC(ts1)-UB_TS2NSEC(ts2)) |
ts1-ts2 in 64-bit nanosecond unit
#define UB_TS_ADD64NS | ( | ts1, | |
ts2 | |||
) | (UB_TS2NSEC(ts1)+UB_TS2NSEC(ts2)) |
ts1+ts2 in 64-bit nanosecond unit
#define UB_TV_DIFF_TV | ( | rtv, | |
tv1, | |||
tv2 | |||
) |
rtv=tv1-tv2 in 64-bit nanosecond unit
#define UB_TS_DIFF_TS | ( | rts, | |
ts1, | |||
ts2 | |||
) |
rts=ts1-ts2 in 64-bit nanosecond unit
#define UB_TV_ADD_TV | ( | rtv, | |
tv1, | |||
tv2 | |||
) |
rtv=tv1+tv2 in 64-bit nanosecond unit
#define UB_TS_ADD_TS | ( | rts, | |
ts1, | |||
ts2 | |||
) |
rts=ts1+ts2 in 64-bit nanosecond unit
#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.
#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.
#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)