1/* @title: Boot OOM */
2#pragma once
3#include <console/panic.h>
4#include <global.h>
5#include <log.h>
6
7#define alloc_or_die(expr) \
8 ({ \
9 if (global.current_bootstage >= BOOTSTAGE_COMPLETE) \
10 log_warn_once("alloc_or_die invoked after boot"); \
11 __typeof__(expr) _p_ = (expr); \
12 if (unlikely(!_p_)) \
13 panic("OOM: %s == NULL, stage: %s", #expr, \
14 bootstage_str[global.current_bootstage]); \
15 _p_; \
16 })
17
18#define kmalloc_or_die(...) alloc_or_die(kmalloc(__VA_ARGS__))
19