diff --git a/c/os/_libc_darwin_arm64.c b/c/os/_libc_darwin_arm64.c new file mode 100644 index 00000000..199f27bd --- /dev/null +++ b/c/os/_libc_darwin_arm64.c @@ -0,0 +1,60 @@ +// Code generated by llcppg; classified from the common libc binding. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int _llcppg___darwin_check_fd_set(int _a, const void *_b) { + return __darwin_check_fd_set(_a, _b); +} + +int _llcppg___darwin_fd_isset(int _fd, const struct fd_set *_p) { + return __darwin_fd_isset(_fd, _p); +} diff --git a/c/os/dir.go b/c/os/dir.go index bd3cf9e2..8fdfac4b 100644 --- a/c/os/dir.go +++ b/c/os/dir.go @@ -14,6 +14,3 @@ type DIR struct { //go:linkname Opendir C.opendir func Opendir(name *c.Char) *DIR - -//go:linkname Closedir C.closedir -func Closedir(dir *DIR) c.Int diff --git a/c/os/dirent_unix64.go b/c/os/dirent_unix64.go new file mode 100644 index 00000000..ed366775 --- /dev/null +++ b/c/os/dirent_unix64.go @@ -0,0 +1,8 @@ +//go:build (darwin && arm64 && !ios) || (linux && amd64 && !android) + +package os + +import "github.com/goplus/lib/c/syscall" + +// Dirent shares the representation already used by Readdir. +type Dirent = syscall.Dirent diff --git a/c/os/flags_default.go b/c/os/flags_default.go index f119efdb..0032225d 100644 --- a/c/os/flags_default.go +++ b/c/os/flags_default.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build !windows && !(linux && (amd64 || arm64) && !android) /* * Copyright (c) 2026 The XGo Authors (xgo.dev). All rights reserved. diff --git a/c/os/functions_default.go b/c/os/functions_default.go index 1efcb374..1e4d639c 100644 --- a/c/os/functions_default.go +++ b/c/os/functions_default.go @@ -27,12 +27,6 @@ func Getcwd(buffer c.Pointer, size uintptr) *c.Char //go:linkname Open C.open func Open(path *c.Char, flags c.Int, __llgo_va_list ...any) c.Int -//go:linkname Fcntl C.fcntl -func Fcntl(a c.Int, b c.Int, __llgo_va_list ...any) c.Int - -//go:linkname Close C.close -func Close(fd c.Int) c.Int - //go:linkname Read C.read func Read(fd c.Int, buf c.Pointer, count uintptr) int diff --git a/c/os/generated_native_darwin_arm64_llgo_test.go b/c/os/generated_native_darwin_arm64_llgo_test.go new file mode 100644 index 00000000..1ca8cbb8 --- /dev/null +++ b/c/os/generated_native_darwin_arm64_llgo_test.go @@ -0,0 +1,30 @@ +//go:build llgo && darwin && arm64 && !ios + +package os + +import ( + "testing" + "unsafe" +) + +func TestGeneratedMachMessageHeaderLayout(t *testing.T) { + var header MachMsgHeaderT + if unsafe.Sizeof(header) != 24 || unsafe.Alignof(header) != 4 { + t.Fatalf("mach_msg_header_t = %d/%d, want 24/4", unsafe.Sizeof(header), unsafe.Alignof(header)) + } +} +func TestGeneratedUUIDOutputBuffer(t *testing.T) { + var value UuidT + for i := range value { + value[i] = 0xa5 + } + UuidClear(&value[0]) + for i, b := range value { + if b != 0 { + t.Fatalf("uuid_clear left byte %d = %d", i, b) + } + } + if result := UuidIsNull(&value[0]); result == 0 { + t.Fatal("cleared uuid is not nil") + } +} diff --git a/c/os/generated_native_llgo_test.go b/c/os/generated_native_llgo_test.go new file mode 100644 index 00000000..9d0cf012 --- /dev/null +++ b/c/os/generated_native_llgo_test.go @@ -0,0 +1,42 @@ +//go:build llgo && ((darwin && arm64 && !ios) || (linux && (amd64 || arm64) && !android)) + +package os + +import ( + "github.com/goplus/lib/c" + "testing" + "unsafe" +) + +func TestGeneratedPipeIO(t *testing.T) { + var pair [2]c.Int + if result := NativePipe(&pair[0]); result != 0 { + t.Fatalf("pipe = %d", result) + } + defer func() { + for _, fd := range pair { + if result := Close(fd); result != 0 { + t.Errorf("close = %d", result) + } + } + }() + input := [6]byte{0, 1, 127, 128, 254, 255} + var output [6]byte + for offset := 0; offset < len(input); { + n := NativeWrite(pair[1], unsafe.Pointer(&input[offset]), c.SizeT(len(input)-offset)) + if n <= 0 { + t.Fatalf("write = %d", n) + } + offset += int(n) + } + for offset := 0; offset < len(output); { + n := NativeRead(pair[0], unsafe.Pointer(&output[offset]), c.SizeT(len(output)-offset)) + if n <= 0 { + t.Fatalf("read = %d", n) + } + offset += int(n) + } + if output != input { + t.Fatalf("pipe data = %v, want %v", output, input) + } +} diff --git a/c/os/legacy_functions_other.go b/c/os/legacy_functions_other.go new file mode 100644 index 00000000..4a961848 --- /dev/null +++ b/c/os/legacy_functions_other.go @@ -0,0 +1,38 @@ +//go:build !windows && !((darwin && arm64 && !ios) || (linux && (amd64 || arm64) && !android)) + +package os + +import ( + "github.com/goplus/lib/c" + _ "unsafe" +) + +//go:linkname Closedir C.closedir +func Closedir(dir *DIR) c.Int + +//go:linkname Close C.close +func Close(fd c.Int) c.Int + +//go:linkname Fchdir C.fchdir +func Fchdir(dirfd c.Int) c.Int + +//go:linkname Dup C.dup +func Dup(fd c.Int) c.Int + +//go:linkname Dup2 C.dup2 +func Dup2(oldfd c.Int, newfd c.Int) c.Int + +//go:linkname Fsync C.fsync +func Fsync(fd c.Int) c.Int + +//go:linkname Isatty C.isatty +func Isatty(fd c.Int) c.Int + +// In Mach, all system calls take normal arguments and always return an +// error code (zero for success). +// +//go:linkname Syscall C.syscall +func Syscall(sysno c.Long, __llgo_va_list ...any) c.Long + +//go:linkname Fcntl C.fcntl +func Fcntl(a c.Int, b c.Int, __llgo_va_list ...any) c.Int diff --git a/c/os/libc_darwin_arm64.go b/c/os/libc_darwin_arm64.go new file mode 100644 index 00000000..7ba26708 --- /dev/null +++ b/c/os/libc_darwin_arm64.go @@ -0,0 +1,3307 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package os + +import ( + "github.com/goplus/lib/c" + llsignal "github.com/goplus/lib/c/signal" + llsys "github.com/goplus/lib/c/sys" + lltime "github.com/goplus/lib/c/time" + "unsafe" +) + +// definitions for library routines operating on directories. +const DIRBLKSIZ = 1024 + +// flags for opendir2 +const ( + DTF_HIDEW = 1 + // don't return duplicate names + DTF_NODUP = 2 + // rewind after reading union stack + DTF_REWIND = 4 + // everything has been read + // assume internal buffer is populated + // there's nothing more to read in the kernel +) + +type X_telldir struct { +} + +// llgo:type C +type llcppgCallback38 = func(_llcppg_param1 **Dirent, _llcppg_param2 **Dirent) c.Int + +// llgo:type C +type llcppgCallback39 = func(_llcppg_param1 *Dirent) c.Int + +//go:linkname Closedir C.closedir +func Closedir(self *DIR) c.Int + +//go:linkname NativeOpendir C.opendir +func NativeOpendir(_llcppg_param1 *c.Char) *DIR + +// llgo:link (*DIR).NativeReaddir C.readdir +func (self *DIR) NativeReaddir() *Dirent { + return nil +} + +// llgo:link (*DIR).ReaddirR C.readdir_r +func (self *DIR) ReaddirR(_llcppg_param2 *Dirent, _llcppg_param3 **Dirent) c.Int { + return 0 +} + +// llgo:link (*DIR).Rewinddir C.rewinddir +func (self *DIR) Rewinddir() { +} + +// llgo:link (*DIR).Seekdir C.seekdir +func (self *DIR) Seekdir(_llcppg_param2 c.Long) { +} + +// llgo:link (*DIR).Telldir C.telldir +func (self *DIR) Telldir() c.Long { + return 0 +} + +//go:linkname NativeFdopendir C.fdopendir +func NativeFdopendir(_llcppg_param1 c.Int) *DIR + +//go:linkname Alphasort C.alphasort +func Alphasort(_llcppg_param1 **Dirent, _llcppg_param2 **Dirent) c.Int + +// llgo:link (*DIR).Dirfd C.dirfd +func (self *DIR) Dirfd() c.Int { + return 0 +} + +//go:linkname Scandir C.scandir +func Scandir(_llcppg_param1 *c.Char, _llcppg_param2 ***Dirent, _llcppg_param3 llcppgCallback39, _llcppg_param4 llcppgCallback38) c.Int + +//go:linkname Getdirentries C.getdirentries_is_not_available_when_64_bit_inodes_are_in_effect +func Getdirentries(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int, _llcppg_param4 *c.Long) c.Int + +//go:linkname X__Opendir2 C.__opendir2 +func X__Opendir2(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) *DIR + +const ( + RTLD_LAZY = 1 + RTLD_NOW = 2 + RTLD_LOCAL = 4 + RTLD_GLOBAL = 8 +) + +const ( + RTLD_NOLOAD = 16 + RTLD_NODELETE = 128 + // Mac OS X 10.5 and later + RTLD_FIRST = 256 +) + +// Structure filled in by dladdr(). +type DlInfo struct { + DliFname *c.Char + DliFbase unsafe.Pointer + DliSname *c.Char + DliSaddr unsafe.Pointer +} + +//go:linkname Dladdr C.dladdr +func Dladdr(_llcppg_param1 unsafe.Pointer, _llcppg_param2 *DlInfo) c.Int + +//go:linkname Dlclose C.dlclose +func Dlclose(__handle unsafe.Pointer) c.Int + +//go:linkname Dlerror C.dlerror +func Dlerror() *c.Char + +//go:linkname Dlopen C.dlopen +func Dlopen(__path *c.Char, __mode c.Int) unsafe.Pointer + +//go:linkname Dlsym C.dlsym +func Dlsym(__handle unsafe.Pointer, __symbol *c.Char) unsafe.Pointer + +//go:linkname DlopenPreflight C.dlopen_preflight +func DlopenPreflight(__path *c.Char) bool + +//go:linkname Gethostuuid C.gethostuuid +func Gethostuuid(_llcppg_param1 *uint8, _llcppg_param2 *lltime.Timespec) c.Int + +// Believed to have been introduced in 1003.2-1992 +const ( + GLOB_APPEND = 1 + // Use gl_offs. + GLOB_DOOFFS = 2 + // Return on error. + GLOB_ERR = 4 + // Append / to matching directories. + GLOB_MARK = 8 + // Return pattern itself if nothing matches. + GLOB_NOCHECK = 16 + // Don't sort. + GLOB_NOSORT = 32 + // Disable backslash escaping. + GLOB_NOESCAPE = 8192 +) + +// Error values returned by glob(3) +const ( + GLOB_NOSPACE = -1 + // Unignored error. + GLOB_ABORTED = -2 + // No match and GLOB_NOCHECK was not set. + GLOB_NOMATCH = -3 + // Obsolete: source comptability only. + GLOB_NOSYS = -4 +) + +const ( + // Use alternately specified directory funcs. + GLOB_ALTDIRFUNC = 64 + // Expand braces ala csh. + GLOB_BRACE = 128 + // Pattern had globbing characters. + GLOB_MAGCHAR = 256 + // GLOB_NOCHECK without magic chars (csh). + GLOB_NOMAGIC = 512 + // Quote special chars with \. + GLOB_QUOTE = 1024 + // Expand tilde names from the passwd file. + GLOB_TILDE = 2048 + // limit number of returned paths + GLOB_LIMIT = 4096 +) + +// source compatibility, these are the old names +const ( + GLOB_MAXPATH = 4096 + GLOB_ABEND = -2 +) + +type GlobT struct { + GlPathc c.SizeT + GlMatchc c.Int + GlOffs c.SizeT + GlFlags c.Int + GlPathv **c.Char + GlErrfunc llcppgCallback37 + GlClosedir llcppgCallback36 + GlReaddir llcppgCallback35 + GlOpendir llcppgCallback34 + GlLstat llcppgCallback33 + GlStat llcppgCallback32 +} + +// llgo:type C +type llcppgCallback32 = func(_llcppg_param1 *c.Char, _llcppg_param2 *StatT) c.Int + +// llgo:type C +type llcppgCallback33 = func(_llcppg_param1 *c.Char, _llcppg_param2 *StatT) c.Int + +// llgo:type C +type llcppgCallback34 = func(_llcppg_param1 *c.Char) unsafe.Pointer + +// llgo:type C +type llcppgCallback35 = func(_llcppg_param1 unsafe.Pointer) *Dirent + +// llgo:type C +type llcppgCallback36 = func(_llcppg_param1 unsafe.Pointer) + +// llgo:type C +type llcppgCallback37 = func(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +// llgo:type C +type llcppgCallback31 = func(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Glob C.glob +func Glob(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, _llcppg_param3 llcppgCallback31, _llcppg_param4 *GlobT) c.Int + +// llgo:link (*GlobT).Globfree C.globfree +func (self *GlobT) Globfree() { +} + +type Group struct { + GrName *c.Char + GrPasswd *c.Char + GrGid c.Uint + GrMem **c.Char +} + +// [XBD] +// +//go:linkname Getgrgid C.getgrgid +func Getgrgid(_llcppg_param1 c.Uint) *Group + +// [TSF] +// +//go:linkname Getgrnam C.getgrnam +func Getgrnam(_llcppg_param1 *c.Char) *Group + +// [TSF] +// +//go:linkname GetgrgidR C.getgrgid_r +func GetgrgidR(_llcppg_param1 c.Uint, _llcppg_param2 *Group, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT, _llcppg_param5 **Group) c.Int + +// [XSI] +// +//go:linkname GetgrnamR C.getgrnam_r +func GetgrnamR(_llcppg_param1 *c.Char, _llcppg_param2 *Group, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT, _llcppg_param5 **Group) c.Int + +// [XSI] +// +//go:linkname Getgrent C.getgrent +func Getgrent() *Group + +//go:linkname Setgrent C.setgrent +func Setgrent() + +//go:linkname Endgrent C.endgrent +func Endgrent() + +//go:linkname GroupFromGid C.group_from_gid +func GroupFromGid(_llcppg_param1 c.Uint, _llcppg_param2 c.Int) *c.Char + +//go:linkname Getgruuid C.getgruuid +func Getgruuid(_llcppg_param1 *uint8) *Group + +//go:linkname GetgruuidR C.getgruuid_r +func GetgruuidR(_llcppg_param1 *uint8, _llcppg_param2 *Group, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT, _llcppg_param5 **Group) c.Int + +//go:linkname Setgrfile C.setgrfile +func Setgrfile(_llcppg_param1 *c.Char) + +//go:linkname Setgroupent C.setgroupent +func Setgroupent(_llcppg_param1 c.Int) c.Int + +type SemaphoreT = MachPortT + +type MachMsgHeaderT struct { + MsghBits c.Uint + MsghSize c.Uint + MsghRemotePort MachPortT + MsghLocalPort MachPortT + MsghVoucherPort c.Uint + MsghId c.Int +} + +// Routine: mach_msg_overwrite +// Purpose: +// Send and/or receive a message. If the message operation +// is interrupted, and the user did not request an indication +// of that fact, then restart the appropriate parts of the +// operation silently (trap version does not restart). +// +// Distinct send and receive buffers may be specified. If +// no separate receive buffer is specified, the msg parameter +// will be used for both send and receive operations. +// +// In addition to a distinct receive buffer, that buffer may +// already contain scatter control information to direct the +// receiving of the message. +// +// llgo:link (*MachMsgHeaderT).MachMsgOverwrite C.mach_msg_overwrite +func (self *MachMsgHeaderT) MachMsgOverwrite(option c.Int, send_size c.Uint, rcv_size c.Uint, rcv_name c.Uint, timeout c.Uint, notify c.Uint, rcv_msg *MachMsgHeaderT, rcv_limit c.Uint) c.Int { + return 0 +} + +// Routine: mach_msg +// Purpose: +// Send and/or receive a message. If the message operation +// is interrupted, and the user did not request an indication +// of that fact, then restart the appropriate parts of the +// operation silently (trap version does not restart). +// +// llgo:link (*MachMsgHeaderT).MachMsg C.mach_msg +func (self *MachMsgHeaderT) MachMsg(option c.Int, send_size c.Uint, rcv_size c.Uint, rcv_name c.Uint, timeout c.Uint, notify c.Uint) c.Int { + return 0 +} + +// Routine: mach_voucher_deallocate +// Purpose: +// +// Deallocate a mach voucher created or received in a message. Drops +// one (send right) reference to the voucher. +// +//go:linkname MachVoucherDeallocate C.mach_voucher_deallocate +func MachVoucherDeallocate(voucher c.Uint) c.Int + +//go:linkname VmStats C.vm_stats +func VmStats(info unsafe.Pointer, count *c.Uint) c.Int + +type SchedParam struct { + SchedPriority c.Int + X__Opaque [4]c.Char +} + +//go:linkname SchedYield C.sched_yield +func SchedYield() c.Int + +//go:linkname SchedGetPriorityMin C.sched_get_priority_min +func SchedGetPriorityMin(_llcppg_param1 c.Int) c.Int + +//go:linkname SchedGetPriorityMax C.sched_get_priority_max +func SchedGetPriorityMax(_llcppg_param1 c.Int) c.Int + +type Passwd struct { + PwName *c.Char + PwPasswd *c.Char + PwUid c.Uint + PwGid c.Uint + PwChange c.Long + PwClass *c.Char + PwGecos *c.Char + PwDir *c.Char + PwShell *c.Char + PwExpire c.Long +} + +//go:linkname Getpwuid C.getpwuid +func Getpwuid(_llcppg_param1 c.Uint) *Passwd + +//go:linkname Getpwnam C.getpwnam +func Getpwnam(_llcppg_param1 *c.Char) *Passwd + +//go:linkname GetpwuidR C.getpwuid_r +func GetpwuidR(_llcppg_param1 c.Uint, _llcppg_param2 *Passwd, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT, _llcppg_param5 **Passwd) c.Int + +//go:linkname GetpwnamR C.getpwnam_r +func GetpwnamR(_llcppg_param1 *c.Char, _llcppg_param2 *Passwd, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT, _llcppg_param5 **Passwd) c.Int + +//go:linkname Getpwent C.getpwent +func Getpwent() *Passwd + +//go:linkname Setpwent C.setpwent +func Setpwent() + +//go:linkname Endpwent C.endpwent +func Endpwent() + +//go:linkname Setpassent C.setpassent +func Setpassent(_llcppg_param1 c.Int) c.Int + +//go:linkname UserFromUid C.user_from_uid +func UserFromUid(_llcppg_param1 c.Uint, _llcppg_param2 c.Int) *c.Char + +//go:linkname Getpwuuid C.getpwuuid +func Getpwuuid(_llcppg_param1 *uint8) *Passwd + +//go:linkname GetpwuuidR C.getpwuuid_r +func GetpwuuidR(_llcppg_param1 *uint8, _llcppg_param2 *Passwd, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT, _llcppg_param5 **Passwd) c.Int + +// flags for CPU Security Mitigation attribute +// POSIX_SPAWN_NP_CSM_ALL should be used in most cases, +// the individual flags are provided only for performance evaluation etc +const ( + POSIX_SPAWN_NP_CSM_ALL = 1 + POSIX_SPAWN_NP_CSM_NOSMT = 2 + POSIX_SPAWN_NP_CSM_TECS = 4 +) + +// Opaque types for use with posix_spawn() family functions. Internals are +// not defined, and should not be accessed directly. Types are defined as +// mandated by POSIX. +type PosixSpawnattrT uintptr + +type PosixSpawnFileActionsT uintptr + +//go:linkname PosixSpawn C.posix_spawn +func PosixSpawn(_llcppg_param1 *c.Int, _llcppg_param2 *c.Char, _llcppg_param3 *PosixSpawnFileActionsT, _llcppg_param4 *PosixSpawnattrT, __argv **c.Char, __envp **c.Char) c.Int + +//go:linkname PosixSpawnp C.posix_spawnp +func PosixSpawnp(_llcppg_param1 *c.Int, _llcppg_param2 *c.Char, _llcppg_param3 *PosixSpawnFileActionsT, _llcppg_param4 *PosixSpawnattrT, __argv **c.Char, __envp **c.Char) c.Int + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddclose C.posix_spawn_file_actions_addclose +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddclose(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAdddup2 C.posix_spawn_file_actions_adddup2 +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAdddup2(_llcppg_param2 c.Int, _llcppg_param3 c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddopen C.posix_spawn_file_actions_addopen +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddopen(_llcppg_param2 c.Int, _llcppg_param3 *c.Char, _llcppg_param4 c.Int, _llcppg_param5 c.Uint16T) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsDestroy C.posix_spawn_file_actions_destroy +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsDestroy() c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsInit C.posix_spawn_file_actions_init +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsInit() c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrDestroy C.posix_spawnattr_destroy +func (self *PosixSpawnattrT) PosixSpawnattrDestroy() c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetsigdefault C.posix_spawnattr_getsigdefault +func (self *PosixSpawnattrT) PosixSpawnattrGetsigdefault(_llcppg_param2 *c.Uint) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetflags C.posix_spawnattr_getflags +func (self *PosixSpawnattrT) PosixSpawnattrGetflags(_llcppg_param2 *int16) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetpgroup C.posix_spawnattr_getpgroup +func (self *PosixSpawnattrT) PosixSpawnattrGetpgroup(_llcppg_param2 *c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetsigmask C.posix_spawnattr_getsigmask +func (self *PosixSpawnattrT) PosixSpawnattrGetsigmask(_llcppg_param2 *c.Uint) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrInit C.posix_spawnattr_init +func (self *PosixSpawnattrT) PosixSpawnattrInit() c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetsigdefault C.posix_spawnattr_setsigdefault +func (self *PosixSpawnattrT) PosixSpawnattrSetsigdefault(_llcppg_param2 *c.Uint) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetflags C.posix_spawnattr_setflags +func (self *PosixSpawnattrT) PosixSpawnattrSetflags(_llcppg_param2 int16) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetpgroup C.posix_spawnattr_setpgroup +func (self *PosixSpawnattrT) PosixSpawnattrSetpgroup(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetsigmask C.posix_spawnattr_setsigmask +func (self *PosixSpawnattrT) PosixSpawnattrSetsigmask(_llcppg_param2 *c.Uint) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetbinprefNp C.posix_spawnattr_getbinpref_np +func (self *PosixSpawnattrT) PosixSpawnattrGetbinprefNp(_llcppg_param2 c.SizeT, _llcppg_param3 *c.Int, _llcppg_param4 *c.SizeT) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetarchprefNp C.posix_spawnattr_getarchpref_np +func (self *PosixSpawnattrT) PosixSpawnattrGetarchprefNp(_llcppg_param2 c.SizeT, _llcppg_param3 *c.Int, _llcppg_param4 *c.Int, _llcppg_param5 *c.SizeT) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetauditsessionportNp C.posix_spawnattr_setauditsessionport_np +func (self *PosixSpawnattrT) PosixSpawnattrSetauditsessionportNp(_llcppg_param2 MachPortT) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetbinprefNp C.posix_spawnattr_setbinpref_np +func (self *PosixSpawnattrT) PosixSpawnattrSetbinprefNp(_llcppg_param2 c.SizeT, _llcppg_param3 *c.Int, _llcppg_param4 *c.SizeT) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetarchprefNp C.posix_spawnattr_setarchpref_np +func (self *PosixSpawnattrT) PosixSpawnattrSetarchprefNp(_llcppg_param2 c.SizeT, _llcppg_param3 *c.Int, _llcppg_param4 *c.Int, _llcppg_param5 *c.SizeT) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetexceptionportsNp C.posix_spawnattr_setexceptionports_np +func (self *PosixSpawnattrT) PosixSpawnattrSetexceptionportsNp(_llcppg_param2 c.Uint, _llcppg_param3 MachPortT, _llcppg_param4 c.Int, _llcppg_param5 c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetspecialportNp C.posix_spawnattr_setspecialport_np +func (self *PosixSpawnattrT) PosixSpawnattrSetspecialportNp(_llcppg_param2 MachPortT, _llcppg_param3 c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetnosmtNp C.posix_spawnattr_setnosmt_np +func (self *PosixSpawnattrT) PosixSpawnattrSetnosmtNp() c.Int { + return 0 +} + +// Set CPU Security Mitigation on the spawned process +// This attribute affects all threads and is inherited on fork and exec +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetCsmNp C.posix_spawnattr_set_csm_np +func (self *PosixSpawnattrT) PosixSpawnattrSetCsmNp(flags c.Uint) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddinheritNp C.posix_spawn_file_actions_addinherit_np +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddinheritNp(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddchdirNp C.posix_spawn_file_actions_addchdir_np +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddchdirNp(_llcppg_param2 *c.Char) c.Int { + return 0 +} + +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddfchdirNp C.posix_spawn_file_actions_addfchdir_np +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddfchdirNp(_llcppg_param2 c.Int) c.Int { + return 0 +} + +//go:linkname Select C.select +func Select(_llcppg_param1 c.Int, _llcppg_param2 *llsys.FdSet, _llcppg_param3 *llsys.FdSet, _llcppg_param4 *llsys.FdSet, _llcppg_param5 *llsys.Timeval) c.Int + +//go:linkname X__DarwinCheckFdSetOverflow C.__darwin_check_fd_set_overflow +func X__DarwinCheckFdSetOverflow(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer, _llcppg_param3 c.Int) c.Int + +//go:linkname X__DarwinCheckFdSet C._llcppg___darwin_check_fd_set +func X__DarwinCheckFdSet(_a c.Int, _b unsafe.Pointer) c.Int + +// This inline avoids argument side-effect issues with FD_ISSET() +// +//go:linkname X__DarwinFdIsset C._llcppg___darwin_fd_isset +func X__DarwinFdIsset(_fd c.Int, _p *llsys.FdSet) c.Int + +type X_filesec struct { +} + +type FilesecT = *X_filesec + +type MachPortT = c.Uint + +type UuidT = X__DarwinUuidT + +type X__DarwinUuidT = [16]uint8 + +type X__DarwinUuidStringT = [37]c.Char + +// File types +const MAXNAMLEN = 255 + +// File types +const ( + DT_UNKNOWN = 0 + DT_FIFO = 1 + DT_CHR = 2 + DT_DIR = 4 + DT_BLK = 6 + DT_REG = 8 + DT_LNK = 10 + DT_SOCK = 12 + DT_WHT = 14 +) + +//go:linkname X__Error C.__error +func X__Error() *c.Int + +const ( + FREAD = 1 + FWRITE = 2 +) + +const ( + // no delay + // set append mode + O_APPEND = 8 +) + +const ( + // open with shared file lock + O_SHLOCK = 16 + // open with exclusive file lock + O_EXLOCK = 32 + // signal pgrp when data ready + O_ASYNC = 64 + // source compatibility: do not use + O_FSYNC = 128 + // don't follow symlinks + O_NOFOLLOW = 256 +) + +const ( + // create if nonexistant + // truncate to zero length + // error if already exists + O_EXCL = 2048 +) + +// descriptor requested for event notifications only +const O_EVTONLY = 32768 + +// don't assign controlling terminal +const O_NOCTTY = 131072 + +const O_DIRECTORY = 1048576 + +// allow open of a symlink +const O_SYMLINK = 2097152 + +// implicitly set FD_CLOEXEC +const O_CLOEXEC = 16777216 + +// no symlinks allowed in path +const O_NOFOLLOW_ANY = 536870912 + +const ( + // open file for execute only + O_EXEC = 1073741824 + // open directory for search only + O_SEARCH = 1074790400 +) + +// Descriptor value for the current working directory +const AT_FDCWD = -2 + +// Flags for the at functions +const ( + AT_EACCESS = 16 + // Act on the symlink itself not the target + AT_SYMLINK_NOFOLLOW = 32 + // Act on target of symlink + AT_SYMLINK_FOLLOW = 64 + // Path refers to directory + AT_REMOVEDIR = 128 +) + +const ( + // Return real device inodes resides on for fstatat(2) + AT_REALDEV = 512 + // Use only the fd and Ignore the path for fstatat(2) + AT_FDONLY = 1024 + // Path should not contain any symlinks + AT_SYMLINK_NOFOLLOW_ANY = 2048 +) + +// Data Protection Flags +const ( + O_DP_GETRAWENCRYPTED = 1 + O_DP_GETRAWUNENCRYPTED = 2 + O_DP_AUTHENTICATE = 4 +) + +// Descriptor value for openat_authenticated_np() to skip authentication with another fd +const AUTH_OPEN_NOAUTHFD = -1 + +const ( + // kernel/compat + FAPPEND = 8 + // kernel/compat + FASYNC = 64 + // kernel + FFSYNC = 128 + // kernel + FFDSYNC = 4194304 + // kernel + FNONBLOCK = 4 + // compat + FNDELAY = 4 + // compat + O_NDELAY = 4 +) + +const ( + CPF_OVERWRITE = 1 + CPF_IGNORE_MODE = 2 + CPF_MASK = 3 +) + +// command values +const ( + F_DUPFD = 0 + // get file descriptor flags + F_GETFD = 1 + // set file descriptor flags + F_SETFD = 2 + // get file status flags + // set file status flags + // get SIGIO/SIGURG proc/pgrp + F_GETOWN = 5 + // set SIGIO/SIGURG proc/pgrp + F_SETOWN = 6 + // get record locking information + F_GETLK = 7 + // set record locking information + F_SETLK = 8 + // F_SETLK; wait if blocked + F_SETLKW = 9 +) + +// F_SETLK; wait if blocked, return on timeout +const F_SETLKWTIMEOUT = 10 + +const ( + F_FLUSH_DATA = 40 + // Used for regression test + F_CHKCLEAN = 41 + // Preallocate storage + F_PREALLOCATE = 42 + // Truncate a file. Equivalent to calling truncate(2) + F_SETSIZE = 43 + // Issue an advisory read async with no copy to user + F_RDADVISE = 44 + // turn read ahead off/on for this fd + F_RDAHEAD = 45 +) + +// 46,47 used to be F_READBOOTSTRAP and F_WRITEBOOTSTRAP +const ( + F_NOCACHE = 48 + // file offset to device offset + F_LOG2PHYS = 49 + // return the full path of the fd + F_GETPATH = 50 + // fsync + ask the drive to flush to the media + F_FULLFSYNC = 51 + // find which component (if any) is a package + F_PATHPKG_CHECK = 52 + // "freeze" all fs operations + F_FREEZE_FS = 53 + // "thaw" all fs operations + F_THAW_FS = 54 + // turn data caching off/on (globally) for this file + F_GLOBAL_NOCACHE = 55 +) + +// add detached signatures +const F_ADDSIGS = 59 + +// add signature from same file (used by dyld for shared libs) +const F_ADDFILESIGS = 61 + +// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes +const F_NODIRECT = 62 + +const ( + // Get the protection class of a file from the EA, returns int + F_GETPROTECTIONCLASS = 63 + // Set the protection class of a file for the EA, requires int + F_SETPROTECTIONCLASS = 64 +) + +// file offset to device offset, extended +const F_LOG2PHYS_EXT = 65 + +// See man fcntl(2) F_GETLK +// Similar to F_GETLK but in addition l_pid is treated as an input parameter +// which is used as a matching value when searching locks on the file +// so that only locks owned by the process with pid l_pid are returned. +// However, any flock(2) type lock will also be found with the returned value +// of l_pid set to -1 (as with F_GETLK). +const F_GETLKPID = 66 + +const ( + // Mark the file as being the backing store for another filesystem + F_SETBACKINGSTORE = 70 + // return the full path of the FD, but error in specific mtmd circumstances + F_GETPATH_MTMINFO = 71 +) + +// Returns the code directory, with associated hashes, to the caller +const F_GETCODEDIR = 72 + +const ( + // No SIGPIPE generated on EPIPE + F_SETNOSIGPIPE = 73 + // Status of SIGPIPE for this fd + F_GETNOSIGPIPE = 74 +) + +// For some cases, we need to rewrap the key for AKS/MKB +const F_TRANSCODEKEY = 75 + +// file being written to a by single writer... if throttling enabled, writes +const F_SINGLE_WRITER = 76 + +// Get the protection version number for this filesystem +const F_GETPROTECTIONLEVEL = 77 + +// Add detached code signatures (used by dyld for shared libs) +const F_FINDSIGS = 78 + +// Add signature from same file, only if it is signed by Apple (used by dyld for simulator) +const F_ADDFILESIGS_FOR_DYLD_SIM = 83 + +// fsync + issue barrier to drive +const F_BARRIERFSYNC = 85 + +const ( + // Acquire or release open file description lock + F_OFD_SETLK = 90 + // (as F_OFD_SETLK but blocking if conflicting lock) + F_OFD_SETLKW = 91 + // Examine OFD lock + F_OFD_GETLK = 92 +) + +// (as F_OFD_SETLKW but return if timeout) +const F_OFD_SETLKWTIMEOUT = 93 + +const ( + // Add signature from same file, return end offset in structure on success + F_ADDFILESIGS_RETURN = 97 + // Check if Library Validation allows this Mach-O file to be mapped into the calling process + F_CHECK_LV = 98 +) + +// Deallocate a range of the file +const F_PUNCHHOLE = 99 + +// Trim an active file +const F_TRIM_ACTIVE_FILE = 100 + +// Asynchronous advisory read fcntl for regular and compressed file +const F_SPECULATIVE_READ = 101 + +// return the full path without firmlinks of the fd +const F_GETPATH_NOFIRMLINK = 102 + +const ( + // Add signature from same file, return information + F_ADDFILESIGS_INFO = 103 + // Add supplemental signature from same file with fd reference to original + F_ADDFILESUPPL = 104 + // Look up code signature information attached to a file or slice + F_GETSIGSINFO = 105 +) + +const ( + // Acquire or release lease + F_SETLEASE = 106 + // Retrieve lease information + F_GETLEASE = 107 +) + +// Transfer allocated extents beyond leof to a different file +const F_TRANSFEREXTENTS = 110 + +// Based on flags, query/set/delete a file's attribution tag +const F_ATTRIBUTION_TAG = 111 + +// FS-specific fcntl()'s numbers begin at 0x00010000 and go up +const FCNTL_FS_SPECIFIC_BASE = 65536 + +// mark the dup with FD_CLOEXEC +const F_DUPFD_CLOEXEC = 67 + +// file descriptor flags (F_GETFD, F_SETFD) +const FD_CLOEXEC = 1 + +// record locking flags (F_GETLK, F_SETLK, F_SETLKW) +const ( + F_RDLCK = 1 + // unlock + F_UNLCK = 2 + // exclusive or write lock + F_WRLCK = 3 +) + +const ( + // allocate contigious space + F_ALLOCATECONTIG = 2 + // allocate all requested space or no space at all + F_ALLOCATEALL = 4 + // do not free space upon close(2) + F_ALLOCATEPERSIST = 8 +) + +// Make it past all of the SEEK pos modes so that +const F_PEOFPOSMODE = 3 + +// we can keep them in sync should we desire +const F_VOLPOSMODE = 4 + +// detached code signatures data type - +// information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. +// F_ADDFILESIGS is a shortcut for files that contain their own signature and +// doesn't require mapping of the file in order to load the signature. +const USER_FSIGNATURES_CDHASH_LEN = 20 + +// At this time F_GETSIGSINFO can only indicate platformness. +// +// As additional requestable information is defined, new keys will be added and the +// fgetsigsinfo_t structure will be lengthened to add space for the additional information +const GETSIGSINFO_PLATFORM_BINARY = 1 + +// lock operations for flock(2) +const ( + LOCK_SH = 1 + // exclusive file lock + LOCK_EX = 2 + // don't block when locking + LOCK_NB = 4 + // unlock file + LOCK_UN = 8 +) + +// fattributiontag_t used by F_ATTRIBUTION_TAG +const ATTRIBUTION_NAME_MAX = 255 + +// ft_flags (F_ATTRIBUTION_TAG) +const ( + F_CREATE_TAG = 1 + F_DELETE_TAG = 2 + F_QUERY_TAG = 4 +) + +const ( + // force window to popup on open + O_POPUP = 2147483648 + // small, clean popup window + O_ALERT = 536870912 +) + +// Advisory file segment locking data type - +// information passed to system by user +type FlockT struct { + LStart c.LongLong + LLen c.LongLong + LPid c.Int + LType int16 + LWhence int16 +} + +// Advisory file segment locking with time out - +// Information passed to system by user for F_SETLKWTIMEOUT +type Flocktimeout struct { + Fl FlockT + Timeout lltime.Timespec +} + +type Radvisory struct { + RaOffset c.LongLong + RaCount c.Int +} + +type Fsignatures struct { + FsFileStart c.LongLong + FsBlobStart unsafe.Pointer + FsBlobSize c.SizeT + FsFsignaturesSize c.SizeT + FsCdhash [20]c.Char + FsHashType c.Int +} + +type Fsupplement struct { + FsFileStart c.LongLong + FsBlobStart c.LongLong + FsBlobSize c.SizeT + FsOrigFd c.Int +} + +// DYLD needs to check if the object is allowed to be combined +// into the main binary. This is done between the code signature +// is loaded and dyld is doing all the work to process the LOAD commands. +// +// While this could be done in F_ADDFILESIGS.* family the hook into +// the MAC module doesn't say no when LV isn't enabled and then that +// is cached on the vnode, and the MAC module never gets change once +// a process that library validation enabled. +type Fchecklv struct { + LvFileStart c.LongLong + LvErrorMessageSize c.SizeT + LvErrorMessage unsafe.Pointer +} + +// fgetsigsinfo_t used by F_GETSIGSINFO command +type Fgetsigsinfo struct { + FgFileStart c.LongLong + FgInfoRequest c.Int + FgSigIsPlatform c.Int +} + +type Fstore struct { + FstFlags c.Uint + FstPosmode c.Int + FstOffset c.LongLong + FstLength c.LongLong + FstBytesalloc c.LongLong +} + +// fpunchhole_t used by F_PUNCHHOLE +type Fpunchhole struct { + FpFlags c.Uint + Reserved c.Uint + FpOffset c.LongLong + FpLength c.LongLong +} + +// factive_file_trim_t used by F_TRIM_ACTIVE_FILE +type Ftrimactivefile struct { + FtaOffset c.LongLong + FtaLength c.LongLong +} + +// fspecread_t used by F_SPECULATIVE_READ +type Fspecread struct { + FsrFlags c.Uint + Reserved c.Uint + FsrOffset c.LongLong + FsrLength c.LongLong +} + +type Fattributiontag struct { + FtFlags c.Uint + FtHash c.UlongLong + FtAttributionName [255]c.Char +} + +type FilesecPropertyT c.Uint + +const ( + FILESEC_OWNER FilesecPropertyT = 1 + FILESEC_GROUP FilesecPropertyT = 2 + FILESEC_UUID FilesecPropertyT = 3 + FILESEC_MODE FilesecPropertyT = 4 + FILESEC_ACL FilesecPropertyT = 5 + FILESEC_GRPUUID FilesecPropertyT = 6 + // XXX these are private to the implementation + FILESEC_ACL_RAW FilesecPropertyT = 100 + FILESEC_ACL_ALLOCSIZE FilesecPropertyT = 101 +) + +type FsignaturesT = Fsignatures + +type FsupplementT = Fsupplement + +// DYLD needs to check if the object is allowed to be combined +// into the main binary. This is done between the code signature +// is loaded and dyld is doing all the work to process the LOAD commands. +// +// While this could be done in F_ADDFILESIGS.* family the hook into +// the MAC module doesn't say no when LV isn't enabled and then that +// is cached on the vnode, and the MAC module never gets change once +// a process that library validation enabled. +type FchecklvT = Fchecklv + +// fgetsigsinfo_t used by F_GETSIGSINFO command +type FgetsigsinfoT = Fgetsigsinfo + +type FstoreT = Fstore + +// fpunchhole_t used by F_PUNCHHOLE +type FpunchholeT = Fpunchhole + +// factive_file_trim_t used by F_TRIM_ACTIVE_FILE +type FtrimactivefileT = Ftrimactivefile + +// fspecread_t used by F_SPECULATIVE_READ +type FspecreadT = Fspecread + +type FattributiontagT = Fattributiontag + +//go:linkname NativeOpen C.open +func NativeOpen(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeOpenat C.openat +func NativeOpenat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeCreat C.creat +func NativeCreat(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint16T) c.Int + +//go:linkname Fcntl C.fcntl +func Fcntl(_llcppg_param1 c.Int, _llcppg_param2 c.Int, __llgo_va_list ...any) c.Int + +// data-protected non-portable open(2) : +// +// int open_dprotected_np(user_addr_t path, int flags, int class, int dpflags, int mode) +// +//go:linkname OpenxNp C.openx_np +func OpenxNp(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, _llcppg_param3 FilesecT) c.Int + +// data-protected non-portable open(2) : +// +// int open_dprotected_np(user_addr_t path, int flags, int class, int dpflags, int mode) +// +//go:linkname OpenDprotectedNp C.open_dprotected_np +func OpenDprotectedNp(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, _llcppg_param3 c.Int, _llcppg_param4 c.Int, __llgo_va_list ...any) c.Int + +//go:linkname OpenatDprotectedNp C.openat_dprotected_np +func OpenatDprotectedNp(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int, _llcppg_param4 c.Int, _llcppg_param5 c.Int, __llgo_va_list ...any) c.Int + +//go:linkname OpenatAuthenticatedNp C.openat_authenticated_np +func OpenatAuthenticatedNp(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int, _llcppg_param4 c.Int) c.Int + +//go:linkname Flock C.flock +func Flock(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname FilesecInit C.filesec_init +func FilesecInit() FilesecT + +// llgo:link FilesecT.FilesecDup C.filesec_dup +func (self FilesecT) FilesecDup() FilesecT { + return self +} + +// llgo:link FilesecT.FilesecFree C.filesec_free +func (self FilesecT) FilesecFree() { +} + +// llgo:link FilesecT.FilesecGetProperty C.filesec_get_property +func (self FilesecT) FilesecGetProperty(_llcppg_param2 FilesecPropertyT, _llcppg_param3 unsafe.Pointer) c.Int { + return 0 +} + +// llgo:link FilesecT.FilesecQueryProperty C.filesec_query_property +func (self FilesecT) FilesecQueryProperty(_llcppg_param2 FilesecPropertyT, _llcppg_param3 *c.Int) c.Int { + return 0 +} + +// llgo:link FilesecT.FilesecSetProperty C.filesec_set_property +func (self FilesecT) FilesecSetProperty(_llcppg_param2 FilesecPropertyT, _llcppg_param3 unsafe.Pointer) c.Int { + return 0 +} + +// llgo:link FilesecT.FilesecUnsetProperty C.filesec_unset_property +func (self FilesecT) FilesecUnsetProperty(_llcppg_param2 FilesecPropertyT) c.Int { + return 0 +} + +type PosixCred struct { +} + +type Ucred struct { +} + +type KauthCredT = *Ucred + +type PosixCredT = *PosixCred + +// Protections are chosen from these bits, or-ed together +const ( + PROT_NONE = 0 + // [MC2] pages can be read + PROT_READ = 1 + // [MC2] pages can be written + PROT_WRITE = 2 + // [MC2] pages can be executed + PROT_EXEC = 4 +) + +// Flags contain sharing type and options. +// Sharing types; choose one. +const ( + MAP_SHARED = 1 + // [MF|SHM] changes are private + MAP_PRIVATE = 2 +) + +// Obsolete +const MAP_COPY = 2 + +// Other flags +const MAP_FIXED = 16 + +const ( + // Sun: rename private pages to file + MAP_RENAME = 32 + // Sun: don't reserve needed swap area + MAP_NORESERVE = 64 + // previously unimplemented MAP_INHERIT + MAP_RESERVED0080 = 128 + // for MAP_FILE, don't change file size + MAP_NOEXTEND = 256 + // region may contain semaphores + MAP_HASSEMAPHORE = 512 + // don't cache pages for this mapping + MAP_NOCACHE = 1024 + // Allocate a region that will be used for JIT purposes + MAP_JIT = 2048 +) + +// Mapping type +const ( + MAP_FILE = 0 + // allocated from memory, swap space + MAP_ANON = 4096 + MAP_ANONYMOUS = 4096 +) + +// The MAP_RESILIENT_* flags can be used when the caller wants to map some +// possibly unreliable memory and be able to access it safely, possibly +// getting the wrong contents rather than raising any exception. +// For safety reasons, such mappings have to be read-only (PROT_READ access +// only). +// +// MAP_RESILIENT_CODESIGN: +// +// accessing this mapping will not generate code-signing violations, +// even if the contents are tainted. +// +// MAP_RESILIENT_MEDIA: +// +// accessing this mapping will not generate an exception if the contents +// are not available (unreachable removable or remote media, access beyond +// end-of-file, ...). Missing contents will be replaced with zeroes. +const ( + MAP_RESILIENT_CODESIGN = 8192 + // no backing-store failures + MAP_RESILIENT_MEDIA = 16384 +) + +// Return virtual addresses <4G only +const MAP_32BIT = 32768 + +// Flags used to support translated processes. +const MAP_TRANSLATED_ALLOW_EXECUTE = 131072 + +// UNIX03 compliance +const MAP_UNIX03 = 262144 + +// Allocate a region that will be protected by TPRO +const MAP_TPRO = 524288 + +// Process memory locking +const ( + MCL_CURRENT = 1 + // [ML] Lock all future memory as well + MCL_FUTURE = 2 +) + +// msync() flags +const ( + MS_ASYNC = 1 + // [MF|SIO] invalidate all cached data + MS_INVALIDATE = 2 + // [MF|SIO] msync synchronously + MS_SYNC = 16 +) + +const ( + // invalidate pages, leave mapped + MS_KILLPAGES = 4 + // deactivate pages, leave mapped + MS_DEACTIVATE = 8 +) + +// Advice to madvise +const ( + POSIX_MADV_NORMAL = 0 + // [MC1] expect random page refs + POSIX_MADV_RANDOM = 1 + // [MC1] expect sequential page refs + POSIX_MADV_SEQUENTIAL = 2 + // [MC1] will need these pages + POSIX_MADV_WILLNEED = 3 + // [MC1] dont need these pages + POSIX_MADV_DONTNEED = 4 +) + +const ( + MADV_NORMAL = 0 + MADV_RANDOM = 1 + MADV_SEQUENTIAL = 2 + MADV_WILLNEED = 3 + MADV_DONTNEED = 4 + // pages unneeded, discard contents + MADV_FREE = 5 + // zero the wired pages that have not been unwired before the entry is deleted + MADV_ZERO_WIRED_PAGES = 6 + // pages can be reused (by anyone) + MADV_FREE_REUSABLE = 7 + // caller wants to reuse those pages + MADV_FREE_REUSE = 8 + MADV_CAN_REUSE = 9 + // page out now (internal only) + MADV_PAGEOUT = 10 +) + +// Return bits from mincore +const ( + MINCORE_INCORE = 1 + // Page has been referenced by us + MINCORE_REFERENCED = 2 + // Page has been modified by us + MINCORE_MODIFIED = 4 + // Page has been referenced + MINCORE_REFERENCED_OTHER = 8 + // Page has been modified + MINCORE_MODIFIED_OTHER = 16 + // Page has been paged out + MINCORE_PAGED_OUT = 32 + // Page has been copied + MINCORE_COPIED = 64 + // Page belongs to an anonymous object + MINCORE_ANONYMOUS = 128 +) + +// [ML] +// +//go:linkname Mlockall C.mlockall +func Mlockall(_llcppg_param1 c.Int) c.Int + +// [MR] +// +//go:linkname Munlockall C.munlockall +func Munlockall() c.Int + +// [MR] +// +//go:linkname Mlock C.mlock +func Mlock(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT) c.Int + +// [MC3] +// +//go:linkname Mmap C.mmap +func Mmap(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 c.Int, _llcppg_param4 c.Int, _llcppg_param5 c.Int, _llcppg_param6 c.LongLong) unsafe.Pointer + +// [MPR] +// +//go:linkname Mprotect C.mprotect +func Mprotect(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 c.Int) c.Int + +// [MF|SIO] +// +//go:linkname Msync C.msync +func Msync(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 c.Int) c.Int + +// [MR] +// +//go:linkname Munlock C.munlock +func Munlock(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT) c.Int + +// [MC3] +// +//go:linkname Munmap C.munmap +func Munmap(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT) c.Int + +// [SHM] +// +//go:linkname ShmOpen C.shm_open +func ShmOpen(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, __llgo_va_list ...any) c.Int + +// [ADV] +// +//go:linkname ShmUnlink C.shm_unlink +func ShmUnlink(_llcppg_param1 *c.Char) c.Int + +// [ADV] +// +//go:linkname PosixMadvise C.posix_madvise +func PosixMadvise(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 c.Int) c.Int + +//go:linkname Madvise C.madvise +func Madvise(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 c.Int) c.Int + +//go:linkname Mincore C.mincore +func Mincore(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 *c.Char) c.Int + +//go:linkname Minherit C.minherit +func Minherit(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.SizeT, _llcppg_param3 c.Int) c.Int + +// Requestable events. If poll(2) finds any of these set, they are +// copied to revents on return. +const ( + POLLIN = 1 + // OOB/Urgent readable data + POLLPRI = 2 + // file descriptor is writeable + POLLOUT = 4 + // non-OOB/URG data available + POLLRDNORM = 64 + // no write type differentiation + POLLWRNORM = 4 + // OOB/Urgent readable data + POLLRDBAND = 128 + // OOB/Urgent data can be written + POLLWRBAND = 256 +) + +// FreeBSD extensions: polling on a regular file might return one +// of these events (currently only supported on local filesystems). +const ( + POLLEXTEND = 512 + // file attributes may have changed + POLLATTRIB = 1024 + // (un)link/rename may have happened + POLLNLINK = 2048 + // file's contents may have changed + POLLWRITE = 4096 +) + +// These events are set if they occur regardless of whether they were +// requested. +const ( + POLLERR = 8 + // file descriptor was "hung up" + POLLHUP = 16 + // requested events "invalid" + POLLNVAL = 32 +) + +const POLLSTANDARD = 511 + +type Pollfd struct { + Fd c.Int + Events int16 + Revents int16 +} + +// This is defined here (instead of ) because this is where +// traditional SVR4 code will look to find it. +// +// llgo:link (*Pollfd).Poll C.poll +func (self *Pollfd) Poll(_llcppg_param2 c.Uint, _llcppg_param3 c.Int) c.Int { + return 0 +} + +// ! +// @function qos_class_self +// +// @abstract +// Returns the requested QOS class of the current thread. +// +// @return +// One of the QOS class values in qos_class_t. +// +//go:linkname QosClassSelf C.qos_class_self +func QosClassSelf() c.Uint + +// ! +// @function qos_class_main +// +// @abstract +// Returns the initial requested QOS class of the main thread. +// +// @discussion +// The QOS class that the main thread of a process is created with depends on +// the type of process (e.g. application or daemon) and on how it has been +// launched. +// +// This function returns that initial requested QOS class value chosen by the +// system to enable propagation of that classification to matching work not +// executing on the main thread. +// +// @return +// One of the QOS class values in qos_class_t. +// +//go:linkname QosClassMain C.qos_class_main +func QosClassMain() c.Uint + +// Possible values of the first parameter to getpriority()/setpriority(), +// used to indicate the type of the second parameter. +const ( + PRIO_PROCESS = 0 + // Second argument is a GID + PRIO_PGRP = 1 + // Second argument is a UID + PRIO_USER = 2 +) + +const ( + // Second argument is always 0 (current thread) + PRIO_DARWIN_THREAD = 3 + // Second argument is a PID + PRIO_DARWIN_PROCESS = 4 +) + +// Range limitations for the value of the third parameter to setpriority(). +const ( + PRIO_MIN = -20 + PRIO_MAX = 20 +) + +// use PRIO_DARWIN_BG to set the current thread into "background" state +// which lowers CPU, disk IO, and networking priorites until thread terminates +// or "background" state is revoked +const PRIO_DARWIN_BG = 4096 + +// use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to +// the GPU. (deprecated) +const PRIO_DARWIN_NONUI = 4097 + +// Possible values of the first parameter to getrusage(), used to indicate +// the scope of the information to be returned. +const ( + RUSAGE_SELF = 0 + // Current process' children + RUSAGE_CHILDREN = -1 +) + +// Flavors for proc_pid_rusage(). +const ( + RUSAGE_INFO_V0 = 0 + RUSAGE_INFO_V1 = 1 + RUSAGE_INFO_V2 = 2 + RUSAGE_INFO_V3 = 3 + RUSAGE_INFO_V4 = 4 + RUSAGE_INFO_V5 = 5 + RUSAGE_INFO_V6 = 6 + RUSAGE_INFO_CURRENT = 6 +) + +// Flags for RUSAGE_INFO_V5 +const RU_PROC_RUNS_RESLIDE = 1 + +// Possible values of the first parameter to getrlimit()/setrlimit(), to +// indicate for which resource the operation is being performed. +const ( + RLIMIT_CPU = 0 + // file size + RLIMIT_FSIZE = 1 + // data segment size + RLIMIT_DATA = 2 + // stack size + RLIMIT_STACK = 3 + // core file size + RLIMIT_CORE = 4 + // address space (resident set size) + RLIMIT_AS = 5 +) + +const ( + // source compatibility alias + RLIMIT_RSS = 5 + // locked-in-memory address space + RLIMIT_MEMLOCK = 6 + // number of processes + RLIMIT_NPROC = 7 +) + +// number of open files +const RLIMIT_NOFILE = 8 + +// total number of resource limits +const RLIM_NLIMITS = 9 + +// proc_rlimit_control() +// +// Resource limit flavors +const ( + RLIMIT_WAKEUPS_MONITOR = 1 + // Configure the CPU usage monitor. + RLIMIT_CPU_USAGE_MONITOR = 2 + // Configure a blocking, per-thread, CPU limits. + RLIMIT_THREAD_CPULIMITS = 3 + // Configure memory footprint interval tracking + RLIMIT_FOOTPRINT_INTERVAL = 4 +) + +// Flags for wakeups monitor control. +const ( + WAKEMON_ENABLE = 1 + WAKEMON_DISABLE = 2 + WAKEMON_GET_PARAMS = 4 + WAKEMON_SET_DEFAULTS = 8 + // Configure the task so that violations are fatal. + WAKEMON_MAKE_FATAL = 16 +) + +// Flags for CPU usage monitor control. +const CPUMON_MAKE_FATAL = 4096 + +// Flags for memory footprint interval tracking. +const FOOTPRINT_INTERVAL_RESET = 1 + +// I/O type +const ( + IOPOL_TYPE_DISK = 0 + IOPOL_TYPE_VFS_ATIME_UPDATES = 2 + IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = 3 + IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = 4 + IOPOL_TYPE_VFS_TRIGGER_RESOLVE = 5 + IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION = 6 + IOPOL_TYPE_VFS_IGNORE_PERMISSIONS = 7 + IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE = 8 + IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES = 9 + IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY = 10 +) + +// scope +const ( + IOPOL_SCOPE_PROCESS = 0 + IOPOL_SCOPE_THREAD = 1 + IOPOL_SCOPE_DARWIN_BG = 2 +) + +// I/O Priority +const ( + IOPOL_DEFAULT = 0 + IOPOL_IMPORTANT = 1 + IOPOL_PASSIVE = 2 + IOPOL_THROTTLE = 3 + IOPOL_UTILITY = 4 + IOPOL_STANDARD = 5 +) + +// compatibility with older names +const ( + IOPOL_APPLICATION = 5 + IOPOL_NORMAL = 1 +) + +const ( + IOPOL_ATIME_UPDATES_DEFAULT = 0 + IOPOL_ATIME_UPDATES_OFF = 1 +) + +const ( + IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = 0 + IOPOL_MATERIALIZE_DATALESS_FILES_OFF = 1 + IOPOL_MATERIALIZE_DATALESS_FILES_ON = 2 +) + +const ( + IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = 0 + IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = 1 +) + +const ( + IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT = 0 + IOPOL_VFS_TRIGGER_RESOLVE_OFF = 1 +) + +const ( + IOPOL_VFS_CONTENT_PROTECTION_DEFAULT = 0 + IOPOL_VFS_CONTENT_PROTECTION_IGNORE = 1 +) + +const ( + IOPOL_VFS_IGNORE_PERMISSIONS_OFF = 0 + IOPOL_VFS_IGNORE_PERMISSIONS_ON = 1 +) + +const ( + IOPOL_VFS_SKIP_MTIME_UPDATE_OFF = 0 + IOPOL_VFS_SKIP_MTIME_UPDATE_ON = 1 +) + +const ( + IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF = 0 + IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON = 1 +) + +const ( + IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT = 0 + IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON = 1 +) + +const ( + IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT = 0 + IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON = 1 +) + +// A structure representing an accounting of resource utilization. The +// address of an instance of this structure is the second parameter to +// getrusage(). +// +// Note: All values other than ru_utime and ru_stime are implementaiton +// +// defined and subject to change in a future release. Their use +// is discouraged for standards compliant programs. +type Rusage struct { + RuUtime llsys.Timeval + RuStime llsys.Timeval + RuMaxrss c.Long + RuIxrss c.Long + RuIdrss c.Long + RuIsrss c.Long + RuMinflt c.Long + RuMajflt c.Long + RuNswap c.Long + RuInblock c.Long + RuOublock c.Long + RuMsgsnd c.Long + RuMsgrcv c.Long + RuNsignals c.Long + RuNvcsw c.Long + RuNivcsw c.Long +} + +type RusageInfoV0 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong +} + +type RusageInfoV1 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong + RiChildUserTime c.UlongLong + RiChildSystemTime c.UlongLong + RiChildPkgIdleWkups c.UlongLong + RiChildInterruptWkups c.UlongLong + RiChildPageins c.UlongLong + RiChildElapsedAbstime c.UlongLong +} + +type RusageInfoV2 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong + RiChildUserTime c.UlongLong + RiChildSystemTime c.UlongLong + RiChildPkgIdleWkups c.UlongLong + RiChildInterruptWkups c.UlongLong + RiChildPageins c.UlongLong + RiChildElapsedAbstime c.UlongLong + RiDiskioBytesread c.UlongLong + RiDiskioByteswritten c.UlongLong +} + +type RusageInfoV3 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong + RiChildUserTime c.UlongLong + RiChildSystemTime c.UlongLong + RiChildPkgIdleWkups c.UlongLong + RiChildInterruptWkups c.UlongLong + RiChildPageins c.UlongLong + RiChildElapsedAbstime c.UlongLong + RiDiskioBytesread c.UlongLong + RiDiskioByteswritten c.UlongLong + RiCpuTimeQosDefault c.UlongLong + RiCpuTimeQosMaintenance c.UlongLong + RiCpuTimeQosBackground c.UlongLong + RiCpuTimeQosUtility c.UlongLong + RiCpuTimeQosLegacy c.UlongLong + RiCpuTimeQosUserInitiated c.UlongLong + RiCpuTimeQosUserInteractive c.UlongLong + RiBilledSystemTime c.UlongLong + RiServicedSystemTime c.UlongLong +} + +type RusageInfoV4 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong + RiChildUserTime c.UlongLong + RiChildSystemTime c.UlongLong + RiChildPkgIdleWkups c.UlongLong + RiChildInterruptWkups c.UlongLong + RiChildPageins c.UlongLong + RiChildElapsedAbstime c.UlongLong + RiDiskioBytesread c.UlongLong + RiDiskioByteswritten c.UlongLong + RiCpuTimeQosDefault c.UlongLong + RiCpuTimeQosMaintenance c.UlongLong + RiCpuTimeQosBackground c.UlongLong + RiCpuTimeQosUtility c.UlongLong + RiCpuTimeQosLegacy c.UlongLong + RiCpuTimeQosUserInitiated c.UlongLong + RiCpuTimeQosUserInteractive c.UlongLong + RiBilledSystemTime c.UlongLong + RiServicedSystemTime c.UlongLong + RiLogicalWrites c.UlongLong + RiLifetimeMaxPhysFootprint c.UlongLong + RiInstructions c.UlongLong + RiCycles c.UlongLong + RiBilledEnergy c.UlongLong + RiServicedEnergy c.UlongLong + RiIntervalMaxPhysFootprint c.UlongLong + RiRunnableTime c.UlongLong +} + +type RusageInfoV5 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong + RiChildUserTime c.UlongLong + RiChildSystemTime c.UlongLong + RiChildPkgIdleWkups c.UlongLong + RiChildInterruptWkups c.UlongLong + RiChildPageins c.UlongLong + RiChildElapsedAbstime c.UlongLong + RiDiskioBytesread c.UlongLong + RiDiskioByteswritten c.UlongLong + RiCpuTimeQosDefault c.UlongLong + RiCpuTimeQosMaintenance c.UlongLong + RiCpuTimeQosBackground c.UlongLong + RiCpuTimeQosUtility c.UlongLong + RiCpuTimeQosLegacy c.UlongLong + RiCpuTimeQosUserInitiated c.UlongLong + RiCpuTimeQosUserInteractive c.UlongLong + RiBilledSystemTime c.UlongLong + RiServicedSystemTime c.UlongLong + RiLogicalWrites c.UlongLong + RiLifetimeMaxPhysFootprint c.UlongLong + RiInstructions c.UlongLong + RiCycles c.UlongLong + RiBilledEnergy c.UlongLong + RiServicedEnergy c.UlongLong + RiIntervalMaxPhysFootprint c.UlongLong + RiRunnableTime c.UlongLong + RiFlags c.UlongLong +} + +type RusageInfoV6 struct { + RiUuid [16]c.Uint8T + RiUserTime c.UlongLong + RiSystemTime c.UlongLong + RiPkgIdleWkups c.UlongLong + RiInterruptWkups c.UlongLong + RiPageins c.UlongLong + RiWiredSize c.UlongLong + RiResidentSize c.UlongLong + RiPhysFootprint c.UlongLong + RiProcStartAbstime c.UlongLong + RiProcExitAbstime c.UlongLong + RiChildUserTime c.UlongLong + RiChildSystemTime c.UlongLong + RiChildPkgIdleWkups c.UlongLong + RiChildInterruptWkups c.UlongLong + RiChildPageins c.UlongLong + RiChildElapsedAbstime c.UlongLong + RiDiskioBytesread c.UlongLong + RiDiskioByteswritten c.UlongLong + RiCpuTimeQosDefault c.UlongLong + RiCpuTimeQosMaintenance c.UlongLong + RiCpuTimeQosBackground c.UlongLong + RiCpuTimeQosUtility c.UlongLong + RiCpuTimeQosLegacy c.UlongLong + RiCpuTimeQosUserInitiated c.UlongLong + RiCpuTimeQosUserInteractive c.UlongLong + RiBilledSystemTime c.UlongLong + RiServicedSystemTime c.UlongLong + RiLogicalWrites c.UlongLong + RiLifetimeMaxPhysFootprint c.UlongLong + RiInstructions c.UlongLong + RiCycles c.UlongLong + RiBilledEnergy c.UlongLong + RiServicedEnergy c.UlongLong + RiIntervalMaxPhysFootprint c.UlongLong + RiRunnableTime c.UlongLong + RiFlags c.UlongLong + RiUserPtime c.UlongLong + RiSystemPtime c.UlongLong + RiPinstructions c.UlongLong + RiPcycles c.UlongLong + RiEnergyNj c.UlongLong + RiPenergyNj c.UlongLong + RiReserved [14]c.UlongLong +} + +// A structure representing a resource limit. The address of an instance +// of this structure is the second parameter to getrlimit()/setrlimit(). +type Rlimit struct { + RlimCur c.UlongLong + RlimMax c.UlongLong +} + +type ProcRlimitControlWakeupmon struct { + WmFlags c.Uint + WmRate c.Int +} + +type RusageInfoT uintptr + +type RusageInfoCurrent = RusageInfoV6 + +//go:linkname Getpriority C.getpriority +func Getpriority(_llcppg_param1 c.Int, _llcppg_param2 c.Uint) c.Int + +//go:linkname GetiopolicyNp C.getiopolicy_np +func GetiopolicyNp(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname NativeGetrlimit C.getrlimit +func NativeGetrlimit(_llcppg_param1 c.Int, _llcppg_param2 *Rlimit) c.Int + +//go:linkname Getrusage C.getrusage +func Getrusage(_llcppg_param1 c.Int, _llcppg_param2 *Rusage) c.Int + +//go:linkname Setpriority C.setpriority +func Setpriority(_llcppg_param1 c.Int, _llcppg_param2 c.Uint, _llcppg_param3 c.Int) c.Int + +//go:linkname SetiopolicyNp C.setiopolicy_np +func SetiopolicyNp(_llcppg_param1 c.Int, _llcppg_param2 c.Int, _llcppg_param3 c.Int) c.Int + +//go:linkname NativeSetrlimit C.setrlimit +func NativeSetrlimit(_llcppg_param1 c.Int, _llcppg_param2 *Rlimit) c.Int + +// 0777 +const ACCESSPERMS = 511 + +// 7777 +const ALLPERMS = 4095 + +// 0666 +const DEFFILEMODE = 438 + +// block size used in the stat struct +const S_BLKSIZE = 512 + +// Definitions of flags stored in file flags word. +// +// Super-user and owner changeable flags. +const ( + UF_SETTABLE = 65535 + // do not dump file + UF_NODUMP = 1 + // file may not be changed + UF_IMMUTABLE = 2 + // writes to file may only append + UF_APPEND = 4 + // directory is opaque wrt. union + UF_OPAQUE = 8 +) + +// file is compressed (some file-systems) +const UF_COMPRESSED = 32 + +// UF_TRACKED is used for dealing with document IDs. We no longer issue +// +// notifications for deletes or renames for files which have UF_TRACKED set. +const UF_TRACKED = 64 + +// entitlement required for reading +const UF_DATAVAULT = 128 + +// Bits 0x0100 through 0x4000 are currently undefined. +const UF_HIDDEN = 32768 + +// Super-user changeable flags. +const ( + SF_SUPPORTED = 10420224 + // mask of superuser changeable flags + SF_SETTABLE = 1073676288 + // mask of system read-only synthetic flags + SF_SYNTHETIC = 3221225472 + // file is archived + SF_ARCHIVED = 65536 + // file may not be changed + SF_IMMUTABLE = 131072 + // writes to file may only append + SF_APPEND = 262144 + // entitlement required for writing + SF_RESTRICTED = 524288 + // Item may not be removed, renamed or mounted on + SF_NOUNLINK = 1048576 +) + +// file is a firmlink +const SF_FIRMLINK = 8388608 + +// Synthetic flags. +// +// These are read-only. We keep them out of SF_SUPPORTED so that +// attempts to set them will fail. +const SF_DATALESS = 1073741824 + +// Extended flags ("EF") returned by ATTR_CMNEXT_EXT_FLAGS from getattrlist/getattrlistbulk +const ( + EF_MAY_SHARE_BLOCKS = 1 + // file has no xattrs at all + EF_NO_XATTRS = 2 + // file is a sync root for iCloud + EF_IS_SYNC_ROOT = 4 + // file is purgeable + EF_IS_PURGEABLE = 8 + // file has at least one sparse region + EF_IS_SPARSE = 16 + // a synthetic directory/symlink + EF_IS_SYNTHETIC = 32 + // file shares all of its blocks with another file + EF_SHARES_ALL_BLOCKS = 64 +) + +const ( + UTIME_NOW = -1 + UTIME_OMIT = -2 +) + +// XXX So deprecated, it would make your head spin +// +// The old stat structure. In fact, this is not used by the kernel at all, +// and should not be used by user space, and should be removed from this +// header file entirely (along with the unused cvtstat() prototype in +// vnode_internal.h). +type Ostat struct { + StDev c.Uint16T + StIno c.UlongLong + StMode c.Uint16T + StNlink c.Uint16T + StUid c.Uint16T + StGid c.Uint16T + StRdev c.Uint16T + StSize c.Int + StAtimespec lltime.Timespec + StMtimespec lltime.Timespec + StCtimespec lltime.Timespec + StBlksize c.Int + StBlocks c.Int + StFlags c.Uint + StGen c.Uint +} + +// [XSI] +// +//go:linkname NativeChmod C.chmod +func NativeChmod(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint16T) c.Int + +//go:linkname NativeFchmod C.fchmod +func NativeFchmod(_llcppg_param1 c.Int, _llcppg_param2 c.Uint16T) c.Int + +//go:linkname NativeFstat C.fstat +func NativeFstat(_llcppg_param1 c.Int, _llcppg_param2 *StatT) c.Int + +//go:linkname NativeLstat C.lstat +func NativeLstat(_llcppg_param1 *c.Char, _llcppg_param2 *StatT) c.Int + +//go:linkname NativeMkdir C.mkdir +func NativeMkdir(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint16T) c.Int + +//go:linkname NativeMkfifo C.mkfifo +func NativeMkfifo(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint16T) c.Int + +//go:linkname NativeStat C.stat +func NativeStat(_llcppg_param1 *c.Char, _llcppg_param2 *StatT) c.Int + +//go:linkname NativeMknod C.mknod +func NativeMknod(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint16T, _llcppg_param3 c.Int) c.Int + +//go:linkname NativeUmask C.umask +func NativeUmask(_llcppg_param1 c.Uint16T) c.Uint16T + +//go:linkname NativeFchmodat C.fchmodat +func NativeFchmodat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Uint16T, _llcppg_param4 c.Int) c.Int + +//go:linkname NativeFstatat C.fstatat +func NativeFstatat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 *StatT, _llcppg_param4 c.Int) c.Int + +//go:linkname Mkdirat C.mkdirat +func Mkdirat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Uint16T) c.Int + +//go:linkname Mkfifoat C.mkfifoat +func Mkfifoat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Uint16T) c.Int + +//go:linkname Mknodat C.mknodat +func Mknodat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Uint16T, _llcppg_param4 c.Int) c.Int + +//go:linkname Futimens C.futimens +func Futimens(__fd c.Int, __times *lltime.Timespec) c.Int + +//go:linkname Utimensat C.utimensat +func Utimensat(__fd c.Int, __path *c.Char, __times *lltime.Timespec, __flag c.Int) c.Int + +//go:linkname Chflags C.chflags +func Chflags(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint) c.Int + +//go:linkname ChmodxNp C.chmodx_np +func ChmodxNp(_llcppg_param1 *c.Char, _llcppg_param2 FilesecT) c.Int + +//go:linkname Fchflags C.fchflags +func Fchflags(_llcppg_param1 c.Int, _llcppg_param2 c.Uint) c.Int + +//go:linkname FchmodxNp C.fchmodx_np +func FchmodxNp(_llcppg_param1 c.Int, _llcppg_param2 FilesecT) c.Int + +//go:linkname FstatxNp C.fstatx_np +func FstatxNp(_llcppg_param1 c.Int, _llcppg_param2 *StatT, _llcppg_param3 FilesecT) c.Int + +//go:linkname Lchflags C.lchflags +func Lchflags(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint) c.Int + +//go:linkname Lchmod C.lchmod +func Lchmod(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint16T) c.Int + +//go:linkname LstatxNp C.lstatx_np +func LstatxNp(_llcppg_param1 *c.Char, _llcppg_param2 *StatT, _llcppg_param3 FilesecT) c.Int + +//go:linkname MkdirxNp C.mkdirx_np +func MkdirxNp(_llcppg_param1 *c.Char, _llcppg_param2 FilesecT) c.Int + +//go:linkname MkfifoxNp C.mkfifox_np +func MkfifoxNp(_llcppg_param1 *c.Char, _llcppg_param2 FilesecT) c.Int + +//go:linkname StatxNp C.statx_np +func StatxNp(_llcppg_param1 *c.Char, _llcppg_param2 *StatT, _llcppg_param3 FilesecT) c.Int + +// llgo:link FilesecT.UmaskxNp C.umaskx_np +func (self FilesecT) UmaskxNp() c.Int { + return 0 +} + +// Defined bits for f_flag field value +const ( + ST_RDONLY = 1 + // Does not honor setuid/setgid + ST_NOSUID = 2 +) + +// Following structure is used as a statvfs/fstatvfs function parameter +type StatvfsT struct { + FBsize c.Ulong + FFrsize c.Ulong + FBlocks c.Uint + FBfree c.Uint + FBavail c.Uint + FFiles c.Uint + FFfree c.Uint + FFavail c.Uint + FFsid c.Ulong + FFlag c.Ulong + FNamemax c.Ulong +} + +//go:linkname Fstatvfs C.fstatvfs +func Fstatvfs(_llcppg_param1 c.Int, _llcppg_param2 *StatvfsT) c.Int + +//go:linkname Statvfs C.statvfs +func Statvfs(_llcppg_param1 *c.Char, _llcppg_param2 *StatvfsT) c.Int + +// Special Control Characters +// +// Index into c_cc[] character array. +// +// Name Subscript Enabled by +const ( + VEOF = 0 + // ICANON + VEOL = 1 +) + +// ICANON together with IEXTEN +const VEOL2 = 2 + +// ICANON +const VERASE = 3 + +// ICANON together with IEXTEN +const VWERASE = 4 + +// ICANON +const VKILL = 5 + +// ICANON together with IEXTEN +const VREPRINT = 6 + +// 7 spare 1 +const ( + VINTR = 8 + // ISIG + VQUIT = 9 + // ISIG + VSUSP = 10 +) + +// ISIG together with IEXTEN +const VDSUSP = 11 + +const ( + // IXON, IXOFF + VSTART = 12 + // IXON, IXOFF + VSTOP = 13 +) + +const ( + // IEXTEN + VLNEXT = 14 + // IEXTEN + VDISCARD = 15 +) + +const ( + // !ICANON + VMIN = 16 + // !ICANON + VTIME = 17 +) + +// ICANON together with IEXTEN +const VSTATUS = 18 + +const NCCS = 20 + +// Input flags - software input processing +const ( + IGNBRK = 1 + // map BREAK to SIGINTR + BRKINT = 2 + // ignore (discard) parity errors + IGNPAR = 4 + // mark parity and framing errors + PARMRK = 8 + // enable checking of parity errors + INPCK = 16 + // strip 8th bit off chars + ISTRIP = 32 + // map NL into CR + INLCR = 64 + // ignore CR + IGNCR = 128 + // map CR to NL (ala CRMOD) + ICRNL = 256 + // enable output flow control + IXON = 512 + // enable input flow control + IXOFF = 1024 + // any char will restart after stop + IXANY = 2048 +) + +const ( + // ring bell on input queue full + IMAXBEL = 8192 + // maintain state for UTF-8 VERASE + IUTF8 = 16384 +) + +// Output flags - software output processing +const ( + OPOST = 1 + // map NL to CR-NL (ala CRMOD) + ONLCR = 2 +) + +const ( + // expand tabs to spaces + OXTABS = 4 + // discard EOT's (^D) on output) + ONOEOT = 8 +) + +// The following block of features is unimplemented. Use of these flags in +// programs will currently result in unexpected behaviour. +// +// - Begin unimplemented features +const ( + OCRNL = 16 + // no CR output at column 0 + ONOCR = 32 + // NL performs CR function + ONLRET = 64 + // use fill characters for delay + OFILL = 128 + // \n delay + NLDLY = 768 + // horizontal tab delay + TABDLY = 3076 + // \r delay + CRDLY = 12288 + // form feed delay + FFDLY = 16384 + // \b delay + BSDLY = 32768 + // vertical tab delay + VTDLY = 65536 + // fill is DEL, else NUL + OFDEL = 131072 +) + +// These manifest constants have the same names as those in the header +// , so you are not permitted to have both definitions +// in scope simultaneously in the same compilation unit. Nevertheless, +// they are required to be in scope when _POSIX_C_SOURCE is requested; +// this means that including the header before this +// one when _POSIX_C_SOURCE is in scope will result in redefintions. We +// attempt to maintain these as the same values so as to avoid this being +// an outright error in most compilers. +const ( + NL0 = 0 + NL1 = 256 +) + +const ( + NL2 = 512 + NL3 = 768 +) + +// not in sys/ioctl_compat.h, use OXTABS value +const ( + TAB0 = 0 + TAB1 = 1024 + TAB2 = 2048 +) + +// not in sys/ioctl_compat.h, use OXTABS value +const ( + TAB3 = 4 + CR0 = 0 + CR1 = 4096 + CR2 = 8192 + CR3 = 12288 + FF0 = 0 + FF1 = 16384 + BS0 = 0 + BS1 = 32768 + VT0 = 0 + VT1 = 65536 +) + +// ignore control flags +const CIGNORE = 1 + +const ( + // character size mask + CSIZE = 768 + // 5 bits (pseudo) + CS5 = 0 + // 6 bits + CS6 = 256 + // 7 bits + CS7 = 512 + // 8 bits + CS8 = 768 + // send 2 stop bits + CSTOPB = 1024 + // enable receiver + CREAD = 2048 + // parity enable + PARENB = 4096 + // odd parity, else even + PARODD = 8192 + // hang up on last close + HUPCL = 16384 + // ignore modem status lines + CLOCAL = 32768 +) + +const ( + // CTS flow control of output + CCTS_OFLOW = 65536 + // RTS flow control of input + CRTS_IFLOW = 131072 + // DTR flow control of input + CDTR_IFLOW = 262144 + // DSR flow control of output + CDSR_OFLOW = 524288 + // DCD flow control of output + CCAR_OFLOW = 1048576 + // old name for CCAR_OFLOW + MDMBUF = 1048576 +) + +// visual erase for line kill +const ECHOKE = 1 + +const ( + // visually erase chars + ECHOE = 2 + // echo NL after line kill + ECHOK = 4 + // enable echoing + ECHO = 8 + // echo NL even if ECHO is off + ECHONL = 16 +) + +const ( + // visual erase mode for hardcopy + ECHOPRT = 32 + // echo control chars as ^(Char) + ECHOCTL = 64 +) + +const ( + // enable signals INTR, QUIT, [D]SUSP + ISIG = 128 + // canonicalize input lines + ICANON = 256 +) + +// use alternate WERASE algorithm +const ALTWERASE = 512 + +// enable DISCARD and LNEXT +const IEXTEN = 1024 + +// external processing +const EXTPROC = 2048 + +// stop background jobs from output +const TOSTOP = 4194304 + +const ( + // output being flushed (state) + FLUSHO = 8388608 + // no kernel output from VSTATUS + NOKERNINFO = 33554432 + // XXX retype pending input (state) + PENDIN = 536870912 +) + +// don't flush after interrupt +const NOFLSH = 2147483648 + +// Commands passed to tcsetattr() for setting the termios structure. +const ( + TCSANOW = 0 + // drain output, then change + TCSADRAIN = 1 + // drain output, flush input + TCSAFLUSH = 2 +) + +// flag - don't alter h.w. state +const TCSASOFT = 16 + +// Standard speeds +const ( + B0 = 0 + B50 = 50 + B75 = 75 + B110 = 110 + B134 = 134 + B150 = 150 + B200 = 200 + B300 = 300 + B600 = 600 + B1200 = 1200 + B1800 = 1800 + B2400 = 2400 + B4800 = 4800 + B9600 = 9600 + B19200 = 19200 + B38400 = 38400 +) + +const ( + B7200 = 7200 + B14400 = 14400 + B28800 = 28800 + B57600 = 57600 + B76800 = 76800 + B115200 = 115200 + B230400 = 230400 + EXTA = 19200 + EXTB = 38400 +) + +const ( + TCIFLUSH = 1 + TCOFLUSH = 2 + TCIOFLUSH = 3 + TCOOFF = 1 + TCOON = 2 + TCIOFF = 3 + TCION = 4 +) + +type Termios struct { + CIflag c.Ulong + COflag c.Ulong + CCflag c.Ulong + CLflag c.Ulong + CCc [20]c.Uint8T + CIspeed c.Ulong + COspeed c.Ulong +} + +// llgo:link (*Termios).Cfgetispeed C.cfgetispeed +func (self *Termios) Cfgetispeed() c.Ulong { + return 0 +} + +// llgo:link (*Termios).Cfgetospeed C.cfgetospeed +func (self *Termios) Cfgetospeed() c.Ulong { + return 0 +} + +// llgo:link (*Termios).Cfsetispeed C.cfsetispeed +func (self *Termios) Cfsetispeed(_llcppg_param2 c.Ulong) c.Int { + return 0 +} + +// llgo:link (*Termios).Cfsetospeed C.cfsetospeed +func (self *Termios) Cfsetospeed(_llcppg_param2 c.Ulong) c.Int { + return 0 +} + +//go:linkname Tcgetattr C.tcgetattr +func Tcgetattr(_llcppg_param1 c.Int, _llcppg_param2 *Termios) c.Int + +//go:linkname Tcsetattr C.tcsetattr +func Tcsetattr(_llcppg_param1 c.Int, _llcppg_param2 c.Int, _llcppg_param3 *Termios) c.Int + +//go:linkname Tcdrain C.tcdrain +func Tcdrain(_llcppg_param1 c.Int) c.Int + +//go:linkname Tcflow C.tcflow +func Tcflow(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Tcflush C.tcflush +func Tcflush(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Tcsendbreak C.tcsendbreak +func Tcsendbreak(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +// llgo:link (*Termios).Cfmakeraw C.cfmakeraw +func (self *Termios) Cfmakeraw() { +} + +// llgo:link (*Termios).Cfsetspeed C.cfsetspeed +func (self *Termios) Cfsetspeed(_llcppg_param2 c.Ulong) c.Int { + return 0 +} + +// [XSI] Structure whose address is passed as the first parameter to times() +type Tms struct { + TmsUtime lltime.ClockT + TmsStime lltime.ClockT + TmsCutime lltime.ClockT + TmsCstime lltime.ClockT +} + +// llgo:link (*Tms).Times C.times +func (self *Tms) Times() lltime.ClockT { + return 0 +} + +const NBBY = 8 + +type QaddrT = *c.LongLong + +// IO direction for uio_t. +// +// UIO_READ - data moves into iovec(s) associated with uio_t +// UIO_WRITE - data moves out of iovec(s) associated with uio_t +type UioRw c.Uint + +const ( + // IO direction for uio_t. + // UIO_READ - data moves into iovec(s) associated with uio_t + // UIO_WRITE - data moves out of iovec(s) associated with uio_t + UIO_READ UioRw = 0 + // IO direction for uio_t. + // UIO_READ - data moves into iovec(s) associated with uio_t + // UIO_WRITE - data moves out of iovec(s) associated with uio_t + UIO_WRITE UioRw = 1 +) + +//go:linkname Readv C.readv +func Readv(_llcppg_param1 c.Int, _llcppg_param2 *c.Iovec, _llcppg_param3 c.Int) c.SsizeT + +//go:linkname Writev C.writev +func Writev(_llcppg_param1 c.Int, _llcppg_param2 *c.Iovec, _llcppg_param3 c.Int) c.SsizeT + +//go:linkname Preadv C.preadv +func Preadv(_llcppg_param1 c.Int, _llcppg_param2 *c.Iovec, _llcppg_param3 c.Int, _llcppg_param4 c.LongLong) c.SsizeT + +//go:linkname Pwritev C.pwritev +func Pwritev(_llcppg_param1 c.Int, _llcppg_param2 *c.Iovec, _llcppg_param3 c.Int, _llcppg_param4 c.LongLong) c.SsizeT + +// access function +const ( + F_OK = 0 + // test for execute or search permission + // test for write permission + W_OK = 2 + // test for read permission + R_OK = 4 +) + +// whence values for lseek(2); renamed by POSIX 1003.1 +const ( + L_SET = 0 + L_INCR = 1 + L_XTND = 2 +) + +const ( + ACCESSX_MAX_DESCRIPTORS = 100 + ACCESSX_MAX_TABLESIZE = 16384 +) + +type AccessxDescriptor struct { + AdNameOffset c.Uint + AdFlags c.Int + AdPad [2]c.Int +} + +//go:linkname Getattrlistbulk C.getattrlistbulk +func Getattrlistbulk(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.SizeT, _llcppg_param5 c.UlongLong) c.Int + +//go:linkname Getattrlistat C.getattrlistat +func Getattrlistat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 unsafe.Pointer, _llcppg_param4 unsafe.Pointer, _llcppg_param5 c.SizeT, _llcppg_param6 c.Ulong) c.Int + +//go:linkname Setattrlistat C.setattrlistat +func Setattrlistat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 unsafe.Pointer, _llcppg_param4 unsafe.Pointer, _llcppg_param5 c.SizeT, _llcppg_param6 c.Uint) c.Int + +//go:linkname Freadlink C.freadlink +func Freadlink(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.SizeT) c.SsizeT + +//go:linkname NativeFaccessat C.faccessat +func NativeFaccessat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int, _llcppg_param4 c.Int) c.Int + +//go:linkname NativeFchownat C.fchownat +func NativeFchownat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Uint, _llcppg_param4 c.Uint, _llcppg_param5 c.Int) c.Int + +//go:linkname Linkat C.linkat +func Linkat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int, _llcppg_param4 *c.Char, _llcppg_param5 c.Int) c.Int + +//go:linkname Readlinkat C.readlinkat +func Readlinkat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 *c.Char, _llcppg_param4 c.SizeT) c.SsizeT + +//go:linkname Symlinkat C.symlinkat +func Symlinkat(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, _llcppg_param3 *c.Char) c.Int + +//go:linkname NativeUnlinkat C.unlinkat +func NativeUnlinkat(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.Int) c.Int + +type Utsname struct { + Sysname [256]c.Char + Nodename [256]c.Char + Release [256]c.Char + Version [256]c.Char + Machine [256]c.Char +} + +// llgo:link (*Utsname).Uname C.uname +func (self *Utsname) Uname() c.Int { + return 0 +} + +// Option bits for the third argument of wait4. WNOHANG causes the +// wait to not hang if there are no stopped or terminated processes, rather +// returning an error indication in this case (pid==0). WUNTRACED +// indicates that the caller should receive status about untraced children +// which stop due to signals. If children are stopped and a wait without +// this option is done, it is as though they were still running... nothing +// about them is returned. +const ( + WNOHANG = 1 + // [XSI] notify on stop, untraced child + WUNTRACED = 2 +) + +const WCOREFLAG = 128 + +// WUNTRACED defined for wait4() but not for waitid() +const WEXITED = 4 + +// waitid() parameter +const WSTOPPED = 8 + +const ( + // [XSI] Any child stopped then continued + WCONTINUED = 16 + // [XSI] Leave process returned waitable + WNOWAIT = 32 +) + +// Tokens for special values of the "pid" parameter to wait4. +const ( + WAIT_ANY = -1 + // any process in my process group + WAIT_MYPGRP = 0 +) + +// [XSI] The type idtype_t shall be defined as an enumeration type whose +// possible values shall include at least P_ALL, P_PID, and P_PGID. +type IdtypeT c.Uint + +const ( + P_ALL IdtypeT = 0 + P_PID IdtypeT = 1 + P_PGID IdtypeT = 2 +) + +//go:linkname NativeWait C.wait +func NativeWait(_llcppg_param1 *c.Int) c.Int + +//go:linkname NativeWaitpid C.waitpid +func NativeWaitpid(_llcppg_param1 c.Int, _llcppg_param2 *c.Int, _llcppg_param3 c.Int) c.Int + +// llgo:link IdtypeT.Waitid C.waitid +func (self IdtypeT) Waitid(_llcppg_param2 c.Uint, _llcppg_param3 *llsignal.SiginfoT, _llcppg_param4 c.Int) c.Int { + return 0 +} + +//go:linkname NativeWait3 C.wait3 +func NativeWait3(_llcppg_param1 *c.Int, _llcppg_param2 c.Int, _llcppg_param3 *Rusage) c.Int + +//go:linkname NativeWait4 C.wait4 +func NativeWait4(_llcppg_param1 c.Int, _llcppg_param2 *c.Int, _llcppg_param3 c.Int, _llcppg_param4 *Rusage) c.Int + +//go:linkname Tcgetsid C.tcgetsid +func Tcgetsid(_llcppg_param1 c.Int) c.Int + +const ( + // standard input file descriptor + STDIN_FILENO = 0 + // standard output file descriptor + STDOUT_FILENO = 1 + // standard error file descriptor + STDERR_FILENO = 2 +) + +// These F_* are really XSI or Issue 6 +const ( + F_ULOCK = 0 + // lock a section for exclusive use + F_LOCK = 1 + // test and lock a section for exclusive use + F_TLOCK = 2 + // test a section for locks by other procs + F_TEST = 3 +) + +const ( + // Flush data and metadata to platter, not just to disk cache + SYNC_VOLUME_FULLSYNC = 1 + // Wait for sync to complete + SYNC_VOLUME_WAIT = 2 +) + +type Fssearchblock struct { +} + +type Searchstate struct { +} + +//go:linkname X_exit C._exit +func X_exit(_llcppg_param1 c.Int) + +//go:linkname Access C.access +func Access(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Alarm C.alarm +func Alarm(_llcppg_param1 c.Uint) c.Uint + +//go:linkname NativeChdir C.chdir +func NativeChdir(_llcppg_param1 *c.Char) c.Int + +//go:linkname NativeChown C.chown +func NativeChown(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint, _llcppg_param3 c.Uint) c.Int + +//go:linkname Close C.close +func Close(_llcppg_param1 c.Int) c.Int + +//go:linkname Dup C.dup +func Dup(_llcppg_param1 c.Int) c.Int + +//go:linkname Dup2 C.dup2 +func Dup2(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname NativeExecl C.execl +func NativeExecl(__path *c.Char, __arg0 *c.Char, __llgo_va_list ...any) c.Int + +//go:linkname NativeExecle C.execle +func NativeExecle(__path *c.Char, __arg0 *c.Char, __llgo_va_list ...any) c.Int + +//go:linkname NativeExeclp C.execlp +func NativeExeclp(__file *c.Char, __arg0 *c.Char, __llgo_va_list ...any) c.Int + +//go:linkname NativeExecv C.execv +func NativeExecv(__path *c.Char, __argv **c.Char) c.Int + +//go:linkname NativeExecve C.execve +func NativeExecve(__file *c.Char, __argv **c.Char, __envp **c.Char) c.Int + +//go:linkname NativeExecvp C.execvp +func NativeExecvp(__file *c.Char, __argv **c.Char) c.Int + +//go:linkname NativeFork C.fork +func NativeFork() c.Int + +//go:linkname Fpathconf C.fpathconf +func Fpathconf(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Long + +//go:linkname NativeGetcwd C.getcwd +func NativeGetcwd(_llcppg_param1 *c.Char, _llcppg_param2 c.SizeT) *c.Char + +//go:linkname NativeGetegid C.getegid +func NativeGetegid() c.Uint + +//go:linkname NativeGeteuid C.geteuid +func NativeGeteuid() c.Uint + +//go:linkname NativeGetgid C.getgid +func NativeGetgid() c.Uint + +//go:linkname Getgroups C.getgroups +func Getgroups(_llcppg_param1 c.Int, _llcppg_param2 *c.Uint) c.Int + +//go:linkname Getlogin C.getlogin +func Getlogin() *c.Char + +//go:linkname Getpgrp C.getpgrp +func Getpgrp() c.Int + +//go:linkname NativeGetpid C.getpid +func NativeGetpid() c.Int + +//go:linkname NativeGetppid C.getppid +func NativeGetppid() c.Int + +//go:linkname NativeGetuid C.getuid +func NativeGetuid() c.Uint + +//go:linkname Isatty C.isatty +func Isatty(_llcppg_param1 c.Int) c.Int + +//go:linkname NativeLink C.link +func NativeLink(_llcppg_param1 *c.Char, _llcppg_param2 *c.Char) c.Int + +//go:linkname NativeLseek C.lseek +func NativeLseek(_llcppg_param1 c.Int, _llcppg_param2 c.LongLong, _llcppg_param3 c.Int) c.LongLong + +//go:linkname Pathconf C.pathconf +func Pathconf(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Long + +//go:linkname Pause C.pause +func Pause() c.Int + +//go:linkname NativePipe C.pipe +func NativePipe(_llcppg_param1 *c.Int) c.Int + +//go:linkname NativeRead C.read +func NativeRead(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer, _llcppg_param3 c.SizeT) c.SsizeT + +//go:linkname NativeRmdir C.rmdir +func NativeRmdir(_llcppg_param1 *c.Char) c.Int + +//go:linkname Setgid C.setgid +func Setgid(_llcppg_param1 c.Uint) c.Int + +//go:linkname Setpgid C.setpgid +func Setpgid(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Setsid C.setsid +func Setsid() c.Int + +//go:linkname Setuid C.setuid +func Setuid(_llcppg_param1 c.Uint) c.Int + +//go:linkname Sleep C.sleep +func Sleep(_llcppg_param1 c.Uint) c.Uint + +//go:linkname Sysconf C.sysconf +func Sysconf(_llcppg_param1 c.Int) c.Long + +//go:linkname Tcgetpgrp C.tcgetpgrp +func Tcgetpgrp(_llcppg_param1 c.Int) c.Int + +//go:linkname Tcsetpgrp C.tcsetpgrp +func Tcsetpgrp(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Ttyname C.ttyname +func Ttyname(_llcppg_param1 c.Int) *c.Char + +//go:linkname TtynameR C.ttyname_r +func TtynameR(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.SizeT) c.Int + +//go:linkname NativeUnlink C.unlink +func NativeUnlink(_llcppg_param1 *c.Char) c.Int + +//go:linkname NativeWrite C.write +func NativeWrite(__fd c.Int, __buf unsafe.Pointer, __nbyte c.SizeT) c.SsizeT + +//go:linkname Confstr C.confstr +func Confstr(_llcppg_param1 c.Int, _llcppg_param2 *c.Char, _llcppg_param3 c.SizeT) c.SizeT + +//go:linkname Getopt C.getopt +func Getopt(_llcppg_param1 c.Int, _llcppg_param2 **c.Char, _llcppg_param3 *c.Char) c.Int + +// getopt(3) external variables +// +//go:linkname Optarg C.optarg +var Optarg *c.Char + +//go:linkname Optind C.optind +var Optind c.Int + +//go:linkname Opterr C.opterr +var Opterr c.Int + +//go:linkname Optopt C.optopt +var Optopt c.Int + +//go:linkname Brk C.brk +func Brk(_llcppg_param1 unsafe.Pointer) unsafe.Pointer + +//go:linkname NativeChroot C.chroot +func NativeChroot(_llcppg_param1 *c.Char) c.Int + +//go:linkname Crypt C.crypt +func Crypt(_llcppg_param1 *c.Char, _llcppg_param2 *c.Char) *c.Char + +//go:linkname Encrypt C.encrypt +func Encrypt(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) + +//go:linkname Fchdir C.fchdir +func Fchdir(_llcppg_param1 c.Int) c.Int + +//go:linkname Gethostid C.gethostid +func Gethostid() c.Long + +//go:linkname Getpgid C.getpgid +func Getpgid(_llcppg_param1 c.Int) c.Int + +//go:linkname Getsid C.getsid +func Getsid(_llcppg_param1 c.Int) c.Int + +//go:linkname Getdtablesize C.getdtablesize +func Getdtablesize() c.Int + +//go:linkname Getpagesize C.getpagesize +func Getpagesize() c.Int + +//go:linkname Getpass C.getpass +func Getpass(_llcppg_param1 *c.Char) *c.Char + +// obsoleted by getcwd() +// +//go:linkname Getwd C.getwd +func Getwd(_llcppg_param1 *c.Char) *c.Char + +//go:linkname NativeLchown C.lchown +func NativeLchown(_llcppg_param1 *c.Char, _llcppg_param2 c.Uint, _llcppg_param3 c.Uint) c.Int + +//go:linkname Lockf C.lockf +func Lockf(_llcppg_param1 c.Int, _llcppg_param2 c.Int, _llcppg_param3 c.LongLong) c.Int + +//go:linkname Nice C.nice +func Nice(_llcppg_param1 c.Int) c.Int + +//go:linkname Pread C.pread +func Pread(__fd c.Int, __buf unsafe.Pointer, __nbyte c.SizeT, __offset c.LongLong) c.SsizeT + +//go:linkname Pwrite C.pwrite +func Pwrite(__fd c.Int, __buf unsafe.Pointer, __nbyte c.SizeT, __offset c.LongLong) c.SsizeT + +//go:linkname Sbrk C.sbrk +func Sbrk(_llcppg_param1 c.Int) unsafe.Pointer + +//go:linkname Setpgrp C.setpgrp +func Setpgrp() c.Int + +//go:linkname Setregid C.setregid +func Setregid(_llcppg_param1 c.Uint, _llcppg_param2 c.Uint) c.Int + +//go:linkname Setreuid C.setreuid +func Setreuid(_llcppg_param1 c.Uint, _llcppg_param2 c.Uint) c.Int + +//go:linkname Sync C.sync +func Sync() + +//go:linkname NativeTruncate C.truncate +func NativeTruncate(_llcppg_param1 *c.Char, _llcppg_param2 c.LongLong) c.Int + +//go:linkname Ualarm C.ualarm +func Ualarm(_llcppg_param1 c.Uint, _llcppg_param2 c.Uint) c.Uint + +//go:linkname Usleep C.usleep +func Usleep(_llcppg_param1 c.Uint) c.Int + +// End XSI +// +//go:linkname Vfork C.vfork +func Vfork() c.Int + +//go:linkname Fsync C.fsync +func Fsync(_llcppg_param1 c.Int) c.Int + +//go:linkname NativeFtruncate C.ftruncate +func NativeFtruncate(_llcppg_param1 c.Int, _llcppg_param2 c.LongLong) c.Int + +//go:linkname GetloginR C.getlogin_r +func GetloginR(_llcppg_param1 *c.Char, _llcppg_param2 c.SizeT) c.Int + +//go:linkname NativeFchown C.fchown +func NativeFchown(_llcppg_param1 c.Int, _llcppg_param2 c.Uint, _llcppg_param3 c.Uint) c.Int + +//go:linkname Gethostname C.gethostname +func Gethostname(_llcppg_param1 *c.Char, _llcppg_param2 c.SizeT) c.Int + +//go:linkname NativeReadlink C.readlink +func NativeReadlink(_llcppg_param1 *c.Char, _llcppg_param2 *c.Char, _llcppg_param3 c.SizeT) c.SsizeT + +//go:linkname Setegid C.setegid +func Setegid(_llcppg_param1 c.Uint) c.Int + +//go:linkname Seteuid C.seteuid +func Seteuid(_llcppg_param1 c.Uint) c.Int + +//go:linkname NativeSymlink C.symlink +func NativeSymlink(_llcppg_param1 *c.Char, _llcppg_param2 *c.Char) c.Int + +// llgo:link (*AccessxDescriptor).AccessxNp C.accessx_np +func (self *AccessxDescriptor) AccessxNp(_llcppg_param2 c.SizeT, _llcppg_param3 *c.Int, _llcppg_param4 c.Uint) c.Int { + return 0 +} + +//go:linkname Acct C.acct +func Acct(_llcppg_param1 *c.Char) c.Int + +//go:linkname AddProfil C.add_profil +func AddProfil(_llcppg_param1 *c.Char, _llcppg_param2 c.SizeT, _llcppg_param3 c.Ulong, _llcppg_param4 c.Uint) c.Int + +//go:linkname Endusershell C.endusershell +func Endusershell() + +//go:linkname ExecvP C.execvP +func ExecvP(__file *c.Char, __searchpath *c.Char, __argv **c.Char) c.Int + +//go:linkname Fflagstostr C.fflagstostr +func Fflagstostr(_llcppg_param1 c.Ulong) *c.Char + +//go:linkname Getdomainname C.getdomainname +func Getdomainname(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Getgrouplist C.getgrouplist +func Getgrouplist(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, _llcppg_param3 *c.Int, _llcppg_param4 *c.Int) c.Int + +//go:linkname Getmode C.getmode +func Getmode(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.Uint16T) c.Uint16T + +//go:linkname Getpeereid C.getpeereid +func Getpeereid(_llcppg_param1 c.Int, _llcppg_param2 *c.Uint, _llcppg_param3 *c.Uint) c.Int + +//go:linkname GetsgroupsNp C.getsgroups_np +func GetsgroupsNp(_llcppg_param1 *c.Int, _llcppg_param2 *uint8) c.Int + +//go:linkname Getusershell C.getusershell +func Getusershell() *c.Char + +//go:linkname GetwgroupsNp C.getwgroups_np +func GetwgroupsNp(_llcppg_param1 *c.Int, _llcppg_param2 *uint8) c.Int + +//go:linkname Initgroups C.initgroups +func Initgroups(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Issetugid C.issetugid +func Issetugid() c.Int + +//go:linkname Mkdtemp C.mkdtemp +func Mkdtemp(_llcppg_param1 *c.Char) *c.Char + +// returns errno +// +//go:linkname MkpathNp C.mkpath_np +func MkpathNp(path *c.Char, omode c.Uint16T) c.Int + +//go:linkname MkpathatNp C.mkpathat_np +func MkpathatNp(dfd c.Int, path *c.Char, omode c.Uint16T) c.Int + +//go:linkname Mkstemps C.mkstemps +func Mkstemps(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Mkostemp C.mkostemp +func Mkostemp(path *c.Char, oflags c.Int) c.Int + +// Non-portable mkstemp that uses open_dprotected_np +// +//go:linkname Mkostemps C.mkostemps +func Mkostemps(path *c.Char, slen c.Int, oflags c.Int) c.Int + +// Non-portable mkstemp that uses open_dprotected_np +// +//go:linkname MkstempDprotectedNp C.mkstemp_dprotected_np +func MkstempDprotectedNp(path *c.Char, dpclass c.Int, dpflags c.Int) c.Int + +//go:linkname MkdtempatNp C.mkdtempat_np +func MkdtempatNp(dfd c.Int, path *c.Char) *c.Char + +//go:linkname MkstempsatNp C.mkstempsat_np +func MkstempsatNp(dfd c.Int, path *c.Char, slen c.Int) c.Int + +//go:linkname MkostempsatNp C.mkostempsat_np +func MkostempsatNp(dfd c.Int, path *c.Char, slen c.Int, oflags c.Int) c.Int + +//go:linkname Nfssvc C.nfssvc +func Nfssvc(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer) c.Int + +//go:linkname Profil C.profil +func Profil(_llcppg_param1 *c.Char, _llcppg_param2 c.SizeT, _llcppg_param3 c.Ulong, _llcppg_param4 c.Uint) c.Int + +//go:linkname Reboot C.reboot +func Reboot(_llcppg_param1 c.Int) c.Int + +//go:linkname Revoke C.revoke +func Revoke(_llcppg_param1 *c.Char) c.Int + +//go:linkname Rcmd C.rcmd +func Rcmd(_llcppg_param1 **c.Char, _llcppg_param2 c.Int, _llcppg_param3 *c.Char, _llcppg_param4 *c.Char, _llcppg_param5 *c.Char, _llcppg_param6 *c.Int) c.Int + +//go:linkname RcmdAf C.rcmd_af +func RcmdAf(_llcppg_param1 **c.Char, _llcppg_param2 c.Int, _llcppg_param3 *c.Char, _llcppg_param4 *c.Char, _llcppg_param5 *c.Char, _llcppg_param6 *c.Int, _llcppg_param7 c.Int) c.Int + +//go:linkname Rresvport C.rresvport +func Rresvport(_llcppg_param1 *c.Int) c.Int + +//go:linkname RresvportAf C.rresvport_af +func RresvportAf(_llcppg_param1 *c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Iruserok C.iruserok +func Iruserok(_llcppg_param1 c.Ulong, _llcppg_param2 c.Int, _llcppg_param3 *c.Char, _llcppg_param4 *c.Char) c.Int + +//go:linkname IruserokSa C.iruserok_sa +func IruserokSa(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.Int, _llcppg_param3 c.Int, _llcppg_param4 *c.Char, _llcppg_param5 *c.Char) c.Int + +//go:linkname Ruserok C.ruserok +func Ruserok(_llcppg_param1 *c.Char, _llcppg_param2 c.Int, _llcppg_param3 *c.Char, _llcppg_param4 *c.Char) c.Int + +//go:linkname Setdomainname C.setdomainname +func Setdomainname(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Setgroups C.setgroups +func Setgroups(_llcppg_param1 c.Int, _llcppg_param2 *c.Uint) c.Int + +//go:linkname Sethostid C.sethostid +func Sethostid(_llcppg_param1 c.Long) + +//go:linkname Sethostname C.sethostname +func Sethostname(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Setlogin C.setlogin +func Setlogin(_llcppg_param1 *c.Char) c.Int + +//go:linkname Setmode C.setmode +func Setmode(_llcppg_param1 *c.Char) unsafe.Pointer + +//go:linkname Setrgid C.setrgid +func Setrgid(_llcppg_param1 c.Uint) c.Int + +//go:linkname Setruid C.setruid +func Setruid(_llcppg_param1 c.Uint) c.Int + +//go:linkname SetsgroupsNp C.setsgroups_np +func SetsgroupsNp(_llcppg_param1 c.Int, _llcppg_param2 *uint8) c.Int + +//go:linkname Setusershell C.setusershell +func Setusershell() + +//go:linkname SetwgroupsNp C.setwgroups_np +func SetwgroupsNp(_llcppg_param1 c.Int, _llcppg_param2 *uint8) c.Int + +//go:linkname Strtofflags C.strtofflags +func Strtofflags(_llcppg_param1 **c.Char, _llcppg_param2 *c.Ulong, _llcppg_param3 *c.Ulong) c.Int + +//go:linkname Swapon C.swapon +func Swapon(_llcppg_param1 *c.Char) c.Int + +//go:linkname Ttyslot C.ttyslot +func Ttyslot() c.Int + +//go:linkname Undelete C.undelete +func Undelete(_llcppg_param1 *c.Char) c.Int + +//go:linkname Unwhiteout C.unwhiteout +func Unwhiteout(_llcppg_param1 *c.Char) c.Int + +//go:linkname Syscall C.syscall +func Syscall(_llcppg_param1 c.Int, __llgo_va_list ...any) c.Int + +//go:linkname Fgetattrlist C.fgetattrlist +func Fgetattrlist(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.SizeT, _llcppg_param5 c.Uint) c.Int + +//go:linkname Fsetattrlist C.fsetattrlist +func Fsetattrlist(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.SizeT, _llcppg_param5 c.Uint) c.Int + +//go:linkname Getattrlist C.getattrlist +func Getattrlist(_llcppg_param1 *c.Char, _llcppg_param2 unsafe.Pointer, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.SizeT, _llcppg_param5 c.Uint) c.Int + +//go:linkname Setattrlist C.setattrlist +func Setattrlist(_llcppg_param1 *c.Char, _llcppg_param2 unsafe.Pointer, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.SizeT, _llcppg_param5 c.Uint) c.Int + +//go:linkname Exchangedata C.exchangedata +func Exchangedata(_llcppg_param1 *c.Char, _llcppg_param2 *c.Char, _llcppg_param3 c.Uint) c.Int + +//go:linkname Getdirentriesattr C.getdirentriesattr +func Getdirentriesattr(_llcppg_param1 c.Int, _llcppg_param2 unsafe.Pointer, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.SizeT, _llcppg_param5 *c.Uint, _llcppg_param6 *c.Uint, _llcppg_param7 *c.Uint, _llcppg_param8 c.Uint) c.Int + +//go:linkname Searchfs C.searchfs +func Searchfs(_llcppg_param1 *c.Char, _llcppg_param2 *Fssearchblock, _llcppg_param3 *c.Ulong, _llcppg_param4 c.Uint, _llcppg_param5 c.Uint, _llcppg_param6 *Searchstate) c.Int + +//go:linkname Fsctl C.fsctl +func Fsctl(_llcppg_param1 *c.Char, _llcppg_param2 c.Ulong, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.Uint) c.Int + +//go:linkname Ffsctl C.ffsctl +func Ffsctl(_llcppg_param1 c.Int, _llcppg_param2 c.Ulong, _llcppg_param3 unsafe.Pointer, _llcppg_param4 c.Uint) c.Int + +//go:linkname FsyncVolumeNp C.fsync_volume_np +func FsyncVolumeNp(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname SyncVolumeNp C.sync_volume_np +func SyncVolumeNp(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Optreset C.optreset +var Optreset c.Int + +type Utimbuf struct { + Actime lltime.TimeT + Modtime lltime.TimeT +} + +//go:linkname Utime C.utime +func Utime(_llcppg_param1 *c.Char, _llcppg_param2 *Utimbuf) c.Int + +type UuidStringT = X__DarwinUuidStringT + +//go:linkname UuidClear C.uuid_clear +func UuidClear(uu *uint8) + +//go:linkname UuidCompare C.uuid_compare +func UuidCompare(uu1 *uint8, uu2 *uint8) c.Int + +//go:linkname UuidCopy C.uuid_copy +func UuidCopy(dst *uint8, src *uint8) + +//go:linkname UuidGenerate C.uuid_generate +func UuidGenerate(out *uint8) + +//go:linkname UuidGenerateRandom C.uuid_generate_random +func UuidGenerateRandom(out *uint8) + +//go:linkname UuidGenerateTime C.uuid_generate_time +func UuidGenerateTime(out *uint8) + +//go:linkname UuidIsNull C.uuid_is_null +func UuidIsNull(uu *uint8) c.Int + +//go:linkname UuidParse C.uuid_parse +func UuidParse(in *c.Char, uu *uint8) c.Int + +//go:linkname UuidUnparse C.uuid_unparse +func UuidUnparse(uu *uint8, out *c.Char) + +//go:linkname UuidUnparseLower C.uuid_unparse_lower +func UuidUnparseLower(uu *uint8, out *c.Char) + +//go:linkname UuidUnparseUpper C.uuid_unparse_upper +func UuidUnparseUpper(uu *uint8, out *c.Char) + +const LLGoFiles = "$LIBC_CC_FLAGS: _os/os.c; _libc_darwin_arm64.c" diff --git a/c/os/libc_linux_amd64.go b/c/os/libc_linux_amd64.go new file mode 100644 index 00000000..9c4922b3 --- /dev/null +++ b/c/os/libc_linux_amd64.go @@ -0,0 +1,2270 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package os + +import ( + "github.com/goplus/lib/c" + llsignal "github.com/goplus/lib/c/signal" + llsys "github.com/goplus/lib/c/sys" + lltime "github.com/goplus/lib/c/time" + "unsafe" +) + +type FlockT struct { + LType int16 + LWhence int16 + LStart c.Long + LLen c.Long + LPid c.Int +} + +type Rlimit struct { + RlimCur c.Ulong + RlimMax c.Ulong +} + +// The purpose of all the unions is to have the kernel-compatible layout +// while keeping the API type as 'long int', and among machines where +// __syscall_slong_t is not 'long int', this only does the right thing +// for little-endian ones, like x32. +type Rusage struct { + RuUtime llsys.Timeval + RuStime llsys.Timeval + _llcppg_anon_10 + _llcppg_anon_11 + _llcppg_anon_12 + _llcppg_anon_13 + _llcppg_anon_14 + _llcppg_anon_15 + _llcppg_anon_16 + _llcppg_anon_17 + _llcppg_anon_18 + _llcppg_anon_19 + _llcppg_anon_20 + _llcppg_anon_21 + _llcppg_anon_22 + _llcppg_anon_23 +} + +type _llcppg_anon_10 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_11 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_12 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_13 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_14 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_15 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_16 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_17 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_18 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_19 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_20 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_21 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_22 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_23 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_10) XGof_ref_ru_maxrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_10) XGof_ref___ru_maxrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_11) XGof_ref_ru_ixrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_11) XGof_ref___ru_ixrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_12) XGof_ref_ru_idrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_12) XGof_ref___ru_idrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_13) XGof_ref_ru_isrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_13) XGof_ref___ru_isrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_14) XGof_ref_ru_minflt() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_14) XGof_ref___ru_minflt_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_15) XGof_ref_ru_majflt() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_15) XGof_ref___ru_majflt_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_16) XGof_ref_ru_nswap() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_16) XGof_ref___ru_nswap_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_17) XGof_ref_ru_inblock() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_17) XGof_ref___ru_inblock_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_18) XGof_ref_ru_oublock() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_18) XGof_ref___ru_oublock_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_19) XGof_ref_ru_msgsnd() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_19) XGof_ref___ru_msgsnd_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_20) XGof_ref_ru_msgrcv() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_20) XGof_ref___ru_msgrcv_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_21) XGof_ref_ru_nsignals() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_21) XGof_ref___ru_nsignals_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_22) XGof_ref_ru_nvcsw() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_22) XGof_ref___ru_nvcsw_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_23) XGof_ref_ru_nivcsw() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_23) XGof_ref___ru_nivcsw_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +// The official definition. +type SchedParam struct { + X__SchedPriority c.Int +} + +type StatvfsT struct { + FBsize c.Ulong + FFrsize c.Ulong + FBlocks c.Ulong + FBfree c.Ulong + FBavail c.Ulong + FFiles c.Ulong + FFfree c.Ulong + FFavail c.Ulong + FFsid c.Ulong + FFlag c.Ulong + FNamemax c.Ulong + X__FSpare [6]c.Int +} + +type Termios struct { + CIflag c.Uint + COflag c.Uint + CCflag c.Uint + CLflag c.Uint + CLine c.Uint8T + CCc [32]c.Uint8T + CIspeed c.Uint + COspeed c.Uint +} + +type X__FsidT struct { + X__Val [2]c.Int +} + +type X__CaddrT = *c.Char + +const MAXNAMLEN = 255 + +// File types for `d_type'. +const ( + DT_UNKNOWN = 0 + DT_FIFO = 1 + DT_CHR = 2 + DT_DIR = 4 + DT_BLK = 6 + DT_REG = 8 + DT_LNK = 10 + DT_SOCK = 12 + DT_WHT = 14 +) + +type X__Dirstream struct { +} + +// llgo:type C +type llcppgCallback20 = func(_llcppg_param1 **Dirent, _llcppg_param2 **Dirent) c.Int + +// llgo:type C +type llcppgCallback21 = func(_llcppg_param1 *Dirent) c.Int + +// Open a directory stream on NAME. +// Return a DIR stream on the directory, or NULL if it could not be opened. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname NativeOpendir C.opendir +func NativeOpendir(__name *c.Char) *DIR + +// Same as opendir, but open the stream on the file descriptor FD. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname NativeFdopendir C.fdopendir +func NativeFdopendir(__fd c.Int) *DIR + +// Close the directory stream DIRP. +// Return 0 if successful, -1 if not. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Closedir C.closedir +func Closedir(self *DIR) c.Int + +// llgo:link (*DIR).NativeReaddir C.readdir +func (self *DIR) NativeReaddir() *Dirent { + return nil +} + +// llgo:link (*DIR).ReaddirR C.readdir_r +func (self *DIR) ReaddirR(__entry *Dirent, __result **Dirent) c.Int { + return 0 +} + +// Rewind DIRP to the beginning of the directory. +// +// llgo:link (*DIR).Rewinddir C.rewinddir +func (self *DIR) Rewinddir() { +} + +// Seek to position POS on DIRP. +// +// llgo:link (*DIR).Seekdir C.seekdir +func (self *DIR) Seekdir(__pos c.Long) { +} + +// Return the current position of DIRP. +// +// llgo:link (*DIR).Telldir C.telldir +func (self *DIR) Telldir() c.Long { + return 0 +} + +// Return the file descriptor used by DIRP. +// +// llgo:link (*DIR).Dirfd C.dirfd +func (self *DIR) Dirfd() c.Int { + return 0 +} + +//go:linkname Scandir C.scandir +func Scandir(__dir *c.Char, __namelist ***Dirent, __selector llcppgCallback21, __cmp llcppgCallback20) c.Int + +//go:linkname Alphasort C.alphasort +func Alphasort(__e1 **Dirent, __e2 **Dirent) c.Int + +//go:linkname Getdirentries C.getdirentries +func Getdirentries(__fd c.Int, __buf *c.Char, __nbytes c.SizeT, __basep *c.Long) c.Long + +// Open the shared object FILE and map it in; return a handle that can be +// passed to `dlsym' to get symbol values from it. +// +//go:linkname Dlopen C.dlopen +func Dlopen(__file *c.Char, __mode c.Int) unsafe.Pointer + +// Unmap and close a shared object opened by `dlopen'. +// The handle cannot be used again after calling `dlclose'. +// +//go:linkname Dlclose C.dlclose +func Dlclose(__handle unsafe.Pointer) c.Int + +// Find the run-time address in the shared object HANDLE refers to +// of the symbol called NAME. +// +//go:linkname Dlsym C.dlsym +func Dlsym(__handle unsafe.Pointer, __name *c.Char) unsafe.Pointer + +// When any of the above functions fails, call this function +// to return a string describing the error. Each call resets +// the error string so that a following call returns null. +// +//go:linkname Dlerror C.dlerror +func Dlerror() *c.Char + +const ( + S_IFMT = 61440 + S_IFDIR = 16384 + S_IFCHR = 8192 + S_IFBLK = 24576 + S_IFREG = 32768 +) + +const S_IFIFO = 4096 + +const S_IFLNK = 40960 + +const S_IFSOCK = 49152 + +const ( + // Set user ID on execution. + S_ISUID = 2048 + // Set group ID on execution. + S_ISGID = 1024 +) + +// Save swapped text after use (sticky bit). This is pretty well obsolete. +const S_ISVTX = 512 + +const ( + // Read by owner. + S_IRUSR = 256 + // Write by owner. + S_IWUSR = 128 + // Execute by owner. + S_IXUSR = 64 +) + +// Read, write, and execute by owner. +const S_IRWXU = 448 + +const ( + // Read by group. + S_IRGRP = 32 + // Write by group. + S_IWGRP = 16 + // Execute by group. + S_IXGRP = 8 +) + +// Read, write, and execute by group. +const S_IRWXG = 56 + +const ( + // Read by others. + S_IROTH = 4 + // Write by others. + S_IWOTH = 2 + // Execute by others. + S_IXOTH = 1 +) + +// Read, write, and execute by others. +const S_IRWXO = 7 + +// Values for the second argument to access. +// These may be OR'd together. +const ( + R_OK = 4 + // Test for write permission. + W_OK = 2 + // Test for execute permission. + // Test for existence. + F_OK = 0 +) + +const ( + // Seek from beginning of file. + SEEK_SET = 0 + // Seek from current position. + SEEK_CUR = 1 + // Seek from end of file. + SEEK_END = 2 +) + +// Special value used to indicate +// the *at functions should use the +// current working directory. +const AT_FDCWD = -100 + +const ( + // Do not follow symbolic links. + AT_SYMLINK_NOFOLLOW = 256 + // Remove directory instead of + // unlinking file. + AT_REMOVEDIR = 512 +) + +// Follow symbolic links. +const AT_SYMLINK_FOLLOW = 1024 + +// Test access permitted for +// effective IDs, not real IDs. +const AT_EACCESS = 512 + +const ( + // Unlock a previously locked region. + F_ULOCK = 0 + // Lock a region for exclusive use. + F_LOCK = 1 + // Test and lock a region for exclusive use. + F_TLOCK = 2 + // Test a region for other processes locks. + F_TEST = 3 +) + +// Do the file control operation described by CMD on FD. +// The remaining arguments are interpreted depending on CMD. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Fcntl C.fcntl +func Fcntl(__fd c.Int, __cmd c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeOpen C.open +func NativeOpen(__file *c.Char, __oflag c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeOpenat C.openat +func NativeOpenat(__fd c.Int, __file *c.Char, __oflag c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeCreat C.creat +func NativeCreat(__file *c.Char, __mode c.Uint) c.Int + +//go:linkname Lockf C.lockf +func Lockf(__fd c.Int, __cmd c.Int, __len c.Long) c.Int + +//go:linkname PosixFadvise C.posix_fadvise +func PosixFadvise(__fd c.Int, __offset c.Long, __len c.Long, __advise c.Int) c.Int + +//go:linkname PosixFallocate C.posix_fallocate +func PosixFallocate(__fd c.Int, __offset c.Long, __len c.Long) c.Int + +// Bits set in the FLAGS argument to `glob'. +const ( + GLOB_ERR = 1 + // Append a slash to each name. + GLOB_MARK = 2 + // Don't sort the names. + GLOB_NOSORT = 4 + // Insert PGLOB->gl_offs NULLs. + GLOB_DOOFFS = 8 + // If nothing matches, return the pattern. + GLOB_NOCHECK = 16 + // Append to results of a previous call. + GLOB_APPEND = 32 + // Backslashes don't quote metacharacters. + GLOB_NOESCAPE = 64 + // Leading `.' can be matched by metachars. + GLOB_PERIOD = 128 +) + +const ( + // Set in gl_flags if any metachars seen. + GLOB_MAGCHAR = 256 + // Use gl_opendir et al functions. + GLOB_ALTDIRFUNC = 512 + // Expand "{a,b}" to "a" "b". + GLOB_BRACE = 1024 + // If no magic chars, return the pattern. + GLOB_NOMAGIC = 2048 + // Expand ~user and ~ to home directories. + GLOB_TILDE = 4096 + // Match only directories. + GLOB_ONLYDIR = 8192 + // Like GLOB_TILDE but return an error + // if the user name is not available. + GLOB_TILDE_CHECK = 16384 +) + +// Error returns from `glob'. +const ( + GLOB_NOSPACE = 1 + // Read error. + GLOB_ABORTED = 2 + // No matches found. + GLOB_NOMATCH = 3 + // Not implemented. + GLOB_NOSYS = 4 +) + +type GlobT struct { + GlPathc c.SizeT + GlPathv **c.Char + GlOffs c.SizeT + GlFlags c.Int + GlClosedir llcppgCallback19 + GlReaddir llcppgCallback18 + GlOpendir llcppgCallback17 + GlLstat llcppgCallback16 + GlStat llcppgCallback15 +} + +// llgo:type C +type llcppgCallback15 = func(_llcppg_param1 *c.Char, _llcppg_param2 unsafe.Pointer) c.Int + +// llgo:type C +type llcppgCallback16 = func(_llcppg_param1 *c.Char, _llcppg_param2 unsafe.Pointer) c.Int + +// llgo:type C +type llcppgCallback17 = func(_llcppg_param1 *c.Char) unsafe.Pointer + +// llgo:type C +type llcppgCallback18 = func(_llcppg_param1 unsafe.Pointer) unsafe.Pointer + +// llgo:type C +type llcppgCallback19 = func(_llcppg_param1 unsafe.Pointer) + +// llgo:type C +type llcppgCallback14 = func(_llcppg_param1 *c.Char, _llcppg_param2 c.Int) c.Int + +//go:linkname Glob C.glob +func Glob(__pattern *c.Char, __flags c.Int, __errfunc llcppgCallback14, __pglob *GlobT) c.Int + +// Free storage allocated in PGLOB by a previous `glob' call. +// +// llgo:link (*GlobT).Globfree C.globfree +func (self *GlobT) Globfree() { +} + +// Reasonable value for the buffer sized used in the reentrant +// functions below. But better use `sysconf'. +const NSS_BUFLEN_GROUP = 1024 + +// The group structure. +type Group struct { + GrName *c.Char + GrPasswd *c.Char + GrGid c.Uint + GrMem **c.Char +} + +// Rewind the group-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Setgrent C.setgrent +func Setgrent() + +// Close the group-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Endgrent C.endgrent +func Endgrent() + +// Read an entry from the group-file stream, opening it if necessary. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getgrent C.getgrent +func Getgrent() *Group + +// Read a group entry from STREAM. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Fgetgrent C.fgetgrent +func Fgetgrent(__stream *c.FILE) *Group + +// Search for an entry with a matching group ID. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getgrgid C.getgrgid +func Getgrgid(__gid c.Uint) *Group + +// Search for an entry with a matching group name. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getgrnam C.getgrnam +func Getgrnam(__name *c.Char) *Group + +// Search for an entry with a matching group ID. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname GetgrgidR C.getgrgid_r +func GetgrgidR(__gid c.Uint, __resultbuf *Group, __buffer *c.Char, __buflen c.SizeT, __result **Group) c.Int + +// Search for an entry with a matching group name. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname GetgrnamR C.getgrnam_r +func GetgrnamR(__name *c.Char, __resultbuf *Group, __buffer *c.Char, __buflen c.SizeT, __result **Group) c.Int + +// Read a group entry from STREAM. This function is not standardized +// an probably never will. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname FgetgrentR C.fgetgrent_r +func FgetgrentR(__stream *c.FILE, __resultbuf *Group, __buffer *c.Char, __buflen c.SizeT, __result **Group) c.Int + +// Set the group set for the current user to GROUPS (N of them). +// +//go:linkname Setgroups C.setgroups +func Setgroups(__n c.SizeT, __groups *c.Uint) c.Int + +// Store at most *NGROUPS members of the group set for USER into +// GROUPS. Also include GROUP. The actual number of groups found is +// returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Getgrouplist C.getgrouplist +func Getgrouplist(__user *c.Char, __group c.Uint, __groups *c.Uint, __ngroups *c.Int) c.Int + +// Initialize the group set for the current user +// by reading the group database and using all groups +// of which USER is a member. Also include GROUP. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Initgroups C.initgroups +func Initgroups(__user *c.Char, __group c.Uint) c.Int + +// Reasonable value for the buffer sized used in the reentrant +// functions below. But better use `sysconf'. +const NSS_BUFLEN_PASSWD = 1024 + +// The passwd structure. +type Passwd struct { + PwName *c.Char + PwPasswd *c.Char + PwUid c.Uint + PwGid c.Uint + PwGecos *c.Char + PwDir *c.Char + PwShell *c.Char +} + +// Rewind the password-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Setpwent C.setpwent +func Setpwent() + +// Close the password-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Endpwent C.endpwent +func Endpwent() + +// Read an entry from the password-file stream, opening it if necessary. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getpwent C.getpwent +func Getpwent() *Passwd + +// Read an entry from STREAM. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Fgetpwent C.fgetpwent +func Fgetpwent(__stream *c.FILE) *Passwd + +// Write the given entry onto the given stream. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +// llgo:link (*Passwd).Putpwent C.putpwent +func (self *Passwd) Putpwent(__f *c.FILE) c.Int { + return 0 +} + +// Search for an entry with a matching user ID. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getpwuid C.getpwuid +func Getpwuid(__uid c.Uint) *Passwd + +// Search for an entry with a matching username. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getpwnam C.getpwnam +func Getpwnam(__name *c.Char) *Passwd + +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +// llgo:link (*Passwd).GetpwentR C.getpwent_r +func (self *Passwd) GetpwentR(__buffer *c.Char, __buflen c.SizeT, __result **Passwd) c.Int { + return 0 +} + +//go:linkname GetpwuidR C.getpwuid_r +func GetpwuidR(__uid c.Uint, __resultbuf *Passwd, __buffer *c.Char, __buflen c.SizeT, __result **Passwd) c.Int + +//go:linkname GetpwnamR C.getpwnam_r +func GetpwnamR(__name *c.Char, __resultbuf *Passwd, __buffer *c.Char, __buflen c.SizeT, __result **Passwd) c.Int + +// Read an entry from STREAM. This function is not standardized and +// probably never will. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname FgetpwentR C.fgetpwent_r +func FgetpwentR(__stream *c.FILE, __resultbuf *Passwd, __buffer *c.Char, __buflen c.SizeT, __result **Passwd) c.Int + +// Set scheduling parameters for a process. +// +//go:linkname SchedSetparam C.sched_setparam +func SchedSetparam(__pid c.Int, __param *SchedParam) c.Int + +// Retrieve scheduling parameters for a particular process. +// +//go:linkname SchedGetparam C.sched_getparam +func SchedGetparam(__pid c.Int, __param *SchedParam) c.Int + +// Set scheduling algorithm and/or parameters for a process. +// +//go:linkname SchedSetscheduler C.sched_setscheduler +func SchedSetscheduler(__pid c.Int, __policy c.Int, __param *SchedParam) c.Int + +// Retrieve scheduling algorithm for a particular purpose. +// +//go:linkname SchedGetscheduler C.sched_getscheduler +func SchedGetscheduler(__pid c.Int) c.Int + +// Yield the processor. +// +//go:linkname SchedYield C.sched_yield +func SchedYield() c.Int + +// Get maximum priority value for a scheduler. +// +//go:linkname SchedGetPriorityMax C.sched_get_priority_max +func SchedGetPriorityMax(__algorithm c.Int) c.Int + +// Get minimum priority value for a scheduler. +// +//go:linkname SchedGetPriorityMin C.sched_get_priority_min +func SchedGetPriorityMin(__algorithm c.Int) c.Int + +// Get the SCHED_RR interval for the named process. +// +//go:linkname SchedRrGetInterval C.sched_rr_get_interval +func SchedRrGetInterval(__pid c.Int, __t *lltime.Timespec) c.Int + +// Flags to be set in the `posix_spawnattr_t'. +const ( + POSIX_SPAWN_RESETIDS = 1 + POSIX_SPAWN_SETPGROUP = 2 + POSIX_SPAWN_SETSIGDEF = 4 + POSIX_SPAWN_SETSIGMASK = 8 + POSIX_SPAWN_SETSCHEDPARAM = 16 + POSIX_SPAWN_SETSCHEDULER = 32 +) + +// Data structure to contain attributes for thread creation. +type PosixSpawnattrT struct { + X__Flags int16 + X__Pgrp c.Int + X__Sd llsignal.SigsetT + X__Ss llsignal.SigsetT + X__Sp SchedParam + X__Policy c.Int + X__Pad [16]c.Int +} + +// Data structure to contain information about the actions to be +// performed in the new process with respect to file descriptors. +type PosixSpawnFileActionsT struct { + X__Allocated c.Int + X__Used c.Int + X__Actions *X__SpawnAction + X__Pad [16]c.Int +} + +type X__SpawnAction struct { +} + +// Spawn a new process executing PATH with the attributes describes in *ATTRP. +// Before running the process perform the actions described in FILE-ACTIONS. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname PosixSpawn C.posix_spawn +func PosixSpawn(__pid *c.Int, __path *c.Char, __file_actions *PosixSpawnFileActionsT, __attrp *PosixSpawnattrT, __argv **c.Char, __envp **c.Char) c.Int + +// Similar to `posix_spawn' but search for FILE in the PATH. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname PosixSpawnp C.posix_spawnp +func PosixSpawnp(__pid *c.Int, __file *c.Char, __file_actions *PosixSpawnFileActionsT, __attrp *PosixSpawnattrT, __argv **c.Char, __envp **c.Char) c.Int + +// Initialize data structure with attributes for `spawn' to default values. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrInit C.posix_spawnattr_init +func (self *PosixSpawnattrT) PosixSpawnattrInit() c.Int { + return 0 +} + +// Free resources associated with ATTR. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrDestroy C.posix_spawnattr_destroy +func (self *PosixSpawnattrT) PosixSpawnattrDestroy() c.Int { + return 0 +} + +// Store signal mask for signals with default handling from ATTR in +// SIGDEFAULT. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetsigdefault C.posix_spawnattr_getsigdefault +func (self *PosixSpawnattrT) PosixSpawnattrGetsigdefault(__sigdefault *llsignal.SigsetT) c.Int { + return 0 +} + +// Set signal mask for signals with default handling in ATTR to SIGDEFAULT. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetsigdefault C.posix_spawnattr_setsigdefault +func (self *PosixSpawnattrT) PosixSpawnattrSetsigdefault(__sigdefault *llsignal.SigsetT) c.Int { + return 0 +} + +// Store signal mask for the new process from ATTR in SIGMASK. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetsigmask C.posix_spawnattr_getsigmask +func (self *PosixSpawnattrT) PosixSpawnattrGetsigmask(__sigmask *llsignal.SigsetT) c.Int { + return 0 +} + +// Set signal mask for the new process in ATTR to SIGMASK. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetsigmask C.posix_spawnattr_setsigmask +func (self *PosixSpawnattrT) PosixSpawnattrSetsigmask(__sigmask *llsignal.SigsetT) c.Int { + return 0 +} + +// Get flag word from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetflags C.posix_spawnattr_getflags +func (self *PosixSpawnattrT) PosixSpawnattrGetflags(__flags *int16) c.Int { + return 0 +} + +// Store flags in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetflags C.posix_spawnattr_setflags +func (self *PosixSpawnattrT) PosixSpawnattrSetflags(__flags int16) c.Int { + return 0 +} + +// Get process group ID from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetpgroup C.posix_spawnattr_getpgroup +func (self *PosixSpawnattrT) PosixSpawnattrGetpgroup(__pgroup *c.Int) c.Int { + return 0 +} + +// Store process group ID in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetpgroup C.posix_spawnattr_setpgroup +func (self *PosixSpawnattrT) PosixSpawnattrSetpgroup(__pgroup c.Int) c.Int { + return 0 +} + +// Get scheduling policy from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetschedpolicy C.posix_spawnattr_getschedpolicy +func (self *PosixSpawnattrT) PosixSpawnattrGetschedpolicy(__schedpolicy *c.Int) c.Int { + return 0 +} + +// Store scheduling policy in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetschedpolicy C.posix_spawnattr_setschedpolicy +func (self *PosixSpawnattrT) PosixSpawnattrSetschedpolicy(__schedpolicy c.Int) c.Int { + return 0 +} + +// Get scheduling parameters from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetschedparam C.posix_spawnattr_getschedparam +func (self *PosixSpawnattrT) PosixSpawnattrGetschedparam(__schedparam *SchedParam) c.Int { + return 0 +} + +// Store scheduling parameters in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetschedparam C.posix_spawnattr_setschedparam +func (self *PosixSpawnattrT) PosixSpawnattrSetschedparam(__schedparam *SchedParam) c.Int { + return 0 +} + +// Initialize data structure for file attribute for `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsInit C.posix_spawn_file_actions_init +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsInit() c.Int { + return 0 +} + +// Free resources associated with FILE-ACTIONS. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsDestroy C.posix_spawn_file_actions_destroy +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsDestroy() c.Int { + return 0 +} + +// Add an action to FILE-ACTIONS which tells the implementation to call +// `open' for the given file during the `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddopen C.posix_spawn_file_actions_addopen +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddopen(__fd c.Int, __path *c.Char, __oflag c.Int, __mode c.Uint) c.Int { + return 0 +} + +// Add an action to FILE-ACTIONS which tells the implementation to call +// `close' for the given file descriptor during the `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddclose C.posix_spawn_file_actions_addclose +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddclose(__fd c.Int) c.Int { + return 0 +} + +// Add an action to FILE-ACTIONS which tells the implementation to call +// `dup2' for the given file descriptors during the `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAdddup2 C.posix_spawn_file_actions_adddup2 +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAdddup2(__fd c.Int, __newfd c.Int) c.Int { + return 0 +} + +const ( + // Seek from beginning of file. + L_SET = 0 + // Seek from current position. + L_INCR = 1 + // Seek from end of file. + L_XTND = 2 +) + +// Apply or remove an advisory lock, according to OPERATION, +// on the file FD refers to. +// +//go:linkname Flock C.flock +func Flock(__fd c.Int, __operation c.Int) c.Int + +//go:linkname Mmap C.mmap +func Mmap(__addr unsafe.Pointer, __len c.SizeT, __prot c.Int, __flags c.Int, __fd c.Int, __offset c.Long) unsafe.Pointer + +// Deallocate any mapping for the region starting at ADDR and extending LEN +// bytes. Returns 0 if successful, -1 for errors (and sets errno). +// +//go:linkname Munmap C.munmap +func Munmap(__addr unsafe.Pointer, __len c.SizeT) c.Int + +// Change the memory protection of the region starting at ADDR and +// extending LEN bytes to PROT. Returns 0 if successful, -1 for errors +// (and sets errno). +// +//go:linkname Mprotect C.mprotect +func Mprotect(__addr unsafe.Pointer, __len c.SizeT, __prot c.Int) c.Int + +// Synchronize the region starting at ADDR and extending LEN bytes with the +// file it maps. Filesystem operations on a file being mapped are +// unpredictable before this is done. Flags are from the MS_* set. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Msync C.msync +func Msync(__addr unsafe.Pointer, __len c.SizeT, __flags c.Int) c.Int + +// Advise the system about particular usage patterns the program follows +// for the region starting at ADDR and extending LEN bytes. +// +//go:linkname Madvise C.madvise +func Madvise(__addr unsafe.Pointer, __len c.SizeT, __advice c.Int) c.Int + +// This is the POSIX name for this function. +// +//go:linkname PosixMadvise C.posix_madvise +func PosixMadvise(__addr unsafe.Pointer, __len c.SizeT, __advice c.Int) c.Int + +// Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to +// be memory resident. +// +//go:linkname Mlock C.mlock +func Mlock(__addr unsafe.Pointer, __len c.SizeT) c.Int + +// Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). +// +//go:linkname Munlock C.munlock +func Munlock(__addr unsafe.Pointer, __len c.SizeT) c.Int + +// Cause all currently mapped pages of the process to be memory resident +// until unlocked by a call to the `munlockall', until the process exits, +// or until the process calls `execve'. +// +//go:linkname Mlockall C.mlockall +func Mlockall(__flags c.Int) c.Int + +// All currently mapped pages of the process' address space become +// unlocked. +// +//go:linkname Munlockall C.munlockall +func Munlockall() c.Int + +// mincore returns the memory residency status of the pages in the +// current process's address space specified by [start, start + len). +// The status is returned in a vector of bytes. The least significant +// bit of each byte is 1 if the referenced page is in memory, otherwise +// it is zero. +// +//go:linkname Mincore C.mincore +func Mincore(__start unsafe.Pointer, __len c.SizeT, __vec *uint8) c.Int + +// Open shared memory segment. +// +//go:linkname ShmOpen C.shm_open +func ShmOpen(__name *c.Char, __oflag c.Int, __mode c.Uint) c.Int + +// Remove shared memory segment. +// +//go:linkname ShmUnlink C.shm_unlink +func ShmUnlink(__name *c.Char) c.Int + +// Data structure describing a polling request. +type Pollfd struct { + Fd c.Int + Events int16 + Revents int16 +} + +// Poll the file descriptors described by the NFDS structures starting at +// FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for +// an event to occur; if TIMEOUT is -1, block until an event occurs. +// Returns the number of file descriptors with events, zero if timed out, +// or -1 for errors. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*Pollfd).Poll C.poll +func (self *Pollfd) Poll(__nfds c.Ulong, __timeout c.Int) c.Int { + return 0 +} + +//go:linkname NativeGetrlimit C.getrlimit +func NativeGetrlimit(__resource c.Int, __rlimits *Rlimit) c.Int + +//go:linkname NativeSetrlimit C.setrlimit +func NativeSetrlimit(__resource c.Int, __rlimits *Rlimit) c.Int + +// Return resource usage information on process indicated by WHO +// and put it in *USAGE. Returns 0 for success, -1 for failure. +// +//go:linkname Getrusage C.getrusage +func Getrusage(__who c.Int, __usage *Rusage) c.Int + +// Return the highest priority of any process specified by WHICH and WHO +// (see above); if WHO is zero, the current process, process group, or user +// (as specified by WHO) is used. A lower priority number means higher +// priority. Priorities range from PRIO_MIN to PRIO_MAX (above). +// +//go:linkname Getpriority C.getpriority +func Getpriority(__which c.Int, __who c.Uint) c.Int + +// Set the priority of all processes specified by WHICH and WHO (see above) +// to PRIO. Returns 0 on success, -1 on errors. +// +//go:linkname Setpriority C.setpriority +func Setpriority(__which c.Int, __who c.Uint, __prio c.Int) c.Int + +const ( + S_IREAD = 256 + S_IWRITE = 128 + S_IEXEC = 64 +) + +// Macros for common mode bit masks. +const ( + ACCESSPERMS = 511 + // 07777 + ALLPERMS = 4095 + // 0666 + DEFFILEMODE = 438 +) + +// Block size for `st_blocks'. +const S_BLKSIZE = 512 + +// Get file attributes for FILE and put them in BUF. +// +//go:linkname NativeStat C.stat +func NativeStat(__file *c.Char, __buf *StatT) c.Int + +// Get file attributes for the file, device, pipe, or socket +// that file descriptor FD is open on and put them in BUF. +// +//go:linkname NativeFstat C.fstat +func NativeFstat(__fd c.Int, __buf *StatT) c.Int + +//go:linkname NativeFstatat C.fstatat +func NativeFstatat(__fd c.Int, __file *c.Char, __buf *StatT, __flag c.Int) c.Int + +// Get file attributes about FILE and put them in BUF. +// If FILE is a symbolic link, do not follow it. +// +//go:linkname NativeLstat C.lstat +func NativeLstat(__file *c.Char, __buf *StatT) c.Int + +// Set file access permissions for FILE to MODE. +// If FILE is a symbolic link, this affects its target instead. +// +//go:linkname NativeChmod C.chmod +func NativeChmod(__file *c.Char, __mode c.Uint) c.Int + +// Set file access permissions for FILE to MODE. +// If FILE is a symbolic link, this affects the link itself +// rather than its target. +// +//go:linkname Lchmod C.lchmod +func Lchmod(__file *c.Char, __mode c.Uint) c.Int + +//go:linkname NativeFchmod C.fchmod +func NativeFchmod(__fd c.Int, __mode c.Uint) c.Int + +// Set file access permissions of FILE relative to +// the directory FD is open on. +// +//go:linkname NativeFchmodat C.fchmodat +func NativeFchmodat(__fd c.Int, __file *c.Char, __mode c.Uint, __flag c.Int) c.Int + +// Set the file creation mask of the current process to MASK, +// and return the old creation mask. +// +//go:linkname NativeUmask C.umask +func NativeUmask(__mask c.Uint) c.Uint + +// Create a new directory named PATH, with permission bits MODE. +// +//go:linkname NativeMkdir C.mkdir +func NativeMkdir(__path *c.Char, __mode c.Uint) c.Int + +// Like mkdir, create a new directory with permission bits MODE. But +// interpret relative PATH names relative to the directory associated +// with FD. +// +//go:linkname Mkdirat C.mkdirat +func Mkdirat(__fd c.Int, __path *c.Char, __mode c.Uint) c.Int + +//go:linkname NativeMknod C.mknod +func NativeMknod(__path *c.Char, __mode c.Uint, __dev c.Ulong) c.Int + +// Like mknod, create a new device file with permission bits MODE and +// device number DEV. But interpret relative PATH names relative to +// the directory associated with FD. +// +//go:linkname Mknodat C.mknodat +func Mknodat(__fd c.Int, __path *c.Char, __mode c.Uint, __dev c.Ulong) c.Int + +// Create a new FIFO named PATH, with permission bits MODE. +// +//go:linkname NativeMkfifo C.mkfifo +func NativeMkfifo(__path *c.Char, __mode c.Uint) c.Int + +// Like mkfifo, create a new FIFO with permission bits MODE. But +// interpret relative PATH names relative to the directory associated +// with FD. +// +//go:linkname Mkfifoat C.mkfifoat +func Mkfifoat(__fd c.Int, __path *c.Char, __mode c.Uint) c.Int + +// Set file access and modification times relative to directory file +// descriptor. +// +//go:linkname Utimensat C.utimensat +func Utimensat(__fd c.Int, __path *c.Char, __times *lltime.Timespec, __flags c.Int) c.Int + +// Set file access and modification times of the file associated with FD. +// +//go:linkname Futimens C.futimens +func Futimens(__fd c.Int, __times *lltime.Timespec) c.Int + +//go:linkname X__Fxstat C.__fxstat +func X__Fxstat(__ver c.Int, __fildes c.Int, __stat_buf *StatT) c.Int + +//go:linkname X__Xstat C.__xstat +func X__Xstat(__ver c.Int, __filename *c.Char, __stat_buf *StatT) c.Int + +//go:linkname X__Lxstat C.__lxstat +func X__Lxstat(__ver c.Int, __filename *c.Char, __stat_buf *StatT) c.Int + +//go:linkname X__Fxstatat C.__fxstatat +func X__Fxstatat(__ver c.Int, __fildes c.Int, __filename *c.Char, __stat_buf *StatT, __flag c.Int) c.Int + +//go:linkname X__Xmknod C.__xmknod +func X__Xmknod(__ver c.Int, __path *c.Char, __mode c.Uint, __dev *c.Ulong) c.Int + +//go:linkname X__Xmknodat C.__xmknodat +func X__Xmknodat(__ver c.Int, __fd c.Int, __path *c.Char, __mode c.Uint, __dev *c.Ulong) c.Int + +//go:linkname Statvfs C.statvfs +func Statvfs(__file *c.Char, __buf *StatvfsT) c.Int + +//go:linkname Fstatvfs C.fstatvfs +func Fstatvfs(__fildes c.Int, __buf *StatvfsT) c.Int + +//go:linkname GnuDevMajor C.gnu_dev_major +func GnuDevMajor(__dev c.UlongLong) c.Uint + +//go:linkname GnuDevMinor C.gnu_dev_minor +func GnuDevMinor(__dev c.UlongLong) c.Uint + +//go:linkname GnuDevMakedev C.gnu_dev_makedev +func GnuDevMakedev(__major c.Uint, __minor c.Uint) c.UlongLong + +// Structure describing CPU time used by a process and its children. +type Tms struct { + TmsUtime lltime.ClockT + TmsStime lltime.ClockT + TmsCutime lltime.ClockT + TmsCstime lltime.ClockT +} + +// Store the CPU time used by this process and all its +// dead children (and their dead children) in BUFFER. +// Return the elapsed real time, or (clock_t) -1 for errors. +// All times are in CLK_TCKths of a second. +// +// llgo:link (*Tms).Times C.times +func (self *Tms) Times() lltime.ClockT { + return 0 +} + +type FsidT = X__FsidT + +type CaddrT = X__CaddrT + +// Read data from file descriptor FD, and put the result in the +// buffers described by IOVEC, which is a vector of COUNT 'struct iovec's. +// The buffers are filled in the order specified. +// Operates just like 'read' (see ) except that data are +// put in IOVEC instead of a contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Readv C.readv +func Readv(__fd c.Int, __iovec *c.Iovec, __count c.Int) c.SsizeT + +// Write data pointed by the buffers described by IOVEC, which +// is a vector of COUNT 'struct iovec's, to file descriptor FD. +// The data is written in the order specified. +// Operates just like 'write' (see ) except that the data +// are taken from IOVEC instead of a contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Writev C.writev +func Writev(__fd c.Int, __iovec *c.Iovec, __count c.Int) c.SsizeT + +// Read data from file descriptor FD at the given position OFFSET +// without change the file pointer, and put the result in the buffers +// described by IOVEC, which is a vector of COUNT 'struct iovec's. +// The buffers are filled in the order specified. Operates just like +// 'pread' (see ) except that data are put in IOVEC instead +// of a contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Preadv C.preadv +func Preadv(__fd c.Int, __iovec *c.Iovec, __count c.Int, __offset c.Long) c.SsizeT + +// Write data pointed by the buffers described by IOVEC, which is a +// vector of COUNT 'struct iovec's, to file descriptor FD at the given +// position OFFSET without change the file pointer. The data is +// written in the order specified. Operates just like 'pwrite' (see +// ) except that the data are taken from IOVEC instead of a +// contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pwritev C.pwritev +func Pwritev(__fd c.Int, __iovec *c.Iovec, __count c.Int, __offset c.Long) c.SsizeT + +// Note that SVID assumes all members have the same size. +const SYS_NMLN = 65 + +// Structure describing the system and machine. +type Utsname struct { + Sysname [65]c.Char + Nodename [65]c.Char + Release [65]c.Char + Version [65]c.Char + Machine [65]c.Char + X__Domainname [65]c.Char +} + +// Put information about the system in NAME. +// +// llgo:link (*Utsname).Uname C.uname +func (self *Utsname) Uname() c.Int { + return 0 +} + +const WCOREFLAG = 128 + +// Special values for the PID argument to `waitpid' and `wait4'. +const ( + WAIT_ANY = -1 + // Any process in my process group. + WAIT_MYPGRP = 0 +) + +type IdtypeT c.Uint + +const ( + P_ALL IdtypeT = 0 + P_PID IdtypeT = 1 + // Wait for members of process group. + P_PGID IdtypeT = 2 +) + +// NativeWait for a child to die. When one does, put its status in *STAT_LOC +// and return its process ID. For errors, return (pid_t) -1. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeWait C.wait +func NativeWait(__stat_loc *c.Int) c.Int + +// Wait for a child matching PID to die. +// If PID is greater than 0, match any process whose process ID is PID. +// If PID is (pid_t) -1, match any process. +// If PID is (pid_t) 0, match any process with the +// same process group as the current process. +// If PID is less than -1, match any process whose +// process group is the absolute value of PID. +// If the WNOHANG bit is set in OPTIONS, and that child +// is not already dead, return (pid_t) 0. If successful, +// return PID and store the dead child's status in STAT_LOC. +// Return (pid_t) -1 for errors. If the WUNTRACED bit is +// set in OPTIONS, return status for stopped children; otherwise don't. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeWaitpid C.waitpid +func NativeWaitpid(__pid c.Int, __stat_loc *c.Int, __options c.Int) c.Int + +// Wait for a childing matching IDTYPE and ID to change the status and +// place appropriate information in *INFOP. +// If IDTYPE is P_PID, match any process whose process ID is ID. +// If IDTYPE is P_PGID, match any process whose process group is ID. +// If IDTYPE is P_ALL, match any process. +// If the WNOHANG bit is set in OPTIONS, and that child +// is not already dead, clear *INFOP and return 0. If successful, store +// exit code and status in *INFOP. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link IdtypeT.Waitid C.waitid +func (self IdtypeT) Waitid(__id c.Uint, __infop *llsignal.SiginfoT, __options c.Int) c.Int { + return 0 +} + +// Wait for a child to exit. When one does, put its status in *STAT_LOC and +// return its process ID. For errors return (pid_t) -1. If USAGE is not +// nil, store information about the child's resource usage there. If the +// WUNTRACED bit is set in OPTIONS, return status for stopped children; +// otherwise don't. +// +//go:linkname NativeWait3 C.wait3 +func NativeWait3(__stat_loc *c.Int, __options c.Int, __usage *Rusage) c.Int + +// PID is like waitpid. Other args are like wait3. +// +//go:linkname NativeWait4 C.wait4 +func NativeWait4(__pid c.Int, __stat_loc *c.Int, __options c.Int, __usage *Rusage) c.Int + +// Return the output baud rate stored in *TERMIOS_P. +// +// llgo:link (*Termios).Cfgetospeed C.cfgetospeed +func (self *Termios) Cfgetospeed() c.Uint { + return 0 +} + +// Return the input baud rate stored in *TERMIOS_P. +// +// llgo:link (*Termios).Cfgetispeed C.cfgetispeed +func (self *Termios) Cfgetispeed() c.Uint { + return 0 +} + +// Set the output baud rate stored in *TERMIOS_P to SPEED. +// +// llgo:link (*Termios).Cfsetospeed C.cfsetospeed +func (self *Termios) Cfsetospeed(__speed c.Uint) c.Int { + return 0 +} + +// Set the input baud rate stored in *TERMIOS_P to SPEED. +// +// llgo:link (*Termios).Cfsetispeed C.cfsetispeed +func (self *Termios) Cfsetispeed(__speed c.Uint) c.Int { + return 0 +} + +// Set both the input and output baud rates in *TERMIOS_OP to SPEED. +// +// llgo:link (*Termios).Cfsetspeed C.cfsetspeed +func (self *Termios) Cfsetspeed(__speed c.Uint) c.Int { + return 0 +} + +// Put the state of FD into *TERMIOS_P. +// +//go:linkname Tcgetattr C.tcgetattr +func Tcgetattr(__fd c.Int, __termios_p *Termios) c.Int + +// Set the state of FD to *TERMIOS_P. +// Values for OPTIONAL_ACTIONS (TCSA*) are in . +// +//go:linkname Tcsetattr C.tcsetattr +func Tcsetattr(__fd c.Int, __optional_actions c.Int, __termios_p *Termios) c.Int + +// Set *TERMIOS_P to indicate raw mode. +// +// llgo:link (*Termios).Cfmakeraw C.cfmakeraw +func (self *Termios) Cfmakeraw() { +} + +// Send zero bits on FD. +// +//go:linkname Tcsendbreak C.tcsendbreak +func Tcsendbreak(__fd c.Int, __duration c.Int) c.Int + +// Wait for pending output to be written on FD. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Tcdrain C.tcdrain +func Tcdrain(__fd c.Int) c.Int + +// Flush pending data on FD. +// Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in . +// +//go:linkname Tcflush C.tcflush +func Tcflush(__fd c.Int, __queue_selector c.Int) c.Int + +// Suspend or restart transmission on FD. +// Values for ACTION (TC[IO]{OFF,ON}) are in . +// +//go:linkname Tcflow C.tcflow +func Tcflow(__fd c.Int, __action c.Int) c.Int + +// Get process group ID for session leader for controlling terminal FD. +// +//go:linkname Tcgetsid C.tcgetsid +func Tcgetsid(__fd c.Int) c.Int + +// Standard file descriptors. +const ( + STDIN_FILENO = 0 + // Standard output. + STDOUT_FILENO = 1 + // Standard error output. + STDERR_FILENO = 2 +) + +// Test for access to NAME using the real UID and real GID. +// +//go:linkname Access C.access +func Access(__name *c.Char, __type c.Int) c.Int + +// Test for access to FILE relative to the directory FD is open on. +// If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess', +// otherwise use real IDs like `access'. +// +//go:linkname NativeFaccessat C.faccessat +func NativeFaccessat(__fd c.Int, __file *c.Char, __type c.Int, __flag c.Int) c.Int + +//go:linkname NativeLseek C.lseek +func NativeLseek(__fd c.Int, __offset c.Long, __whence c.Int) c.Long + +// NativeClose the file descriptor FD. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Close C.close +func Close(__fd c.Int) c.Int + +// NativeRead NBYTES into BUF from FD. Return the +// number read, -1 for errors or 0 for EOF. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeRead C.read +func NativeRead(__fd c.Int, __buf unsafe.Pointer, __nbytes c.SizeT) c.SsizeT + +// NativeWrite N bytes of BUF to FD. Return the number written, or -1. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeWrite C.write +func NativeWrite(__fd c.Int, __buf unsafe.Pointer, __n c.SizeT) c.SsizeT + +// Read NBYTES into BUF from FD at the given position OFFSET without +// changing the file pointer. Return the number read, -1 for errors +// or 0 for EOF. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pread C.pread +func Pread(__fd c.Int, __buf unsafe.Pointer, __nbytes c.SizeT, __offset c.Long) c.SsizeT + +// Write N bytes of BUF to FD at the given position OFFSET without +// changing the file pointer. Return the number written, or -1. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pwrite C.pwrite +func Pwrite(__fd c.Int, __buf unsafe.Pointer, __n c.SizeT, __offset c.Long) c.SsizeT + +// Create a one-way communication channel (pipe). +// If successful, two file descriptors are stored in PIPEDES; +// bytes written on PIPEDES[1] can be read from PIPEDES[0]. +// Returns 0 if successful, -1 if not. +// +//go:linkname NativePipe C.pipe +func NativePipe(__pipedes *c.Int) c.Int + +// Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. +// If SECONDS is zero, any currently scheduled alarm will be cancelled. +// The function returns the number of seconds remaining until the last +// alarm scheduled would have signaled, or zero if there wasn't one. +// There is no return value to indicate an error, but you can set `errno' +// to 0 and check its value after calling `alarm', and this might tell you. +// The signal may come late due to processor scheduling. +// +//go:linkname Alarm C.alarm +func Alarm(__seconds c.Uint) c.Uint + +// Make the process sleep for SECONDS seconds, or until a signal arrives +// and is not ignored. The function returns the number of seconds less +// than SECONDS which it actually slept (thus zero if it slept the full time). +// If a signal handler does a `longjmp' or modifies the handling of the +// SIGALRM signal while inside `sleep' call, the handling of the SIGALRM +// signal afterwards is undefined. There is no return value to indicate +// error, but if `sleep' returns SECONDS, it probably didn't work. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Sleep C.sleep +func Sleep(__seconds c.Uint) c.Uint + +// Set an alarm to go off (generating a SIGALRM signal) in VALUE +// microseconds. If INTERVAL is nonzero, when the alarm goes off, the +// timer is reset to go off every INTERVAL microseconds thereafter. +// Returns the number of microseconds remaining before the alarm. +// +//go:linkname Ualarm C.ualarm +func Ualarm(__value c.Uint, __interval c.Uint) c.Uint + +// Sleep USECONDS microseconds, or until a signal arrives that is not blocked +// or ignored. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Usleep C.usleep +func Usleep(__useconds c.Uint) c.Int + +// Suspend the process until a signal arrives. +// This always returns -1 and sets `errno' to EINTR. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pause C.pause +func Pause() c.Int + +// Change the owner and group of FILE. +// +//go:linkname NativeChown C.chown +func NativeChown(__file *c.Char, __owner c.Uint, __group c.Uint) c.Int + +// Change the owner and group of the file that FD is open on. +// +//go:linkname NativeFchown C.fchown +func NativeFchown(__fd c.Int, __owner c.Uint, __group c.Uint) c.Int + +// Change owner and group of FILE, if it is a symbolic +// link the ownership of the symbolic link is changed. +// +//go:linkname NativeLchown C.lchown +func NativeLchown(__file *c.Char, __owner c.Uint, __group c.Uint) c.Int + +// Change the owner and group of FILE relative to the directory FD is open +// on. +// +//go:linkname NativeFchownat C.fchownat +func NativeFchownat(__fd c.Int, __file *c.Char, __owner c.Uint, __group c.Uint, __flag c.Int) c.Int + +// Change the process's working directory to PATH. +// +//go:linkname NativeChdir C.chdir +func NativeChdir(__path *c.Char) c.Int + +// Change the process's working directory to the one FD is open on. +// +//go:linkname Fchdir C.fchdir +func Fchdir(__fd c.Int) c.Int + +// Get the pathname of the current working directory, +// and put it in SIZE bytes of BUF. Returns NULL if the +// directory couldn't be determined or SIZE was too small. +// If successful, returns BUF. In GNU, if BUF is NULL, +// an array is allocated with `malloc'; the array is SIZE +// bytes long, unless SIZE == 0, in which case it is as +// big as necessary. +// +//go:linkname NativeGetcwd C.getcwd +func NativeGetcwd(__buf *c.Char, __size c.SizeT) *c.Char + +// Put the absolute pathname of the current working directory in BUF. +// If successful, return BUF. If not, put an error message in +// BUF and return NULL. BUF should be at least PATH_MAX bytes long. +// +//go:linkname Getwd C.getwd +func Getwd(__buf *c.Char) *c.Char + +// Duplicate FD, returning a new file descriptor on the same file. +// +//go:linkname Dup C.dup +func Dup(__fd c.Int) c.Int + +// Duplicate FD to FD2, closing FD2 and making it open on the same file. +// +//go:linkname Dup2 C.dup2 +func Dup2(__fd c.Int, __fd2 c.Int) c.Int + +// Replace the current process, executing PATH with arguments ARGV and +// environment ENVP. ARGV and ENVP are terminated by NULL pointers. +// +//go:linkname NativeExecve C.execve +func NativeExecve(__path *c.Char, __argv **c.Char, __envp **c.Char) c.Int + +// Execute the file FD refers to, overlaying the running program image. +// ARGV and ENVP are passed to the new program, as for `execve'. +// +//go:linkname Fexecve C.fexecve +func Fexecve(__fd c.Int, __argv **c.Char, __envp **c.Char) c.Int + +// Execute PATH with arguments ARGV and environment from `environ'. +// +//go:linkname NativeExecv C.execv +func NativeExecv(__path *c.Char, __argv **c.Char) c.Int + +// Execute PATH with all arguments after PATH until a NULL pointer, +// and the argument after that for environment. +// +//go:linkname NativeExecle C.execle +func NativeExecle(__path *c.Char, __arg *c.Char, __llgo_va_list ...any) c.Int + +// Execute PATH with all arguments after PATH until +// a NULL pointer and environment from `environ'. +// +//go:linkname NativeExecl C.execl +func NativeExecl(__path *c.Char, __arg *c.Char, __llgo_va_list ...any) c.Int + +// Execute FILE, searching in the `PATH' environment variable if it contains +// no slashes, with arguments ARGV and environment from `environ'. +// +//go:linkname NativeExecvp C.execvp +func NativeExecvp(__file *c.Char, __argv **c.Char) c.Int + +// Execute FILE, searching in the `PATH' environment variable if +// it contains no slashes, with all arguments after FILE until a +// NULL pointer and environment from `environ'. +// +//go:linkname NativeExeclp C.execlp +func NativeExeclp(__file *c.Char, __arg *c.Char, __llgo_va_list ...any) c.Int + +// Add INC to priority of the current process. +// +//go:linkname Nice C.nice +func Nice(__inc c.Int) c.Int + +// Terminate program execution with the low-order 8 bits of STATUS. +// +//go:linkname X_exit C._exit +func X_exit(__status c.Int) + +// Get file-specific configuration information about PATH. +// +//go:linkname Pathconf C.pathconf +func Pathconf(__path *c.Char, __name c.Int) c.Long + +// Get file-specific configuration about descriptor FD. +// +//go:linkname Fpathconf C.fpathconf +func Fpathconf(__fd c.Int, __name c.Int) c.Long + +// Get the value of the system variable NAME. +// +//go:linkname Sysconf C.sysconf +func Sysconf(__name c.Int) c.Long + +// Get the value of the string-valued system variable NAME. +// +//go:linkname Confstr C.confstr +func Confstr(__name c.Int, __buf *c.Char, __len c.SizeT) c.SizeT + +// Get the process ID of the calling process. +// +//go:linkname NativeGetpid C.getpid +func NativeGetpid() c.Int + +// Get the process ID of the calling process's parent. +// +//go:linkname NativeGetppid C.getppid +func NativeGetppid() c.Int + +// Get the process group ID of the calling process. +// +//go:linkname Getpgrp C.getpgrp +func Getpgrp() c.Int + +// Get the process group ID of process PID. +// +//go:linkname X__Getpgid C.__getpgid +func X__Getpgid(__pid c.Int) c.Int + +//go:linkname Getpgid C.getpgid +func Getpgid(__pid c.Int) c.Int + +// Set the process group ID of the process matching PID to PGID. +// If PID is zero, the current process's process group ID is set. +// If PGID is zero, the process ID of the process is used. +// +//go:linkname Setpgid C.setpgid +func Setpgid(__pid c.Int, __pgid c.Int) c.Int + +// Set the process group ID of the calling process to its own PID. +// This is exactly the same as `setpgid (0, 0)'. +// +//go:linkname Setpgrp C.setpgrp +func Setpgrp() c.Int + +// Create a new session with the calling process as its leader. +// The process group IDs of the session and the calling process +// are set to the process ID of the calling process, which is returned. +// +//go:linkname Setsid C.setsid +func Setsid() c.Int + +// Return the session ID of the given process. +// +//go:linkname Getsid C.getsid +func Getsid(__pid c.Int) c.Int + +// Get the real user ID of the calling process. +// +//go:linkname NativeGetuid C.getuid +func NativeGetuid() c.Uint + +// Get the effective user ID of the calling process. +// +//go:linkname NativeGeteuid C.geteuid +func NativeGeteuid() c.Uint + +// Get the real group ID of the calling process. +// +//go:linkname NativeGetgid C.getgid +func NativeGetgid() c.Uint + +// Get the effective group ID of the calling process. +// +//go:linkname NativeGetegid C.getegid +func NativeGetegid() c.Uint + +// If SIZE is zero, return the number of supplementary groups +// the calling process is in. Otherwise, fill in the group IDs +// of its supplementary groups in LIST and return the number written. +// +//go:linkname Getgroups C.getgroups +func Getgroups(__size c.Int, __list *c.Uint) c.Int + +// Set the user ID of the calling process to UID. +// If the calling process is the super-user, set the real +// and effective user IDs, and the saved set-user-ID to UID; +// if not, the effective user ID is set to UID. +// +//go:linkname Setuid C.setuid +func Setuid(__uid c.Uint) c.Int + +// Set the real user ID of the calling process to RUID, +// and the effective user ID of the calling process to EUID. +// +//go:linkname Setreuid C.setreuid +func Setreuid(__ruid c.Uint, __euid c.Uint) c.Int + +// Set the effective user ID of the calling process to UID. +// +//go:linkname Seteuid C.seteuid +func Seteuid(__uid c.Uint) c.Int + +// Set the group ID of the calling process to GID. +// If the calling process is the super-user, set the real +// and effective group IDs, and the saved set-group-ID to GID; +// if not, the effective group ID is set to GID. +// +//go:linkname Setgid C.setgid +func Setgid(__gid c.Uint) c.Int + +// Set the real group ID of the calling process to RGID, +// and the effective group ID of the calling process to EGID. +// +//go:linkname Setregid C.setregid +func Setregid(__rgid c.Uint, __egid c.Uint) c.Int + +// Set the effective group ID of the calling process to GID. +// +//go:linkname Setegid C.setegid +func Setegid(__gid c.Uint) c.Int + +// Clone the calling process, creating an exact copy. +// Return -1 for errors, 0 to the new process, +// and the process ID of the new process to the old process. +// +//go:linkname NativeFork C.fork +func NativeFork() c.Int + +// Clone the calling process, but without copying the whole address space. +// The calling process is suspended until the new process exits or is +// replaced by a call to `execve'. Return -1 for errors, 0 to the new process, +// and the process ID of the new process to the old process. +// +//go:linkname Vfork C.vfork +func Vfork() c.Int + +// Return the pathname of the terminal FD is open on, or NULL on errors. +// The returned storage is good only until the next call to this function. +// +//go:linkname Ttyname C.ttyname +func Ttyname(__fd c.Int) *c.Char + +// Store at most BUFLEN characters of the pathname of the terminal FD is +// open on in BUF. Return 0 on success, otherwise an error number. +// +//go:linkname TtynameR C.ttyname_r +func TtynameR(__fd c.Int, __buf *c.Char, __buflen c.SizeT) c.Int + +// Return 1 if FD is a valid descriptor associated +// with a terminal, zero if not. +// +//go:linkname Isatty C.isatty +func Isatty(__fd c.Int) c.Int + +// Return the index into the active-logins file (utmp) for +// the controlling terminal. +// +//go:linkname Ttyslot C.ttyslot +func Ttyslot() c.Int + +// Make a link to FROM named TO. +// +//go:linkname NativeLink C.link +func NativeLink(__from *c.Char, __to *c.Char) c.Int + +// Like link but relative paths in TO and FROM are interpreted relative +// to FROMFD and TOFD respectively. +// +//go:linkname Linkat C.linkat +func Linkat(__fromfd c.Int, __from *c.Char, __tofd c.Int, __to *c.Char, __flags c.Int) c.Int + +// Make a symbolic link to FROM named TO. +// +//go:linkname NativeSymlink C.symlink +func NativeSymlink(__from *c.Char, __to *c.Char) c.Int + +// Read the contents of the symbolic link PATH into no more than +// LEN bytes of BUF. The contents are not null-terminated. +// Returns the number of characters read, or -1 for errors. +// +//go:linkname NativeReadlink C.readlink +func NativeReadlink(__path *c.Char, __buf *c.Char, __len c.SizeT) c.SsizeT + +// Like symlink but a relative path in TO is interpreted relative to TOFD. +// +//go:linkname Symlinkat C.symlinkat +func Symlinkat(__from *c.Char, __tofd c.Int, __to *c.Char) c.Int + +// Like readlink but a relative PATH is interpreted relative to FD. +// +//go:linkname Readlinkat C.readlinkat +func Readlinkat(__fd c.Int, __path *c.Char, __buf *c.Char, __len c.SizeT) c.SsizeT + +// Remove the link NAME. +// +//go:linkname NativeUnlink C.unlink +func NativeUnlink(__name *c.Char) c.Int + +// Remove the link NAME relative to FD. +// +//go:linkname NativeUnlinkat C.unlinkat +func NativeUnlinkat(__fd c.Int, __name *c.Char, __flag c.Int) c.Int + +// Remove the directory PATH. +// +//go:linkname NativeRmdir C.rmdir +func NativeRmdir(__path *c.Char) c.Int + +// Return the foreground process group ID of FD. +// +//go:linkname Tcgetpgrp C.tcgetpgrp +func Tcgetpgrp(__fd c.Int) c.Int + +// Set the foreground process group ID of FD set PGRP_ID. +// +//go:linkname Tcsetpgrp C.tcsetpgrp +func Tcsetpgrp(__fd c.Int, __pgrp_id c.Int) c.Int + +// Return the login name of the user. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getlogin C.getlogin +func Getlogin() *c.Char + +// Return at most NAME_LEN characters of the login name of the user in NAME. +// If it cannot be determined or some other error occurred, return the error +// code. Otherwise return 0. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname GetloginR C.getlogin_r +func GetloginR(__name *c.Char, __name_len c.SizeT) c.Int + +// Set the login name returned by `getlogin'. +// +//go:linkname Setlogin C.setlogin +func Setlogin(__name *c.Char) c.Int + +// Put the name of the current host in no more than LEN bytes of NAME. +// The result is null-terminated if LEN is large enough for the full +// name and the terminator. +// +//go:linkname Gethostname C.gethostname +func Gethostname(__name *c.Char, __len c.SizeT) c.Int + +// Set the name of the current host to NAME, which is LEN bytes long. +// This call is restricted to the super-user. +// +//go:linkname Sethostname C.sethostname +func Sethostname(__name *c.Char, __len c.SizeT) c.Int + +// Set the current machine's Internet number to ID. +// This call is restricted to the super-user. +// +//go:linkname Sethostid C.sethostid +func Sethostid(__id c.Long) c.Int + +// Get and set the NIS (aka YP) domain name, if any. +// Called just like `gethostname' and `sethostname'. +// The NIS domain name is usually the empty string when not using NIS. +// +//go:linkname Getdomainname C.getdomainname +func Getdomainname(__name *c.Char, __len c.SizeT) c.Int + +// Ignore +// +//go:linkname Setdomainname C.setdomainname +func Setdomainname(__name *c.Char, __len c.SizeT) c.Int + +// Revoke access permissions to all processes currently communicating +// with the control terminal, and then send a SIGHUP signal to the process +// group of the control terminal. +// +//go:linkname Vhangup C.vhangup +func Vhangup() c.Int + +// Revoke the access of all descriptors currently open on FILE. +// +//go:linkname Revoke C.revoke +func Revoke(__file *c.Char) c.Int + +// Enable statistical profiling, writing samples of the PC into at most +// SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling +// is enabled, the system examines the user PC and increments +// SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero, +// disable profiling. Returns zero on success, -1 on error. +// +//go:linkname Profil C.profil +func Profil(__sample_buffer *uint16, __size c.SizeT, __offset c.SizeT, __scale c.Uint) c.Int + +// Turn accounting on if NAME is an existing file. The system will then write +// a record for each process as it terminates, to this file. If NAME is NULL, +// turn accounting off. This call is restricted to the super-user. +// +//go:linkname Acct C.acct +func Acct(__name *c.Char) c.Int + +// Successive calls return the shells listed in `/etc/shells'. +// +//go:linkname Getusershell C.getusershell +func Getusershell() *c.Char + +// Discard cached info. +// +//go:linkname Endusershell C.endusershell +func Endusershell() + +// Rewind and re-read the file. +// +//go:linkname Setusershell C.setusershell +func Setusershell() + +// Put the program in the background, and dissociate from the controlling +// terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, +// redirects stdin, stdout, and stderr to /dev/null. +// +//go:linkname Daemon C.daemon +func Daemon(__nochdir c.Int, __noclose c.Int) c.Int + +// Make PATH be the root directory (the starting point for absolute paths). +// This call is restricted to the super-user. +// +//go:linkname NativeChroot C.chroot +func NativeChroot(__path *c.Char) c.Int + +// Prompt with PROMPT and read a string from the terminal without echoing. +// Uses /dev/tty if possible; otherwise stderr and stdin. +// +//go:linkname Getpass C.getpass +func Getpass(__prompt *c.Char) *c.Char + +// Make all changes done to FD actually appear on disk. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Fsync C.fsync +func Fsync(__fd c.Int) c.Int + +// Return identifier for the current host. +// +//go:linkname Gethostid C.gethostid +func Gethostid() c.Long + +// Make all changes done to all files actually appear on disk. +// +//go:linkname Sync C.sync +func Sync() + +// Return the number of bytes in a page. This is the system's page size, +// which is not necessarily the same as the hardware page size. +// +//go:linkname Getpagesize C.getpagesize +func Getpagesize() c.Int + +// Return the maximum number of file descriptors +// the current process could possibly have. +// +//go:linkname Getdtablesize C.getdtablesize +func Getdtablesize() c.Int + +// Ignore +// +//go:linkname NativeTruncate C.truncate +func NativeTruncate(__file *c.Char, __length c.Long) c.Int + +// Ignore +// +//go:linkname NativeFtruncate C.ftruncate +func NativeFtruncate(__fd c.Int, __length c.Long) c.Int + +// Set the end of accessible data space (aka "the break") to ADDR. +// Returns zero on success and -1 for errors (with errno set). +// +//go:linkname Brk C.brk +func Brk(__addr unsafe.Pointer) c.Int + +// Increase or decrease the end of accessible data space by DELTA bytes. +// If successful, returns the address the previous end of data space +// (i.e. the beginning of the new space, if DELTA > 0); +// returns (void *) -1 for errors (with errno set). +// +//go:linkname Sbrk C.sbrk +func Sbrk(__delta c.IntptrT) unsafe.Pointer + +// Invoke `system call' number SYSNO, passing it the remaining arguments. +// This is completely system-dependent, and not often useful. +// +// In Unix, `syscall' sets `errno' for all errors and most calls return -1 +// for errors; in many systems you cannot pass arguments or get return +// values for all system calls (`pipe', `fork', and `getppid' typically +// among them). +// +// In Mach, all system calls take normal arguments and always return an +// error code (zero for success). +// +//go:linkname Syscall C.syscall +func Syscall(__sysno c.Long, __llgo_va_list ...any) c.Long + +// Synchronize at least the data part of a file with the underlying +// media. +// +//go:linkname Fdatasync C.fdatasync +func Fdatasync(__fildes c.Int) c.Int + +// Structure describing file times. +type Utimbuf struct { + Actime c.Long + Modtime c.Long +} + +// Set the access and modification times of FILE to those given in +// FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. +// +//go:linkname Utime C.utime +func Utime(__file *c.Char, __file_times *Utimbuf) c.Int + +const ( + EAGAIN = 11 + F_GETFL = 3 + F_SETFL = 4 + O_ACCMODE = 3 + O_CREAT = 64 + O_NONBLOCK = 2048 + O_RDONLY = 0 + O_RDWR = 2 + O_TRUNC = 512 + O_WRONLY = 1 +) diff --git a/c/os/libc_linux_arm64.go b/c/os/libc_linux_arm64.go new file mode 100644 index 00000000..85d4087f --- /dev/null +++ b/c/os/libc_linux_arm64.go @@ -0,0 +1,2278 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package os + +import ( + "github.com/goplus/lib/c" + llsignal "github.com/goplus/lib/c/signal" + llsys "github.com/goplus/lib/c/sys" + lltime "github.com/goplus/lib/c/time" + "unsafe" +) + +type FlockT struct { + LType int16 + LWhence int16 + LStart c.Long + LLen c.Long + LPid c.Int +} + +type Rlimit struct { + RlimCur c.Ulong + RlimMax c.Ulong +} + +// The purpose of all the unions is to have the kernel-compatible layout +// while keeping the API type as 'long int', and among machines where +// __syscall_slong_t is not 'long int', this only does the right thing +// for little-endian ones, like x32. +type Rusage struct { + RuUtime llsys.Timeval + RuStime llsys.Timeval + _llcppg_anon_9 + _llcppg_anon_10 + _llcppg_anon_11 + _llcppg_anon_12 + _llcppg_anon_13 + _llcppg_anon_14 + _llcppg_anon_15 + _llcppg_anon_16 + _llcppg_anon_17 + _llcppg_anon_18 + _llcppg_anon_19 + _llcppg_anon_20 + _llcppg_anon_21 + _llcppg_anon_22 +} + +type _llcppg_anon_9 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_10 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_11 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_12 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_13 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_14 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_15 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_16 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_17 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_18 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_19 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_20 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_21 struct { + _xgo_union [1]uint64 +} + +type _llcppg_anon_22 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_9) XGof_ref_ru_maxrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_9) XGof_ref___ru_maxrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_10) XGof_ref_ru_ixrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_10) XGof_ref___ru_ixrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_11) XGof_ref_ru_idrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_11) XGof_ref___ru_idrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_12) XGof_ref_ru_isrss() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_12) XGof_ref___ru_isrss_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_13) XGof_ref_ru_minflt() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_13) XGof_ref___ru_minflt_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_14) XGof_ref_ru_majflt() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_14) XGof_ref___ru_majflt_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_15) XGof_ref_ru_nswap() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_15) XGof_ref___ru_nswap_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_16) XGof_ref_ru_inblock() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_16) XGof_ref___ru_inblock_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_17) XGof_ref_ru_oublock() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_17) XGof_ref___ru_oublock_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_18) XGof_ref_ru_msgsnd() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_18) XGof_ref___ru_msgsnd_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_19) XGof_ref_ru_msgrcv() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_19) XGof_ref___ru_msgrcv_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_20) XGof_ref_ru_nsignals() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_20) XGof_ref___ru_nsignals_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_21) XGof_ref_ru_nvcsw() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_21) XGof_ref___ru_nvcsw_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_22) XGof_ref_ru_nivcsw() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_22) XGof_ref___ru_nivcsw_word() *c.Long { + return (*c.Long)(unsafe.Pointer(p)) +} + +// The official definition. +type SchedParam struct { + X__SchedPriority c.Int +} + +type StatvfsT struct { + FBsize c.Ulong + FFrsize c.Ulong + FBlocks c.Ulong + FBfree c.Ulong + FBavail c.Ulong + FFiles c.Ulong + FFfree c.Ulong + FFavail c.Ulong + FFsid c.Ulong + FFlag c.Ulong + FNamemax c.Ulong + X__FSpare [6]c.Int +} + +type Termios struct { + CIflag c.Uint + COflag c.Uint + CCflag c.Uint + CLflag c.Uint + CLine c.Uint8T + CCc [32]c.Uint8T + CIspeed c.Uint + COspeed c.Uint +} + +type X__FsidT struct { + X__Val [2]c.Int +} + +type X__CaddrT = *uint8 + +const MAXNAMLEN = 255 + +// File types for `d_type'. +const ( + DT_UNKNOWN = 0 + DT_FIFO = 1 + DT_CHR = 2 + DT_DIR = 4 + DT_BLK = 6 + DT_REG = 8 + DT_LNK = 10 + DT_SOCK = 12 + DT_WHT = 14 +) + +type X__Dirstream struct { +} + +// llgo:type C +type llcppgCallback20 = func(_llcppg_param1 **Dirent, _llcppg_param2 **Dirent) c.Int + +// llgo:type C +type llcppgCallback21 = func(_llcppg_param1 *Dirent) c.Int + +// Open a directory stream on NAME. +// Return a DIR stream on the directory, or NULL if it could not be opened. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname NativeOpendir C.opendir +func NativeOpendir(__name *uint8) *DIR + +// Same as opendir, but open the stream on the file descriptor FD. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname NativeFdopendir C.fdopendir +func NativeFdopendir(__fd c.Int) *DIR + +// Close the directory stream DIRP. +// Return 0 if successful, -1 if not. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Closedir C.closedir +func Closedir(self *DIR) c.Int + +// llgo:link (*DIR).NativeReaddir C.readdir +func (self *DIR) NativeReaddir() *Dirent { + return nil +} + +// llgo:link (*DIR).ReaddirR C.readdir_r +func (self *DIR) ReaddirR(__entry *Dirent, __result **Dirent) c.Int { + return 0 +} + +// Rewind DIRP to the beginning of the directory. +// +// llgo:link (*DIR).Rewinddir C.rewinddir +func (self *DIR) Rewinddir() { +} + +// Seek to position POS on DIRP. +// +// llgo:link (*DIR).Seekdir C.seekdir +func (self *DIR) Seekdir(__pos c.Long) { +} + +// Return the current position of DIRP. +// +// llgo:link (*DIR).Telldir C.telldir +func (self *DIR) Telldir() c.Long { + return 0 +} + +// Return the file descriptor used by DIRP. +// +// llgo:link (*DIR).Dirfd C.dirfd +func (self *DIR) Dirfd() c.Int { + return 0 +} + +//go:linkname Scandir C.scandir +func Scandir(__dir *uint8, __namelist ***Dirent, __selector llcppgCallback21, __cmp llcppgCallback20) c.Int + +//go:linkname Alphasort C.alphasort +func Alphasort(__e1 **Dirent, __e2 **Dirent) c.Int + +//go:linkname Getdirentries C.getdirentries +func Getdirentries(__fd c.Int, __buf *uint8, __nbytes c.SizeT, __basep *c.Long) c.Long + +// Open the shared object FILE and map it in; return a handle that can be +// passed to `dlsym' to get symbol values from it. +// +//go:linkname Dlopen C.dlopen +func Dlopen(__file *uint8, __mode c.Int) unsafe.Pointer + +// Unmap and close a shared object opened by `dlopen'. +// The handle cannot be used again after calling `dlclose'. +// +//go:linkname Dlclose C.dlclose +func Dlclose(__handle unsafe.Pointer) c.Int + +// Find the run-time address in the shared object HANDLE refers to +// of the symbol called NAME. +// +//go:linkname Dlsym C.dlsym +func Dlsym(__handle unsafe.Pointer, __name *uint8) unsafe.Pointer + +// When any of the above functions fails, call this function +// to return a string describing the error. Each call resets +// the error string so that a following call returns null. +// +//go:linkname Dlerror C.dlerror +func Dlerror() *uint8 + +const ( + S_IFMT = 61440 + S_IFDIR = 16384 + S_IFCHR = 8192 + S_IFBLK = 24576 + S_IFREG = 32768 +) + +const S_IFIFO = 4096 + +const S_IFLNK = 40960 + +const S_IFSOCK = 49152 + +const ( + // Set user ID on execution. + S_ISUID = 2048 + // Set group ID on execution. + S_ISGID = 1024 +) + +// Save swapped text after use (sticky bit). This is pretty well obsolete. +const S_ISVTX = 512 + +const ( + // Read by owner. + S_IRUSR = 256 + // Write by owner. + S_IWUSR = 128 + // Execute by owner. + S_IXUSR = 64 +) + +// Read, write, and execute by owner. +const S_IRWXU = 448 + +const ( + // Read by group. + S_IRGRP = 32 + // Write by group. + S_IWGRP = 16 + // Execute by group. + S_IXGRP = 8 +) + +// Read, write, and execute by group. +const S_IRWXG = 56 + +const ( + // Read by others. + S_IROTH = 4 + // Write by others. + S_IWOTH = 2 + // Execute by others. + S_IXOTH = 1 +) + +// Read, write, and execute by others. +const S_IRWXO = 7 + +// Values for the second argument to access. +// These may be OR'd together. +const ( + R_OK = 4 + // Test for write permission. + W_OK = 2 + // Test for execute permission. + // Test for existence. + F_OK = 0 +) + +const ( + // Seek from beginning of file. + SEEK_SET = 0 + // Seek from current position. + SEEK_CUR = 1 + // Seek from end of file. + SEEK_END = 2 +) + +// Special value used to indicate +// the *at functions should use the +// current working directory. +const AT_FDCWD = -100 + +const ( + // Do not follow symbolic links. + AT_SYMLINK_NOFOLLOW = 256 + // Remove directory instead of + // unlinking file. + AT_REMOVEDIR = 512 +) + +// Follow symbolic links. +const AT_SYMLINK_FOLLOW = 1024 + +// Test access permitted for +// effective IDs, not real IDs. +const AT_EACCESS = 512 + +const ( + // Unlock a previously locked region. + F_ULOCK = 0 + // Lock a region for exclusive use. + F_LOCK = 1 + // Test and lock a region for exclusive use. + F_TLOCK = 2 + // Test a region for other processes locks. + F_TEST = 3 +) + +// Do the file control operation described by CMD on FD. +// The remaining arguments are interpreted depending on CMD. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Fcntl C.fcntl +func Fcntl(__fd c.Int, __cmd c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeOpen C.open +func NativeOpen(__file *uint8, __oflag c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeOpenat C.openat +func NativeOpenat(__fd c.Int, __file *uint8, __oflag c.Int, __llgo_va_list ...any) c.Int + +//go:linkname NativeCreat C.creat +func NativeCreat(__file *uint8, __mode c.Uint) c.Int + +//go:linkname Lockf C.lockf +func Lockf(__fd c.Int, __cmd c.Int, __len c.Long) c.Int + +//go:linkname PosixFadvise C.posix_fadvise +func PosixFadvise(__fd c.Int, __offset c.Long, __len c.Long, __advise c.Int) c.Int + +//go:linkname PosixFallocate C.posix_fallocate +func PosixFallocate(__fd c.Int, __offset c.Long, __len c.Long) c.Int + +// Bits set in the FLAGS argument to `glob'. +const ( + GLOB_ERR = 1 + // Append a slash to each name. + GLOB_MARK = 2 + // Don't sort the names. + GLOB_NOSORT = 4 + // Insert PGLOB->gl_offs NULLs. + GLOB_DOOFFS = 8 + // If nothing matches, return the pattern. + GLOB_NOCHECK = 16 + // Append to results of a previous call. + GLOB_APPEND = 32 + // Backslashes don't quote metacharacters. + GLOB_NOESCAPE = 64 + // Leading `.' can be matched by metachars. + GLOB_PERIOD = 128 +) + +const ( + // Set in gl_flags if any metachars seen. + GLOB_MAGCHAR = 256 + // Use gl_opendir et al functions. + GLOB_ALTDIRFUNC = 512 + // Expand "{a,b}" to "a" "b". + GLOB_BRACE = 1024 + // If no magic chars, return the pattern. + GLOB_NOMAGIC = 2048 + // Expand ~user and ~ to home directories. + GLOB_TILDE = 4096 + // Match only directories. + GLOB_ONLYDIR = 8192 + // Like GLOB_TILDE but return an error + // if the user name is not available. + GLOB_TILDE_CHECK = 16384 +) + +// Error returns from `glob'. +const ( + GLOB_NOSPACE = 1 + // Read error. + GLOB_ABORTED = 2 + // No matches found. + GLOB_NOMATCH = 3 + // Not implemented. + GLOB_NOSYS = 4 +) + +type GlobT struct { + GlPathc c.SizeT + GlPathv **uint8 + GlOffs c.SizeT + GlFlags c.Int + GlClosedir llcppgCallback19 + GlReaddir llcppgCallback18 + GlOpendir llcppgCallback17 + GlLstat llcppgCallback16 + GlStat llcppgCallback15 +} + +// llgo:type C +type llcppgCallback15 = func(_llcppg_param1 *uint8, _llcppg_param2 unsafe.Pointer) c.Int + +// llgo:type C +type llcppgCallback16 = func(_llcppg_param1 *uint8, _llcppg_param2 unsafe.Pointer) c.Int + +// llgo:type C +type llcppgCallback17 = func(_llcppg_param1 *uint8) unsafe.Pointer + +// llgo:type C +type llcppgCallback18 = func(_llcppg_param1 unsafe.Pointer) unsafe.Pointer + +// llgo:type C +type llcppgCallback19 = func(_llcppg_param1 unsafe.Pointer) + +// llgo:type C +type llcppgCallback14 = func(_llcppg_param1 *uint8, _llcppg_param2 c.Int) c.Int + +//go:linkname Glob C.glob +func Glob(__pattern *uint8, __flags c.Int, __errfunc llcppgCallback14, __pglob *GlobT) c.Int + +// Free storage allocated in PGLOB by a previous `glob' call. +// +// llgo:link (*GlobT).Globfree C.globfree +func (self *GlobT) Globfree() { +} + +// Reasonable value for the buffer sized used in the reentrant +// functions below. But better use `sysconf'. +const NSS_BUFLEN_GROUP = 1024 + +// The group structure. +type Group struct { + GrName *uint8 + GrPasswd *uint8 + GrGid c.Uint + GrMem **uint8 +} + +// Rewind the group-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Setgrent C.setgrent +func Setgrent() + +// Close the group-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Endgrent C.endgrent +func Endgrent() + +// Read an entry from the group-file stream, opening it if necessary. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getgrent C.getgrent +func Getgrent() *Group + +// Read a group entry from STREAM. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Fgetgrent C.fgetgrent +func Fgetgrent(__stream *c.FILE) *Group + +// Search for an entry with a matching group ID. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getgrgid C.getgrgid +func Getgrgid(__gid c.Uint) *Group + +// Search for an entry with a matching group name. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getgrnam C.getgrnam +func Getgrnam(__name *uint8) *Group + +// Search for an entry with a matching group ID. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname GetgrgidR C.getgrgid_r +func GetgrgidR(__gid c.Uint, __resultbuf *Group, __buffer *uint8, __buflen c.SizeT, __result **Group) c.Int + +// Search for an entry with a matching group name. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname GetgrnamR C.getgrnam_r +func GetgrnamR(__name *uint8, __resultbuf *Group, __buffer *uint8, __buflen c.SizeT, __result **Group) c.Int + +// Read a group entry from STREAM. This function is not standardized +// an probably never will. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname FgetgrentR C.fgetgrent_r +func FgetgrentR(__stream *c.FILE, __resultbuf *Group, __buffer *uint8, __buflen c.SizeT, __result **Group) c.Int + +// Set the group set for the current user to GROUPS (N of them). +// +//go:linkname Setgroups C.setgroups +func Setgroups(__n c.SizeT, __groups *c.Uint) c.Int + +// Store at most *NGROUPS members of the group set for USER into +// GROUPS. Also include GROUP. The actual number of groups found is +// returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Getgrouplist C.getgrouplist +func Getgrouplist(__user *uint8, __group c.Uint, __groups *c.Uint, __ngroups *c.Int) c.Int + +// Initialize the group set for the current user +// by reading the group database and using all groups +// of which USER is a member. Also include GROUP. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Initgroups C.initgroups +func Initgroups(__user *uint8, __group c.Uint) c.Int + +// Reasonable value for the buffer sized used in the reentrant +// functions below. But better use `sysconf'. +const NSS_BUFLEN_PASSWD = 1024 + +// The passwd structure. +type Passwd struct { + PwName *uint8 + PwPasswd *uint8 + PwUid c.Uint + PwGid c.Uint + PwGecos *uint8 + PwDir *uint8 + PwShell *uint8 +} + +// Rewind the password-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Setpwent C.setpwent +func Setpwent() + +// Close the password-file stream. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Endpwent C.endpwent +func Endpwent() + +// Read an entry from the password-file stream, opening it if necessary. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getpwent C.getpwent +func Getpwent() *Passwd + +// Read an entry from STREAM. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname Fgetpwent C.fgetpwent +func Fgetpwent(__stream *c.FILE) *Passwd + +// Write the given entry onto the given stream. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +// llgo:link (*Passwd).Putpwent C.putpwent +func (self *Passwd) Putpwent(__f *c.FILE) c.Int { + return 0 +} + +// Search for an entry with a matching user ID. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getpwuid C.getpwuid +func Getpwuid(__uid c.Uint) *Passwd + +// Search for an entry with a matching username. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getpwnam C.getpwnam +func Getpwnam(__name *uint8) *Passwd + +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +// llgo:link (*Passwd).GetpwentR C.getpwent_r +func (self *Passwd) GetpwentR(__buffer *uint8, __buflen c.SizeT, __result **Passwd) c.Int { + return 0 +} + +//go:linkname GetpwuidR C.getpwuid_r +func GetpwuidR(__uid c.Uint, __resultbuf *Passwd, __buffer *uint8, __buflen c.SizeT, __result **Passwd) c.Int + +//go:linkname GetpwnamR C.getpwnam_r +func GetpwnamR(__name *uint8, __resultbuf *Passwd, __buffer *uint8, __buflen c.SizeT, __result **Passwd) c.Int + +// Read an entry from STREAM. This function is not standardized and +// probably never will. +// +// This function is not part of POSIX and therefore no official +// cancellation point. But due to similarity with an POSIX interface +// or due to the implementation it is a cancellation point and +// therefore not marked with __THROW. +// +//go:linkname FgetpwentR C.fgetpwent_r +func FgetpwentR(__stream *c.FILE, __resultbuf *Passwd, __buffer *uint8, __buflen c.SizeT, __result **Passwd) c.Int + +// Set scheduling parameters for a process. +// +//go:linkname SchedSetparam C.sched_setparam +func SchedSetparam(__pid c.Int, __param *SchedParam) c.Int + +// Retrieve scheduling parameters for a particular process. +// +//go:linkname SchedGetparam C.sched_getparam +func SchedGetparam(__pid c.Int, __param *SchedParam) c.Int + +// Set scheduling algorithm and/or parameters for a process. +// +//go:linkname SchedSetscheduler C.sched_setscheduler +func SchedSetscheduler(__pid c.Int, __policy c.Int, __param *SchedParam) c.Int + +// Retrieve scheduling algorithm for a particular purpose. +// +//go:linkname SchedGetscheduler C.sched_getscheduler +func SchedGetscheduler(__pid c.Int) c.Int + +// Yield the processor. +// +//go:linkname SchedYield C.sched_yield +func SchedYield() c.Int + +// Get maximum priority value for a scheduler. +// +//go:linkname SchedGetPriorityMax C.sched_get_priority_max +func SchedGetPriorityMax(__algorithm c.Int) c.Int + +// Get minimum priority value for a scheduler. +// +//go:linkname SchedGetPriorityMin C.sched_get_priority_min +func SchedGetPriorityMin(__algorithm c.Int) c.Int + +// Get the SCHED_RR interval for the named process. +// +//go:linkname SchedRrGetInterval C.sched_rr_get_interval +func SchedRrGetInterval(__pid c.Int, __t *lltime.Timespec) c.Int + +// Flags to be set in the `posix_spawnattr_t'. +const ( + POSIX_SPAWN_RESETIDS = 1 + POSIX_SPAWN_SETPGROUP = 2 + POSIX_SPAWN_SETSIGDEF = 4 + POSIX_SPAWN_SETSIGMASK = 8 + POSIX_SPAWN_SETSCHEDPARAM = 16 + POSIX_SPAWN_SETSCHEDULER = 32 +) + +// Data structure to contain attributes for thread creation. +type PosixSpawnattrT struct { + X__Flags int16 + X__Pgrp c.Int + X__Sd llsignal.SigsetT + X__Ss llsignal.SigsetT + X__Sp SchedParam + X__Policy c.Int + X__Pad [16]c.Int +} + +// Data structure to contain information about the actions to be +// performed in the new process with respect to file descriptors. +type PosixSpawnFileActionsT struct { + X__Allocated c.Int + X__Used c.Int + X__Actions *X__SpawnAction + X__Pad [16]c.Int +} + +type X__SpawnAction struct { +} + +// Spawn a new process executing PATH with the attributes describes in *ATTRP. +// Before running the process perform the actions described in FILE-ACTIONS. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname PosixSpawn C.posix_spawn +func PosixSpawn(__pid *c.Int, __path *uint8, __file_actions *PosixSpawnFileActionsT, __attrp *PosixSpawnattrT, __argv **uint8, __envp **uint8) c.Int + +// Similar to `posix_spawn' but search for FILE in the PATH. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname PosixSpawnp C.posix_spawnp +func PosixSpawnp(__pid *c.Int, __file *uint8, __file_actions *PosixSpawnFileActionsT, __attrp *PosixSpawnattrT, __argv **uint8, __envp **uint8) c.Int + +// Initialize data structure with attributes for `spawn' to default values. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrInit C.posix_spawnattr_init +func (self *PosixSpawnattrT) PosixSpawnattrInit() c.Int { + return 0 +} + +// Free resources associated with ATTR. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrDestroy C.posix_spawnattr_destroy +func (self *PosixSpawnattrT) PosixSpawnattrDestroy() c.Int { + return 0 +} + +// Store signal mask for signals with default handling from ATTR in +// SIGDEFAULT. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetsigdefault C.posix_spawnattr_getsigdefault +func (self *PosixSpawnattrT) PosixSpawnattrGetsigdefault(__sigdefault *llsignal.SigsetT) c.Int { + return 0 +} + +// Set signal mask for signals with default handling in ATTR to SIGDEFAULT. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetsigdefault C.posix_spawnattr_setsigdefault +func (self *PosixSpawnattrT) PosixSpawnattrSetsigdefault(__sigdefault *llsignal.SigsetT) c.Int { + return 0 +} + +// Store signal mask for the new process from ATTR in SIGMASK. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetsigmask C.posix_spawnattr_getsigmask +func (self *PosixSpawnattrT) PosixSpawnattrGetsigmask(__sigmask *llsignal.SigsetT) c.Int { + return 0 +} + +// Set signal mask for the new process in ATTR to SIGMASK. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetsigmask C.posix_spawnattr_setsigmask +func (self *PosixSpawnattrT) PosixSpawnattrSetsigmask(__sigmask *llsignal.SigsetT) c.Int { + return 0 +} + +// Get flag word from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetflags C.posix_spawnattr_getflags +func (self *PosixSpawnattrT) PosixSpawnattrGetflags(__flags *int16) c.Int { + return 0 +} + +// Store flags in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetflags C.posix_spawnattr_setflags +func (self *PosixSpawnattrT) PosixSpawnattrSetflags(__flags int16) c.Int { + return 0 +} + +// Get process group ID from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetpgroup C.posix_spawnattr_getpgroup +func (self *PosixSpawnattrT) PosixSpawnattrGetpgroup(__pgroup *c.Int) c.Int { + return 0 +} + +// Store process group ID in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetpgroup C.posix_spawnattr_setpgroup +func (self *PosixSpawnattrT) PosixSpawnattrSetpgroup(__pgroup c.Int) c.Int { + return 0 +} + +// Get scheduling policy from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetschedpolicy C.posix_spawnattr_getschedpolicy +func (self *PosixSpawnattrT) PosixSpawnattrGetschedpolicy(__schedpolicy *c.Int) c.Int { + return 0 +} + +// Store scheduling policy in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetschedpolicy C.posix_spawnattr_setschedpolicy +func (self *PosixSpawnattrT) PosixSpawnattrSetschedpolicy(__schedpolicy c.Int) c.Int { + return 0 +} + +// Get scheduling parameters from the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrGetschedparam C.posix_spawnattr_getschedparam +func (self *PosixSpawnattrT) PosixSpawnattrGetschedparam(__schedparam *SchedParam) c.Int { + return 0 +} + +// Store scheduling parameters in the attribute structure. +// +// llgo:link (*PosixSpawnattrT).PosixSpawnattrSetschedparam C.posix_spawnattr_setschedparam +func (self *PosixSpawnattrT) PosixSpawnattrSetschedparam(__schedparam *SchedParam) c.Int { + return 0 +} + +// Initialize data structure for file attribute for `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsInit C.posix_spawn_file_actions_init +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsInit() c.Int { + return 0 +} + +// Free resources associated with FILE-ACTIONS. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsDestroy C.posix_spawn_file_actions_destroy +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsDestroy() c.Int { + return 0 +} + +// Add an action to FILE-ACTIONS which tells the implementation to call +// `open' for the given file during the `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddopen C.posix_spawn_file_actions_addopen +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddopen(__fd c.Int, __path *uint8, __oflag c.Int, __mode c.Uint) c.Int { + return 0 +} + +// Add an action to FILE-ACTIONS which tells the implementation to call +// `close' for the given file descriptor during the `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAddclose C.posix_spawn_file_actions_addclose +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAddclose(__fd c.Int) c.Int { + return 0 +} + +// Add an action to FILE-ACTIONS which tells the implementation to call +// `dup2' for the given file descriptors during the `spawn' call. +// +// llgo:link (*PosixSpawnFileActionsT).PosixSpawnFileActionsAdddup2 C.posix_spawn_file_actions_adddup2 +func (self *PosixSpawnFileActionsT) PosixSpawnFileActionsAdddup2(__fd c.Int, __newfd c.Int) c.Int { + return 0 +} + +const ( + // Seek from beginning of file. + L_SET = 0 + // Seek from current position. + L_INCR = 1 + // Seek from end of file. + L_XTND = 2 +) + +// Apply or remove an advisory lock, according to OPERATION, +// on the file FD refers to. +// +//go:linkname Flock C.flock +func Flock(__fd c.Int, __operation c.Int) c.Int + +//go:linkname Mmap C.mmap +func Mmap(__addr unsafe.Pointer, __len c.SizeT, __prot c.Int, __flags c.Int, __fd c.Int, __offset c.Long) unsafe.Pointer + +// Deallocate any mapping for the region starting at ADDR and extending LEN +// bytes. Returns 0 if successful, -1 for errors (and sets errno). +// +//go:linkname Munmap C.munmap +func Munmap(__addr unsafe.Pointer, __len c.SizeT) c.Int + +// Change the memory protection of the region starting at ADDR and +// extending LEN bytes to PROT. Returns 0 if successful, -1 for errors +// (and sets errno). +// +//go:linkname Mprotect C.mprotect +func Mprotect(__addr unsafe.Pointer, __len c.SizeT, __prot c.Int) c.Int + +// Synchronize the region starting at ADDR and extending LEN bytes with the +// file it maps. Filesystem operations on a file being mapped are +// unpredictable before this is done. Flags are from the MS_* set. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Msync C.msync +func Msync(__addr unsafe.Pointer, __len c.SizeT, __flags c.Int) c.Int + +// Advise the system about particular usage patterns the program follows +// for the region starting at ADDR and extending LEN bytes. +// +//go:linkname Madvise C.madvise +func Madvise(__addr unsafe.Pointer, __len c.SizeT, __advice c.Int) c.Int + +// This is the POSIX name for this function. +// +//go:linkname PosixMadvise C.posix_madvise +func PosixMadvise(__addr unsafe.Pointer, __len c.SizeT, __advice c.Int) c.Int + +// Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to +// be memory resident. +// +//go:linkname Mlock C.mlock +func Mlock(__addr unsafe.Pointer, __len c.SizeT) c.Int + +// Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). +// +//go:linkname Munlock C.munlock +func Munlock(__addr unsafe.Pointer, __len c.SizeT) c.Int + +// Cause all currently mapped pages of the process to be memory resident +// until unlocked by a call to the `munlockall', until the process exits, +// or until the process calls `execve'. +// +//go:linkname Mlockall C.mlockall +func Mlockall(__flags c.Int) c.Int + +// All currently mapped pages of the process' address space become +// unlocked. +// +//go:linkname Munlockall C.munlockall +func Munlockall() c.Int + +// mincore returns the memory residency status of the pages in the +// current process's address space specified by [start, start + len). +// The status is returned in a vector of bytes. The least significant +// bit of each byte is 1 if the referenced page is in memory, otherwise +// it is zero. +// +//go:linkname Mincore C.mincore +func Mincore(__start unsafe.Pointer, __len c.SizeT, __vec *uint8) c.Int + +// Open shared memory segment. +// +//go:linkname ShmOpen C.shm_open +func ShmOpen(__name *uint8, __oflag c.Int, __mode c.Uint) c.Int + +// Remove shared memory segment. +// +//go:linkname ShmUnlink C.shm_unlink +func ShmUnlink(__name *uint8) c.Int + +// Data structure describing a polling request. +type Pollfd struct { + Fd c.Int + Events int16 + Revents int16 +} + +// Poll the file descriptors described by the NFDS structures starting at +// FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for +// an event to occur; if TIMEOUT is -1, block until an event occurs. +// Returns the number of file descriptors with events, zero if timed out, +// or -1 for errors. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*Pollfd).Poll C.poll +func (self *Pollfd) Poll(__nfds c.Ulong, __timeout c.Int) c.Int { + return 0 +} + +//go:linkname NativeGetrlimit C.getrlimit +func NativeGetrlimit(__resource c.Int, __rlimits *Rlimit) c.Int + +//go:linkname NativeSetrlimit C.setrlimit +func NativeSetrlimit(__resource c.Int, __rlimits *Rlimit) c.Int + +// Return resource usage information on process indicated by WHO +// and put it in *USAGE. Returns 0 for success, -1 for failure. +// +//go:linkname Getrusage C.getrusage +func Getrusage(__who c.Int, __usage *Rusage) c.Int + +// Return the highest priority of any process specified by WHICH and WHO +// (see above); if WHO is zero, the current process, process group, or user +// (as specified by WHO) is used. A lower priority number means higher +// priority. Priorities range from PRIO_MIN to PRIO_MAX (above). +// +//go:linkname Getpriority C.getpriority +func Getpriority(__which c.Int, __who c.Uint) c.Int + +// Set the priority of all processes specified by WHICH and WHO (see above) +// to PRIO. Returns 0 on success, -1 on errors. +// +//go:linkname Setpriority C.setpriority +func Setpriority(__which c.Int, __who c.Uint, __prio c.Int) c.Int + +const ( + S_IREAD = 256 + S_IWRITE = 128 + S_IEXEC = 64 +) + +// Macros for common mode bit masks. +const ( + ACCESSPERMS = 511 + // 07777 + ALLPERMS = 4095 + // 0666 + DEFFILEMODE = 438 +) + +// Block size for `st_blocks'. +const S_BLKSIZE = 512 + +// Get file attributes for FILE and put them in BUF. +// +//go:linkname NativeStat C.stat +func NativeStat(__file *uint8, __buf *StatT) c.Int + +// Get file attributes for the file, device, pipe, or socket +// that file descriptor FD is open on and put them in BUF. +// +//go:linkname NativeFstat C.fstat +func NativeFstat(__fd c.Int, __buf *StatT) c.Int + +//go:linkname NativeFstatat C.fstatat +func NativeFstatat(__fd c.Int, __file *uint8, __buf *StatT, __flag c.Int) c.Int + +// Get file attributes about FILE and put them in BUF. +// If FILE is a symbolic link, do not follow it. +// +//go:linkname NativeLstat C.lstat +func NativeLstat(__file *uint8, __buf *StatT) c.Int + +// Set file access permissions for FILE to MODE. +// If FILE is a symbolic link, this affects its target instead. +// +//go:linkname NativeChmod C.chmod +func NativeChmod(__file *uint8, __mode c.Uint) c.Int + +// Set file access permissions for FILE to MODE. +// If FILE is a symbolic link, this affects the link itself +// rather than its target. +// +//go:linkname Lchmod C.lchmod +func Lchmod(__file *uint8, __mode c.Uint) c.Int + +//go:linkname NativeFchmod C.fchmod +func NativeFchmod(__fd c.Int, __mode c.Uint) c.Int + +// Set file access permissions of FILE relative to +// the directory FD is open on. +// +//go:linkname NativeFchmodat C.fchmodat +func NativeFchmodat(__fd c.Int, __file *uint8, __mode c.Uint, __flag c.Int) c.Int + +// Set the file creation mask of the current process to MASK, +// and return the old creation mask. +// +//go:linkname NativeUmask C.umask +func NativeUmask(__mask c.Uint) c.Uint + +// Create a new directory named PATH, with permission bits MODE. +// +//go:linkname NativeMkdir C.mkdir +func NativeMkdir(__path *uint8, __mode c.Uint) c.Int + +// Like mkdir, create a new directory with permission bits MODE. But +// interpret relative PATH names relative to the directory associated +// with FD. +// +//go:linkname Mkdirat C.mkdirat +func Mkdirat(__fd c.Int, __path *uint8, __mode c.Uint) c.Int + +//go:linkname NativeMknod C.mknod +func NativeMknod(__path *uint8, __mode c.Uint, __dev c.Ulong) c.Int + +// Like mknod, create a new device file with permission bits MODE and +// device number DEV. But interpret relative PATH names relative to +// the directory associated with FD. +// +//go:linkname Mknodat C.mknodat +func Mknodat(__fd c.Int, __path *uint8, __mode c.Uint, __dev c.Ulong) c.Int + +// Create a new FIFO named PATH, with permission bits MODE. +// +//go:linkname NativeMkfifo C.mkfifo +func NativeMkfifo(__path *uint8, __mode c.Uint) c.Int + +// Like mkfifo, create a new FIFO with permission bits MODE. But +// interpret relative PATH names relative to the directory associated +// with FD. +// +//go:linkname Mkfifoat C.mkfifoat +func Mkfifoat(__fd c.Int, __path *uint8, __mode c.Uint) c.Int + +// Set file access and modification times relative to directory file +// descriptor. +// +//go:linkname Utimensat C.utimensat +func Utimensat(__fd c.Int, __path *uint8, __times *lltime.Timespec, __flags c.Int) c.Int + +// Set file access and modification times of the file associated with FD. +// +//go:linkname Futimens C.futimens +func Futimens(__fd c.Int, __times *lltime.Timespec) c.Int + +//go:linkname X__Fxstat C.__fxstat +func X__Fxstat(__ver c.Int, __fildes c.Int, __stat_buf *StatT) c.Int + +//go:linkname X__Xstat C.__xstat +func X__Xstat(__ver c.Int, __filename *uint8, __stat_buf *StatT) c.Int + +//go:linkname X__Lxstat C.__lxstat +func X__Lxstat(__ver c.Int, __filename *uint8, __stat_buf *StatT) c.Int + +//go:linkname X__Fxstatat C.__fxstatat +func X__Fxstatat(__ver c.Int, __fildes c.Int, __filename *uint8, __stat_buf *StatT, __flag c.Int) c.Int + +//go:linkname X__Xmknod C.__xmknod +func X__Xmknod(__ver c.Int, __path *uint8, __mode c.Uint, __dev *c.Ulong) c.Int + +//go:linkname X__Xmknodat C.__xmknodat +func X__Xmknodat(__ver c.Int, __fd c.Int, __path *uint8, __mode c.Uint, __dev *c.Ulong) c.Int + +//go:linkname Statvfs C.statvfs +func Statvfs(__file *uint8, __buf *StatvfsT) c.Int + +//go:linkname Fstatvfs C.fstatvfs +func Fstatvfs(__fildes c.Int, __buf *StatvfsT) c.Int + +//go:linkname GnuDevMajor C.gnu_dev_major +func GnuDevMajor(__dev c.UlongLong) c.Uint + +//go:linkname GnuDevMinor C.gnu_dev_minor +func GnuDevMinor(__dev c.UlongLong) c.Uint + +//go:linkname GnuDevMakedev C.gnu_dev_makedev +func GnuDevMakedev(__major c.Uint, __minor c.Uint) c.UlongLong + +// Structure describing CPU time used by a process and its children. +type Tms struct { + TmsUtime lltime.ClockT + TmsStime lltime.ClockT + TmsCutime lltime.ClockT + TmsCstime lltime.ClockT +} + +// Store the CPU time used by this process and all its +// dead children (and their dead children) in BUFFER. +// Return the elapsed real time, or (clock_t) -1 for errors. +// All times are in CLK_TCKths of a second. +// +// llgo:link (*Tms).Times C.times +func (self *Tms) Times() lltime.ClockT { + return 0 +} + +type FsidT = X__FsidT + +type CaddrT = X__CaddrT + +// Read data from file descriptor FD, and put the result in the +// buffers described by IOVEC, which is a vector of COUNT 'struct iovec's. +// The buffers are filled in the order specified. +// Operates just like 'read' (see ) except that data are +// put in IOVEC instead of a contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Readv C.readv +func Readv(__fd c.Int, __iovec *c.Iovec, __count c.Int) c.SsizeT + +// Write data pointed by the buffers described by IOVEC, which +// is a vector of COUNT 'struct iovec's, to file descriptor FD. +// The data is written in the order specified. +// Operates just like 'write' (see ) except that the data +// are taken from IOVEC instead of a contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Writev C.writev +func Writev(__fd c.Int, __iovec *c.Iovec, __count c.Int) c.SsizeT + +// Read data from file descriptor FD at the given position OFFSET +// without change the file pointer, and put the result in the buffers +// described by IOVEC, which is a vector of COUNT 'struct iovec's. +// The buffers are filled in the order specified. Operates just like +// 'pread' (see ) except that data are put in IOVEC instead +// of a contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Preadv C.preadv +func Preadv(__fd c.Int, __iovec *c.Iovec, __count c.Int, __offset c.Long) c.SsizeT + +// Write data pointed by the buffers described by IOVEC, which is a +// vector of COUNT 'struct iovec's, to file descriptor FD at the given +// position OFFSET without change the file pointer. The data is +// written in the order specified. Operates just like 'pwrite' (see +// ) except that the data are taken from IOVEC instead of a +// contiguous buffer. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pwritev C.pwritev +func Pwritev(__fd c.Int, __iovec *c.Iovec, __count c.Int, __offset c.Long) c.SsizeT + +// Note that SVID assumes all members have the same size. +const SYS_NMLN = 65 + +// Structure describing the system and machine. +type Utsname struct { + Sysname [65]uint8 + Nodename [65]uint8 + Release [65]uint8 + Version [65]uint8 + Machine [65]uint8 + X__Domainname [65]uint8 +} + +// Put information about the system in NAME. +// +// llgo:link (*Utsname).Uname C.uname +func (self *Utsname) Uname() c.Int { + return 0 +} + +const WCOREFLAG = 128 + +// Special values for the PID argument to `waitpid' and `wait4'. +const ( + WAIT_ANY = -1 + // Any process in my process group. + WAIT_MYPGRP = 0 +) + +type IdtypeT c.Uint + +const ( + P_ALL IdtypeT = 0 + P_PID IdtypeT = 1 + // Wait for members of process group. + P_PGID IdtypeT = 2 +) + +// NativeWait for a child to die. When one does, put its status in *STAT_LOC +// and return its process ID. For errors, return (pid_t) -1. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeWait C.wait +func NativeWait(__stat_loc *c.Int) c.Int + +// Wait for a child matching PID to die. +// If PID is greater than 0, match any process whose process ID is PID. +// If PID is (pid_t) -1, match any process. +// If PID is (pid_t) 0, match any process with the +// same process group as the current process. +// If PID is less than -1, match any process whose +// process group is the absolute value of PID. +// If the WNOHANG bit is set in OPTIONS, and that child +// is not already dead, return (pid_t) 0. If successful, +// return PID and store the dead child's status in STAT_LOC. +// Return (pid_t) -1 for errors. If the WUNTRACED bit is +// set in OPTIONS, return status for stopped children; otherwise don't. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeWaitpid C.waitpid +func NativeWaitpid(__pid c.Int, __stat_loc *c.Int, __options c.Int) c.Int + +// Wait for a childing matching IDTYPE and ID to change the status and +// place appropriate information in *INFOP. +// If IDTYPE is P_PID, match any process whose process ID is ID. +// If IDTYPE is P_PGID, match any process whose process group is ID. +// If IDTYPE is P_ALL, match any process. +// If the WNOHANG bit is set in OPTIONS, and that child +// is not already dead, clear *INFOP and return 0. If successful, store +// exit code and status in *INFOP. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link IdtypeT.Waitid C.waitid +func (self IdtypeT) Waitid(__id c.Uint, __infop *llsignal.SiginfoT, __options c.Int) c.Int { + return 0 +} + +// Wait for a child to exit. When one does, put its status in *STAT_LOC and +// return its process ID. For errors return (pid_t) -1. If USAGE is not +// nil, store information about the child's resource usage there. If the +// WUNTRACED bit is set in OPTIONS, return status for stopped children; +// otherwise don't. +// +//go:linkname NativeWait3 C.wait3 +func NativeWait3(__stat_loc *c.Int, __options c.Int, __usage *Rusage) c.Int + +// PID is like waitpid. Other args are like wait3. +// +//go:linkname NativeWait4 C.wait4 +func NativeWait4(__pid c.Int, __stat_loc *c.Int, __options c.Int, __usage *Rusage) c.Int + +// Return the output baud rate stored in *TERMIOS_P. +// +// llgo:link (*Termios).Cfgetospeed C.cfgetospeed +func (self *Termios) Cfgetospeed() c.Uint { + return 0 +} + +// Return the input baud rate stored in *TERMIOS_P. +// +// llgo:link (*Termios).Cfgetispeed C.cfgetispeed +func (self *Termios) Cfgetispeed() c.Uint { + return 0 +} + +// Set the output baud rate stored in *TERMIOS_P to SPEED. +// +// llgo:link (*Termios).Cfsetospeed C.cfsetospeed +func (self *Termios) Cfsetospeed(__speed c.Uint) c.Int { + return 0 +} + +// Set the input baud rate stored in *TERMIOS_P to SPEED. +// +// llgo:link (*Termios).Cfsetispeed C.cfsetispeed +func (self *Termios) Cfsetispeed(__speed c.Uint) c.Int { + return 0 +} + +// Set both the input and output baud rates in *TERMIOS_OP to SPEED. +// +// llgo:link (*Termios).Cfsetspeed C.cfsetspeed +func (self *Termios) Cfsetspeed(__speed c.Uint) c.Int { + return 0 +} + +// Put the state of FD into *TERMIOS_P. +// +//go:linkname Tcgetattr C.tcgetattr +func Tcgetattr(__fd c.Int, __termios_p *Termios) c.Int + +// Set the state of FD to *TERMIOS_P. +// Values for OPTIONAL_ACTIONS (TCSA*) are in . +// +//go:linkname Tcsetattr C.tcsetattr +func Tcsetattr(__fd c.Int, __optional_actions c.Int, __termios_p *Termios) c.Int + +// Set *TERMIOS_P to indicate raw mode. +// +// llgo:link (*Termios).Cfmakeraw C.cfmakeraw +func (self *Termios) Cfmakeraw() { +} + +// Send zero bits on FD. +// +//go:linkname Tcsendbreak C.tcsendbreak +func Tcsendbreak(__fd c.Int, __duration c.Int) c.Int + +// Wait for pending output to be written on FD. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Tcdrain C.tcdrain +func Tcdrain(__fd c.Int) c.Int + +// Flush pending data on FD. +// Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in . +// +//go:linkname Tcflush C.tcflush +func Tcflush(__fd c.Int, __queue_selector c.Int) c.Int + +// Suspend or restart transmission on FD. +// Values for ACTION (TC[IO]{OFF,ON}) are in . +// +//go:linkname Tcflow C.tcflow +func Tcflow(__fd c.Int, __action c.Int) c.Int + +// Get process group ID for session leader for controlling terminal FD. +// +//go:linkname Tcgetsid C.tcgetsid +func Tcgetsid(__fd c.Int) c.Int + +// Standard file descriptors. +const ( + STDIN_FILENO = 0 + // Standard output. + STDOUT_FILENO = 1 + // Standard error output. + STDERR_FILENO = 2 +) + +// Test for access to NAME using the real UID and real GID. +// +//go:linkname Access C.access +func Access(__name *uint8, __type c.Int) c.Int + +// Test for access to FILE relative to the directory FD is open on. +// If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess', +// otherwise use real IDs like `access'. +// +//go:linkname NativeFaccessat C.faccessat +func NativeFaccessat(__fd c.Int, __file *uint8, __type c.Int, __flag c.Int) c.Int + +//go:linkname NativeLseek C.lseek +func NativeLseek(__fd c.Int, __offset c.Long, __whence c.Int) c.Long + +// NativeClose the file descriptor FD. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Close C.close +func Close(__fd c.Int) c.Int + +// NativeRead NBYTES into BUF from FD. Return the +// number read, -1 for errors or 0 for EOF. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeRead C.read +func NativeRead(__fd c.Int, __buf unsafe.Pointer, __nbytes c.SizeT) c.SsizeT + +// NativeWrite N bytes of BUF to FD. Return the number written, or -1. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeWrite C.write +func NativeWrite(__fd c.Int, __buf unsafe.Pointer, __n c.SizeT) c.SsizeT + +// Read NBYTES into BUF from FD at the given position OFFSET without +// changing the file pointer. Return the number read, -1 for errors +// or 0 for EOF. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pread C.pread +func Pread(__fd c.Int, __buf unsafe.Pointer, __nbytes c.SizeT, __offset c.Long) c.SsizeT + +// Write N bytes of BUF to FD at the given position OFFSET without +// changing the file pointer. Return the number written, or -1. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pwrite C.pwrite +func Pwrite(__fd c.Int, __buf unsafe.Pointer, __n c.SizeT, __offset c.Long) c.SsizeT + +// Create a one-way communication channel (pipe). +// If successful, two file descriptors are stored in PIPEDES; +// bytes written on PIPEDES[1] can be read from PIPEDES[0]. +// Returns 0 if successful, -1 if not. +// +//go:linkname NativePipe C.pipe +func NativePipe(__pipedes *c.Int) c.Int + +// Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. +// If SECONDS is zero, any currently scheduled alarm will be cancelled. +// The function returns the number of seconds remaining until the last +// alarm scheduled would have signaled, or zero if there wasn't one. +// There is no return value to indicate an error, but you can set `errno' +// to 0 and check its value after calling `alarm', and this might tell you. +// The signal may come late due to processor scheduling. +// +//go:linkname Alarm C.alarm +func Alarm(__seconds c.Uint) c.Uint + +// Make the process sleep for SECONDS seconds, or until a signal arrives +// and is not ignored. The function returns the number of seconds less +// than SECONDS which it actually slept (thus zero if it slept the full time). +// If a signal handler does a `longjmp' or modifies the handling of the +// SIGALRM signal while inside `sleep' call, the handling of the SIGALRM +// signal afterwards is undefined. There is no return value to indicate +// error, but if `sleep' returns SECONDS, it probably didn't work. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Sleep C.sleep +func Sleep(__seconds c.Uint) c.Uint + +// Set an alarm to go off (generating a SIGALRM signal) in VALUE +// microseconds. If INTERVAL is nonzero, when the alarm goes off, the +// timer is reset to go off every INTERVAL microseconds thereafter. +// Returns the number of microseconds remaining before the alarm. +// +//go:linkname Ualarm C.ualarm +func Ualarm(__value c.Uint, __interval c.Uint) c.Uint + +// Sleep USECONDS microseconds, or until a signal arrives that is not blocked +// or ignored. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Usleep C.usleep +func Usleep(__useconds c.Uint) c.Int + +// Suspend the process until a signal arrives. +// This always returns -1 and sets `errno' to EINTR. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pause C.pause +func Pause() c.Int + +// Change the owner and group of FILE. +// +//go:linkname NativeChown C.chown +func NativeChown(__file *uint8, __owner c.Uint, __group c.Uint) c.Int + +// Change the owner and group of the file that FD is open on. +// +//go:linkname NativeFchown C.fchown +func NativeFchown(__fd c.Int, __owner c.Uint, __group c.Uint) c.Int + +// Change owner and group of FILE, if it is a symbolic +// link the ownership of the symbolic link is changed. +// +//go:linkname NativeLchown C.lchown +func NativeLchown(__file *uint8, __owner c.Uint, __group c.Uint) c.Int + +// Change the owner and group of FILE relative to the directory FD is open +// on. +// +//go:linkname NativeFchownat C.fchownat +func NativeFchownat(__fd c.Int, __file *uint8, __owner c.Uint, __group c.Uint, __flag c.Int) c.Int + +// Change the process's working directory to PATH. +// +//go:linkname NativeChdir C.chdir +func NativeChdir(__path *uint8) c.Int + +// Change the process's working directory to the one FD is open on. +// +//go:linkname Fchdir C.fchdir +func Fchdir(__fd c.Int) c.Int + +// Get the pathname of the current working directory, +// and put it in SIZE bytes of BUF. Returns NULL if the +// directory couldn't be determined or SIZE was too small. +// If successful, returns BUF. In GNU, if BUF is NULL, +// an array is allocated with `malloc'; the array is SIZE +// bytes long, unless SIZE == 0, in which case it is as +// big as necessary. +// +//go:linkname NativeGetcwd C.getcwd +func NativeGetcwd(__buf *uint8, __size c.SizeT) *uint8 + +// Put the absolute pathname of the current working directory in BUF. +// If successful, return BUF. If not, put an error message in +// BUF and return NULL. BUF should be at least PATH_MAX bytes long. +// +//go:linkname Getwd C.getwd +func Getwd(__buf *uint8) *uint8 + +// Duplicate FD, returning a new file descriptor on the same file. +// +//go:linkname Dup C.dup +func Dup(__fd c.Int) c.Int + +// Duplicate FD to FD2, closing FD2 and making it open on the same file. +// +//go:linkname Dup2 C.dup2 +func Dup2(__fd c.Int, __fd2 c.Int) c.Int + +// Replace the current process, executing PATH with arguments ARGV and +// environment ENVP. ARGV and ENVP are terminated by NULL pointers. +// +//go:linkname NativeExecve C.execve +func NativeExecve(__path *uint8, __argv **uint8, __envp **uint8) c.Int + +// Execute the file FD refers to, overlaying the running program image. +// ARGV and ENVP are passed to the new program, as for `execve'. +// +//go:linkname Fexecve C.fexecve +func Fexecve(__fd c.Int, __argv **uint8, __envp **uint8) c.Int + +// Execute PATH with arguments ARGV and environment from `environ'. +// +//go:linkname NativeExecv C.execv +func NativeExecv(__path *uint8, __argv **uint8) c.Int + +// Execute PATH with all arguments after PATH until a NULL pointer, +// and the argument after that for environment. +// +//go:linkname NativeExecle C.execle +func NativeExecle(__path *uint8, __arg *uint8, __llgo_va_list ...any) c.Int + +// Execute PATH with all arguments after PATH until +// a NULL pointer and environment from `environ'. +// +//go:linkname NativeExecl C.execl +func NativeExecl(__path *uint8, __arg *uint8, __llgo_va_list ...any) c.Int + +// Execute FILE, searching in the `PATH' environment variable if it contains +// no slashes, with arguments ARGV and environment from `environ'. +// +//go:linkname NativeExecvp C.execvp +func NativeExecvp(__file *uint8, __argv **uint8) c.Int + +// Execute FILE, searching in the `PATH' environment variable if +// it contains no slashes, with all arguments after FILE until a +// NULL pointer and environment from `environ'. +// +//go:linkname NativeExeclp C.execlp +func NativeExeclp(__file *uint8, __arg *uint8, __llgo_va_list ...any) c.Int + +// Add INC to priority of the current process. +// +//go:linkname Nice C.nice +func Nice(__inc c.Int) c.Int + +// Terminate program execution with the low-order 8 bits of STATUS. +// +//go:linkname X_exit C._exit +func X_exit(__status c.Int) + +// Get file-specific configuration information about PATH. +// +//go:linkname Pathconf C.pathconf +func Pathconf(__path *uint8, __name c.Int) c.Long + +// Get file-specific configuration about descriptor FD. +// +//go:linkname Fpathconf C.fpathconf +func Fpathconf(__fd c.Int, __name c.Int) c.Long + +// Get the value of the system variable NAME. +// +//go:linkname Sysconf C.sysconf +func Sysconf(__name c.Int) c.Long + +// Get the value of the string-valued system variable NAME. +// +//go:linkname Confstr C.confstr +func Confstr(__name c.Int, __buf *uint8, __len c.SizeT) c.SizeT + +// Get the process ID of the calling process. +// +//go:linkname NativeGetpid C.getpid +func NativeGetpid() c.Int + +// Get the process ID of the calling process's parent. +// +//go:linkname NativeGetppid C.getppid +func NativeGetppid() c.Int + +// Get the process group ID of the calling process. +// +//go:linkname Getpgrp C.getpgrp +func Getpgrp() c.Int + +// Get the process group ID of process PID. +// +//go:linkname X__Getpgid C.__getpgid +func X__Getpgid(__pid c.Int) c.Int + +//go:linkname Getpgid C.getpgid +func Getpgid(__pid c.Int) c.Int + +// Set the process group ID of the process matching PID to PGID. +// If PID is zero, the current process's process group ID is set. +// If PGID is zero, the process ID of the process is used. +// +//go:linkname Setpgid C.setpgid +func Setpgid(__pid c.Int, __pgid c.Int) c.Int + +// Set the process group ID of the calling process to its own PID. +// This is exactly the same as `setpgid (0, 0)'. +// +//go:linkname Setpgrp C.setpgrp +func Setpgrp() c.Int + +// Create a new session with the calling process as its leader. +// The process group IDs of the session and the calling process +// are set to the process ID of the calling process, which is returned. +// +//go:linkname Setsid C.setsid +func Setsid() c.Int + +// Return the session ID of the given process. +// +//go:linkname Getsid C.getsid +func Getsid(__pid c.Int) c.Int + +// Get the real user ID of the calling process. +// +//go:linkname NativeGetuid C.getuid +func NativeGetuid() c.Uint + +// Get the effective user ID of the calling process. +// +//go:linkname NativeGeteuid C.geteuid +func NativeGeteuid() c.Uint + +// Get the real group ID of the calling process. +// +//go:linkname NativeGetgid C.getgid +func NativeGetgid() c.Uint + +// Get the effective group ID of the calling process. +// +//go:linkname NativeGetegid C.getegid +func NativeGetegid() c.Uint + +// If SIZE is zero, return the number of supplementary groups +// the calling process is in. Otherwise, fill in the group IDs +// of its supplementary groups in LIST and return the number written. +// +//go:linkname Getgroups C.getgroups +func Getgroups(__size c.Int, __list *c.Uint) c.Int + +// Set the user ID of the calling process to UID. +// If the calling process is the super-user, set the real +// and effective user IDs, and the saved set-user-ID to UID; +// if not, the effective user ID is set to UID. +// +//go:linkname Setuid C.setuid +func Setuid(__uid c.Uint) c.Int + +// Set the real user ID of the calling process to RUID, +// and the effective user ID of the calling process to EUID. +// +//go:linkname Setreuid C.setreuid +func Setreuid(__ruid c.Uint, __euid c.Uint) c.Int + +// Set the effective user ID of the calling process to UID. +// +//go:linkname Seteuid C.seteuid +func Seteuid(__uid c.Uint) c.Int + +// Set the group ID of the calling process to GID. +// If the calling process is the super-user, set the real +// and effective group IDs, and the saved set-group-ID to GID; +// if not, the effective group ID is set to GID. +// +//go:linkname Setgid C.setgid +func Setgid(__gid c.Uint) c.Int + +// Set the real group ID of the calling process to RGID, +// and the effective group ID of the calling process to EGID. +// +//go:linkname Setregid C.setregid +func Setregid(__rgid c.Uint, __egid c.Uint) c.Int + +// Set the effective group ID of the calling process to GID. +// +//go:linkname Setegid C.setegid +func Setegid(__gid c.Uint) c.Int + +// Clone the calling process, creating an exact copy. +// Return -1 for errors, 0 to the new process, +// and the process ID of the new process to the old process. +// +//go:linkname NativeFork C.fork +func NativeFork() c.Int + +// Clone the calling process, but without copying the whole address space. +// The calling process is suspended until the new process exits or is +// replaced by a call to `execve'. Return -1 for errors, 0 to the new process, +// and the process ID of the new process to the old process. +// +//go:linkname Vfork C.vfork +func Vfork() c.Int + +// Return the pathname of the terminal FD is open on, or NULL on errors. +// The returned storage is good only until the next call to this function. +// +//go:linkname Ttyname C.ttyname +func Ttyname(__fd c.Int) *uint8 + +// Store at most BUFLEN characters of the pathname of the terminal FD is +// open on in BUF. Return 0 on success, otherwise an error number. +// +//go:linkname TtynameR C.ttyname_r +func TtynameR(__fd c.Int, __buf *uint8, __buflen c.SizeT) c.Int + +// Return 1 if FD is a valid descriptor associated +// with a terminal, zero if not. +// +//go:linkname Isatty C.isatty +func Isatty(__fd c.Int) c.Int + +// Return the index into the active-logins file (utmp) for +// the controlling terminal. +// +//go:linkname Ttyslot C.ttyslot +func Ttyslot() c.Int + +// Make a link to FROM named TO. +// +//go:linkname NativeLink C.link +func NativeLink(__from *uint8, __to *uint8) c.Int + +// Like link but relative paths in TO and FROM are interpreted relative +// to FROMFD and TOFD respectively. +// +//go:linkname Linkat C.linkat +func Linkat(__fromfd c.Int, __from *uint8, __tofd c.Int, __to *uint8, __flags c.Int) c.Int + +// Make a symbolic link to FROM named TO. +// +//go:linkname NativeSymlink C.symlink +func NativeSymlink(__from *uint8, __to *uint8) c.Int + +// Read the contents of the symbolic link PATH into no more than +// LEN bytes of BUF. The contents are not null-terminated. +// Returns the number of characters read, or -1 for errors. +// +//go:linkname NativeReadlink C.readlink +func NativeReadlink(__path *uint8, __buf *uint8, __len c.SizeT) c.SsizeT + +// Like symlink but a relative path in TO is interpreted relative to TOFD. +// +//go:linkname Symlinkat C.symlinkat +func Symlinkat(__from *uint8, __tofd c.Int, __to *uint8) c.Int + +// Like readlink but a relative PATH is interpreted relative to FD. +// +//go:linkname Readlinkat C.readlinkat +func Readlinkat(__fd c.Int, __path *uint8, __buf *uint8, __len c.SizeT) c.SsizeT + +// Remove the link NAME. +// +//go:linkname NativeUnlink C.unlink +func NativeUnlink(__name *uint8) c.Int + +// Remove the link NAME relative to FD. +// +//go:linkname NativeUnlinkat C.unlinkat +func NativeUnlinkat(__fd c.Int, __name *uint8, __flag c.Int) c.Int + +// Remove the directory PATH. +// +//go:linkname NativeRmdir C.rmdir +func NativeRmdir(__path *uint8) c.Int + +// Return the foreground process group ID of FD. +// +//go:linkname Tcgetpgrp C.tcgetpgrp +func Tcgetpgrp(__fd c.Int) c.Int + +// Set the foreground process group ID of FD set PGRP_ID. +// +//go:linkname Tcsetpgrp C.tcsetpgrp +func Tcsetpgrp(__fd c.Int, __pgrp_id c.Int) c.Int + +// Return the login name of the user. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname Getlogin C.getlogin +func Getlogin() *uint8 + +// Return at most NAME_LEN characters of the login name of the user in NAME. +// If it cannot be determined or some other error occurred, return the error +// code. Otherwise return 0. +// +// This function is a possible cancellation point and therefore not +// marked with __THROW. +// +//go:linkname GetloginR C.getlogin_r +func GetloginR(__name *uint8, __name_len c.SizeT) c.Int + +// Set the login name returned by `getlogin'. +// +//go:linkname Setlogin C.setlogin +func Setlogin(__name *uint8) c.Int + +// Put the name of the current host in no more than LEN bytes of NAME. +// The result is null-terminated if LEN is large enough for the full +// name and the terminator. +// +//go:linkname Gethostname C.gethostname +func Gethostname(__name *uint8, __len c.SizeT) c.Int + +// Set the name of the current host to NAME, which is LEN bytes long. +// This call is restricted to the super-user. +// +//go:linkname Sethostname C.sethostname +func Sethostname(__name *uint8, __len c.SizeT) c.Int + +// Set the current machine's Internet number to ID. +// This call is restricted to the super-user. +// +//go:linkname Sethostid C.sethostid +func Sethostid(__id c.Long) c.Int + +// Get and set the NIS (aka YP) domain name, if any. +// Called just like `gethostname' and `sethostname'. +// The NIS domain name is usually the empty string when not using NIS. +// +//go:linkname Getdomainname C.getdomainname +func Getdomainname(__name *uint8, __len c.SizeT) c.Int + +// Ignore +// +//go:linkname Setdomainname C.setdomainname +func Setdomainname(__name *uint8, __len c.SizeT) c.Int + +// Revoke access permissions to all processes currently communicating +// with the control terminal, and then send a SIGHUP signal to the process +// group of the control terminal. +// +//go:linkname Vhangup C.vhangup +func Vhangup() c.Int + +// Revoke the access of all descriptors currently open on FILE. +// +//go:linkname Revoke C.revoke +func Revoke(__file *uint8) c.Int + +// Enable statistical profiling, writing samples of the PC into at most +// SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling +// is enabled, the system examines the user PC and increments +// SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero, +// disable profiling. Returns zero on success, -1 on error. +// +//go:linkname Profil C.profil +func Profil(__sample_buffer *uint16, __size c.SizeT, __offset c.SizeT, __scale c.Uint) c.Int + +// Turn accounting on if NAME is an existing file. The system will then write +// a record for each process as it terminates, to this file. If NAME is NULL, +// turn accounting off. This call is restricted to the super-user. +// +//go:linkname Acct C.acct +func Acct(__name *uint8) c.Int + +// Successive calls return the shells listed in `/etc/shells'. +// +//go:linkname Getusershell C.getusershell +func Getusershell() *uint8 + +// Discard cached info. +// +//go:linkname Endusershell C.endusershell +func Endusershell() + +// Rewind and re-read the file. +// +//go:linkname Setusershell C.setusershell +func Setusershell() + +// Put the program in the background, and dissociate from the controlling +// terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, +// redirects stdin, stdout, and stderr to /dev/null. +// +//go:linkname Daemon C.daemon +func Daemon(__nochdir c.Int, __noclose c.Int) c.Int + +// Make PATH be the root directory (the starting point for absolute paths). +// This call is restricted to the super-user. +// +//go:linkname NativeChroot C.chroot +func NativeChroot(__path *uint8) c.Int + +// Prompt with PROMPT and read a string from the terminal without echoing. +// Uses /dev/tty if possible; otherwise stderr and stdin. +// +//go:linkname Getpass C.getpass +func Getpass(__prompt *uint8) *uint8 + +// Make all changes done to FD actually appear on disk. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Fsync C.fsync +func Fsync(__fd c.Int) c.Int + +// Return identifier for the current host. +// +//go:linkname Gethostid C.gethostid +func Gethostid() c.Long + +// Make all changes done to all files actually appear on disk. +// +//go:linkname Sync C.sync +func Sync() + +// Return the number of bytes in a page. This is the system's page size, +// which is not necessarily the same as the hardware page size. +// +//go:linkname Getpagesize C.getpagesize +func Getpagesize() c.Int + +// Return the maximum number of file descriptors +// the current process could possibly have. +// +//go:linkname Getdtablesize C.getdtablesize +func Getdtablesize() c.Int + +// Ignore +// +//go:linkname NativeTruncate C.truncate +func NativeTruncate(__file *uint8, __length c.Long) c.Int + +// Ignore +// +//go:linkname NativeFtruncate C.ftruncate +func NativeFtruncate(__fd c.Int, __length c.Long) c.Int + +// Set the end of accessible data space (aka "the break") to ADDR. +// Returns zero on success and -1 for errors (with errno set). +// +//go:linkname Brk C.brk +func Brk(__addr unsafe.Pointer) c.Int + +// Increase or decrease the end of accessible data space by DELTA bytes. +// If successful, returns the address the previous end of data space +// (i.e. the beginning of the new space, if DELTA > 0); +// returns (void *) -1 for errors (with errno set). +// +//go:linkname Sbrk C.sbrk +func Sbrk(__delta c.IntptrT) unsafe.Pointer + +// Invoke `system call' number SYSNO, passing it the remaining arguments. +// This is completely system-dependent, and not often useful. +// +// In Unix, `syscall' sets `errno' for all errors and most calls return -1 +// for errors; in many systems you cannot pass arguments or get return +// values for all system calls (`pipe', `fork', and `getppid' typically +// among them). +// +// In Mach, all system calls take normal arguments and always return an +// error code (zero for success). +// +//go:linkname Syscall C.syscall +func Syscall(__sysno c.Long, __llgo_va_list ...any) c.Long + +// Synchronize at least the data part of a file with the underlying +// media. +// +//go:linkname Fdatasync C.fdatasync +func Fdatasync(__fildes c.Int) c.Int + +// Structure describing file times. +type Utimbuf struct { + Actime c.Long + Modtime c.Long +} + +// Set the access and modification times of FILE to those given in +// FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. +// +//go:linkname Utime C.utime +func Utime(__file *uint8, __file_times *Utimbuf) c.Int + +type Dirent struct { + DIno c.Ulong + DOff c.Long + DReclen uint16 + DType uint8 + DName [256]uint8 +} + +const ( + EAGAIN = 11 + F_GETFL = 3 + F_SETFL = 4 + O_ACCMODE = 3 + O_CREAT = 64 + O_NONBLOCK = 2048 + O_RDONLY = 0 + O_RDWR = 2 + O_TRUNC = 512 + O_WRONLY = 1 +) diff --git a/c/os/llcppg.cfg b/c/os/llcppg.cfg new file mode 100644 index 00000000..75e27be3 --- /dev/null +++ b/c/os/llcppg.cfg @@ -0,0 +1,3 @@ +{ + "Dir": ".sysroot/include" +} diff --git a/c/os/llcppg.pub b/c/os/llcppg.pub index 53cba11f..d82882cd 100644 --- a/c/os/llcppg.pub +++ b/c/os/llcppg.pub @@ -1,7 +1,88 @@ -T mode_t ModeT -T uid_t UidT +D github.com/goplus/lib/c/signal +D github.com/goplus/lib/c/sys +D github.com/goplus/lib/c/time +T DIR DIR +T Dl_info DlInfo +T __caddr_t X__CaddrT +T __darwin_uuid_string_t X__DarwinUuidStringT +T __darwin_uuid_t X__DarwinUuidT +T __dirstream X__Dirstream +T __fsid_t X__FsidT +T __spawn_action X__SpawnAction +T _filesec X_filesec +T _telldir X_telldir +T accessx_descriptor AccessxDescriptor +T caddr_t CaddrT +T dev_t DevT +T dirent Dirent +T dl_info DlInfo +T fattributiontag Fattributiontag +T fattributiontag_t FattributiontagT +T fchecklv Fchecklv +T fchecklv_t FchecklvT +T fgetsigsinfo Fgetsigsinfo +T fgetsigsinfo_t FgetsigsinfoT +T filesec_property_t FilesecPropertyT +T filesec_t FilesecT +T flock FlockT +T flocktimeout Flocktimeout +T fpunchhole Fpunchhole +T fpunchhole_t FpunchholeT +T fsid Fsid +T fsid_t FsidT +T fsignatures Fsignatures +T fsignatures_t FsignaturesT +T fspecread Fspecread +T fspecread_t FspecreadT +T fssearchblock Fssearchblock +T fstore Fstore +T fstore_t FstoreT +T fsupplement Fsupplement +T fsupplement_t FsupplementT +T ftrimactivefile Ftrimactivefile +T ftrimactivefile_t FtrimactivefileT T gid_t GidT +T glob_t GlobT +T group Group +T idtype_t IdtypeT +T kauth_cred_t KauthCredT +T mach_msg_header_t MachMsgHeaderT +T mach_port_t MachPortT +T mode_t ModeT T off_t OffT -T dev_t DevT -T stat StatT +T ostat Ostat +T passwd Passwd T pid_t PidT +T pollfd Pollfd +T posix_cred PosixCred +T posix_cred_t PosixCredT +T posix_spawn_file_actions_t PosixSpawnFileActionsT +T posix_spawnattr_t PosixSpawnattrT +T proc_rlimit_control_wakeupmon ProcRlimitControlWakeupmon +T qaddr_t QaddrT +T radvisory Radvisory +T rlimit Rlimit +T rusage Rusage +T rusage_info_current RusageInfoCurrent +T rusage_info_t RusageInfoT +T rusage_info_v0 RusageInfoV0 +T rusage_info_v1 RusageInfoV1 +T rusage_info_v2 RusageInfoV2 +T rusage_info_v3 RusageInfoV3 +T rusage_info_v4 RusageInfoV4 +T rusage_info_v5 RusageInfoV5 +T rusage_info_v6 RusageInfoV6 +T sched_param SchedParam +T searchstate Searchstate +T semaphore_t SemaphoreT +T stat StatT +T statvfs StatvfsT +T termios Termios +T tms Tms +T ucred Ucred +T uid_t UidT +T uio_rw UioRw +T utimbuf Utimbuf +T utsname Utsname +T uuid_string_t UuidStringT +T uuid_t UuidT diff --git a/c/os/native_files_darwin_other.go b/c/os/native_files_darwin_other.go new file mode 100644 index 00000000..75b7eafa --- /dev/null +++ b/c/os/native_files_darwin_other.go @@ -0,0 +1,5 @@ +//go:build darwin && (!arm64 || ios) + +package os + +const LLGoFiles = llgoLegacyFilesDarwin diff --git a/c/os/os.go b/c/os/os.go index 00ba8353..18e1048e 100644 --- a/c/os/os.go +++ b/c/os/os.go @@ -95,9 +95,6 @@ func Unsetenv(name *c.Char) c.Int // ----------------------------------------------------------------------------- -//go:linkname Fchdir C.fchdir -func Fchdir(dirfd c.Int) c.Int - //go:linkname Faccessat C.faccessat func Faccessat(dirfd c.Int, path *c.Char, mode c.Int, flags c.Int) c.Int @@ -115,12 +112,6 @@ func Openat(dirfd c.Int, path *c.Char, flags c.Int, mode ModeT) c.Int //go:linkname Creat C.creat func Creat(path *c.Char, mode ModeT) c.Int -//go:linkname Dup C.dup -func Dup(fd c.Int) c.Int - -//go:linkname Dup2 C.dup2 -func Dup2(oldfd c.Int, newfd c.Int) c.Int - //go:linkname Dup3 C.dup3 func Dup3(oldfd c.Int, newfd c.Int, flags c.Int) c.Int @@ -133,9 +124,6 @@ func Mknod(path *c.Char, mode ModeT, dev DevT) c.Int //go:linkname Lseek C.lseek func Lseek(fd c.Int, offset OffT, whence c.Int) OffT -//go:linkname Fsync C.fsync -func Fsync(fd c.Int) c.Int - //go:linkname Ftruncate C.ftruncate func Ftruncate(fd c.Int, length OffT) c.Int @@ -145,9 +133,6 @@ func Fchmod(fd c.Int, mode ModeT) c.Int //go:linkname Fchown C.fchown func Fchown(fd c.Int, owner UidT, group GidT) c.Int -//go:linkname Isatty C.isatty -func Isatty(fd c.Int) c.Int - // ----------------------------------------------------------------------------- // Execl(const char *path, const char *arg0, ..., /*, (char *)0, */) @@ -194,12 +179,6 @@ func Getppid() PidT // values for all system calls (`pipe', `fork', and `getppid' typically // among them). -// In Mach, all system calls take normal arguments and always return an -// error code (zero for success). -// -//go:linkname Syscall C.syscall -func Syscall(sysno c.Long, __llgo_va_list ...any) c.Long - // If wait() returns due to a stopped or terminated child process, the process ID // of the child is returned to the calling process. Otherwise, a value of -1 is // returned and errno is set to indicate the error. diff --git a/c/os/os_darwin.go b/c/os/os_darwin.go index b9ca31ea..a00311ac 100644 --- a/c/os/os_darwin.go +++ b/c/os/os_darwin.go @@ -23,8 +23,8 @@ import ( ) const ( - LLGoFiles = "_os/os.c" - LLGoPackage = "link" + llgoLegacyFilesDarwin = "_os/os.c" + LLGoPackage = "link" ) const (