AM263Px MCU+ SDK: Utility Macros

| AM263Px MCU+ SDK 26.00.00 |

Files | Macros
Utility Macros
APIs for Unibase Binding

## Introduction

## 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(__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, msg) typedef char msg[(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...

## Macro Definition Documentation

## ◆ UB_SEC_NS

#define UB_SEC_NS 1000000000LL

one second in unit of nano second

## ◆ UB_MSEC_NS

#define UB_MSEC_NS 1000000

one mili second in unit of nano second

## ◆ UB_USEC_NS

#define UB_USEC_NS 1000

one micro second in unit of nano second

## ◆ UB_SEC_US

#define UB_SEC_US 1000000LL

one second in unit of microsecond

## ◆ UB_MSEC_US

#define UB_MSEC_US 1000

one mili second in unit of microsecond

## ◆ UB_SEC_MS

#define UB_SEC_MS 1000

one second in unit of milisecond

## ◆ UB_CHARS_IN_LINE

#define UB_CHARS_IN_LINE 384

## ◆ UB_BIT

#define UB_BIT | ( |  | x | ) | (1U<<(x))

bit x

## ◆ UB_MAX

#define UB_MAX | ( |  | x,
|  |  | y
| ) |  | ((x)>(y)?(x):(y))

max(x,y)

## ◆ UB_MIN

#define UB_MIN | ( |  | x,
|  |  | y
| ) |  | ((x)<(y)?(x):(y))

min(x,y)

## ◆ UB_CONSOLE_PRINT

#define UB_CONSOLE_PRINT | ( |  | ... | ) |

Value:
{ \
char coutstr[UB_CHARS_IN_LINE]; \
(void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \
ub_console_debug_select_print(true, false, coutstr); \
}

## ◆ UB_DEBUGMEM_PRINT

#define UB_DEBUGMEM_PRINT | ( |  | ... | ) |

Value:
{ \
char coutstr[UB_CHARS_IN_LINE]; \
(void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \
ub_console_debug_select_print(false, true, coutstr); \
}

## ◆ UB_CONSOLE_DEBUGMEM_PRINT

#define UB_CONSOLE_DEBUGMEM_PRINT | ( |  | ... | ) |

Value:
{ \
char coutstr[UB_CHARS_IN_LINE]; \
(void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \
ub_console_debug_select_print(true, true, coutstr); \
}

## ◆ UB_SELECT_PRINT

#define UB_SELECT_PRINT | ( |  | console,
|  |  | debugmem,
|  |  | ...
| ) |  |

Value:
{ \
char coutstr[UB_CHARS_IN_LINE]; \
(void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \
ub_console_debug_select_print(console, debugmem, coutstr); \
}

## ◆ UB_LOG

#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.

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

## ◆ UB_TLOG

#define UB_TLOG | ( |  | level,
|  |  | ...
| ) |  | UB_TLOG_##level(__VA_ARGS__)

UB_TLOG add timestamp regardless the timestamp option in the category.

## ◆ UB_VLOG

#define UB_VLOG | ( |  | var,
|  |  | ...
| ) |  |

Value:
if((var)==UBL_DEBUGV){UB_LOG(UBL_DEBUGV,__VA_ARGS__);}\
else if((var)==UBL_DEBUG){UB_LOG(UBL_DEBUG,__VA_ARGS__);}\
else if((var)==UBL_INFOV){UB_LOG(UBL_INFOV,__VA_ARGS__);}\
else if((var)==UBL_INFO){UB_LOG(UBL_INFO,__VA_ARGS__);}\
else if((var)==UBL_WARN){UB_LOG(UBL_WARN,__VA_ARGS__);}\
else if((var)==UBL_ERROR){UB_LOG(UBL_ERROR,__VA_ARGS__);}\
else if((var)==UBL_FATAL){UB_LOG(UBL_FATAL,__VA_ARGS__);}\
else{;}

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.

Note
  This macro may be inefficient and can impact performance. Please use with the caution.

## ◆ UB_PRIhexB8

#define UB_PRIhexB8 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X"

use this to print ub_streamid_t

used with UB_PRIhexB8

## ◆ UB_ARRAY_B8

#define UB_ARRAY_B8 | ( |  | x | ) | (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7]

## ◆ UB_PRIhexB6

#define UB_PRIhexB6 "%02X:%02X:%02X:%02X:%02X:%02X"

use this to print ub_macaddr_t

## ◆ UB_ARRAY_B6

#define UB_ARRAY_B6 | ( |  | x | ) | (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5]

used with UB_PRIhexB6

## ◆ UB_NON_ZERO_B6

#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

## ◆ UB_NON_ZERO_B8

#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

## ◆ UB_ALLFF_B6

#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

## ◆ UB_ALLFF_B8

#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

## ◆ UB_ABIT8_FIELD

#define UB_ABIT8_FIELD | ( |  | name,
|  |  | s,
|  |  | m
| ) |  |

Value:
static inline int name##_bit_field(uint8_t x) \
{ return (x >> (s)) & (m); } \
static inline int name##_set_bit_field(uint8_t x, uint8_t v) \
{ return (x & ~((m) << (s))) | ((v & (m)) << (s)) ; }

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),

- bs_bit_field(v): read 'bit6 to bit2 of 'v'
- v=bs_set_bit_field(v, 5): set 'bit6 to bit2' of 'v' to 5

## ◆ UB_ABIT16_FIELD

#define UB_ABIT16_FIELD | ( |  | name,
|  |  | s,
|  |  | m
| ) |  |

Value:
static inline int name##_bit_field(uint16_t x) \
{ return (htons(x) >> (s)) & (m); } \
static inline int name##_set_bit_field(uint16_t x, uint16_t v) \
{return ntohs((htons(x) & ~((m) << (s))) \
| ((v & (m)) << (s)));}

the same like UB_BIT8_FILED, works on 16-bit variable

## ◆ UB_ABIT32_FIELD

#define UB_ABIT32_FIELD | ( |  | name,
|  |  | s,
|  |  | m
| ) |  |

Value:
static inline int name##_bit_field(uint32_t x) \
{ return (htonl(x) >> (s)) & (m); } \
static inline int name##_set_bit_field(uint32_t x, uint32_t v) \
{return ntohl((htonl(x) & ~((m) << (s))) \
| ((v & (m)) << (s)));}

the same like UB_BIT8_FILED, works on 32-bit variable

## ◆ UB_ABIT8_TOGGLE_FIELD

#define UB_ABIT8_TOGGLE_FIELD | ( |  | name,
|  |  | s,
|  |  | m
| ) |  |

Value:
static inline int name##_toggle_bit_field(uint8_t x) \
{return (x ^ ((m) << (s)));}

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),

- v=bs_toggle_bit_field(v): toggle bit2 at each time of call

## ◆ UB_ABIT16_TOGGLE_FIELD

#define UB_ABIT16_TOGGLE_FIELD | ( |  | name,
|  |  | s,
|  |  | m
| ) |  |

Value:
static inline int name##_toggle_bit_field(uint16_t x) \
{return ntohs((htons(x) ^ ((m) << (s))));}

the same like UB_BIT8_TOGGLE_FIELD, works on 16-bit variable

## ◆ UB_ABIT32_TOGGLE_FIELD

#define UB_ABIT32_TOGGLE_FIELD | ( |  | name,
|  |  | s,
|  |  | m
| ) |  |

Value:
static inline int name##_toggle_bit_field(uint32_t x) \
{return ntohl((htonl(x) ^ ((m) << (s))));}

the same like UB_BIT8_TOGGLE_FIELD, works on 32-bit variable

## ◆ UB_TS2NSEC

#define UB_TS2NSEC | ( |  | ts | ) | (((int64_t)(ts).tv_sec*1000000000)+(ts).tv_nsec)

convert 'struct timespec' vaule to nanosecond integer

## ◆ UB_TS2USEC

#define UB_TS2USEC | ( |  | ts | ) | (((int64_t)(ts).tv_sec*1000000)+(ts).tv_nsec/UB_USEC_NS)

convert 'struct timespec' vaule to microsecond integer

## ◆ UB_TS2MSEC

#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

## ◆ UB_TV2NSEC

#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

## ◆ UB_TV2USEC

#define UB_TV2USEC | ( |  | tv | ) | (((int64_t)(tv).tv_sec*1000000)+(tv).tv_usec)

convert 'struct timeval' vaule to nanosecond integer

## ◆ UB_TV2MSEC

#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

## ◆ UB_NSEC2TS

#define UB_NSEC2TS | ( |  | ns,
|  |  | ts
| ) |  | {(ts).tv_sec=(ns)/1000000000;(ts).tv_nsec=(ns)%1000000000;}

convert nanosec value to 'struct timespec' vaule

## ◆ UB_USEC2TS

#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

## ◆ UB_MSEC2TS

#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

## ◆ UB_NSEC2TV

#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

## ◆ UB_USEC2TV

#define UB_USEC2TV | ( |  | us,
|  |  | tv
| ) |  | {(tv).tv_sec=(us)/1000000;(tv).tv_usec=(us)%1000000;}

convert microsec value to 'struct timeval' vaule

## ◆ UB_MSEC2TV

#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

## ◆ UB_TV_DIFF64NS

#define UB_TV_DIFF64NS | ( |  | tv1,
|  |  | tv2
| ) |  | (UB_TV2NSEC(tv1)-UB_TV2NSEC(tv2))

tv1-tv2 in 64-bit nanosecond unit

## ◆ UB_TV_ADD64NS

#define UB_TV_ADD64NS | ( |  | tv1,
|  |  | tv2
| ) |  | (UB_TV2NSEC(tv1)+UB_TV2NSEC(tv2))

tv1+tv2 in 64-bit nanosecond unit

## ◆ UB_TS_DIFF64NS

#define UB_TS_DIFF64NS | ( |  | ts1,
|  |  | ts2
| ) |  | (UB_TS2NSEC(ts1)-UB_TS2NSEC(ts2))

ts1-ts2 in 64-bit nanosecond unit

## ◆ UB_TS_ADD64NS

#define UB_TS_ADD64NS | ( |  | ts1,
|  |  | ts2
| ) |  | (UB_TS2NSEC(ts1)+UB_TS2NSEC(ts2))

ts1+ts2 in 64-bit nanosecond unit

## ◆ UB_TV_DIFF_TV

#define UB_TV_DIFF_TV | ( |  | rtv,
|  |  | tv1,
|  |  | tv2
| ) |  |

Value:
{ \
int64_t ns_ub_m_=(int64_t)UB_TV_DIFF64NS(tv1,tv2); \
UB_NSEC2TV(ns_ub_m_,rtv); \
}

rtv=tv1-tv2 in 64-bit nanosecond unit

## ◆ UB_TS_DIFF_TS

#define UB_TS_DIFF_TS | ( |  | rts,
|  |  | ts1,
|  |  | ts2
| ) |  |

Value:
{ \
int64_t ns_ub_m_=(int64_t)UB_TS_DIFF64NS(ts1,ts2); \
UB_NSEC2TS(ns_ub_m_,rts); \
}

rts=ts1-ts2 in 64-bit nanosecond unit

## ◆ UB_TV_ADD_TV

#define UB_TV_ADD_TV | ( |  | rtv,
|  |  | tv1,
|  |  | tv2
| ) |  |

Value:
{ \
int64_t ns_ub_m_=(int64_t)UB_TV_ADD64NS(tv1,tv2); \
UB_NSEC2TV(ns_ub_m_,rtv); \
}

rtv=tv1+tv2 in 64-bit nanosecond unit

## ◆ UB_TS_ADD_TS

#define UB_TS_ADD_TS | ( |  | rts,
|  |  | ts1,
|  |  | ts2
| ) |  |

Value:
{ \
int64_t ns_ub_m_=(int64_t)UB_TS_ADD64NS(ts1,ts2); \
UB_NSEC2TS(ns_ub_m_,rts); \
}

rts=ts1+ts2 in 64-bit nanosecond unit

## ◆ UB_HTONLL

#define UB_HTONLL | ( |  | x | ) |

Value:
((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | \
htonl((x) >> 32))

convert values between host and network byte order. which converts the unsigned integer host long long from host byte order to network byte order.

## ◆ UB_NTOHLL

#define UB_NTOHLL | ( |  | x | ) |

Value:
((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | \
ntohl((x) >> 32))

convert values between host and network byte order. converts the unsigned integer netlong from network byte order to host byte order.

## ◆ UB_STATIC_ASSERT

#define UB_STATIC_ASSERT | ( |  | cond,
|  |  | msg
| ) |  | typedef char msg[(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)

## ◆ UB_PROTECTED_FUNC

#define UB_PROTECTED_FUNC | ( |  | cbfunc,
|  |  | rval,
|  |  | ...
| ) |  |

Value:
int ub_func_private_mutex_lock(void); \
int ub_func_private_mutex_unlock(void); \
ub_func_private_mutex_lock(); \
rval=cbfunc(__VA_ARGS__); \
ub_func_private_mutex_unlock();

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.

## ◆ UB_PROTECTED_FUNC_VOID

#define UB_PROTECTED_FUNC_VOID | ( |  | cbfunc,
|  |  | ...
| ) |  |

Value:
int ub_func_private_mutex_lock(void); \
int ub_func_private_mutex_unlock(void); \
ub_func_private_mutex_lock(); \
cbfunc(__VA_ARGS__); \
ub_func_private_mutex_unlock();

similar to the UB_PROTECTED_FUNC without return value rval

UBL_DEBUG
#define UBL_DEBUG
Definition: ub_logging.h:96
UBL_INFO
#define UBL_INFO
Definition: ub_logging.h:94
UB_TV_DIFF64NS
#define UB_TV_DIFF64NS(tv1, tv2)
tv1-tv2 in 64-bit nanosecond unit
Definition: unibase_macros.h:254
UB_TS_ADD64NS
#define UB_TS_ADD64NS(ts1, ts2)
ts1+ts2 in 64-bit nanosecond unit
Definition: unibase_macros.h:263
ntohs
#define ntohs
Definition: cb_lld_ethernet.h:75
UBL_DEBUGV
#define UBL_DEBUGV
Definition: ub_logging.h:97
UB_CHARS_IN_LINE
#define UB_CHARS_IN_LINE
Definition: unibase_macros.h:73
htons
#define htons
Definition: cb_lld_ethernet.h:72
UBL_INFOV
#define UBL_INFOV
Definition: ub_logging.h:95
UBL_WARN
#define UBL_WARN
Definition: ub_logging.h:93
UBL_FATAL
#define UBL_FATAL
Definition: ub_logging.h:91
UB_TV_ADD64NS
#define UB_TV_ADD64NS(tv1, tv2)
tv1+tv2 in 64-bit nanosecond unit
Definition: unibase_macros.h:257
UB_TS_DIFF64NS
#define UB_TS_DIFF64NS(ts1, ts2)
ts1-ts2 in 64-bit nanosecond unit
Definition: unibase_macros.h:260
htonl
#define htonl
Definition: cb_lld_ethernet.h:78
UBL_ERROR
#define UBL_ERROR
Definition: ub_logging.h:92
UB_LOG
#define UB_LOG(level,...)
UB_LOG(level, formt, ...), level is compared to the level in the category which is defined by UB_LOGC...
Definition: unibase_macros.h:116
ntohl
#define ntohl
Definition: cb_lld_ethernet.h:81