util

package
v0.0.0-...-1cdf030 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicUpdateMaxUint32

func AtomicUpdateMaxUint32(store *atomic.Uint32, newValue uint32)

AtomicUpdateMaxUint32 updates the value in store using atomic memory primitives. newValue will only be placed in store if newValue is larger than the current value in store. To avoid inconsistency parallel updates to store should be avoided.

func DecToUint64

func DecToUint64(str string) uint64

DecToUint64 is a convenience function to extract a decimal string to a uint64 and not worry about errors. Essentially a "mustConvertDecToUint64".

func HashString

func HashString(s string) uint64

HashString turns a string into a 64-bit hash.

func HexToUint64

func HexToUint64(str string) uint64

HexToUint64 is a convenience function to extract a hex string to a uint64 and not worry about errors. Essentially a "mustConvertHexToUint64".

func IsValidString

func IsValidString(s string) bool

IsValidString checks if string is UTF-8-encoded and only contains expected characters.

func NextPowerOfTwo

func NextPowerOfTwo(v uint32) uint32

NextPowerOfTwo returns the next highest power of 2 for a given value v or v, if v is a power of 2.

func VersionUint

func VersionUint(major, minor, patch uint32) uint32

VersionUint returns a single integer composed of major, minor, patch.

Types

type KTime

type KTime int64

KTime stores a time value, retrieved from a monotonic clock, in nanoseconds

func GetKTime

func GetKTime() KTime

GetKTime gets the current time in same nanosecond format as bpf_ktime_get_ns() eBPF call This relies runtime.nanotime to use CLOCK_MONOTONIC. If this changes, this needs to be adjusted accordingly. Using this internal is superior in performance, as it is able to use the vDSO to query the time without syscall.

type OnDiskFileIdentifier

type OnDiskFileIdentifier struct {
	DeviceID uint64 // dev_t as reported by stat.
	InodeNum uint64 // ino_t should fit into 64 bits
}

OnDiskFileIdentifier can be used as unique identifier for a file. It is a structure to identify a particular file on disk by deviceID and inode number.

func (OnDiskFileIdentifier) Hash32

func (odfi OnDiskFileIdentifier) Hash32() uint32

type PID

type PID int32

PID represent Unix Process ID (pid_t)

func (PID) Hash32

func (p PID) Hash32() uint32

type Range

type Range struct {
	Start uint64
	End   uint64
}

Range describes a range with Start and End values.

type SourceLineno

type SourceLineno uint64

SourceLineno represents a line number within a source file. It is intended to be used for the source line numbers associated with offsets in native code, or for source line numbers in interpreted code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL