platform

package
v0.0.0-...-90e8e0c Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package platform defines the supported plattforms and hardware architectures.

Package platform defines the supported platforms and hardware architectures.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedOs   = errors.New("unsupported os")
	ErrUnsupportedArch = errors.New("unsupported arch")
)
View Source
var Archs = []Arch{
	X86_64{},
}

List of supported architectures.

View Source
var Oses = []Os{
	Macos{},
	Linux{},
	Freestanding{},
}

List of supported operating systems.

Functions

This section is empty.

Types

type Arch

type Arch interface {
	String() string
	BitSize() int
	Pointer() token.Token // U32 or U64
	Register(reg, typ token.Token) (name string)
	SizeOf(typ token.Token) uint64
	// contains filtered or unexported methods
}

Arch is implemented for supported architectures.

func GetArch

func GetArch(s string) Arch

type Freestanding

type Freestanding struct{}

func (Freestanding) AppendSyscall

func (Freestanding) AppendSyscall(stmts []ast.Stmt, values []ast.Value, loc ast.Location) []ast.Stmt

func (Freestanding) Entry

func (Freestanding) Entry() string

func (Freestanding) SizeOf

func (Freestanding) SizeOf(typ token.Token) uint64

func (Freestanding) String

func (Freestanding) String() string

func (Freestanding) SyscallCC

func (Freestanding) SyscallCC(_ Arch) []token.Token

type Linux

type Linux struct{}

func (Linux) AppendSyscall

func (m Linux) AppendSyscall(stmts []ast.Stmt, values []ast.Value, loc ast.Location) []ast.Stmt

func (Linux) Entry

func (Linux) Entry() string

func (Linux) String

func (Linux) String() string

func (Linux) SyscallCC

func (Linux) SyscallCC(arch Arch) []token.Token

type Macos

type Macos struct{}

func (Macos) AppendSyscall

func (m Macos) AppendSyscall(stmts []ast.Stmt, values []ast.Value, loc ast.Location) []ast.Stmt

func (Macos) Entry

func (Macos) Entry() string

func (Macos) String

func (Macos) String() string

func (Macos) SyscallCC

func (Macos) SyscallCC(arch Arch) []token.Token

type Os

type Os interface {
	String() string
	// Entry for the binary.
	Entry() string
	// Syscall calling convention for this arch.
	SyscallCC(arch Arch) []token.Token
	// AppendSyscall appends statements to `stmts` that generate a syscall with the given `values`.
	AppendSyscall(stmts []ast.Stmt, values []ast.Value, loc ast.Location) []ast.Stmt
	// contains filtered or unexported methods
}

Os is implemented for supported operating systems.

func GetOs

func GetOs(s string) Os

type Platform

type Platform struct {
	Os   Os
	Arch Arch
}

func Default

func Default() Platform

Default platform for the runnning operating system and architecture. Defaults to freestanding/x86_64.

func Init

func Init(os, arch string) (Platform, error)

Init returns the platform corresponding to `os` and `arch` or an error if invalid.

func (Platform) String

func (pt Platform) String() string

type X86_64

type X86_64 struct{}

func (X86_64) BitSize

func (X86_64) BitSize() int

func (X86_64) Pointer

func (X86_64) Pointer() token.Token

func (X86_64) Register

func (X86_64) Register(reg, typ token.Token) string

func (X86_64) SizeOf

func (X86_64) SizeOf(typ token.Token) uint64

SizeOf typ in bytes. 0 for invalid type.

func (X86_64) String

func (X86_64) String() string

Jump to

Keyboard shortcuts

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