Skip to content

Instantly share code, notes, and snippets.

@heatd

heatd/awful.c Secret

Created May 14, 2024 18:45
Show Gist options
  • Save heatd/40652ac145ea90c1d05e71bbf49a82f5 to your computer and use it in GitHub Desktop.
Save heatd/40652ac145ea90c1d05e71bbf49a82f5 to your computer and use it in GitHub Desktop.
#ifdef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstring-plus-int"
#endif
struct page_flag
{
unsigned long val;
const char *name;
};
/* 10 = strlen(PAGE_FLAG_) */
#define X(macro) \
{ \
.val = macro, .name = #macro + 10 \
}
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
static const struct page_flag flags[] = {
X(PAGE_FLAG_LOCKED), X(PAGE_FLAG_DIRTY),
X(PAGE_FLAG_PINNED), {.val = PAGE_BUDDY, .name = "BUDDY"},
X(PAGE_FLAG_BUFFER), X(PAGE_FLAG_FILESYSTEM1),
X(PAGE_FLAG_WAITERS), X(PAGE_FLAG_UPTODATE),
X(PAGE_FLAG_WRITEBACK), X(PAGE_FLAG_READAHEAD),
X(PAGE_FLAG_LRU), X(PAGE_FLAG_REFERENCED),
};
#ifdef __clang__
#pragma GCC diagnostic pop
#endif
#undef X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment