common

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Overview

Package common contains basic routines needed by other modules in go-dpdk package.

Index

Constants

View Source
const (
	// Size of the void pointer.
	SizeOfCPtr = C.sizeof_struct_void_ptr
)
View Source
const (
	SocketIDAny = int(C.SOCKET_ID_ANY)
)

SocketIDAny represents selection for any NUMA socket.

Variables

View Source
var (
	ErrNoConfig  = errors.New("Missing rte_config")
	ErrSecondary = errors.New("Operation not allowed in secondary processes")
)
View Source
var (
	ErrUnprintable  = errors.New("unprintable char")
	ErrOpenQuote    = errors.New("no closing quote")
	DefaultSplitter = &Splitter{
		unicode.IsSpace,
		func(r rune) (rune, bool) {
			if r == '"' {
				return '"', true
			}
			if r == '\'' {
				return '\'', true
			}
			return ' ', false
		},
		false,
	}
)

Functions

func Assert

func Assert(t testing.TB, fail bool) func(bool, ...interface{})

Assert allows to perform one-lined tests and, optionally, print some diagnostic info if the test failed.

If fail is true, test failure will cause panic and cease test execution.

func Errno

func Errno(n interface{}) error

Errno converts return value of C function into meaningful error.

If n is nil, then n = RteErrno() if n is not nil and not a signed integer, function panics.

func IntOrErr

func IntOrErr(n interface{}) (int, error)

IntOrErr returns error as in Errno in case n is negative. Otherwise, the value itself with nil error will be returned.

If n is nil, then n = RteErrno() if n is not nil and not a signed integer, function panics.

func RteErrno

func RteErrno() int

RteErrno returns rte_errno variable.

func SplitFunc

func SplitFunc(s *Splitter) bufio.SplitFunc

func Uintptr

func Uintptr(i interface{}) uintptr

Uintptr returns pointer as an integer number for arbitraty input value. The attempt to interpret the value as convertible is made.

Types

type ObjectID

type ObjectID uint64

type Registry

type Registry interface {
	Create(interface{}) ObjectID
	Read(ObjectID) interface{}
	Update(ObjectID, interface{})
	Delete(ObjectID)
}

Registry implements CRUD operations to map ID and objects.

func NewRegistryArray

func NewRegistryArray() Registry

func NewRegistryMap

func NewRegistryMap() Registry

type Splitter

type Splitter struct {
	// True if rune is a white space.
	IsSpace func(rune) bool

	// True if rune is quote. Any rune embraced by the one of these
	// pairs is considered a part of a token even if IsSpace returns
	// true.  A pairs must not contradict white space and another
	// pair.
	//
	// If true, return closing quote rune.
	IsQuote func(rune) (rune, bool)

	// If true, final token is allowed not to contain closing quote.
	// If false, ErrOpenQuote error will be returned if no closing
	// quote found.
	AllowOpenQuote bool
}

Jump to

Keyboard shortcuts

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