From 82710fba6bad6c73598de8ed4df6cc9b1717ba12 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Tue, 20 Oct 2026 05:29:40 +0100 Subject: [PATCH] Add utils --- src/utils/utils.h | 27 +++++++++++++++++++++++++++ src/utils/utils_inc.h | 8 ++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/utils/utils.h create mode 100644 src/utils/utils_inc.h diff --git a/src/utils/utils.h b/src/utils/utils.h new file mode 100644 index 0000000..1cd2887 --- /dev/null +++ b/src/utils/utils.h @@ -0,0 +1,27 @@ +// vim:fileencoding=utf-8:foldmethod=marker + +#ifndef UTILS_H +#define UTILS_H + +#include "../wapp/wapp.h" + +#ifdef USE_RUNTIME_ASSERT +#define baseAssert wpRuntimeAssert +#else +#define baseAssert wpDebugAssert +#endif + +#define assertWithLogger(COND, LOGGER_PTR, MSG) do { \ + WpStr8RO msg = wpStr8LitRo(MSG); \ + if (!(COND)) { wpLogError((LOGGER_PTR), msg); } \ + baseAssert(COND, MSG); \ +} while(0) + +#define makeVersion(MAJOR, MINOR, PATCH) (wpU32Const(MAJOR) << 24 | \ + wpU32Const(MINOR) << 16 | \ + wpU32Const(PATCH)) +#define majorFromVersion(VERSION) (VERSION >> 24) +#define minorFromVersion(VERSION) ((VERSION >> 16) & 0xff) +#define patchFromVersion(VERSION) (VERSION & 0xffff) + +#endif // !UTILS_H diff --git a/src/utils/utils_inc.h b/src/utils/utils_inc.h new file mode 100644 index 0000000..8abe422 --- /dev/null +++ b/src/utils/utils_inc.h @@ -0,0 +1,8 @@ +// vim:fileencoding=utf-8:foldmethod=marker + +#ifndef UTILS_INC_H +#define UTILS_INC_H + +#include "utils.h" + +#endif // !UTILS_INC_H