• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #include <stdio.h>
14 
15 #define BUG_ON(expr)                                              \
16     do {                                                          \
17         if ((expr)) {                                             \
18             printf("BUG: %s:%d %s\n", __func__, __LINE__, #expr); \
19             for (;;) {                                            \
20             }                                                     \
21         }                                                         \
22     } while (0)
23 
24 #define BUG(str)                                            \
25     do {                                                    \
26         printf("BUG: %s:%d %s\n", __func__, __LINE__, str); \
27         for (;;) {                                          \
28         }                                                   \
29     } while (0)
30 
31 #define WARN(msg) printf("WARN: %s:%d %s\n", __func__, __LINE__, msg)
32 
33 #define WARN_ON(cond, msg)                                                    \
34     do {                                                                      \
35         if ((cond)) {                                                         \
36             printf("WARN: %s:%d %s on " #cond "\n", __func__, __LINE__, msg); \
37         }                                                                     \
38     } while (0)
39 
40 #define fail_cond(cond, fmt, ...)   \
41     do {                            \
42         if (!(cond))                \
43             break;                  \
44         printf(fmt, ##__VA_ARGS__); \
45         usys_exit(-1);              \
46     } while (0)
47