github.com/primecitizens/pcz/std@v0.2.1/core/sys/auxv.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  //go:build !noos && (linux || freebsd || netbsd || solaris || dragonfly)
     5  
     6  package sys
     7  
     8  import (
     9  	_ "unsafe" // for go:linkname
    10  
    11  	"github.com/primecitizens/pcz/std/core/iter"
    12  )
    13  
    14  func (it AuxvIter) Nth(i int) (aux Auxv, ok bool) {
    15  	if it < 0 {
    16  		return
    17  	}
    18  
    19  	i, ok = iter.Index(i, len(auxvs)-int(it))
    20  	if ok {
    21  		return nthauxv(i), true
    22  	}
    23  
    24  	return
    25  }
    26  
    27  func (it AuxvIter) Len() int { return len(auxvs) - int(it) }
    28  
    29  func (it AuxvIter) SliceFrom(start int) AuxvIter {
    30  	start, ok := iter.Bound(start, len(auxvs)-int(it))
    31  	if ok {
    32  		return it + AuxvIter(start)
    33  	}
    34  
    35  	return AuxvIter(len(auxvs))
    36  }