Skip to content

Commit b099ead

Browse files
committed
fix: bugs
1 parent 1c62b87 commit b099ead

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

llama/addon/globals/getSystemMemoryInfo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static std::optional<uint64_t> multiplyUint64(uint64_t left, uint64_t right) {
3232
return uint64_t(0);
3333
}
3434

35-
if (left > (std::numeric_limits<uint64_t>::max() / right)) {
35+
if (left > ((std::numeric_limits<uint64_t>::max)() / right)) {
3636
return std::nullopt;
3737
}
3838

@@ -181,7 +181,7 @@ static std::optional<uint64_t> parseLinuxMeminfoValueBytes(const std::string& li
181181
}
182182

183183
const long double roundedBytesValue = std::round(bytesValue);
184-
if (roundedBytesValue > static_cast<long double>(std::numeric_limits<uint64_t>::max())) {
184+
if (roundedBytesValue > static_cast<long double>((std::numeric_limits<uint64_t>::max)())) {
185185
return std::nullopt;
186186
}
187187

@@ -211,7 +211,7 @@ static std::optional<uint64_t> parseLinuxVmstatValuePages(const std::string& lin
211211
sawDigit = true;
212212

213213
const uint64_t digit = uint64_t(line[index] - '0');
214-
if (pageCount > ((std::numeric_limits<uint64_t>::max() - digit) / 10)) {
214+
if (pageCount > (((std::numeric_limits<uint64_t>::max)() - digit) / 10)) {
215215
return std::nullopt;
216216
}
217217

@@ -396,10 +396,10 @@ static AddonSystemMemoryInfo retrieveSystemMemoryInfo() {
396396
#endif
397397

398398
if (systemMemoryInfo.total.has_value() && systemMemoryInfo.wired.has_value())
399-
systemMemoryInfo.wired = std::min(systemMemoryInfo.wired.value(), systemMemoryInfo.total.value());
399+
systemMemoryInfo.wired = (std::min)(systemMemoryInfo.wired.value(), systemMemoryInfo.total.value());
400400

401401
if (systemMemoryInfo.total.has_value() && systemMemoryInfo.free.has_value())
402-
systemMemoryInfo.free = std::min(systemMemoryInfo.free.value(), systemMemoryInfo.total.value());
402+
systemMemoryInfo.free = (std::min)(systemMemoryInfo.free.value(), systemMemoryInfo.total.value());
403403

404404
return systemMemoryInfo;
405405
}

0 commit comments

Comments
 (0)