Skip to content

Commit

Permalink
Add getPageSize function to system std (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer authored Feb 12, 2024
1 parent 965a1e5 commit 8fe6612
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions std/os/system_linux.spice
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// External functions
ext f<long> get_nprocs();
ext f<unsigned int> getpagesize();

/**
* Returns the number of CPU cores of the host system.
Expand All @@ -8,4 +9,13 @@ ext f<long> get_nprocs();
*/
public f<long> getCPUCoreCount() {
return get_nprocs();
}

/**
* Returns the system page size of the host system.
*
* return Page size
*/
public f<unsigned int> getPageSize() {
return getpagesize();
}
15 changes: 13 additions & 2 deletions std/os/system_windows.spice
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type SystemInfo struct {
unsigned short wProcessorArchitecture
unsigned short wReserved
unsigned int dwPageSize
long* lpMinimumApplicationAddress
long* lpMaximumApplicationAddress
byte* lpMinimumApplicationAddress
byte* lpMaximumApplicationAddress
int* dwActiveProcessorMask
unsigned int dwNumberOfProcessors
int dwProcessorType
Expand Down Expand Up @@ -62,4 +62,15 @@ public f<string> getArchName() {
return "intel";
}
return "unknown";
}

/**
* Returns the system page size of the host system.
*
* return Page size
*/
public f<unsigned int> getPageSize() {
SystemInfo info = SystemInfo{};
GetSystemInfo(&info);
return info.dwPageSize;
}

0 comments on commit 8fe6612

Please sign in to comment.