32 lines
587 B
C++
32 lines
587 B
C++
#include <pslang/jit/storage.hpp>
|
|
|
|
#ifdef __linux__
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#ifdef __APPLE__
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
namespace pslang::jit
|
|
{
|
|
|
|
std::size_t binary_storage::align()
|
|
{
|
|
auto const page_size = native_page_size();
|
|
auto aligned_size = ((storage.size() + (page_size - 1)) / page_size) * page_size;
|
|
storage.resize(aligned_size);
|
|
return storage.size();
|
|
}
|
|
|
|
std::size_t native_page_size()
|
|
{
|
|
#if defined(__linux__) || defined(__APPLE__)
|
|
return getpagesize();
|
|
#else
|
|
throw std::runtime_error("Native page size is not supported for this platform");
|
|
#endif
|
|
}
|
|
|
|
}
|
|
|