| 1 | /* @title: Boot OOM */ |
| 2 | #pragma once |
| 3 | #include <console/panic.h> |
| 4 | #include <global.h> |
| 5 | #include <log.h> |
| 6 | |
| 7 | #define nofail(expr) \ |
| 8 | ({ \ |
| 9 | if (global.current_bootstage >= BOOTSTAGE_COMPLETE) \ |
| 10 | log_msg_once(LOG_WARN, "nofail() invoked after boot"); \ |
| 11 | typeof(expr) _p_ = (expr); \ |
| 12 | if (cc_unlikely(!_p_)) \ |
| 13 | panic(OUT_OF_MEMORY, "%s == NULL, bootstage: %s", #expr, \ |
| 14 | bootstage_str[global.current_bootstage]); \ |
| 15 | _p_; \ |
| 16 | }) |
| 17 | |
| 18 | #define nofail_valloc(...) nofail(valloc(__VA_ARGS__)) |
| 19 | #define nofail_vnew(...) nofail(vnew(__VA_ARGS__)) |
| 20 | #define nofail_vnews(...) nofail(vnews(__VA_ARGS__)) |
| 21 | #define nofail_vnew_flex(...) nofail(vnew_flex(__VA_ARGS__)) |
| 22 | #define nofail_vrealloc(...) nofail(vrealloc(__VA_ARGS__)) |
| 23 | #define nofail_vrenews(...) nofail(vrenews(__VA_ARGS__)) |
| 24 | |