From f03b950bb7ef168337a716f47e157bea3c299397 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 13:57:15 +0800 Subject: [PATCH 1/6] feat(c/sys): publish native system type mappings --- c/sys/llcppg.pub | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 c/sys/llcppg.pub diff --git a/c/sys/llcppg.pub b/c/sys/llcppg.pub new file mode 100644 index 00000000..f55888e6 --- /dev/null +++ b/c/sys/llcppg.pub @@ -0,0 +1,3 @@ +D github.com/goplus/lib/c +T fd_set FdSet +T timeval Timeval From 4058749b0c7a00bab16011809ea99d93a63ba3ff Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 17:46:26 +0800 Subject: [PATCH 2/6] Regenerate c/sys independently with native platform inputs --- c/sys/arm-_types_darwin_arm64.go | 64 +++++++++++ c/sys/bits-select_linux_amd64.go | 7 ++ c/sys/bits-time_linux_amd64.go | 10 ++ c/sys/bits-time_linux_arm64.go | 10 ++ c/sys/bits-types_linux_amd64.go | 133 +++++++++++++++++++++++ c/sys/bits-types_linux_arm64.go | 133 +++++++++++++++++++++++ c/sys/llcppg-linux_amd64.cfg | 21 ++++ c/sys/llcppg-linux_arm64.cfg | 21 ++++ c/sys/llcppg.cfg | 21 ++++ c/sys/llcppg.pub | 93 +++++++++++++++- c/sys/sys-_types-_fd_def_darwin_arm64.go | 18 +++ c/sys/sys-_types_darwin_arm64.go | 63 +++++++++++ c/sys/sys-select_darwin_arm64.go | 15 +++ c/sys/sys-select_linux_amd64.go | 34 ++++++ c/sys/sys-select_linux_arm64.go | 34 ++++++ 15 files changed, 676 insertions(+), 1 deletion(-) create mode 100644 c/sys/arm-_types_darwin_arm64.go create mode 100644 c/sys/bits-select_linux_amd64.go create mode 100644 c/sys/bits-time_linux_amd64.go create mode 100644 c/sys/bits-time_linux_arm64.go create mode 100644 c/sys/bits-types_linux_amd64.go create mode 100644 c/sys/bits-types_linux_arm64.go create mode 100644 c/sys/llcppg-linux_amd64.cfg create mode 100644 c/sys/llcppg-linux_arm64.cfg create mode 100644 c/sys/llcppg.cfg create mode 100644 c/sys/sys-_types-_fd_def_darwin_arm64.go create mode 100644 c/sys/sys-_types_darwin_arm64.go create mode 100644 c/sys/sys-select_darwin_arm64.go create mode 100644 c/sys/sys-select_linux_amd64.go create mode 100644 c/sys/sys-select_linux_arm64.go diff --git a/c/sys/arm-_types_darwin_arm64.go b/c/sys/arm-_types_darwin_arm64.go new file mode 100644 index 00000000..61c413d4 --- /dev/null +++ b/c/sys/arm-_types_darwin_arm64.go @@ -0,0 +1,64 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +type X__MbstateT struct { + _xgo_union [16]uint64 +} +type X__Int8T = int8 +type X__Uint8T = uint8 +type X__Int16T = int16 +type X__Uint16T = uint16 +type X__Int32T = c.Int +type X__Uint32T = c.Uint +type X__Int64T = c.LongLong +type X__Uint64T = c.UlongLong +type X__DarwinIntptrT = c.Long +type X__DarwinNaturalT = c.Uint + +// ct_rune_t +type X__DarwinCtRuneT = c.Int + +// mbstate_t +type X__DarwinMbstateT = X__MbstateT + +// ptr1 - ptr2 +type X__DarwinPtrdiffT = c.Long + +// sizeof() +type X__DarwinSizeT = c.Ulong + +// wchar_t +type X__DarwinWcharT = c.Int + +// rune_t +type X__DarwinRuneT = X__DarwinWcharT + +// wint_t +type X__DarwinWintT = c.Int + +// clock() +type X__DarwinClockT = c.Ulong + +// socklen_t (duh) +type X__DarwinSocklenT = X__Uint32T + +// byte count or error +type X__DarwinSsizeT = c.Long + +// time() +type X__DarwinTimeT = c.Long + +func (p *X__MbstateT) XGof_ref___mbstate8() *[128]c.Char { + return (*[128]c.Char)(unsafe.Pointer(p)) +} +func (p *X__MbstateT) XGof_ref__mbstateL() *c.LongLong { + return (*c.LongLong)(unsafe.Pointer(p)) +} diff --git a/c/sys/bits-select_linux_amd64.go b/c/sys/bits-select_linux_amd64.go new file mode 100644 index 00000000..97debebc --- /dev/null +++ b/c/sys/bits-select_linux_amd64.go @@ -0,0 +1,7 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +const X__FD_ZERO_STOS = "stosq" diff --git a/c/sys/bits-time_linux_amd64.go b/c/sys/bits-time_linux_amd64.go new file mode 100644 index 00000000..11589680 --- /dev/null +++ b/c/sys/bits-time_linux_amd64.go @@ -0,0 +1,10 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +const X_STRUCT_TIMEVAL = 1 + +// A time value that is accurate to the nearest +// microsecond but also has a range of years. diff --git a/c/sys/bits-time_linux_arm64.go b/c/sys/bits-time_linux_arm64.go new file mode 100644 index 00000000..2a661a7e --- /dev/null +++ b/c/sys/bits-time_linux_arm64.go @@ -0,0 +1,10 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +const X_STRUCT_TIMEVAL = 1 + +// A time value that is accurate to the nearest +// microsecond but also has a range of years. diff --git a/c/sys/bits-types_linux_amd64.go b/c/sys/bits-types_linux_amd64.go new file mode 100644 index 00000000..a538e871 --- /dev/null +++ b/c/sys/bits-types_linux_amd64.go @@ -0,0 +1,133 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import "github.com/goplus/lib/c" + +const X_BITS_TYPES_H = 1 + +type X__FsidT struct { + X__Val [2]c.Int +} + +// Convenience types. +type X__UChar = uint8 +type X__UShort = uint16 +type X__UInt = c.Uint +type X__ULong = c.Ulong + +// Fixed-size types, underlying types depend on word size and compiler. +type X__Int8T = int8 +type X__Uint8T = uint8 +type X__Int16T = int16 +type X__Uint16T = uint16 +type X__Int32T = c.Int +type X__Uint32T = c.Uint +type X__Int64T = c.Long +type X__Uint64T = c.Ulong +type X__QuadT = c.Long +type X__UQuadT = c.Ulong + +// Type of device numbers. +type X__DevT = c.Ulong + +// Type of user identifications. +type X__UidT = c.Uint + +// Type of group identifications. +type X__GidT = c.Uint + +// Type of file serial numbers. +type X__InoT = c.Ulong + +// Type of file serial numbers (LFS). +type X__Ino64T = c.Ulong + +// Type of file attribute bitmasks. +type X__ModeT = c.Uint + +// Type of file link counts. +type X__NlinkT = c.Ulong + +// Type of file sizes and offsets. +type X__OffT = c.Long + +// Type of file sizes and offsets (LFS). +type X__Off64T = c.Long + +// Type of process identifications. +type X__PidT = c.Int + +// Type of CPU usage counts. +type X__ClockT = c.Long + +// Type for resource measurement. +type X__RlimT = c.Ulong + +// Type for resource measurement (LFS). +type X__Rlim64T = c.Ulong + +// General type for IDs. +type X__IdT = c.Uint + +// Seconds since the Epoch. +type X__TimeT = c.Long + +// Count of microseconds. +type X__UsecondsT = c.Uint + +// Signed count of microseconds. +type X__SusecondsT = c.Long + +// The type of a disk address. +type X__DaddrT = c.Int + +// Type of an IPC key. +type X__KeyT = c.Int + +// Clock ID used in clock and timer functions. +type X__ClockidT = c.Int + +// Timer ID returned by `timer_create'. +type X__TimerT uintptr + +// Type to represent block size. +type X__BlksizeT = c.Long + +// Type to count number of disk blocks. +type X__BlkcntT = c.Long +type X__Blkcnt64T = c.Long + +// Type to count file system blocks. +type X__FsblkcntT = c.Ulong +type X__Fsblkcnt64T = c.Ulong + +// Type to count file system nodes. +type X__FsfilcntT = c.Ulong +type X__Fsfilcnt64T = c.Ulong + +// Type of miscellaneous file system fields. +type X__FswordT = c.Long + +// Type of a byte count, or error. +type X__SsizeT = c.Long + +// Signed long type used in system calls. +type X__SyscallSlongT = c.Long + +// Unsigned long type used in system calls. +type X__SyscallUlongT = c.Ulong + +// These few don't really vary by system, they always correspond +// to one of the other defined types. +type X__LoffT = X__Off64T +type X__QaddrT = *X__QuadT +type X__CaddrT = *c.Char + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__IntptrT = c.Long + +// Duplicate info from sys/socket.h. +type X__SocklenT = c.Uint diff --git a/c/sys/bits-types_linux_arm64.go b/c/sys/bits-types_linux_arm64.go new file mode 100644 index 00000000..ef28c63d --- /dev/null +++ b/c/sys/bits-types_linux_arm64.go @@ -0,0 +1,133 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import "github.com/goplus/lib/c" + +const X_BITS_TYPES_H = 1 + +type X__FsidT struct { + X__Val [2]c.Int +} + +// Convenience types. +type X__UChar = uint8 +type X__UShort = uint16 +type X__UInt = c.Uint +type X__ULong = c.Ulong + +// Fixed-size types, underlying types depend on word size and compiler. +type X__Int8T = int8 +type X__Uint8T = uint8 +type X__Int16T = int16 +type X__Uint16T = uint16 +type X__Int32T = c.Int +type X__Uint32T = c.Uint +type X__Int64T = c.Long +type X__Uint64T = c.Ulong +type X__QuadT = c.Long +type X__UQuadT = c.Ulong + +// Type of device numbers. +type X__DevT = c.Ulong + +// Type of user identifications. +type X__UidT = c.Uint + +// Type of group identifications. +type X__GidT = c.Uint + +// Type of file serial numbers. +type X__InoT = c.Ulong + +// Type of file serial numbers (LFS). +type X__Ino64T = c.Ulong + +// Type of file attribute bitmasks. +type X__ModeT = c.Uint + +// Type of file link counts. +type X__NlinkT = c.Uint + +// Type of file sizes and offsets. +type X__OffT = c.Long + +// Type of file sizes and offsets (LFS). +type X__Off64T = c.Long + +// Type of process identifications. +type X__PidT = c.Int + +// Type of CPU usage counts. +type X__ClockT = c.Long + +// Type for resource measurement. +type X__RlimT = c.Ulong + +// Type for resource measurement (LFS). +type X__Rlim64T = c.Ulong + +// General type for IDs. +type X__IdT = c.Uint + +// Seconds since the Epoch. +type X__TimeT = c.Long + +// Count of microseconds. +type X__UsecondsT = c.Uint + +// Signed count of microseconds. +type X__SusecondsT = c.Long + +// The type of a disk address. +type X__DaddrT = c.Int + +// Type of an IPC key. +type X__KeyT = c.Int + +// Clock ID used in clock and timer functions. +type X__ClockidT = c.Int + +// Timer ID returned by `timer_create'. +type X__TimerT uintptr + +// Type to represent block size. +type X__BlksizeT = c.Int + +// Type to count number of disk blocks. +type X__BlkcntT = c.Long +type X__Blkcnt64T = c.Long + +// Type to count file system blocks. +type X__FsblkcntT = c.Ulong +type X__Fsblkcnt64T = c.Ulong + +// Type to count file system nodes. +type X__FsfilcntT = c.Ulong +type X__Fsfilcnt64T = c.Ulong + +// Type of miscellaneous file system fields. +type X__FswordT = c.Long + +// Type of a byte count, or error. +type X__SsizeT = c.Long + +// Signed long type used in system calls. +type X__SyscallSlongT = c.Long + +// Unsigned long type used in system calls. +type X__SyscallUlongT = c.Ulong + +// These few don't really vary by system, they always correspond +// to one of the other defined types. +type X__LoffT = X__Off64T +type X__QaddrT = *X__QuadT +type X__CaddrT = *uint8 + +// Duplicates info from stdint.h but this is used in unistd.h. +type X__IntptrT = c.Long + +// Duplicate info from sys/socket.h. +type X__SocklenT = c.Uint diff --git a/c/sys/llcppg-linux_amd64.cfg b/c/sys/llcppg-linux_amd64.cfg new file mode 100644 index 00000000..e88da7cc --- /dev/null +++ b/c/sys/llcppg-linux_amd64.cfg @@ -0,0 +1,21 @@ +{ + "Name": "sys", + "Language": "c", + "Dir": ".sysroot/include", + "Stdlib": ".sysroot/stdlib", + "Files": [ + "llcppg.h" + ], + "Deps": [ + "..", + "../time", + "../signal" + ], + "FailFast": 0, + "FuncIgnore": [ + "select" + ], + "TypeIgnore": [ + "va_list" + ] +} diff --git a/c/sys/llcppg-linux_arm64.cfg b/c/sys/llcppg-linux_arm64.cfg new file mode 100644 index 00000000..e88da7cc --- /dev/null +++ b/c/sys/llcppg-linux_arm64.cfg @@ -0,0 +1,21 @@ +{ + "Name": "sys", + "Language": "c", + "Dir": ".sysroot/include", + "Stdlib": ".sysroot/stdlib", + "Files": [ + "llcppg.h" + ], + "Deps": [ + "..", + "../time", + "../signal" + ], + "FailFast": 0, + "FuncIgnore": [ + "select" + ], + "TypeIgnore": [ + "va_list" + ] +} diff --git a/c/sys/llcppg.cfg b/c/sys/llcppg.cfg new file mode 100644 index 00000000..e88da7cc --- /dev/null +++ b/c/sys/llcppg.cfg @@ -0,0 +1,21 @@ +{ + "Name": "sys", + "Language": "c", + "Dir": ".sysroot/include", + "Stdlib": ".sysroot/stdlib", + "Files": [ + "llcppg.h" + ], + "Deps": [ + "..", + "../time", + "../signal" + ], + "FailFast": 0, + "FuncIgnore": [ + "select" + ], + "TypeIgnore": [ + "va_list" + ] +} diff --git a/c/sys/llcppg.pub b/c/sys/llcppg.pub index f55888e6..75ecb6c7 100644 --- a/c/sys/llcppg.pub +++ b/c/sys/llcppg.pub @@ -1,3 +1,94 @@ -D github.com/goplus/lib/c +D github.com/goplus/lib/c/signal +D github.com/goplus/lib/c/time +T __blkcnt64_t X__Blkcnt64T +T __blkcnt_t X__BlkcntT +T __blksize_t X__BlksizeT +T __caddr_t X__CaddrT +T __clock_t X__ClockT +T __clockid_t X__ClockidT +T __daddr_t X__DaddrT +T __darwin_blkcnt_t X__DarwinBlkcntT +T __darwin_blksize_t X__DarwinBlksizeT +T __darwin_clock_t X__DarwinClockT +T __darwin_ct_rune_t X__DarwinCtRuneT +T __darwin_dev_t X__DarwinDevT +T __darwin_fsblkcnt_t X__DarwinFsblkcntT +T __darwin_fsfilcnt_t X__DarwinFsfilcntT +T __darwin_gid_t X__DarwinGidT +T __darwin_id_t X__DarwinIdT +T __darwin_ino64_t X__DarwinIno64T +T __darwin_ino_t X__DarwinInoT +T __darwin_intptr_t X__DarwinIntptrT +T __darwin_mach_port_name_t X__DarwinMachPortNameT +T __darwin_mach_port_t X__DarwinMachPortT +T __darwin_mbstate_t X__DarwinMbstateT +T __darwin_mode_t X__DarwinModeT +T __darwin_natural_t X__DarwinNaturalT +T __darwin_off_t X__DarwinOffT +T __darwin_pid_t X__DarwinPidT +T __darwin_ptrdiff_t X__DarwinPtrdiffT +T __darwin_rune_t X__DarwinRuneT +T __darwin_sigset_t X__DarwinSigsetT +T __darwin_size_t X__DarwinSizeT +T __darwin_socklen_t X__DarwinSocklenT +T __darwin_ssize_t X__DarwinSsizeT +T __darwin_suseconds_t X__DarwinSusecondsT +T __darwin_time_t X__DarwinTimeT +T __darwin_uid_t X__DarwinUidT +T __darwin_useconds_t X__DarwinUsecondsT +T __darwin_uuid_string_t X__DarwinUuidStringT +T __darwin_uuid_t X__DarwinUuidT +T __darwin_wchar_t X__DarwinWcharT +T __darwin_wint_t X__DarwinWintT +T __dev_t X__DevT +T __fd_mask X__FdMask +T __fsblkcnt64_t X__Fsblkcnt64T +T __fsblkcnt_t X__FsblkcntT +T __fsfilcnt64_t X__Fsfilcnt64T +T __fsfilcnt_t X__FsfilcntT +T __fsid_t X__FsidT +T __fsword_t X__FswordT +T __gid_t X__GidT +T __id_t X__IdT +T __ino64_t X__Ino64T +T __ino_t X__InoT +T __int16_t X__Int16T +T __int32_t X__Int32T +T __int64_t X__Int64T +T __int8_t X__Int8T +T __intptr_t X__IntptrT +T __key_t X__KeyT +T __loff_t X__LoffT +T __mbstate_t X__MbstateT +T __mode_t X__ModeT +T __nlink_t X__NlinkT +T __off64_t X__Off64T +T __off_t X__OffT +T __pid_t X__PidT +T __qaddr_t X__QaddrT +T __quad_t X__QuadT +T __rlim64_t X__Rlim64T +T __rlim_t X__RlimT +T __socklen_t X__SocklenT +T __ssize_t X__SsizeT +T __suseconds_t X__SusecondsT +T __syscall_slong_t X__SyscallSlongT +T __syscall_ulong_t X__SyscallUlongT +T __time_t X__TimeT +T __timer_t X__TimerT +T __u_char X__UChar +T __u_int X__UInt +T __u_long X__ULong +T __u_quad_t X__UQuadT +T __u_short X__UShort +T __uid_t X__UidT +T __uint16_t X__Uint16T +T __uint32_t X__Uint32T +T __uint64_t X__Uint64T +T __uint8_t X__Uint8T +T __useconds_t X__UsecondsT +T fd_mask FdMask T fd_set FdSet +T sigset_t SigsetT +T suseconds_t SusecondsT T timeval Timeval diff --git a/c/sys/sys-_types-_fd_def_darwin_arm64.go b/c/sys/sys-_types-_fd_def_darwin_arm64.go new file mode 100644 index 00000000..7474a5a3 --- /dev/null +++ b/c/sys/sys-_types-_fd_def_darwin_arm64.go @@ -0,0 +1,18 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +const X__DARWIN_FD_SETSIZE = 1024 +const +// bits in a byte +X__DARWIN_NBBY = 8 + +//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 diff --git a/c/sys/sys-_types_darwin_arm64.go b/c/sys/sys-_types_darwin_arm64.go new file mode 100644 index 00000000..c3a32838 --- /dev/null +++ b/c/sys/sys-_types_darwin_arm64.go @@ -0,0 +1,63 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import "github.com/goplus/lib/c" + +// total blocks +type X__DarwinBlkcntT = X__Int64T + +// preferred block size +type X__DarwinBlksizeT = X__Int32T + +// dev_t +type X__DarwinDevT = X__Int32T + +// Used by statvfs and fstatvfs +type X__DarwinFsblkcntT = c.Uint + +// Used by statvfs and fstatvfs +type X__DarwinFsfilcntT = c.Uint + +// [???] process and group IDs +type X__DarwinGidT = X__Uint32T + +// [XSI] pid_t, uid_t, or gid_t +type X__DarwinIdT = X__Uint32T + +// [???] Used for 64 bit inodes +type X__DarwinIno64T = X__Uint64T + +// [???] Used for inodes +type X__DarwinInoT = X__DarwinIno64T + +// Used by mach +type X__DarwinMachPortNameT = X__DarwinNaturalT + +// Used by mach +type X__DarwinMachPortT = X__DarwinMachPortNameT + +// [???] Some file attributes +type X__DarwinModeT = X__Uint16T + +// [???] Used for file sizes +type X__DarwinOffT = X__Int64T + +// [???] process and group IDs +type X__DarwinPidT = X__Int32T + +// [???] signal set +type X__DarwinSigsetT = X__Uint32T + +// [???] microseconds +type X__DarwinSusecondsT = X__Int32T + +// [???] user IDs +type X__DarwinUidT = X__Uint32T + +// [???] microseconds +type X__DarwinUsecondsT = X__Uint32T +type X__DarwinUuidT = [16]uint8 +type X__DarwinUuidStringT = [37]c.Char diff --git a/c/sys/sys-select_darwin_arm64.go b/c/sys/sys-select_darwin_arm64.go new file mode 100644 index 00000000..adc5d3a2 --- /dev/null +++ b/c/sys/sys-select_darwin_arm64.go @@ -0,0 +1,15 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import ( + "github.com/goplus/lib/c" + "github.com/goplus/lib/c/signal" + "github.com/goplus/lib/c/time" + _ "unsafe" +) + +//go:linkname Pselect C.pselect +func Pselect(_llcppg_param1 c.Int, _llcppg_param2 *FdSet, _llcppg_param3 *FdSet, _llcppg_param4 *FdSet, _llcppg_param5 *time.Timespec, _llcppg_param6 *signal.SigsetT) c.Int diff --git a/c/sys/sys-select_linux_amd64.go b/c/sys/sys-select_linux_amd64.go new file mode 100644 index 00000000..56c201a5 --- /dev/null +++ b/c/sys/sys-select_linux_amd64.go @@ -0,0 +1,34 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import ( + "github.com/goplus/lib/c" + "github.com/goplus/lib/c/signal" + "github.com/goplus/lib/c/time" + _ "unsafe" +) + +const X_SYS_SELECT_H = 1 + +// fd_set for select and pselect. +type SigsetT = signal.X__SigsetT +type SusecondsT = X__SusecondsT + +// The fd_set member is required to be an array of longs. +type X__FdMask = c.Long + +// Sometimes the fd_set member is assumed to have this type. +type FdMask = X__FdMask + +// Same as above only that the TIMEOUT value is given with higher +// resolution and a sigmask which is been set temporarily. This version +// should be used. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pselect C.pselect +func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *time.Timespec, __sigmask *signal.X__SigsetT) c.Int diff --git a/c/sys/sys-select_linux_arm64.go b/c/sys/sys-select_linux_arm64.go new file mode 100644 index 00000000..cfa88f9b --- /dev/null +++ b/c/sys/sys-select_linux_arm64.go @@ -0,0 +1,34 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package sys + +import ( + "github.com/goplus/lib/c" + "github.com/goplus/lib/c/signal" + "github.com/goplus/lib/c/time" + _ "unsafe" +) + +const X_SYS_SELECT_H = 1 + +// fd_set for select and pselect. +type SigsetT = signal.X__SigsetT +type SusecondsT = X__SusecondsT + +// The fd_set member is required to be an array of longs. +type X__FdMask = c.Long + +// Sometimes the fd_set member is assumed to have this type. +type FdMask = X__FdMask + +// Same as above only that the TIMEOUT value is given with higher +// resolution and a sigmask which is been set temporarily. This version +// should be used. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Pselect C.pselect +func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *time.Timespec, __sigmask *signal.X__SigsetT) c.Int From d6efffdf52f29cfb17fb63dc8f191ebb36a22e0e Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 19:56:46 +0800 Subject: [PATCH 3/6] Classify unified libc output and skip unsupported layouts --- c/sys/arm-_types_darwin_arm64.go | 64 --------- c/sys/bits-select_linux_amd64.go | 7 - c/sys/bits-time_linux_amd64.go | 10 -- c/sys/bits-time_linux_arm64.go | 10 -- c/sys/bits-types_linux_amd64.go | 133 ------------------ c/sys/bits-types_linux_arm64.go | 133 ------------------ ...t_darwin_arm64.go => libc_darwin_arm64.go} | 6 +- ...ect_linux_amd64.go => libc_linux_amd64.go} | 20 +-- ...ect_linux_arm64.go => libc_linux_arm64.go} | 20 +-- c/sys/llcppg.pub | 90 ------------ c/sys/sys-_types-_fd_def_darwin_arm64.go | 18 --- c/sys/sys-_types_darwin_arm64.go | 63 --------- 12 files changed, 15 insertions(+), 559 deletions(-) delete mode 100644 c/sys/arm-_types_darwin_arm64.go delete mode 100644 c/sys/bits-select_linux_amd64.go delete mode 100644 c/sys/bits-time_linux_amd64.go delete mode 100644 c/sys/bits-time_linux_arm64.go delete mode 100644 c/sys/bits-types_linux_amd64.go delete mode 100644 c/sys/bits-types_linux_arm64.go rename c/sys/{sys-select_darwin_arm64.go => libc_darwin_arm64.go} (56%) rename c/sys/{sys-select_linux_amd64.go => libc_linux_amd64.go} (52%) rename c/sys/{sys-select_linux_arm64.go => libc_linux_arm64.go} (52%) delete mode 100644 c/sys/sys-_types-_fd_def_darwin_arm64.go delete mode 100644 c/sys/sys-_types_darwin_arm64.go diff --git a/c/sys/arm-_types_darwin_arm64.go b/c/sys/arm-_types_darwin_arm64.go deleted file mode 100644 index 61c413d4..00000000 --- a/c/sys/arm-_types_darwin_arm64.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -type X__MbstateT struct { - _xgo_union [16]uint64 -} -type X__Int8T = int8 -type X__Uint8T = uint8 -type X__Int16T = int16 -type X__Uint16T = uint16 -type X__Int32T = c.Int -type X__Uint32T = c.Uint -type X__Int64T = c.LongLong -type X__Uint64T = c.UlongLong -type X__DarwinIntptrT = c.Long -type X__DarwinNaturalT = c.Uint - -// ct_rune_t -type X__DarwinCtRuneT = c.Int - -// mbstate_t -type X__DarwinMbstateT = X__MbstateT - -// ptr1 - ptr2 -type X__DarwinPtrdiffT = c.Long - -// sizeof() -type X__DarwinSizeT = c.Ulong - -// wchar_t -type X__DarwinWcharT = c.Int - -// rune_t -type X__DarwinRuneT = X__DarwinWcharT - -// wint_t -type X__DarwinWintT = c.Int - -// clock() -type X__DarwinClockT = c.Ulong - -// socklen_t (duh) -type X__DarwinSocklenT = X__Uint32T - -// byte count or error -type X__DarwinSsizeT = c.Long - -// time() -type X__DarwinTimeT = c.Long - -func (p *X__MbstateT) XGof_ref___mbstate8() *[128]c.Char { - return (*[128]c.Char)(unsafe.Pointer(p)) -} -func (p *X__MbstateT) XGof_ref__mbstateL() *c.LongLong { - return (*c.LongLong)(unsafe.Pointer(p)) -} diff --git a/c/sys/bits-select_linux_amd64.go b/c/sys/bits-select_linux_amd64.go deleted file mode 100644 index 97debebc..00000000 --- a/c/sys/bits-select_linux_amd64.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -const X__FD_ZERO_STOS = "stosq" diff --git a/c/sys/bits-time_linux_amd64.go b/c/sys/bits-time_linux_amd64.go deleted file mode 100644 index 11589680..00000000 --- a/c/sys/bits-time_linux_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -const X_STRUCT_TIMEVAL = 1 - -// A time value that is accurate to the nearest -// microsecond but also has a range of years. diff --git a/c/sys/bits-time_linux_arm64.go b/c/sys/bits-time_linux_arm64.go deleted file mode 100644 index 2a661a7e..00000000 --- a/c/sys/bits-time_linux_arm64.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -const X_STRUCT_TIMEVAL = 1 - -// A time value that is accurate to the nearest -// microsecond but also has a range of years. diff --git a/c/sys/bits-types_linux_amd64.go b/c/sys/bits-types_linux_amd64.go deleted file mode 100644 index a538e871..00000000 --- a/c/sys/bits-types_linux_amd64.go +++ /dev/null @@ -1,133 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -import "github.com/goplus/lib/c" - -const X_BITS_TYPES_H = 1 - -type X__FsidT struct { - X__Val [2]c.Int -} - -// Convenience types. -type X__UChar = uint8 -type X__UShort = uint16 -type X__UInt = c.Uint -type X__ULong = c.Ulong - -// Fixed-size types, underlying types depend on word size and compiler. -type X__Int8T = int8 -type X__Uint8T = uint8 -type X__Int16T = int16 -type X__Uint16T = uint16 -type X__Int32T = c.Int -type X__Uint32T = c.Uint -type X__Int64T = c.Long -type X__Uint64T = c.Ulong -type X__QuadT = c.Long -type X__UQuadT = c.Ulong - -// Type of device numbers. -type X__DevT = c.Ulong - -// Type of user identifications. -type X__UidT = c.Uint - -// Type of group identifications. -type X__GidT = c.Uint - -// Type of file serial numbers. -type X__InoT = c.Ulong - -// Type of file serial numbers (LFS). -type X__Ino64T = c.Ulong - -// Type of file attribute bitmasks. -type X__ModeT = c.Uint - -// Type of file link counts. -type X__NlinkT = c.Ulong - -// Type of file sizes and offsets. -type X__OffT = c.Long - -// Type of file sizes and offsets (LFS). -type X__Off64T = c.Long - -// Type of process identifications. -type X__PidT = c.Int - -// Type of CPU usage counts. -type X__ClockT = c.Long - -// Type for resource measurement. -type X__RlimT = c.Ulong - -// Type for resource measurement (LFS). -type X__Rlim64T = c.Ulong - -// General type for IDs. -type X__IdT = c.Uint - -// Seconds since the Epoch. -type X__TimeT = c.Long - -// Count of microseconds. -type X__UsecondsT = c.Uint - -// Signed count of microseconds. -type X__SusecondsT = c.Long - -// The type of a disk address. -type X__DaddrT = c.Int - -// Type of an IPC key. -type X__KeyT = c.Int - -// Clock ID used in clock and timer functions. -type X__ClockidT = c.Int - -// Timer ID returned by `timer_create'. -type X__TimerT uintptr - -// Type to represent block size. -type X__BlksizeT = c.Long - -// Type to count number of disk blocks. -type X__BlkcntT = c.Long -type X__Blkcnt64T = c.Long - -// Type to count file system blocks. -type X__FsblkcntT = c.Ulong -type X__Fsblkcnt64T = c.Ulong - -// Type to count file system nodes. -type X__FsfilcntT = c.Ulong -type X__Fsfilcnt64T = c.Ulong - -// Type of miscellaneous file system fields. -type X__FswordT = c.Long - -// Type of a byte count, or error. -type X__SsizeT = c.Long - -// Signed long type used in system calls. -type X__SyscallSlongT = c.Long - -// Unsigned long type used in system calls. -type X__SyscallUlongT = c.Ulong - -// These few don't really vary by system, they always correspond -// to one of the other defined types. -type X__LoffT = X__Off64T -type X__QaddrT = *X__QuadT -type X__CaddrT = *c.Char - -// Duplicates info from stdint.h but this is used in unistd.h. -type X__IntptrT = c.Long - -// Duplicate info from sys/socket.h. -type X__SocklenT = c.Uint diff --git a/c/sys/bits-types_linux_arm64.go b/c/sys/bits-types_linux_arm64.go deleted file mode 100644 index ef28c63d..00000000 --- a/c/sys/bits-types_linux_arm64.go +++ /dev/null @@ -1,133 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -import "github.com/goplus/lib/c" - -const X_BITS_TYPES_H = 1 - -type X__FsidT struct { - X__Val [2]c.Int -} - -// Convenience types. -type X__UChar = uint8 -type X__UShort = uint16 -type X__UInt = c.Uint -type X__ULong = c.Ulong - -// Fixed-size types, underlying types depend on word size and compiler. -type X__Int8T = int8 -type X__Uint8T = uint8 -type X__Int16T = int16 -type X__Uint16T = uint16 -type X__Int32T = c.Int -type X__Uint32T = c.Uint -type X__Int64T = c.Long -type X__Uint64T = c.Ulong -type X__QuadT = c.Long -type X__UQuadT = c.Ulong - -// Type of device numbers. -type X__DevT = c.Ulong - -// Type of user identifications. -type X__UidT = c.Uint - -// Type of group identifications. -type X__GidT = c.Uint - -// Type of file serial numbers. -type X__InoT = c.Ulong - -// Type of file serial numbers (LFS). -type X__Ino64T = c.Ulong - -// Type of file attribute bitmasks. -type X__ModeT = c.Uint - -// Type of file link counts. -type X__NlinkT = c.Uint - -// Type of file sizes and offsets. -type X__OffT = c.Long - -// Type of file sizes and offsets (LFS). -type X__Off64T = c.Long - -// Type of process identifications. -type X__PidT = c.Int - -// Type of CPU usage counts. -type X__ClockT = c.Long - -// Type for resource measurement. -type X__RlimT = c.Ulong - -// Type for resource measurement (LFS). -type X__Rlim64T = c.Ulong - -// General type for IDs. -type X__IdT = c.Uint - -// Seconds since the Epoch. -type X__TimeT = c.Long - -// Count of microseconds. -type X__UsecondsT = c.Uint - -// Signed count of microseconds. -type X__SusecondsT = c.Long - -// The type of a disk address. -type X__DaddrT = c.Int - -// Type of an IPC key. -type X__KeyT = c.Int - -// Clock ID used in clock and timer functions. -type X__ClockidT = c.Int - -// Timer ID returned by `timer_create'. -type X__TimerT uintptr - -// Type to represent block size. -type X__BlksizeT = c.Int - -// Type to count number of disk blocks. -type X__BlkcntT = c.Long -type X__Blkcnt64T = c.Long - -// Type to count file system blocks. -type X__FsblkcntT = c.Ulong -type X__Fsblkcnt64T = c.Ulong - -// Type to count file system nodes. -type X__FsfilcntT = c.Ulong -type X__Fsfilcnt64T = c.Ulong - -// Type of miscellaneous file system fields. -type X__FswordT = c.Long - -// Type of a byte count, or error. -type X__SsizeT = c.Long - -// Signed long type used in system calls. -type X__SyscallSlongT = c.Long - -// Unsigned long type used in system calls. -type X__SyscallUlongT = c.Ulong - -// These few don't really vary by system, they always correspond -// to one of the other defined types. -type X__LoffT = X__Off64T -type X__QaddrT = *X__QuadT -type X__CaddrT = *uint8 - -// Duplicates info from stdint.h but this is used in unistd.h. -type X__IntptrT = c.Long - -// Duplicate info from sys/socket.h. -type X__SocklenT = c.Uint diff --git a/c/sys/sys-select_darwin_arm64.go b/c/sys/libc_darwin_arm64.go similarity index 56% rename from c/sys/sys-select_darwin_arm64.go rename to c/sys/libc_darwin_arm64.go index adc5d3a2..f5769907 100644 --- a/c/sys/sys-select_darwin_arm64.go +++ b/c/sys/libc_darwin_arm64.go @@ -1,15 +1,15 @@ //go:build darwin && arm64 && !ios // Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. package sys import ( "github.com/goplus/lib/c" - "github.com/goplus/lib/c/signal" - "github.com/goplus/lib/c/time" + lltime "github.com/goplus/lib/c/time" _ "unsafe" ) //go:linkname Pselect C.pselect -func Pselect(_llcppg_param1 c.Int, _llcppg_param2 *FdSet, _llcppg_param3 *FdSet, _llcppg_param4 *FdSet, _llcppg_param5 *time.Timespec, _llcppg_param6 *signal.SigsetT) c.Int +func Pselect(_llcppg_param1 c.Int, _llcppg_param2 *FdSet, _llcppg_param3 *FdSet, _llcppg_param4 *FdSet, _llcppg_param5 *lltime.Timespec, _llcppg_param6 *c.Uint) c.Int diff --git a/c/sys/sys-select_linux_amd64.go b/c/sys/libc_linux_amd64.go similarity index 52% rename from c/sys/sys-select_linux_amd64.go rename to c/sys/libc_linux_amd64.go index 56c201a5..a7b06f8f 100644 --- a/c/sys/sys-select_linux_amd64.go +++ b/c/sys/libc_linux_amd64.go @@ -1,27 +1,19 @@ //go:build linux && amd64 && !android // Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. package sys import ( "github.com/goplus/lib/c" - "github.com/goplus/lib/c/signal" - "github.com/goplus/lib/c/time" + llsignal "github.com/goplus/lib/c/signal" + lltime "github.com/goplus/lib/c/time" _ "unsafe" ) -const X_SYS_SELECT_H = 1 - -// fd_set for select and pselect. -type SigsetT = signal.X__SigsetT -type SusecondsT = X__SusecondsT - -// The fd_set member is required to be an array of longs. -type X__FdMask = c.Long - -// Sometimes the fd_set member is assumed to have this type. -type FdMask = X__FdMask +// Maximum number of file descriptors in `fd_set'. +const FD_SETSIZE = 1024 // Same as above only that the TIMEOUT value is given with higher // resolution and a sigmask which is been set temporarily. This version @@ -31,4 +23,4 @@ type FdMask = X__FdMask // __THROW. // //go:linkname Pselect C.pselect -func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *time.Timespec, __sigmask *signal.X__SigsetT) c.Int +func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *lltime.Timespec, __sigmask *llsignal.SigsetT) c.Int diff --git a/c/sys/sys-select_linux_arm64.go b/c/sys/libc_linux_arm64.go similarity index 52% rename from c/sys/sys-select_linux_arm64.go rename to c/sys/libc_linux_arm64.go index cfa88f9b..307645cf 100644 --- a/c/sys/sys-select_linux_arm64.go +++ b/c/sys/libc_linux_arm64.go @@ -1,27 +1,19 @@ //go:build linux && arm64 && !android // Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. package sys import ( "github.com/goplus/lib/c" - "github.com/goplus/lib/c/signal" - "github.com/goplus/lib/c/time" + llsignal "github.com/goplus/lib/c/signal" + lltime "github.com/goplus/lib/c/time" _ "unsafe" ) -const X_SYS_SELECT_H = 1 - -// fd_set for select and pselect. -type SigsetT = signal.X__SigsetT -type SusecondsT = X__SusecondsT - -// The fd_set member is required to be an array of longs. -type X__FdMask = c.Long - -// Sometimes the fd_set member is assumed to have this type. -type FdMask = X__FdMask +// Maximum number of file descriptors in `fd_set'. +const FD_SETSIZE = 1024 // Same as above only that the TIMEOUT value is given with higher // resolution and a sigmask which is been set temporarily. This version @@ -31,4 +23,4 @@ type FdMask = X__FdMask // __THROW. // //go:linkname Pselect C.pselect -func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *time.Timespec, __sigmask *signal.X__SigsetT) c.Int +func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *lltime.Timespec, __sigmask *llsignal.SigsetT) c.Int diff --git a/c/sys/llcppg.pub b/c/sys/llcppg.pub index 75ecb6c7..8588e1ae 100644 --- a/c/sys/llcppg.pub +++ b/c/sys/llcppg.pub @@ -1,94 +1,4 @@ D github.com/goplus/lib/c/signal D github.com/goplus/lib/c/time -T __blkcnt64_t X__Blkcnt64T -T __blkcnt_t X__BlkcntT -T __blksize_t X__BlksizeT -T __caddr_t X__CaddrT -T __clock_t X__ClockT -T __clockid_t X__ClockidT -T __daddr_t X__DaddrT -T __darwin_blkcnt_t X__DarwinBlkcntT -T __darwin_blksize_t X__DarwinBlksizeT -T __darwin_clock_t X__DarwinClockT -T __darwin_ct_rune_t X__DarwinCtRuneT -T __darwin_dev_t X__DarwinDevT -T __darwin_fsblkcnt_t X__DarwinFsblkcntT -T __darwin_fsfilcnt_t X__DarwinFsfilcntT -T __darwin_gid_t X__DarwinGidT -T __darwin_id_t X__DarwinIdT -T __darwin_ino64_t X__DarwinIno64T -T __darwin_ino_t X__DarwinInoT -T __darwin_intptr_t X__DarwinIntptrT -T __darwin_mach_port_name_t X__DarwinMachPortNameT -T __darwin_mach_port_t X__DarwinMachPortT -T __darwin_mbstate_t X__DarwinMbstateT -T __darwin_mode_t X__DarwinModeT -T __darwin_natural_t X__DarwinNaturalT -T __darwin_off_t X__DarwinOffT -T __darwin_pid_t X__DarwinPidT -T __darwin_ptrdiff_t X__DarwinPtrdiffT -T __darwin_rune_t X__DarwinRuneT -T __darwin_sigset_t X__DarwinSigsetT -T __darwin_size_t X__DarwinSizeT -T __darwin_socklen_t X__DarwinSocklenT -T __darwin_ssize_t X__DarwinSsizeT -T __darwin_suseconds_t X__DarwinSusecondsT -T __darwin_time_t X__DarwinTimeT -T __darwin_uid_t X__DarwinUidT -T __darwin_useconds_t X__DarwinUsecondsT -T __darwin_uuid_string_t X__DarwinUuidStringT -T __darwin_uuid_t X__DarwinUuidT -T __darwin_wchar_t X__DarwinWcharT -T __darwin_wint_t X__DarwinWintT -T __dev_t X__DevT -T __fd_mask X__FdMask -T __fsblkcnt64_t X__Fsblkcnt64T -T __fsblkcnt_t X__FsblkcntT -T __fsfilcnt64_t X__Fsfilcnt64T -T __fsfilcnt_t X__FsfilcntT -T __fsid_t X__FsidT -T __fsword_t X__FswordT -T __gid_t X__GidT -T __id_t X__IdT -T __ino64_t X__Ino64T -T __ino_t X__InoT -T __int16_t X__Int16T -T __int32_t X__Int32T -T __int64_t X__Int64T -T __int8_t X__Int8T -T __intptr_t X__IntptrT -T __key_t X__KeyT -T __loff_t X__LoffT -T __mbstate_t X__MbstateT -T __mode_t X__ModeT -T __nlink_t X__NlinkT -T __off64_t X__Off64T -T __off_t X__OffT -T __pid_t X__PidT -T __qaddr_t X__QaddrT -T __quad_t X__QuadT -T __rlim64_t X__Rlim64T -T __rlim_t X__RlimT -T __socklen_t X__SocklenT -T __ssize_t X__SsizeT -T __suseconds_t X__SusecondsT -T __syscall_slong_t X__SyscallSlongT -T __syscall_ulong_t X__SyscallUlongT -T __time_t X__TimeT -T __timer_t X__TimerT -T __u_char X__UChar -T __u_int X__UInt -T __u_long X__ULong -T __u_quad_t X__UQuadT -T __u_short X__UShort -T __uid_t X__UidT -T __uint16_t X__Uint16T -T __uint32_t X__Uint32T -T __uint64_t X__Uint64T -T __uint8_t X__Uint8T -T __useconds_t X__UsecondsT -T fd_mask FdMask T fd_set FdSet -T sigset_t SigsetT -T suseconds_t SusecondsT T timeval Timeval diff --git a/c/sys/sys-_types-_fd_def_darwin_arm64.go b/c/sys/sys-_types-_fd_def_darwin_arm64.go deleted file mode 100644 index 7474a5a3..00000000 --- a/c/sys/sys-_types-_fd_def_darwin_arm64.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -const X__DARWIN_FD_SETSIZE = 1024 -const -// bits in a byte -X__DARWIN_NBBY = 8 - -//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 diff --git a/c/sys/sys-_types_darwin_arm64.go b/c/sys/sys-_types_darwin_arm64.go deleted file mode 100644 index c3a32838..00000000 --- a/c/sys/sys-_types_darwin_arm64.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package sys - -import "github.com/goplus/lib/c" - -// total blocks -type X__DarwinBlkcntT = X__Int64T - -// preferred block size -type X__DarwinBlksizeT = X__Int32T - -// dev_t -type X__DarwinDevT = X__Int32T - -// Used by statvfs and fstatvfs -type X__DarwinFsblkcntT = c.Uint - -// Used by statvfs and fstatvfs -type X__DarwinFsfilcntT = c.Uint - -// [???] process and group IDs -type X__DarwinGidT = X__Uint32T - -// [XSI] pid_t, uid_t, or gid_t -type X__DarwinIdT = X__Uint32T - -// [???] Used for 64 bit inodes -type X__DarwinIno64T = X__Uint64T - -// [???] Used for inodes -type X__DarwinInoT = X__DarwinIno64T - -// Used by mach -type X__DarwinMachPortNameT = X__DarwinNaturalT - -// Used by mach -type X__DarwinMachPortT = X__DarwinMachPortNameT - -// [???] Some file attributes -type X__DarwinModeT = X__Uint16T - -// [???] Used for file sizes -type X__DarwinOffT = X__Int64T - -// [???] process and group IDs -type X__DarwinPidT = X__Int32T - -// [???] signal set -type X__DarwinSigsetT = X__Uint32T - -// [???] microseconds -type X__DarwinSusecondsT = X__Int32T - -// [???] user IDs -type X__DarwinUidT = X__Uint32T - -// [???] microseconds -type X__DarwinUsecondsT = X__Uint32T -type X__DarwinUuidT = [16]uint8 -type X__DarwinUuidStringT = [37]c.Char From b1450eaafbe928802fb4a610f8a9622cf776e727 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 20 Oct 2026 00:21:45 +0800 Subject: [PATCH 4/6] Publish expanded unified libc classification for c/sys --- c/sys/libc_darwin_arm64.go | 69 +++++++++++++++++++++++++++- c/sys/libc_linux_amd64.go | 88 ++++++++++++++++++++++++++++++++++++ c/sys/libc_linux_arm64.go | 88 ++++++++++++++++++++++++++++++++++++ c/sys/llcppg-linux_amd64.cfg | 21 --------- c/sys/llcppg-linux_arm64.cfg | 21 --------- c/sys/llcppg.cfg | 20 +------- c/sys/llcppg.pub | 4 ++ 7 files changed, 249 insertions(+), 62 deletions(-) delete mode 100644 c/sys/llcppg-linux_amd64.cfg delete mode 100644 c/sys/llcppg-linux_arm64.cfg diff --git a/c/sys/libc_darwin_arm64.go b/c/sys/libc_darwin_arm64.go index f5769907..178f580d 100644 --- a/c/sys/libc_darwin_arm64.go +++ b/c/sys/libc_darwin_arm64.go @@ -8,8 +8,75 @@ package sys import ( "github.com/goplus/lib/c" lltime "github.com/goplus/lib/c/time" - _ "unsafe" + "unsafe" ) //go:linkname Pselect C.pselect func Pselect(_llcppg_param1 c.Int, _llcppg_param2 *FdSet, _llcppg_param3 *FdSet, _llcppg_param4 *FdSet, _llcppg_param5 *lltime.Timespec, _llcppg_param6 *c.Uint) c.Int + +// Names of the interval timers, and structure +// defining a timer setting. +const ( + ITIMER_REAL = 0 + ITIMER_VIRTUAL = 1 + ITIMER_PROF = 2 +) + +const ( + // not on dst + DST_NONE = 0 + // USA style dst + DST_USA = 1 + // Australian style dst + DST_AUST = 2 + // Western European dst + DST_WET = 3 + // Middle European dst + DST_MET = 4 + // Eastern European dst + DST_EET = 5 + // Canada + DST_CAN = 6 +) + +// Structure used as a parameter by getitimer(2) and setitimer(2) system +// calls. +type Itimerval struct { + ItInterval Timeval + ItValue Timeval +} + +type Timezone struct { + TzMinuteswest c.Int + TzDsttime c.Int +} + +// llgo:link (*Timeval).Adjtime C.adjtime +func (self *Timeval) Adjtime(_llcppg_param2 *Timeval) c.Int { + return 0 +} + +//go:linkname Futimes C.futimes +func Futimes(_llcppg_param1 c.Int, _llcppg_param2 *Timeval) c.Int + +//go:linkname Lutimes C.lutimes +func Lutimes(_llcppg_param1 *c.Char, _llcppg_param2 *Timeval) c.Int + +// llgo:link (*Timeval).Settimeofday C.settimeofday +func (self *Timeval) Settimeofday(_llcppg_param2 *Timezone) c.Int { + return 0 +} + +//go:linkname Getitimer C.getitimer +func Getitimer(_llcppg_param1 c.Int, _llcppg_param2 *Itimerval) c.Int + +// llgo:link (*Timeval).Gettimeofday C.gettimeofday +func (self *Timeval) Gettimeofday(_llcppg_param2 unsafe.Pointer) c.Int { + return 0 +} + +//go:linkname Setitimer C.setitimer +func Setitimer(_llcppg_param1 c.Int, _llcppg_param2 *Itimerval, _llcppg_param3 *Itimerval) c.Int + +//go:linkname Utimes C.utimes +func Utimes(_llcppg_param1 *c.Char, _llcppg_param2 *Timeval) c.Int diff --git a/c/sys/libc_linux_amd64.go b/c/sys/libc_linux_amd64.go index a7b06f8f..451efec0 100644 --- a/c/sys/libc_linux_amd64.go +++ b/c/sys/libc_linux_amd64.go @@ -24,3 +24,91 @@ const FD_SETSIZE = 1024 // //go:linkname Pselect C.pselect func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *lltime.Timespec, __sigmask *llsignal.SigsetT) c.Int + +// Structure crudely representing a timezone. +// This is obsolete and should never be used. +type Timezone struct { + TzMinuteswest c.Int + TzDsttime c.Int +} + +// Values for the first argument to `getitimer' and `setitimer'. +type X__ItimerWhich c.Uint + +const ( + // Timers run in real time. + ITIMER_REAL X__ItimerWhich = 0 + // Timers run only when the process is executing. + ITIMER_VIRTUAL X__ItimerWhich = 1 + // Timers run when the process is executing and when + // the system is executing on behalf of the process. + ITIMER_PROF X__ItimerWhich = 2 +) + +// Type of the second argument to `getitimer' and +// the second and third arguments `setitimer'. +type Itimerval struct { + ItInterval Timeval + ItValue Timeval +} + +type X__TimezonePtrT = *Timezone + +// Get the current time of day and timezone information, +// putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. +// Returns 0 on success, -1 on errors. +// NOTE: This form of timezone information is obsolete. +// Use the functions and variables declared in instead. +// +// llgo:link (*Timeval).Gettimeofday C.gettimeofday +func (self *Timeval) Gettimeofday(__tz X__TimezonePtrT) c.Int { + return 0 +} + +// Set the current time of day and timezone information. +// This call is restricted to the super-user. +// +// llgo:link (*Timeval).Settimeofday C.settimeofday +func (self *Timeval) Settimeofday(__tz *Timezone) c.Int { + return 0 +} + +// Adjust the current time of day by the amount in DELTA. +// If OLDDELTA is not NULL, it is filled in with the amount +// of time adjustment remaining to be done from the last `adjtime' call. +// This call is restricted to the super-user. +// +// llgo:link (*Timeval).Adjtime C.adjtime +func (self *Timeval) Adjtime(__olddelta *Timeval) c.Int { + return 0 +} + +// Set *VALUE to the current setting of timer WHICH. +// Return 0 on success, -1 on errors. +// +//go:linkname Getitimer C.getitimer +func Getitimer(__which c.Int, __value *Itimerval) c.Int + +// Set the timer WHICH to *NEW. If OLD is not NULL, +// set *OLD to the old value of timer WHICH. +// Returns 0 on success, -1 on errors. +// +//go:linkname Setitimer C.setitimer +func Setitimer(__which c.Int, __new *Itimerval, __old *Itimerval) c.Int + +// Change the access time of FILE to TVP[0] and the modification time of +// FILE to TVP[1]. If TVP is a null pointer, use the current time instead. +// Returns 0 on success, -1 on errors. +// +//go:linkname Utimes C.utimes +func Utimes(__file *c.Char, __tvp *Timeval) c.Int + +// Same as `utimes', but does not follow symbolic links. +// +//go:linkname Lutimes C.lutimes +func Lutimes(__file *c.Char, __tvp *Timeval) c.Int + +// Same as `utimes', but takes an open file descriptor instead of a name. +// +//go:linkname Futimes C.futimes +func Futimes(__fd c.Int, __tvp *Timeval) c.Int diff --git a/c/sys/libc_linux_arm64.go b/c/sys/libc_linux_arm64.go index 307645cf..de406a82 100644 --- a/c/sys/libc_linux_arm64.go +++ b/c/sys/libc_linux_arm64.go @@ -24,3 +24,91 @@ const FD_SETSIZE = 1024 // //go:linkname Pselect C.pselect func Pselect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *lltime.Timespec, __sigmask *llsignal.SigsetT) c.Int + +// Structure crudely representing a timezone. +// This is obsolete and should never be used. +type Timezone struct { + TzMinuteswest c.Int + TzDsttime c.Int +} + +// Values for the first argument to `getitimer' and `setitimer'. +type X__ItimerWhich c.Uint + +const ( + // Timers run in real time. + ITIMER_REAL X__ItimerWhich = 0 + // Timers run only when the process is executing. + ITIMER_VIRTUAL X__ItimerWhich = 1 + // Timers run when the process is executing and when + // the system is executing on behalf of the process. + ITIMER_PROF X__ItimerWhich = 2 +) + +// Type of the second argument to `getitimer' and +// the second and third arguments `setitimer'. +type Itimerval struct { + ItInterval Timeval + ItValue Timeval +} + +type X__TimezonePtrT = *Timezone + +// Get the current time of day and timezone information, +// putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. +// Returns 0 on success, -1 on errors. +// NOTE: This form of timezone information is obsolete. +// Use the functions and variables declared in instead. +// +// llgo:link (*Timeval).Gettimeofday C.gettimeofday +func (self *Timeval) Gettimeofday(__tz X__TimezonePtrT) c.Int { + return 0 +} + +// Set the current time of day and timezone information. +// This call is restricted to the super-user. +// +// llgo:link (*Timeval).Settimeofday C.settimeofday +func (self *Timeval) Settimeofday(__tz *Timezone) c.Int { + return 0 +} + +// Adjust the current time of day by the amount in DELTA. +// If OLDDELTA is not NULL, it is filled in with the amount +// of time adjustment remaining to be done from the last `adjtime' call. +// This call is restricted to the super-user. +// +// llgo:link (*Timeval).Adjtime C.adjtime +func (self *Timeval) Adjtime(__olddelta *Timeval) c.Int { + return 0 +} + +// Set *VALUE to the current setting of timer WHICH. +// Return 0 on success, -1 on errors. +// +//go:linkname Getitimer C.getitimer +func Getitimer(__which c.Int, __value *Itimerval) c.Int + +// Set the timer WHICH to *NEW. If OLD is not NULL, +// set *OLD to the old value of timer WHICH. +// Returns 0 on success, -1 on errors. +// +//go:linkname Setitimer C.setitimer +func Setitimer(__which c.Int, __new *Itimerval, __old *Itimerval) c.Int + +// Change the access time of FILE to TVP[0] and the modification time of +// FILE to TVP[1]. If TVP is a null pointer, use the current time instead. +// Returns 0 on success, -1 on errors. +// +//go:linkname Utimes C.utimes +func Utimes(__file *uint8, __tvp *Timeval) c.Int + +// Same as `utimes', but does not follow symbolic links. +// +//go:linkname Lutimes C.lutimes +func Lutimes(__file *uint8, __tvp *Timeval) c.Int + +// Same as `utimes', but takes an open file descriptor instead of a name. +// +//go:linkname Futimes C.futimes +func Futimes(__fd c.Int, __tvp *Timeval) c.Int diff --git a/c/sys/llcppg-linux_amd64.cfg b/c/sys/llcppg-linux_amd64.cfg deleted file mode 100644 index e88da7cc..00000000 --- a/c/sys/llcppg-linux_amd64.cfg +++ /dev/null @@ -1,21 +0,0 @@ -{ - "Name": "sys", - "Language": "c", - "Dir": ".sysroot/include", - "Stdlib": ".sysroot/stdlib", - "Files": [ - "llcppg.h" - ], - "Deps": [ - "..", - "../time", - "../signal" - ], - "FailFast": 0, - "FuncIgnore": [ - "select" - ], - "TypeIgnore": [ - "va_list" - ] -} diff --git a/c/sys/llcppg-linux_arm64.cfg b/c/sys/llcppg-linux_arm64.cfg deleted file mode 100644 index e88da7cc..00000000 --- a/c/sys/llcppg-linux_arm64.cfg +++ /dev/null @@ -1,21 +0,0 @@ -{ - "Name": "sys", - "Language": "c", - "Dir": ".sysroot/include", - "Stdlib": ".sysroot/stdlib", - "Files": [ - "llcppg.h" - ], - "Deps": [ - "..", - "../time", - "../signal" - ], - "FailFast": 0, - "FuncIgnore": [ - "select" - ], - "TypeIgnore": [ - "va_list" - ] -} diff --git a/c/sys/llcppg.cfg b/c/sys/llcppg.cfg index e88da7cc..75e27be3 100644 --- a/c/sys/llcppg.cfg +++ b/c/sys/llcppg.cfg @@ -1,21 +1,3 @@ { - "Name": "sys", - "Language": "c", - "Dir": ".sysroot/include", - "Stdlib": ".sysroot/stdlib", - "Files": [ - "llcppg.h" - ], - "Deps": [ - "..", - "../time", - "../signal" - ], - "FailFast": 0, - "FuncIgnore": [ - "select" - ], - "TypeIgnore": [ - "va_list" - ] + "Dir": ".sysroot/include" } diff --git a/c/sys/llcppg.pub b/c/sys/llcppg.pub index 8588e1ae..053009ca 100644 --- a/c/sys/llcppg.pub +++ b/c/sys/llcppg.pub @@ -1,4 +1,8 @@ D github.com/goplus/lib/c/signal D github.com/goplus/lib/c/time +T __itimer_which X__ItimerWhich +T __timezone_ptr_t X__TimezonePtrT T fd_set FdSet +T itimerval Itimerval T timeval Timeval +T timezone Timezone From 296afb746c72c0548b8a63161f17d7f867b7ff7d Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 20 Oct 2026 14:03:33 +0800 Subject: [PATCH 5/6] Regenerate c/sys native APIs and verify native calls --- c/sys/generated_native_llgo_test.go | 21 ++++++++++++++++++++ c/sys/libc_darwin_arm64.go | 18 ++++++----------- c/sys/libc_linux_amd64.go | 30 +++++++++++++++++------------ c/sys/libc_linux_arm64.go | 30 +++++++++++++++++------------ 4 files changed, 63 insertions(+), 36 deletions(-) create mode 100644 c/sys/generated_native_llgo_test.go diff --git a/c/sys/generated_native_llgo_test.go b/c/sys/generated_native_llgo_test.go new file mode 100644 index 00000000..052aad24 --- /dev/null +++ b/c/sys/generated_native_llgo_test.go @@ -0,0 +1,21 @@ +//go:build llgo && ((darwin && arm64 && !ios) || (linux && (amd64 || arm64) && !android)) + +package sys + +import ( + "testing" + "unsafe" +) + +func TestGeneratedGettimeofday(t *testing.T) { + var value Timeval + if unsafe.Sizeof(value) != 16 || unsafe.Alignof(value) != 8 { + t.Fatalf("timeval layout = %d/%d", unsafe.Sizeof(value), unsafe.Alignof(value)) + } + if result := Gettimeofday(&value, nil); result != 0 { + t.Fatalf("gettimeofday = %d", result) + } + if value.Sec <= 0 || value.Usec < 0 || value.Usec >= 1000000 { + t.Fatalf("invalid timeval %v", value) + } +} diff --git a/c/sys/libc_darwin_arm64.go b/c/sys/libc_darwin_arm64.go index 178f580d..b2ec88f6 100644 --- a/c/sys/libc_darwin_arm64.go +++ b/c/sys/libc_darwin_arm64.go @@ -51,10 +51,8 @@ type Timezone struct { TzDsttime c.Int } -// llgo:link (*Timeval).Adjtime C.adjtime -func (self *Timeval) Adjtime(_llcppg_param2 *Timeval) c.Int { - return 0 -} +//go:linkname Adjtime C.adjtime +func Adjtime(_llcppg_param1 *Timeval, _llcppg_param2 *Timeval) c.Int //go:linkname Futimes C.futimes func Futimes(_llcppg_param1 c.Int, _llcppg_param2 *Timeval) c.Int @@ -62,18 +60,14 @@ func Futimes(_llcppg_param1 c.Int, _llcppg_param2 *Timeval) c.Int //go:linkname Lutimes C.lutimes func Lutimes(_llcppg_param1 *c.Char, _llcppg_param2 *Timeval) c.Int -// llgo:link (*Timeval).Settimeofday C.settimeofday -func (self *Timeval) Settimeofday(_llcppg_param2 *Timezone) c.Int { - return 0 -} +//go:linkname Settimeofday C.settimeofday +func Settimeofday(_llcppg_param1 *Timeval, _llcppg_param2 *Timezone) c.Int //go:linkname Getitimer C.getitimer func Getitimer(_llcppg_param1 c.Int, _llcppg_param2 *Itimerval) c.Int -// llgo:link (*Timeval).Gettimeofday C.gettimeofday -func (self *Timeval) Gettimeofday(_llcppg_param2 unsafe.Pointer) c.Int { - return 0 -} +//go:linkname Gettimeofday C.gettimeofday +func Gettimeofday(_llcppg_param1 *Timeval, _llcppg_param2 unsafe.Pointer) c.Int //go:linkname Setitimer C.setitimer func Setitimer(_llcppg_param1 c.Int, _llcppg_param2 *Itimerval, _llcppg_param3 *Itimerval) c.Int diff --git a/c/sys/libc_linux_amd64.go b/c/sys/libc_linux_amd64.go index 451efec0..e0687cf3 100644 --- a/c/sys/libc_linux_amd64.go +++ b/c/sys/libc_linux_amd64.go @@ -15,6 +15,18 @@ import ( // Maximum number of file descriptors in `fd_set'. const FD_SETSIZE = 1024 +// Check the first NFDS descriptors each in READFDS (if not NULL) for read +// readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS +// (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out +// after waiting the interval specified therein. Returns the number of ready +// descriptors, or -1 for errors. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeSelect C.select +func NativeSelect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *Timeval) c.Int + // Same as above only that the TIMEOUT value is given with higher // resolution and a sigmask which is been set temporarily. This version // should be used. @@ -60,28 +72,22 @@ type X__TimezonePtrT = *Timezone // NOTE: This form of timezone information is obsolete. // Use the functions and variables declared in instead. // -// llgo:link (*Timeval).Gettimeofday C.gettimeofday -func (self *Timeval) Gettimeofday(__tz X__TimezonePtrT) c.Int { - return 0 -} +//go:linkname Gettimeofday C.gettimeofday +func Gettimeofday(__tv *Timeval, __tz X__TimezonePtrT) c.Int // Set the current time of day and timezone information. // This call is restricted to the super-user. // -// llgo:link (*Timeval).Settimeofday C.settimeofday -func (self *Timeval) Settimeofday(__tz *Timezone) c.Int { - return 0 -} +//go:linkname Settimeofday C.settimeofday +func Settimeofday(__tv *Timeval, __tz *Timezone) c.Int // Adjust the current time of day by the amount in DELTA. // If OLDDELTA is not NULL, it is filled in with the amount // of time adjustment remaining to be done from the last `adjtime' call. // This call is restricted to the super-user. // -// llgo:link (*Timeval).Adjtime C.adjtime -func (self *Timeval) Adjtime(__olddelta *Timeval) c.Int { - return 0 -} +//go:linkname Adjtime C.adjtime +func Adjtime(__delta *Timeval, __olddelta *Timeval) c.Int // Set *VALUE to the current setting of timer WHICH. // Return 0 on success, -1 on errors. diff --git a/c/sys/libc_linux_arm64.go b/c/sys/libc_linux_arm64.go index de406a82..98bcefc3 100644 --- a/c/sys/libc_linux_arm64.go +++ b/c/sys/libc_linux_arm64.go @@ -15,6 +15,18 @@ import ( // Maximum number of file descriptors in `fd_set'. const FD_SETSIZE = 1024 +// Check the first NFDS descriptors each in READFDS (if not NULL) for read +// readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS +// (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out +// after waiting the interval specified therein. Returns the number of ready +// descriptors, or -1 for errors. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname NativeSelect C.select +func NativeSelect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *Timeval) c.Int + // Same as above only that the TIMEOUT value is given with higher // resolution and a sigmask which is been set temporarily. This version // should be used. @@ -60,28 +72,22 @@ type X__TimezonePtrT = *Timezone // NOTE: This form of timezone information is obsolete. // Use the functions and variables declared in instead. // -// llgo:link (*Timeval).Gettimeofday C.gettimeofday -func (self *Timeval) Gettimeofday(__tz X__TimezonePtrT) c.Int { - return 0 -} +//go:linkname Gettimeofday C.gettimeofday +func Gettimeofday(__tv *Timeval, __tz X__TimezonePtrT) c.Int // Set the current time of day and timezone information. // This call is restricted to the super-user. // -// llgo:link (*Timeval).Settimeofday C.settimeofday -func (self *Timeval) Settimeofday(__tz *Timezone) c.Int { - return 0 -} +//go:linkname Settimeofday C.settimeofday +func Settimeofday(__tv *Timeval, __tz *Timezone) c.Int // Adjust the current time of day by the amount in DELTA. // If OLDDELTA is not NULL, it is filled in with the amount // of time adjustment remaining to be done from the last `adjtime' call. // This call is restricted to the super-user. // -// llgo:link (*Timeval).Adjtime C.adjtime -func (self *Timeval) Adjtime(__olddelta *Timeval) c.Int { - return 0 -} +//go:linkname Adjtime C.adjtime +func Adjtime(__delta *Timeval, __olddelta *Timeval) c.Int // Set *VALUE to the current setting of timer WHICH. // Return 0 on success, -1 on errors. From 30a9efc006b29d8478fddef10c61b05ad8c9ba33 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 20 Oct 2026 15:18:11 +0800 Subject: [PATCH 6/6] Replace redundant Native bindings while preserving public contracts --- c/sys/generated_native_llgo_test.go | 4 ++++ c/sys/libc_linux_amd64.go | 12 ------------ c/sys/libc_linux_arm64.go | 12 ------------ c/sys/select.go | 15 ++++++++++++--- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/c/sys/generated_native_llgo_test.go b/c/sys/generated_native_llgo_test.go index 052aad24..fbe14744 100644 --- a/c/sys/generated_native_llgo_test.go +++ b/c/sys/generated_native_llgo_test.go @@ -8,6 +8,10 @@ import ( ) func TestGeneratedGettimeofday(t *testing.T) { + var timeout Timeval + if result := Select(0, nil, nil, nil, &timeout); result != 0 { + t.Fatalf("select with zero timeout = %d", result) + } var value Timeval if unsafe.Sizeof(value) != 16 || unsafe.Alignof(value) != 8 { t.Fatalf("timeval layout = %d/%d", unsafe.Sizeof(value), unsafe.Alignof(value)) diff --git a/c/sys/libc_linux_amd64.go b/c/sys/libc_linux_amd64.go index e0687cf3..1c7afb30 100644 --- a/c/sys/libc_linux_amd64.go +++ b/c/sys/libc_linux_amd64.go @@ -15,18 +15,6 @@ import ( // Maximum number of file descriptors in `fd_set'. const FD_SETSIZE = 1024 -// Check the first NFDS descriptors each in READFDS (if not NULL) for read -// readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS -// (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out -// after waiting the interval specified therein. Returns the number of ready -// descriptors, or -1 for errors. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -//go:linkname NativeSelect C.select -func NativeSelect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *Timeval) c.Int - // Same as above only that the TIMEOUT value is given with higher // resolution and a sigmask which is been set temporarily. This version // should be used. diff --git a/c/sys/libc_linux_arm64.go b/c/sys/libc_linux_arm64.go index 98bcefc3..e7429366 100644 --- a/c/sys/libc_linux_arm64.go +++ b/c/sys/libc_linux_arm64.go @@ -15,18 +15,6 @@ import ( // Maximum number of file descriptors in `fd_set'. const FD_SETSIZE = 1024 -// Check the first NFDS descriptors each in READFDS (if not NULL) for read -// readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS -// (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out -// after waiting the interval specified therein. Returns the number of ready -// descriptors, or -1 for errors. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -//go:linkname NativeSelect C.select -func NativeSelect(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *Timeval) c.Int - // Same as above only that the TIMEOUT value is given with higher // resolution and a sigmask which is been set temporarily. This version // should be used. diff --git a/c/sys/select.go b/c/sys/select.go index 9449efc9..34852aea 100644 --- a/c/sys/select.go +++ b/c/sys/select.go @@ -30,7 +30,16 @@ func FD_SET(fd c.Int, fds *FdSet) //go:linkname FD_ISSET C.llgo_FD_ISSET func FD_ISSET(fd c.Int, fds *FdSet) c.Int -//go:linkname Select C.select -func Select(n c.Int, fdsRead, fdsWrite, fdsError *FdSet, timeout *Timeval) c.Int - // ----------------------------------------------------------------------------- + +// Check the first NFDS descriptors each in READFDS (if not NULL) for read +// readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS +// (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out +// after waiting the interval specified therein. Returns the number of ready +// descriptors, or -1 for errors. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +//go:linkname Select C.select +func Select(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *Timeval) c.Int