runtime

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package runtime provides stub declarations for the RTG runtime. This package is used for Go compiler type checking and IDE completion. The actual implementations are provided by the RTG compiler's builtins. This package should never be executed at runtime.

Index

Constants

View Source
const (
	SYS_EXIT          int64 = 0
	SYS_EXIT_GROUP    int64 = 1
	SYS_WRITE         int64 = 2
	SYS_READ          int64 = 3
	SYS_OPENAT        int64 = 4
	SYS_CLOSE         int64 = 5
	SYS_MMAP          int64 = 6
	SYS_MUNMAP        int64 = 7
	SYS_MOUNT         int64 = 8
	SYS_MKDIRAT       int64 = 9
	SYS_MKNODAT       int64 = 10
	SYS_CHROOT        int64 = 11
	SYS_CHDIR         int64 = 12
	SYS_SETHOSTNAME   int64 = 13
	SYS_IOCTL         int64 = 14
	SYS_DUP3          int64 = 15
	SYS_SETSID        int64 = 16
	SYS_REBOOT        int64 = 17
	SYS_INIT_MODULE   int64 = 18
	SYS_CLOCK_SETTIME int64 = 19
	SYS_CLOCK_GETTIME int64 = 20
	SYS_SOCKET        int64 = 21
	SYS_SENDTO        int64 = 22
	SYS_RECVFROM      int64 = 23
	SYS_EXECVE        int64 = 24
	SYS_CLONE         int64 = 25
	SYS_WAIT4         int64 = 26
	SYS_MPROTECT      int64 = 27
	SYS_GETPID        int64 = 28
	SYS_PIVOT_ROOT    int64 = 29
	SYS_UMOUNT2       int64 = 30
	SYS_UNLINKAT      int64 = 31
	SYS_SYMLINKAT     int64 = 32
	SYS_CONNECT       int64 = 33
	SYS_BIND          int64 = 34
	SYS_LISTEN        int64 = 35
	SYS_ACCEPT        int64 = 36
	SYS_SHUTDOWN      int64 = 37
	SYS_SETSOCKOPT    int64 = 38
	SYS_GETSOCKOPT    int64 = 39
	SYS_SENDMSG       int64 = 40
	SYS_RECVMSG       int64 = 41
	SYS_PIPE2         int64 = 42
	SYS_FCNTL         int64 = 43
	SYS_KILL          int64 = 44
)

Syscall numbers (architecture-independent definitions for type checking)

View Source
const (
	O_RDONLY   int64 = 0
	O_WRONLY   int64 = 1
	O_RDWR     int64 = 2
	O_CREAT    int64 = 0o100
	O_TRUNC    int64 = 0o1000
	O_SYNC     int64 = 0o4010000
	O_NONBLOCK int64 = 0o4000
	O_CLOEXEC  int64 = 0o2000000
)

File open flags

View Source
const (
	F_GETFL         int64 = 3
	F_SETFL         int64 = 4
	F_DUPFD_CLOEXEC int64 = 0x406
)

fcntl commands

View Source
const (
	PROT_READ  int64 = 1
	PROT_WRITE int64 = 2
	PROT_EXEC  int64 = 4
)

Memory protection flags

View Source
const (
	MAP_SHARED    int64 = 1
	MAP_PRIVATE   int64 = 2
	MAP_ANONYMOUS int64 = 0x20
)

Memory map flags

View Source
const (
	EBUSY  int64 = -16
	EPERM  int64 = -1
	EEXIST int64 = -17
	EPIPE  int64 = -32
)

Error numbers (as negative values for syscall returns)

View Source
const (
	LINUX_REBOOT_MAGIC1        int64 = 0xfee1dead
	LINUX_REBOOT_MAGIC2        int64 = 672274793
	LINUX_REBOOT_CMD_RESTART   int64 = 0x01234567
	LINUX_REBOOT_CMD_POWER_OFF int64 = 0x4321fedc
)

Reboot magic numbers and commands

View Source
const (
	AF_INET       int64 = 2
	AF_NETLINK    int64 = 16
	SOCK_DGRAM    int64 = 2
	SOCK_RAW      int64 = 3
	NETLINK_ROUTE int64 = 0
)

Network constants

View Source
const (
	AF_VSOCK        int64 = 40 // Address family for vsock
	SOCK_STREAM     int64 = 1  // Stream socket type
	VMADDR_CID_HOST int64 = 2  // Host CID
	VMADDR_CID_ANY  int64 = -1 // Bind to any CID
	VMADDR_PORT_ANY int64 = -1 // Bind to any port
)

Vsock constants

View Source
const (
	IFF_UP            int64 = 0x1
	SIOCSIFFLAGS      int64 = 0x8914
	SIOCSIFADDR       int64 = 0x8916
	SIOCSIFNETMASK    int64 = 0x891c
	SIOCGIFINDEX      int64 = 0x8933
	RTM_NEWROUTE      int64 = 24
	NLM_F_REQUEST     int64 = 0x1
	NLM_F_CREATE      int64 = 0x400
	NLM_F_REPLACE     int64 = 0x100
	NLM_F_ACK         int64 = 0x4
	RT_TABLE_MAIN     int64 = 254
	RTPROT_BOOT       int64 = 3
	RT_SCOPE_UNIVERSE int64 = 0
	RTN_UNICAST       int64 = 1
	RTA_OIF           int64 = 4
	RTA_GATEWAY       int64 = 5
)

Network interface ioctl constants

View Source
const (
	AT_FDCWD int64 = -100
)

File descriptor constants

View Source
const (
	AT_REMOVEDIR int64 = 0x200
)

Unlink flags

View Source
const (
	CLOCK_REALTIME int64 = 0
)

Clock constants

View Source
const (
	MNT_DETACH int64 = 0x2
)

Mount/unmount flags

View Source
const (
	SIGCHLD int64 = 17
)

Clone flags

View Source
const (
	S_IFCHR int64 = 0o020000
)

File mode constants

View Source
const (
	TIOCSCTTY int64 = 0x540E
)

TTY ioctl constants

Variables

View Source
var GOARCH string = "amd64"

GOARCH is resolved at RTG compile time to the target architecture. The default value is for IDE completion only.

Functions

func CacheFlush added in v0.0.2

func CacheFlush(base int64, size int64)

CacheFlush flushes the CPU caches for the given memory region. On ARM64, this performs the full cache maintenance sequence: 1. Clean data cache lines (DC CVAU) 2. DSB ISH (data synchronization barrier) 3. Invalidate instruction cache lines (IC IVAU) 4. DSB ISH 5. ISB (instruction synchronization barrier) This MUST be called after writing code to memory and before executing it. On x86-64, this is a no-op since x86 has coherent instruction caches.

func Call

func Call(target int64) int64

Call performs an indirect function call to the given address.

func Config

func Config(key string) any

Config retrieves a compile-time configuration value by key. This is evaluated at RTG compile time, not at runtime. The key must be a string literal. Supported value types: string, int64 Returns error at compile time if key is not found.

func EmbedBytes

func EmbedBytes(bytes ...byte) (int64, int64)

EmbedBytes embeds raw bytes in the binary and returns a pointer and length. Usage: ptr, len := runtime.EmbedBytes(0x01, 0x02, 0x03)

func EmbedCString

func EmbedCString(s string) (int64, int64)

EmbedCString embeds a C-style string constant (with null terminator) and returns a pointer and length. The length returned is the original string length WITHOUT the null terminator. Usage: ptr, len := runtime.EmbedCString("hello")

func EmbedConfigCString

func EmbedConfigCString(key string) (int64, int64)

EmbedConfigCString embeds a config string value as a C-style string (with null terminator). The key is looked up in CompileOptions.Config at compile time. The length returned is the original string length WITHOUT the null terminator. Usage: ptr, len := runtime.EmbedConfigCString("hostname")

func EmbedConfigString

func EmbedConfigString(key string) (int64, int64)

EmbedConfigString embeds a config string value in the binary and returns a pointer and length. The key is looked up in CompileOptions.Config at compile time. The string does NOT have a null terminator. Usage: ptr, len := runtime.EmbedConfigString("hostname")

func EmbedString

func EmbedString(s string) (int64, int64)

EmbedString embeds a string constant in the binary and returns a pointer and length. The string does NOT have a null terminator. Usage: ptr, len := runtime.EmbedString("hello")

func GotoLabel

func GotoLabel(label int64)

GotoLabel jumps to the specified label.

func ISB

func ISB()

ISB is an instruction synchronization barrier (ARM64). Required after modifying code in memory before executing it.

func Ifdef

func Ifdef(flag string) bool

Ifdef returns true if the named compile-time flag is set. This is evaluated at RTG compile time, not at runtime. The flag name must be a string literal. Undefined flags are treated as false.

func Load8

func Load8(ptr, offset int64) int64

Load8 loads an 8-bit value from memory at ptr+offset.

func Load16

func Load16(ptr, offset int64) int64

Load16 loads a 16-bit value from memory at ptr+offset.

func Load32

func Load32(ptr, offset int64) int64

Load32 loads a 32-bit value from memory at ptr+offset.

func Load64

func Load64(ptr, offset int64) int64

Load64 loads a 64-bit value from memory at ptr+offset.

func LogKmsg

func LogKmsg(msg string)

LogKmsg writes a message to /dev/kmsg (kernel message buffer). The message is visible via dmesg. This is non-fatal if /dev/kmsg is unavailable.

func Printf

func Printf(format string, args ...any)

Printf prints a formatted message to the console.

func Store8

func Store8(ptr, offset, value int64)

Store8 stores an 8-bit value to memory at ptr+offset.

func Store16

func Store16(ptr, offset, value int64)

Store16 stores a 16-bit value to memory at ptr+offset.

func Store32

func Store32(ptr, offset, value int64)

Store32 stores a 32-bit value to memory at ptr+offset.

func Store64

func Store64(ptr, offset, value int64)

Store64 stores a 64-bit value to memory at ptr+offset.

func Syscall

func Syscall(num int64, args ...any) int64

Syscall executes a system call with the given number and arguments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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