Documentation
¶
Overview ¶
The libc package implements various functions from the C standard library in Go.
Index ¶
- Variables
- func Abort()
- func AbsI32(x int32) int32
- func AbsI64(x int64) int64
- func AddPointer[T any](ptr *T, offset int) *T
- func Addr[T any](p *T) uintptr
- func Alloca[T any](count, size int64) *T
- func AllocaFree(p *byte)
- func Arc4randomBuf(buf *byte, n int64)
- func Argv() unsafe.Pointer
- func As[T any](p unsafe.Pointer) *T
- func AssertFail(expr, file *byte, line int32, function *byte)
- func AssertRtn(function, file *byte, line int32, expr *byte)
- func AtomicAddI8(addr *byte, delta byte) byte
- func AtomicCASI8(addr *byte, old, neu byte) bool
- func AtomicLoadI8(addr *byte) byte
- func AtomicSwapI8(addr *byte, neu byte) byte
- func Bytes(p *byte, n int) []byte
- func Calloc[T any](count, size int64) *T
- func Close(fd int32) int32
- func CtypeBLoc() **int16
- func CtypeWiden(this unsafe.Pointer, c byte) byte
- func CtypeWidenInit(this *byte)
- func CxaAtexit(fn, arg, dso *byte) int32
- func CxxNoop(this *byte) unsafe.Pointer
- func Dlsym(handle, name *byte) *byte
- func Dup(fd int32) int32
- func DynamicCast(src, srcType, dstType *byte, src2dst int64) *byte
- func ErrnoLocation() *int32
- func Exit(status int32)
- func Fclose(f *os.File) int32
- func Fcntl(fd int32, cmd int32, args ...any) int32
- func Fdopen(fd int32, mode *byte) *os.File
- func Fence()
- func FilebufClose(this *byte) unsafe.Pointer
- func FilebufOpen(this *byte, path *byte, mode int32) unsafe.Pointer
- func FilebufUnderflow(this *byte) int32
- func Fprintf(stream *os.File, format *byte, args ...any) int32
- func Fputc(c int32, stream *os.File) int32
- func Fputs(s *byte, stream *os.File) int32
- func Free(p *byte)
- func Fstat64(fd int32, st *byte) int32
- func FuncCode[F any](fn F) unsafe.Pointer
- func FuncFromCode[F any](code unsafe.Pointer) F
- func Getauxval(typ int64) int64
- func Getchar() int32
- func Getcwd(buf *byte, size int64) *byte
- func Getentropy(buf *byte, n int64) int32
- func Getenv(name *byte) *byte
- func Getpid() int32
- func Getrandom(buf *byte, buflen int64, flags int32) int64
- func Gettid() int32
- func GoString(s *byte) string
- func I1Pack8(v [8]bool) byte
- func I1Pack16(v [16]bool) int16
- func I1Pack32(v [32]bool) int32
- func I1Pack64(v [64]bool) int64
- func I1Unpack8(m byte) (v [8]bool)
- func I1Unpack16(m int16) (v [16]bool)
- func I1Unpack32(m int32) (v [32]bool)
- func I1Unpack64(m int64) (v [64]bool)
- func I128Eq(a, b I128) bool
- func I128Ne(a, b I128) bool
- func I128Sge(a, b I128) bool
- func I128Sgt(a, b I128) bool
- func I128Sle(a, b I128) bool
- func I128Slt(a, b I128) bool
- func I128TruncI1(a I128) bool
- func I128TruncI8(a I128) byte
- func I128TruncI16(a I128) int16
- func I128TruncI32(a I128) int32
- func I128TruncI64(a I128) int64
- func I128Uge(a, b I128) bool
- func I128Ugt(a, b I128) bool
- func I128Ule(a, b I128) bool
- func I128Ult(a, b I128) bool
- func I256Eq(a, b I256) bool
- func I256Ne(a, b I256) bool
- func I256Sge(a, b I256) bool
- func I256Sgt(a, b I256) bool
- func I256Sle(a, b I256) bool
- func I256Slt(a, b I256) bool
- func I256TruncI1(a I256) bool
- func I256TruncI8(a I256) byte
- func I256TruncI16(a I256) int16
- func I256TruncI32(a I256) int32
- func I256TruncI64(a I256) int64
- func I256Uge(a, b I256) bool
- func I256Ugt(a, b I256) bool
- func I256Ule(a, b I256) bool
- func I256Ult(a, b I256) bool
- func IfstreamClose(this *byte) unsafe.Pointer
- func IfstreamCloseVTT(this *byte, vtt *byte) unsafe.Pointer
- func IfstreamOpen(this *byte, path *byte, mode int32) unsafe.Pointer
- func InitOstream(this unsafe.Pointer)
- func InlineAsm(asm, constraint string)
- func IosBaseCtor(this *byte) unsafe.Pointer
- func IosBool(this *byte) bool
- func IosClear(this *byte, state int32)
- func IosEof(this *byte) bool
- func IosFail(this *byte) bool
- func IosGetloc(ret *byte, _ ...any) unsafe.Pointer
- func IosNot(this *byte) bool
- func IosPrecisionSet(this *byte, n int64) int64
- func IstreamApplyIosManip(is *byte, _ *byte) *byte
- func IstreamExtractI32(is *byte, out *byte) *byte
- func IstreamGetline(is, str *byte) *byte
- func IstreamSentryCtor(this *byte, is *byte, _ bool) unsafe.Pointer
- func Iswalnum(c int32) int32
- func Iswalpha(c int32) int32
- func Iswblank(c int32) int32
- func Iswcntrl(c int32) int32
- func Iswdigit(c int32) int32
- func Iswlower(c int32) int32
- func Iswspace(c int32) int32
- func Iswupper(c int32) int32
- func Iswxdigit(c int32) int32
- func LibcxxTreeConstructFromTree(tree, src, construct *byte) *byte
- func LibcxxTreeGetValue(this *byte) *byte
- func LibcxxTreeMin(x *byte) *byte
- func LibcxxTreeNext(x *byte) *byte
- func LibcxxTreePrev(x *byte) *byte
- func Load[T any](p unsafe.Pointer, off int) T
- func LoadRelativeI64(p unsafe.Pointer, off int64) unsafe.Pointer
- func LocaleCtor(this *byte) unsafe.Pointer
- func LocaleDtor(this *byte) unsafe.Pointer
- func LocaleUseFacet(loc *byte, id *byte) unsafe.Pointer
- func Lrand48() int64
- func Lseek64(fd int32, offset int64, whence int32) int64
- func Malloc[T any](n int64) *T
- func MarkStdoutStream(this unsafe.Pointer)
- func MaximumNumF64(a, b float64) float64
- func Memchr(s *byte, c int32, n int64) *byte
- func Memcmp(s1 *byte, s2 *byte, n int64) int32
- func MemcpyChk(dest *byte, src *byte, length int64, destlen int64) *byte
- func Memmove(dst *byte, src *byte, length int64) *byte
- func Memset(b *byte, c byte, length int64) *byte
- func MemsetChk(b *byte, c byte, length int64, destlen int64) *byte
- func MemsetPattern16(b *byte, pattern16 *byte, length int64)
- func Mmap(addr any, length int64, prot, flags, fd int32, offset int64) unsafe.Pointer
- func Mmap64(addr any, length int64, prot, flags, fd int32, offset int64) unsafe.Pointer
- func Mprotect(addr *byte, length int64, prot int32) int32
- func Munmap(addr *byte, length int64) int32
- func NSGetArgc() unsafe.Pointer
- func NSGetArgv() unsafe.Pointer
- func NSGetEnviron() unsafe.Pointer
- func NSGetProgname() unsafe.Pointer
- func OStringStreamClose(this *byte) unsafe.Pointer
- func OStringStreamCtor(this *byte) unsafe.Pointer
- func OStringStreamStr(ret, this *byte)
- func Off(p unsafe.Pointer, n int) unsafe.Pointer
- func Open(path *byte, flags int32, mode ...int32) int32
- func Open64(path *byte, flags int32, mode ...int32) int32
- func OssVptr() unsafe.Pointer
- func OstreamEndl(out *byte) *byte
- func OstreamFlush(out *byte) *byte
- func OstreamInsert(out *byte, s *byte, n int64) *byte
- func OstreamInsertBool(out *byte, v bool) *byte
- func OstreamInsertF64(out *byte, x float64) *byte
- func OstreamInsertI64(out *byte, n int64) *byte
- func OstreamInsertPtr(out *byte, p unsafe.Pointer) *byte
- func OstreamInsertU64(out *byte, n uint64) *byte
- func OstreamLsCStr(out *byte, s *byte) *byte
- func OstreamLsString(out *byte, s *byte) *byte
- func OstreamPut(out *byte, c byte) *byte
- func OstreamSentryCtor(this *byte, os *byte) unsafe.Pointer
- func OstreamSentryDestroy(this *byte) unsafe.Pointer
- func Poll(fds *byte, nfds int64, timeout int32) int32
- func Printf(format *byte, args ...any) int32
- func PthreadAttrDestroy(attr *byte) int32
- func PthreadAttrGetstack(attr, stackaddr *byte, stacksize *byte) int32
- func PthreadGetStackaddrNp(thread int64) unsafe.Pointer
- func PthreadGetStacksizeNp(thread int64) int64
- func PthreadGetattrNp(thread int64, attr *byte) int32
- func PthreadMutexDestroy(m *byte) int32
- func PthreadMutexInit(m, attr *byte) int32
- func PthreadMutexLock(m *byte) int32
- func PthreadMutexTrylock(m *byte) int32
- func PthreadMutexUnlock(m *byte) int32
- func PthreadMutexattrDestroy(attr *byte) int32
- func PthreadMutexattrInit(attr *byte) int32
- func PthreadMutexattrSettype(attr *byte, typ int32) int32
- func PthreadSelf() int64
- func PthreadSetnameNp(_ ...any) int32
- func PthreadThreadidNp(_ any, id *byte) int32
- func Ptr[T any](p *T) unsafe.Pointer
- func PtrMask(p unsafe.Pointer, mask int64) unsafe.Pointer
- func Putc(c int32, stream *os.File) int32
- func Putchar(c int32) int32
- func Puts(s *byte) int32
- func RbTreeDecrement(x *byte) *byte
- func RbTreeIncrement(x *byte) *byte
- func RbTreeInit(tree *byte)
- func RbTreeInsertAndRebalance(insertLeft bool, x, p, header *byte)
- func RbTreeRebalanceForErase(z, header *byte) *byte
- func Read(fd int32, buf *byte, n int64) int64
- func Realloc(p *byte, n int64) *byte
- func Realpath(path *byte, resolved *byte) *byte
- func RustAlloc(size, align int64) unsafe.Pointer
- func RustAllocZeroed(size, align int64) unsafe.Pointer
- func RustDealloc(p unsafe.Pointer, size, align int64)
- func RustFmtI32(val, _ unsafe.Pointer) bool
- func RustFmtUsize(val, _ unsafe.Pointer) bool
- func RustPrint(tmpl, args unsafe.Pointer)
- func RustRealloc(p unsafe.Pointer, oldSize, align, newSize int64) unsafe.Pointer
- func SAddWithOverflowI32(a, b int32) struct{ ... }
- func SMaxI32(a, b int32) int32
- func SMaxI64(a, b int64) int64
- func SMinI32(a, b int32) int32
- func SMinI64(a, b int64) int64
- func Scanf(format *byte, args ...any) int32
- func Sigaction(signum int32, act, oldact *byte) int32
- func Sigaltstack(ss, oss *byte) int32
- func Signal(sig int32, handler int64) int64
- func Snprintf(buf *byte, n int64, format *byte, args ...any) int32
- func Srand48(seed int64)
- func Sscanf(str *byte, format *byte, args ...any) int32
- func StandinVptr() unsafe.Pointer
- func Stat64(path *byte, st *byte) int32
- func Statx(dirfd int32, pathname *byte, flags int32, mask int32, buf *byte) int32
- func StdStringAppendCStr(s, cstr *byte, n int64) unsafe.Pointer
- func StdStringAssign(this *byte, other *byte) unsafe.Pointer
- func StdStringAssignCStr(s, cstr *byte, n int64) unsafe.Pointer
- func StdStringCompareCStr(s *byte, pos, n int64, cstr *byte, n2 int64) int32
- func StdStringCopy(this *byte, other *byte) unsafe.Pointer
- func StdStringDestroy(this *byte) unsafe.Pointer
- func StdStringEqCStr(s, cstr *byte) bool
- func StdStringErase(s *byte, pos, n int64) unsafe.Pointer
- func StdStringInit(this *byte, s *byte, n int64) unsafe.Pointer
- func StdStringInsertCStr(s *byte, pos int64, cstr *byte, n int64) unsafe.Pointer
- func StdStringPlusCStrLeft(ret, cstr, s *byte)
- func StdStringPlusCStrRight(ret, s, cstr *byte)
- func StdStringPushBack(s *byte, c byte) unsafe.Pointer
- func StdStringSubstr(this, other *byte, pos, n int64, alloc *byte) unsafe.Pointer
- func StdToString(ret *byte, v uint64)
- func StdToStringI(ret *byte, v int64)
- func Store[T any](p unsafe.Pointer, off int, v T)
- func StrcatChk(dest *byte, src *byte, destlen int64) *byte
- func Strchr(s *byte, c int32) *byte
- func Strcmp(s1 *byte, s2 *byte) int32
- func Strcpy(s1 *byte, s2 *byte) *byte
- func Strcspn(s1 *byte, s2 *byte) int64
- func StreambufCtor(this *byte) unsafe.Pointer
- func StreambufSgetc(this *byte) int32
- func StrerrorR(errnum int32, buf *byte, buflen int64) int32
- func StringbufCtor(this *byte) unsafe.Pointer
- func StringbufStr(this, s *byte)
- func StringstreamClose(this *byte) unsafe.Pointer
- func StringstreamCtor(this *byte, str *byte, mode int32) unsafe.Pointer
- func StringstreamDefaultClose(this *byte) unsafe.Pointer
- func StringstreamDefaultCtor(this *byte) unsafe.Pointer
- func StringstreamStr(ret, this *byte)
- func Strlen(s *byte) int64
- func Strncat(s1 *byte, s2 *byte, n int64) *byte
- func Strncmp(s1 *byte, s2 *byte, n int64) int32
- func Strncpy(s1 *byte, s2 *byte, n int64) *byte
- func Strpbrk(s1 *byte, s2 *byte) *byte
- func Strrchr(s *byte, c int32) *byte
- func Strspn(s1 *byte, s2 *byte) int64
- func Strstr(s1 *byte, s2 *byte) *byte
- func Syscall(nr int64, args ...interface{}) int64
- func Sysconf(name int32) int64
- func Towlower(c int32) int32
- func Towupper(c int32) int32
- func UAddSatU64(a, b uint64) uint64
- func UMaxU32(a, b int32) int32
- func UMaxU64(a, b int64) int64
- func UMinU32(a, b int32) int32
- func UMinU64(a, b int64) int64
- func UMulWithOverflowU64(a, b int64) struct{ ... }
- func USubSatU64(a, b uint64) uint64
- func VAArg(list *byte) *byte
- func VecReduceAddV4I32(v [4]int32) int32
- func Vsnprintf(buf *byte, n int64, format *byte, ap *byte) int32
- func Wmemchr(s *byte, c int32, n int64) *byte
- func Write(fd int32, buf *byte, n int64) int64
- type I128
- func I128AShr(a, n I128) I128
- func I128Add(a, b I128) I128
- func I128And(a, b I128) I128
- func I128FromI64(x int64) I128
- func I128FromU64(x uint64) I128
- func I128LShr(a, n I128) I128
- func I128Mul(a, b I128) I128
- func I128Or(a, b I128) I128
- func I128SDiv(a, b I128) I128
- func I128SRem(a, b I128) I128
- func I128Shl(a, n I128) I128
- func I128Sub(a, b I128) I128
- func I128UDiv(a, b I128) I128
- func I128URem(a, b I128) I128
- func I128Xor(a, b I128) I128
- func I256TruncI128(a I256) I128
- type I256
- func I256AShr(a, n I256) I256
- func I256Add(a, b I256) I256
- func I256And(a, b I256) I256
- func I256FromI64(x int64) I256
- func I256FromI128(x I128) I256
- func I256FromI128S(x I128) I256
- func I256FromU64(x uint64) I256
- func I256LShr(a, n I256) I256
- func I256Mul(a, b I256) I256
- func I256Or(a, b I256) I256
- func I256SDiv(a, b I256) I256
- func I256SRem(a, b I256) I256
- func I256Shl(a, n I256) I256
- func I256Sub(a, b I256) I256
- func I256UDiv(a, b I256) I256
- func I256URem(a, b I256) I256
- func I256Xor(a, b I256) I256
Constants ¶
This section is empty.
Variables ¶
var ( ClassTypeInfoVT [4]unsafe.Pointer SIClassTypeInfoVT [4]unsafe.Pointer VMIClassTypeInfoVT [4]unsafe.Pointer )
Itanium type_info vtables. User IR stores GEP(@VT, 2) as the type_info vptr. DynamicCast compares that word to identify class / si / vmi.
Functions ¶
func AddPointer ¶
AddPointer is p + i (C pointer arithmetic, scaled).
func Alloca ¶
Alloca is LLVM alloca: mmap bump stack, not the malloc slab. Sharing malloc's freelist zeroed a still-referenced object (Darwin seed 42: Expression vptr=0, virtual call at +0x50). Codegen defers AllocaFree (LIFO, same as C stack).
func Arc4randomBuf ¶
Arc4randomBuf is BSD arc4random_buf(buf, n): fill n bytes from the CSPRNG.
func AssertFail ¶
AssertFail is glibc/clang __assert_fail(expr, file, line, function). Noreturn in C; panic in Go so control-flow after it typechecks.
func AtomicAddI8 ¶
AtomicAddI8 is atomicrmw add on i8. Returns the new value (like AddInt32).
func AtomicCASI8 ¶
AtomicCASI8 is cmpxchg on i8 (returns whether the swap happened).
func AtomicLoadI8 ¶
AtomicLoadI8 is the load half of a failed cmpxchg on i8.
func AtomicSwapI8 ¶
AtomicSwapI8 is atomicrmw xchg on i8. Go has no SwapInt8; CAS the aligned 32-bit word that holds the byte (same approach as LLVM on targets without native 8-bit atomics).
func CtypeBLoc ¶
func CtypeBLoc() **int16
CtypeBLoc is glibc __ctype_b_loc(): returns a pointer to the ctype bitmask table.
func CtypeWiden ¶
CtypeWiden is ctype<char>::widen. Identity; this may be nil when use_facet was inlined against a dummy locale.
func CtypeWidenInit ¶
func CtypeWidenInit(this *byte)
CtypeWidenInit is ctype<char>::_M_widen_init. Identity table, widen_ok=1.
func CxaAtexit ¶
CxaAtexit is __cxa_atexit(fn, arg, dso). C++ static dtors register here from llvm.global_ctors. dso is ignored: we never unload.
func CxxNoop ¶
CxxNoop is a declare-only C++ dtor we never constructed a real object for (locale, ios_base, __basic_file).
func Dlsym ¶
Dlsym is dlsym(3). Always nil so rust getrandom uses the file backend (calling a Go func through a C fnptr cast is not defined).
func Dup ¶
Dup is C dup(fd). Pure-Go: only maps 0/1/2 to themselves; other FDs return -1 (tree-sitter uses this for print-dot-graph on std FDs).
func DynamicCast ¶
DynamicCast is Itanium __dynamic_cast(src, src_type, dst_type, src2dst). Null src is a null result (ABI). A missing vtable or unknown type_info kind panics so the unsatisfied signal is not turned into a silent null.
func Fcntl ¶
Fcntl is fcntl(2). The libc fd is looked up, then the host fcntl runs on that *os.File (unix.FcntlInt via SyscallConn).
func Fdopen ¶
Fdopen is C fdopen(fd, mode). Maps 0/1/2 to stdin/stdout/stderr; other FDs use os.NewFile. Mode is accepted but not fully applied.
func Fence ¶
func Fence()
Fence is LLVM `fence <ordering>`. rustc emits `fence acquire` before Arc::drop_slow so the last refcount decrement is visible. Same barrier as empty asm ~{memory}.
func FilebufClose ¶
FilebufClose is basic_filebuf::close. O2 inlines ifstream::close as filebuf::close(this+16). Return this (non-null) on success.
func FilebufOpen ¶
FilebufOpen is basic_filebuf::open. Slurps the file into the get area so inlined sgetc/getline can read without underflow. Returns this on success, nil on failure (libc++).
func FilebufUnderflow ¶
FilebufUnderflow is basic_filebuf::underflow. Get area already holds the file; empty means EOF.
func Free ¶
func Free(p *byte)
Free is C free(p). All heap traffic (malloc, RustAlloc, operator new with align≤16) shares the modernc slab.
func FuncCode ¶
FuncCode is the code word of a Go func. Inverse of FuncFromCode. Used for C++ atexit slots and rustc vtable method pointers.
func FuncFromCode ¶
FuncFromCode rebuilds a Go func from a code word (nil closure data).
func Getentropy ¶
Getentropy is getentropy(2). n must be ≤ 256.
func I128TruncI1 ¶
func I128TruncI8 ¶
func I128TruncI16 ¶
func I128TruncI32 ¶
func I128TruncI64 ¶
func I256TruncI1 ¶
func I256TruncI8 ¶
func I256TruncI16 ¶
func I256TruncI32 ¶
func I256TruncI64 ¶
func IfstreamClose ¶
IfstreamClose is ifstream::close / D1 destructor.
func IfstreamCloseVTT ¶
IfstreamCloseVTT is D2(this, vtt).
func IfstreamOpen ¶
IfstreamOpen is basic_ifstream::basic_ifstream(char const*, ios_openmode). Opens the path for real. fail is set if open fails. mode is recorded only as in/out; unknown bits fail the stream instead of pretending.
func InitOstream ¶
InitOstream writes the stand-in Itanium vptr and ctype<char>. clang++ -O2 endl: off = *(vptr-24); ios = this+off; ctype = *(ios+240); null ctype → __throw_bad_cast (OutputMgr::OutputHeader).
func InlineAsm ¶
func InlineAsm(asm, constraint string)
InlineAsm is LLVM `call asm`. The rustc compiler barrier (`""` / `~{memory}`) is an atomic fence so the call is not deleted. Any other template panics with the asm text.
func IosBaseCtor ¶
IosBaseCtor is std::ios_base::ios_base() / _M_init / basic_ios::init. gensym's stack ostringstream calls this before operator<< / str(). Same stand-in vptr and ctype as cout so inlined fail/endl stay honest.
func IosClear ¶
IosClear is basic_ios::clear(iostate). Writes the inlined iostate slot and updates the side table so later fail/eof loads stay honest.
func IosGetloc ¶
IosGetloc is ios_base::getloc(). Writes a dummy locale into the sret slot (first arg) when clang returns locale by value.
func IosPrecisionSet ¶
IosPrecisionSet is ios_base::precision(streamsize).
func IstreamApplyIosManip ¶
IstreamApplyIosManip is istream::operator>>(ios_base&(*)(ios_base&)). str2int only feeds std::hex; set base 16. The function pointer is ignored.
func IstreamExtractI32 ¶
IstreamExtractI32 is istream::operator>>(int&). Parses the next integer from the stringstream side table with the current base. out is the address of an i32 (opaque ptr in IR → *byte here).
func IstreamGetline ¶
IstreamGetline is std::getline(istream&, string&). Reads one line from the ifstream side table into a libstdc++ string. Missing stream fails (no fake success). Existing fail/eof bits are kept; eof is set when extraction stops at EOF or the stream was already bad.
func IstreamSentryCtor ¶
IstreamSentryCtor is basic_istream::sentry::sentry(istream&, bool).
func LibcxxTreeConstructFromTree ¶
LibcxxTreeConstructFromTree is __tree::__construct_from_tree. tree and construct are unused (allocator / lambda); we malloc and memcpy the pair ourselves.
Inlined insert may write pair<K,V> at +0, so __right_ is a small integer and __left_ is the key pointer. Do not walk those; copy the pair onto dest+32 and emit a leaf.
func LibcxxTreeGetValue ¶
LibcxxTreeGetValue is __tree_node::__get_value. Returns this+32, or nil when this is not a user pointer (so a leftover unsigned in a child slot does not SEGV).
func LibcxxTreeNext ¶
LibcxxTreeNext is std::__tree_next. Bad child pointers (overlay unsigned / key) are treated as null so increment cannot hang.
func LibcxxTreePrev ¶
LibcxxTreePrev is std::__tree_prev_iter. x may be the end node (only __left_ is meaningful).
func LoadRelativeI64 ¶
LoadRelativeI64 is llvm.load.relative.i64: load i32 at ptr+offset, return ptr+i32.
func LocaleCtor ¶
LocaleCtor is std::locale::locale() (default and copy). gensym's ostringstream constructs a locale after ios_base; we do not reconstruct facets (ctype is already on the ios object).
func LocaleUseFacet ¶
LocaleUseFacet is locale::use_facet(id&). Returns the stand-in ctype.
func Lrand48 ¶
func Lrand48() int64
Lrand48 is POSIX lrand48(3): bits 47..1 of the next Xi (31 bits).
func MarkStdoutStream ¶
MarkStdoutStream records cout/cerr so writeOstream does not capture them.
func MaximumNumF64 ¶
MaximumNumF64 is llvm.maximumnum.f64 (IEEE 754-2019 maximumNumber). rustc emits this for f64::max: NaN is ignored; -0.0 is less than +0.0.
func Memchr ¶
Memchr returns a pointer to the first occurrence of c in string s. It returns nil if no such byte exists within n bytes.
func MemcpyChk ¶
MemcpyChk copies length bytes from src to dest. If length is greater than destlen (interpreted as unsigned integers), it will panic.
func MemsetChk ¶
MemsetChk fills the memory at b with bytes of the value c. If length is greater than destlen (interpreted as unsigned integers), it will panic.
func MemsetPattern16 ¶
MemsetPattern16 fills the memory at b with a 16-byte pattern.
func Mmap64 ¶
Mmap64 is mmap64. addr is taken as an integer so a non-heap MAP_FIXED address is not a Go *byte the GC can nil.
func NSGetEnviron ¶
NSGetEnviron is Darwin _NSGetEnviron. Returns char *** (empty).
func NSGetProgname ¶
NSGetProgname is Darwin _NSGetProgname. Returns char **.
func OStringStreamClose ¶
OStringStreamClose is basic_ostringstream dtor.
func OStringStreamCtor ¶
OStringStreamCtor is basic_ostringstream default ctor (gensym). Object is ~112 bytes; do not InitOstream (ctype at +240).
func OStringStreamStr ¶
func OStringStreamStr(ret, this *byte)
OStringStreamStr is basic_ostringstream::str() / stringstream::str() → string.
func OstreamEndl ¶
OstreamEndl is std::endl. Writes '\n'; flush is a no-op on stdout.
func OstreamFlush ¶
OstreamFlush is ostream::flush. stdout is unbuffered here.
func OstreamInsert ¶
OstreamInsert is std::__ostream_insert<char>(ostream&, char const*, long). csmith OutputMgr::OutputHeader writes the generated program header through this. Unknown streams go to stdout (DefaultOutputMgr::get_main_out is cout); registered ostringstreams append.
func OstreamInsertBool ¶
OstreamInsertBool is operator<<(ostream&, bool) without boolalpha.
func OstreamInsertF64 ¶
OstreamInsertF64 is operator<<(ostream&, double) / float.
func OstreamInsertI64 ¶
OstreamInsertI64 is ostream::_M_insert<long> / operator<<(long).
func OstreamInsertPtr ¶
OstreamInsertPtr is operator<<(ostream&, void const*). libstdc++ prints the address as hex with a 0x prefix.
func OstreamInsertU64 ¶
OstreamInsertU64 is ostream::_M_insert<unsigned long>.
func OstreamLsCStr ¶
OstreamLsCStr is operator<<(ostream&, char const*).
func OstreamLsString ¶
OstreamLsString is operator<<(ostream&, basic_string const&).
func OstreamPut ¶
OstreamPut is ostream::put(char) / operator<<(char).
func OstreamSentryCtor ¶
OstreamSentryCtor is basic_ostream::sentry::sentry(ostream&).
func OstreamSentryDestroy ¶
OstreamSentryDestroy is basic_ostream::sentry::~sentry.
func Poll ¶
Poll is poll(2). pollfd is {i32 fd; i16 events; i16 revents} (8 bytes). Marks every slot ready (revents=events) so rhai-run stdin checks proceed.
func PthreadAttrDestroy ¶
PthreadAttrDestroy is a no-op for the dummy attr.
func PthreadAttrGetstack ¶
PthreadAttrGetstack reports a synthetic stack for stack-overflow guards.
func PthreadGetStackaddrNp ¶
PthreadGetStackaddrNp is Darwin pthread_get_stackaddr_np. Darwin returns the top of the stack (highest address); rustc subtracts get_stacksize_np to find the bottom before mmap MAP_FIXED of the guard.
func PthreadGetStacksizeNp ¶
PthreadGetStacksizeNp is Darwin pthread_get_stacksize_np.
func PthreadGetattrNp ¶
PthreadGetattrNp fills a dummy attr (stack base/size via getstack).
func PthreadMutexDestroy ¶
func PthreadMutexInit ¶
func PthreadMutexLock ¶
func PthreadMutexTrylock ¶
func PthreadMutexUnlock ¶
func PthreadMutexattrDestroy ¶
func PthreadMutexattrInit ¶
Single-threaded: mutex/attr calls succeed and do nothing.
func PthreadMutexattrSettype ¶
func PthreadSelf ¶
func PthreadSelf() int64
PthreadSelf is pthread_self. Single-threaded: fixed non-zero id.
func PthreadSetnameNp ¶
PthreadSetnameNp is Darwin pthread_setname_np(name) or POSIX (thread, name).
func PthreadThreadidNp ¶
PthreadThreadidNp is Darwin pthread_threadid_np. Writes 1 into *id.
func RbTreeDecrement ¶
RbTreeDecrement is std::_Rb_tree_decrement.
func RbTreeIncrement ¶
RbTreeIncrement is std::_Rb_tree_increment.
func RbTreeInit ¶
func RbTreeInit(tree *byte)
RbTreeInit is the empty map / _Rb_tree default ctor. `tree` points at the _Rb_tree / map object (impl start). Header is at +8; left/right self-ref the header node (libstdc++ _Rb_tree_header::_M_reset).
func RbTreeInsertAndRebalance ¶
RbTreeInsertAndRebalance is std::_Rb_tree_insert_and_rebalance (gcc libstdc++-v3/src/c++98/tree.cc).
func RbTreeRebalanceForErase ¶
RbTreeRebalanceForErase is std::_Rb_tree_rebalance_for_erase (gcc libstdc++-v3/src/c++98/tree.cc). Returns the node to free (z). header is _M_header of the tree.
func Realloc ¶
Realloc is C realloc. n==0 frees p and returns nil. Grows via malloc+copy+free so the old block goes through freeQuarantine (modernc UintptrRealloc freelist-scribbles the old block immediately).
func RustAlloc ¶
RustAlloc is __rust_alloc(size, align) and C++ operator new. Uses the same modernc slab as Malloc/Free (no Go-heap make+pin). size==0 returns a non-null dangling pointer (rustc / C++ convention).
func RustAllocZeroed ¶
RustAllocZeroed is __rust_alloc_zeroed: slab alloc then clear.
func RustDealloc ¶
RustDealloc is __rust_dealloc / operator delete. Same slab as Free.
func RustFmtI32 ¶
RustFmtI32 is <i32 as core::fmt::Display>::fmt. Ok is false (i1 0).
func RustFmtUsize ¶
RustFmtUsize is <usize as core::fmt::Display>::fmt.
func RustPrint ¶
RustPrint is std::io::stdio::_print(template, args). Template encoding: rustc 1.97 fmt::Arguments (byte pieces + 0xC0 placeholders).
func RustRealloc ¶
RustRealloc is __rust_realloc(ptr, oldSize, align, newSize).
func SAddWithOverflowI32 ¶
SAddWithOverflowI32 is llvm.sadd.with.overflow.i32: wrapping sum and signed overflow.
func Sigaltstack ¶
Sigaltstack is sigaltstack(2). Report existing stack (flags=0, not SS_DISABLE) so rustc stack_overflow::make_handler skips mmap. stack_t: { void *ss_sp; int ss_flags; size_t ss_size } @0,8,16.
func Signal ¶
Signal is signal(2). Returns previous disposition (pretend SIG_DFL=0). rhai-run ignores SIGPIPE (13) with SIG_IGN (1).
func Srand48 ¶
func Srand48(seed int64)
Srand48 is POSIX srand48(3): Xi = (uint32(seed) << 16) | 0x330e.
func Sscanf ¶
Sscanf is C sscanf / glibc __isoc23_sscanf. Dest pointers from opaque-ptr IR arrive as *byte; write the scanned value through them.
func StandinVptr ¶
StandinVptr is an Itanium vptr into ifstreamVT. vptr-24 is slot 0 (0). Declare-only VTTs store these so inlined dtors do not load nil-24.
func Statx ¶
Statx is Linux statx(2). rustc std FileAttr declares `extern_weak ... @statx` and calls it when the symbol exists. Fills Linux statx_t (stx_size at offset 40) from os.FileInfo.
func StdStringAppendCStr ¶
StdStringAppendCStr is libc++ string::append(char const*) / append(char const*, n). n<0 means strlen.
func StdStringAssign ¶
StdStringAssign is libc++ basic_string::operator=(basic_string const&).
func StdStringAssignCStr ¶
StdStringAssignCStr is libc++ string::assign(char const*) / assign(char const*, n). n<0 means strlen.
func StdStringCompareCStr ¶
StdStringCompareCStr is libc++ string::compare(pos, n, cstr, n2).
func StdStringCopy ¶
StdStringCopy is libc++ basic_string(basic_string const&).
func StdStringDestroy ¶
StdStringDestroy is libc++ basic_string::~basic_string.
func StdStringEqCStr ¶
StdStringEqCStr is libc++ string == const char*.
func StdStringErase ¶
StdStringErase is libc++ string::erase(pos, n). n<0 is npos.
func StdStringInit ¶
StdStringInit is libc++ basic_string::__init(char const*, size_t).
func StdStringInsertCStr ¶
StdStringInsertCStr is libc++ string::insert(pos, char const*) / insert(pos, char const*, n). n<0 means strlen.
func StdStringPlusCStrLeft ¶
func StdStringPlusCStrLeft(ret, cstr, s *byte)
StdStringPlusCStrLeft is operator+(char const*, string const&).
func StdStringPlusCStrRight ¶
func StdStringPlusCStrRight(ret, s, cstr *byte)
StdStringPlusCStrRight is operator+(string const&, char const*).
func StdStringPushBack ¶
StdStringPushBack is libc++ string::push_back(char).
func StdStringSubstr ¶
StdStringSubstr is libc++ basic_string(s, pos, n, alloc). n<0 is npos.
func StdToString ¶
StdToString is std::to_string(unsigned long) and the other unsigned integer overloads. ret is the LLVM sret string.
func StdToStringI ¶
StdToStringI is std::to_string(long) and the other signed overloads.
func StrcatChk ¶
StrcatChk concatenates two C strings. It panics if the space required is more than destlen bytes.
func StreambufCtor ¶
StreambufCtor is basic_streambuf / basic_filebuf default ctor.
func StreambufSgetc ¶
StreambufSgetc is basic_streambuf::sgetc. Reads the get area.
func StrerrorR ¶
StrerrorR is POSIX strerror_r (XSI: returns 0 or -1). Darwin rustc uses this for errno text; a short message in buf is enough.
func StringbufCtor ¶
StringbufCtor is basic_stringbuf(openmode). Inlined stringstream ctor calls this; new_ctrl_vars then << 'i' into the put-area.
func StringbufStr ¶
func StringbufStr(this, s *byte)
StringbufStr is libc++ basic_stringbuf::str(string const&). Fills the get area (inlined sgetc) and the stringstream table (>>).
func StringstreamClose ¶
StringstreamClose is stringstream::~stringstream / D1.
func StringstreamCtor ¶
StringstreamCtor is basic_stringstream(string const&, ios_openmode). csmith StringUtils::str2int builds one to parse an int (dec or hex). Object is ~128 bytes; do not write ostream ctype at +240.
func StringstreamDefaultClose ¶
StringstreamDefaultClose is basic_stringstream dtor (default or string ctor).
func StringstreamDefaultCtor ¶
StringstreamDefaultCtor is basic_stringstream() used by Variable::new_ctrl_vars. Registers both the object and the ostream subobject (+16) for <<.
func StringstreamStr ¶
func StringstreamStr(ret, this *byte)
StringstreamStr is an alias of OStringStreamStr for mangling tables.
func Syscall ¶
Syscall is the libc syscall(2) shim for a few numbers rustc needs. Single-threaded: futex wait/wake are no-ops that succeed.
func UAddSatU64 ¶
UAddSatU64 is llvm.uadd.sat for integer widths ≤64.
func UMulWithOverflowU64 ¶
UMulWithOverflowU64 is llvm.umul.with.overflow.i64.
func USubSatU64 ¶
USubSatU64 is llvm.usub.sat for integer widths ≤64.
func VAArg ¶
VAArg returns a pointer to the next argument in a varargs list. The actual type of list is *[]interface{}, but it is declared as void * in C.
func VecReduceAddV4I32 ¶
VecReduceAddV4I32 is llvm.vector.reduce.add.v4i32.
func Vsnprintf ¶
Vsnprintf is C vsnprintf. ap points at system va_list storage (__va_list_tag); llvm.va_start stores &varargs at overflow_arg_area (offset 8).
Types ¶
type I128 ¶
I128 is LLVM i128 as two little-endian two's-complement limbs. rustc TypeId and i128 math use the full width; this is not int64.
func I128FromI64 ¶
I128FromI64 is sext of a 64-bit signed value to i128.
func I128FromU64 ¶
I128FromU64 is zext of a 64-bit unsigned value to i128.
func I256TruncI128 ¶
type I256 ¶
I256 is LLVM i256 as two little-endian I128 limbs. rustc core::fmt::num::__fmt_inner widens u128 to i256.
func I256FromI64 ¶
I256FromI64 is sext of a 64-bit signed value to i256.
func I256FromU64 ¶
I256FromU64 is zext of a 64-bit unsigned value to i256.