Skip to content

Commit

Permalink
Add page_size to hat::system_info
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Oct 7, 2024
1 parent 2a2c7c3 commit 0d77b44
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ set(LIBHAT_SRC
src/Scanner.cpp
src/System.cpp

src/os/unix/System.cpp

src/os/win32/MemoryProtector.cpp
src/os/win32/Process.cpp
src/os/win32/Scanner.cpp
src/os/win32/System.cpp

src/arch/x86/SSE.cpp
src/arch/x86/AVX2.cpp
Expand Down
6 changes: 3 additions & 3 deletions include/libhat/Scanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ namespace hat {
enum class scan_mode {
Auto, // Picks a mode at runtime
Single, // std::find + std::equal
SSE, // x86 SSE 4.1
AVX2, // x86 AVX2
AVX512, // x86 AVX512
SSE, // x86/x64 SSE 4.1
AVX2, // x86/x64 AVX2
AVX512, // x64 AVX512
};

class scan_context {
Expand Down
2 changes: 2 additions & 0 deletions include/libhat/System.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace hat {
struct system_info {
size_t page_size{};

system_info(const system_info&) = delete;
system_info& operator=(const system_info&) = delete;
system_info(system_info&&) = delete;
Expand Down
2 changes: 0 additions & 2 deletions src/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace hat {

system_info::system_info() {}

const system_info_impl system_info_impl::instance{};
const system_info_impl& get_system() {
return system_info_impl::instance;
Expand Down
14 changes: 14 additions & 0 deletions src/os/unix/System.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <libhat/Defines.hpp>
#ifdef LIBHAT_UNIX

#include <libhat/System.hpp>
#include <unistd.h>

namespace hat {

system_info::system_info() {
this->page_size = static_cast<size_t>(sysconf(_SC_PAGESIZE));
}
}

#endif
16 changes: 16 additions & 0 deletions src/os/win32/System.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <libhat/Defines.hpp>
#ifdef LIBHAT_WINDOWS

#include <libhat/System.hpp>
#include <Windows.h>

namespace hat {

system_info::system_info() {
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
this->page_size = sysInfo.dwPageSize;
}
}

#endif

0 comments on commit 0d77b44

Please sign in to comment.