1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2022 Marvell. 3 */ 4 5 #ifndef ML_COMMON_H 6 #define ML_COMMON_H 7 8 #include <stdio.h> 9 10 #define CLNRM "\x1b[0m" 11 #define CLRED "\x1b[31m" 12 #define CLGRN "\x1b[32m" 13 #define CLYEL "\x1b[33m" 14 15 #define ML_STR_FMT 20 16 17 #define ml_err(fmt, ...) \ 18 fprintf(stderr, CLRED "error: %s() " fmt CLNRM "\n", __func__, ##__VA_ARGS__) 19 20 #define ml_info(fmt, ...) fprintf(stdout, CLYEL "" fmt CLNRM "\n", ##__VA_ARGS__) 21 22 #define ml_dump(str, fmt, ...) printf("\t%-*s : " fmt "\n", ML_STR_FMT, str, ##__VA_ARGS__) 23 24 #define ml_dump_begin(str) printf("\t%-*s :\n\t{\n", ML_STR_FMT, str) 25 26 #define ml_dump_list(str, id, val) printf("\t%*s[%2u] : %s\n", ML_STR_FMT - 4, str, id, val) 27 28 #define ml_dump_end printf("\b\t}\n\n") 29 30 static inline void 31 ml_print_line(uint16_t len) 32 { 33 uint16_t i; 34 35 for (i = 0; i < len; i++) 36 printf("-"); 37 38 printf("\n"); 39 } 40 41 #endif /* ML_COMMON_H */ 42