mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-30 07:03:06 -08:00
fix: RLIM_INFINITY type is uint64 on loong64
Signed-off-by: znley <shanjiantao@loongson.cn>
This commit is contained in:
parent
584966f1c4
commit
6f6af5a59b
|
@ -18,16 +18,18 @@ package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// syscall.RLIM_INFINITY is a constant and its default type is int.
|
// syscall.RLIM_INFINITY is a constant.
|
||||||
// It needs to be converted to an int64 variable to be compared with uint64 values.
|
// Its type is int on most architectures but there are exceptions such as loong64.
|
||||||
// See https://golang.org/ref/spec#Conversions
|
// Uniform it to uint accorind to the standard.
|
||||||
var unlimited int64 = syscall.RLIM_INFINITY
|
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html
|
||||||
|
var unlimited uint64 = syscall.RLIM_INFINITY & math.MaxUint64
|
||||||
|
|
||||||
func limitToString(v uint64, unit string) string {
|
func limitToString(v uint64, unit string) string {
|
||||||
if v == uint64(unlimited) {
|
if v == unlimited {
|
||||||
return "unlimited"
|
return "unlimited"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%d%s", v, unit)
|
return fmt.Sprintf("%d%s", v, unit)
|
||||||
|
|
Loading…
Reference in a new issue