Add alignment helpers

This commit is contained in:
baldurk
2018-12-19 15:38:40 +00:00
parent b08fb8c9b5
commit c16371d779
+12
View File
@@ -256,6 +256,18 @@ std::string GetEnvVar(const char *var);
#define RANDF(mn, mx) ((float(rand()) / float(RAND_MAX)) * ((mx) - (mn)) + (mn))
template <typename T>
inline T AlignUp(T x, T a)
{
return (x + (a - 1)) & (~(a - 1));
}
template <typename T, typename A>
inline T AlignUpPtr(T x, A a)
{
return (T)AlignUp<uintptr_t>((uintptr_t)x, (uintptr_t)a);
}
std::string strlower(const std::string &str);
std::string strupper(const std::string &str);
std::string trim(const std::string &str);