mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
add: [system] sys::conf page_size for win
This commit is contained in:
parent
c604fadbea
commit
db2b2b38ec
@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "libimp/def.h"
|
#include "libimp/def.h"
|
||||||
#include "libimp/export.h"
|
#include "libimp/export.h"
|
||||||
@ -27,7 +28,7 @@ LIBIMP_EXPORT void error_code(result_code) noexcept;
|
|||||||
LIBIMP_EXPORT std::string error_str(result_code) noexcept;
|
LIBIMP_EXPORT std::string error_str(result_code) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @brief A text description string with an error number attached
|
* @brief A text description string with an error number attached
|
||||||
*/
|
*/
|
||||||
LIBIMP_EXPORT std::string error_msg(result_code) noexcept;
|
LIBIMP_EXPORT std::string error_msg(result_code) noexcept;
|
||||||
|
|
||||||
|
|||||||
@ -62,8 +62,8 @@ std::int64_t conf(info r) noexcept {
|
|||||||
case info::page_size: {
|
case info::page_size: {
|
||||||
auto val = ::sysconf(_SC_PAGESIZE);
|
auto val = ::sysconf(_SC_PAGESIZE);
|
||||||
if (val >= 0) return (std::int64_t)val;
|
if (val >= 0) return (std::int64_t)val;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
log.error("invalid info = {}", enum_cast(r));
|
log.error("invalid info = {}", enum_cast(r));
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include "libimp/system.h"
|
#include "libimp/system.h"
|
||||||
#include "libimp/log.h"
|
#include "libimp/log.h"
|
||||||
#include "libimp/codecvt.h"
|
#include "libimp/codecvt.h"
|
||||||
|
#include "libimp/enum_cast.h"
|
||||||
|
|
||||||
LIBIMP_NAMESPACE_BEG_
|
LIBIMP_NAMESPACE_BEG_
|
||||||
namespace sys {
|
namespace sys {
|
||||||
@ -76,5 +77,24 @@ std::string error_str(result_code code) noexcept {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieves information about the current system
|
||||||
|
* https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo
|
||||||
|
* https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getnativesysteminfo
|
||||||
|
*/
|
||||||
|
std::int64_t conf(info r) noexcept {
|
||||||
|
LIBIMP_LOG_();
|
||||||
|
switch (r) {
|
||||||
|
case info::page_size: {
|
||||||
|
::SYSTEM_INFO info {};
|
||||||
|
::GetNativeSystemInfo(&info);
|
||||||
|
return (std::int64_t)info.dwPageSize;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.error("invalid info = {}", enum_cast(r));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sys
|
} // namespace sys
|
||||||
LIBIMP_NAMESPACE_END_
|
LIBIMP_NAMESPACE_END_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user