 |
PDK API Guide for J721E
|
Go to the documentation of this file. 58 #ifndef UNIBASE_MARCORS_H_ 59 #define UNIBASE_MARCORS_H_ 66 #define UB_SEC_NS 1000000000LL 67 #define UB_MSEC_NS 1000000 68 #define UB_USEC_NS 1000 69 #define UB_SEC_US 1000000LL 70 #define UB_MSEC_US 1000 71 #define UB_SEC_MS 1000 73 #define UB_CHARS_IN_LINE 384 75 #define UB_BIT(x) (1U<<(x)) 76 #define UB_MAX(x,y) ((x)>(y)?(x):(y)) 77 #define UB_MIN(x,y) ((x)<(y)?(x):(y)) 79 #define UB_CONSOLE_PRINT(...) \ 81 char coutstr[UB_CHARS_IN_LINE]; \ 82 (void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \ 83 ub_console_debug_select_print(true, false, coutstr); \ 86 #define UB_DEBUGMEM_PRINT(...) \ 88 char coutstr[UB_CHARS_IN_LINE]; \ 89 (void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \ 90 ub_console_debug_select_print(false, true, coutstr); \ 93 #define UB_CONSOLE_DEBUGMEM_PRINT(...) \ 95 char coutstr[UB_CHARS_IN_LINE]; \ 96 (void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \ 97 ub_console_debug_select_print(true, true, coutstr); \ 100 #define UB_SELECT_PRINT(console, debugmem, ...) \ 102 char coutstr[UB_CHARS_IN_LINE]; \ 103 (void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \ 104 ub_console_debug_select_print(console, debugmem, coutstr); \ 116 #define UB_LOG(level, ...) \ 118 char coutstr[UB_CHARS_IN_LINE]; \ 119 (void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \ 120 (void)ub_log_print(UB_LOGCAT, 0, level, coutstr); \ 126 #define UB_TLOG(level, ...) \ 128 char coutstr[UB_CHARS_IN_LINE]; \ 129 (void)snprintf(coutstr, UB_CHARS_IN_LINE, __VA_ARGS__); \ 130 (void)ub_log_print(UB_LOGCAT, UB_LOGTSTYPE, level, coutstr); \ 134 #define UB_PRIhexB8 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X" 135 #define UB_ARRAY_B8(x) (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7] 138 #define UB_PRIhexB6 "%02X:%02X:%02X:%02X:%02X:%02X" 139 #define UB_ARRAY_B6(x) (x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5] 142 #define UB_NON_ZERO_B6(x) (((x)[0]|(x)[1]|(x)[2]|(x)[3]|(x)[4]|(x)[5])!=0u) 145 #define UB_NON_ZERO_B8(x) (((x)[0]|(x)[1]|(x)[2]|(x)[3]|(x)[4]|(x)[5]|(x)[6]|(x)[7])!=0u) 148 #define UB_ALLFF_B6(x) (((x)[0]&(x)[1]&(x)[2]&(x)[3]&(x)[4]&(x)[5])==0xffu) 151 #define UB_ALLFF_B8(x) (((x)[0]&(x)[1]&(x)[2]&(x)[3]&(x)[4]&(x)[5]&(x)[6]&(x)[7])==0xffu) 161 #define UB_ABIT8_FIELD(name, s, m) \ 162 static inline int name##_bit_field(uint8_t x) \ 163 { return (x >> (s)) & (m); } \ 164 static inline int name##_set_bit_field(uint8_t x, uint8_t v) \ 165 { return (x & ~((m) << (s))) | ((v & (m)) << (s)) ; } 168 #define UB_ABIT16_FIELD(name, s, m) \ 169 static inline int name##_bit_field(uint16_t x) \ 170 { return (htons(x) >> (s)) & (m); } \ 171 static inline int name##_set_bit_field(uint16_t x, uint16_t v) \ 172 {return ntohs((htons(x) & ~((m) << (s))) \ 173 | ((v & (m)) << (s)));} 176 #define UB_ABIT32_FIELD(name, s, m) \ 177 static inline int name##_bit_field(uint32_t x) \ 178 { return (htonl(x) >> (s)) & (m); } \ 179 static inline int name##_set_bit_field(uint32_t x, uint32_t v) \ 180 {return ntohl((htonl(x) & ~((m) << (s))) \ 181 | ((v & (m)) << (s)));} 190 #define UB_ABIT8_TOGGLE_FIELD(name, s, m) \ 191 static inline int name##_toggle_bit_field(uint8_t x) \ 192 {return (x ^ ((m) << (s)));} 195 #define UB_ABIT16_TOGGLE_FIELD(name, s, m) \ 196 static inline int name##_toggle_bit_field(uint16_t x) \ 197 {return ntohs((htons(x) ^ ((m) << (s))));} 200 #define UB_ABIT32_TOGGLE_FIELD(name, s, m) \ 201 static inline int name##_toggle_bit_field(uint32_t x) \ 202 {return ntohl((htonl(x) ^ ((m) << (s))));} 205 #define UB_TS2NSEC(ts) (((ts).tv_sec*1000000000)+(ts).tv_nsec) 208 #define UB_TS2USEC(ts) (((ts).tv_sec*1000000)+(ts).tv_nsec/UB_USEC_NS) 211 #define UB_TS2MSEC(ts) (((ts).tv_sec*UB_SEC_MS)+(ts).tv_nsec/UB_MSEC_NS) 214 #define UB_TV2NSEC(tv) (((tv).tv_sec*1000000000)+(tv).tv_usec*UB_USEC_NS) 217 #define UB_TV2USEC(tv) (((tv).tv_sec*1000000)+(tv).tv_usec) 220 #define UB_TV2MSEC(tv) (((tv).tv_sec*UB_SEC_MS)+(tv).tv_usec/UB_MSEC_US) 223 #define UB_NSEC2TS(ns, ts) {(ts).tv_sec=(ns)/1000000000;(ts).tv_nsec=(ns)%1000000000;} 226 #define UB_USEC2TS(us, ts) {(ts).tv_sec=(us)/1000000;(ts).tv_nsec=((us)%1000000)*UB_USEC_NS;} 229 #define UB_MSEC2TS(ms, ts) {(ts).tv_sec=(ms)/UB_SEC_MS;(ts).tv_nsec=((ms)%UB_SEC_MS)*UB_MSEC_NS;} 232 #define UB_NSEC2TV(ns, tv) {(tv).tv_sec=(ns)/1000000000;(tv).tv_usec=((ns)%1000000000)/UB_USEC_NS;} 235 #define UB_USEC2TV(us, tv) {(tv).tv_sec=(us)/1000000;(tv).tv_usec=(us)%1000000;} 238 #define UB_MSEC2TV(ms, tv) {(tv).tv_sec=(ms)/UB_SEC_MS;(tv).tv_usec=((ms)%UB_SEC_MS)*UB_MSEC_US;} 241 #define UB_TV_DIFF64NS(tv1,tv2) (UB_TV2NSEC(tv1)-UB_TV2NSEC(tv2)) 244 #define UB_TV_ADD64NS(tv1,tv2) (UB_TV2NSEC(tv1)+UB_TV2NSEC(tv2)) 247 #define UB_TS_DIFF64NS(ts1,ts2) (UB_TS2NSEC(ts1)-UB_TS2NSEC(ts2)) 250 #define UB_TS_ADD64NS(ts1,ts2) (UB_TS2NSEC(ts1)+UB_TS2NSEC(ts2)) 253 #define UB_TV_DIFF_TV(rtv,tv1,tv2) { \ 254 int64_t ns_ub_m_=(int64_t)UB_TV_DIFF64NS(tv1,tv2); \ 255 UB_NSEC2TV(ns_ub_m_,rtv); \ 259 #define UB_TS_DIFF_TS(rts,ts1,ts2) { \ 260 int64_t ns_ub_m_=(int64_t)UB_TS_DIFF64NS(ts1,ts2); \ 261 UB_NSEC2TS(ns_ub_m_,rts); \ 265 #define UB_TV_ADD_TV(rtv,tv1,tv2) { \ 266 int64_t ns_ub_m_=(int64_t)UB_TV_ADD64NS(tv1,tv2); \ 267 UB_NSEC2TV(ns_ub_m_,rtv); \ 271 #define UB_TS_ADD_TS(rts,ts1,ts2) { \ 272 int64_t ns_ub_m_=(int64_t)UB_TS_ADD64NS(ts1,ts2); \ 273 UB_NSEC2TS(ns_ub_m_,rts); \ 281 #define UB_HTONLL(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | \ 289 #define UB_NTOHLL(x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | \ 297 #define UB_STATIC_ASSERT(cond, error) typedef char type[(cond) ? 1 : -1]