From cdd0fa49f548b5c07aed5aba28bc0ef411667cf5 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 13:57:15 +0800 Subject: [PATCH 1/8] feat(c/signal): add native signal support types --- c/signal/libc_linux_amd64.go | 135 +++++++++++++++++++++++++++++++++ c/signal/llcppg.pub | 5 ++ c/signal/types_darwin_arm64.go | 14 ++++ c/signal/types_linux_amd64.go | 14 ++++ 4 files changed, 168 insertions(+) create mode 100644 c/signal/libc_linux_amd64.go create mode 100644 c/signal/llcppg.pub create mode 100644 c/signal/types_darwin_arm64.go create mode 100644 c/signal/types_linux_amd64.go diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go new file mode 100644 index 00000000..743fceb4 --- /dev/null +++ b/c/signal/libc_linux_amd64.go @@ -0,0 +1,135 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +type Sigval struct { + _xgo_union [1]uint64 +} + +type X__SigvalT = Sigval + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} + +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} + +type SiginfoT struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + X__Pad0 c.Int + X_sifields _llcppg_anon_5 +} + +type _llcppg_anon_5 struct { + _xgo_union [14]uint64 +} + +func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { + return (*[28]c.Int)(unsafe.Pointer(p)) +} + +// kill(). +type _llcppg_anon_27 struct { + SiPid c.Int + SiUid c.Uint +} + +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_27 { + return (*_llcppg_anon_27)(unsafe.Pointer(p)) +} + +// POSIX.1b timers. +type _llcppg_anon_28 struct { + SiTid c.Int + SiOverrun c.Int + SiSigval X__SigvalT +} + +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_28 { + return (*_llcppg_anon_28)(unsafe.Pointer(p)) +} + +// POSIX.1b signals. +type _llcppg_anon_29 struct { + SiPid c.Int + SiUid c.Uint + SiSigval X__SigvalT +} + +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_29 { + return (*_llcppg_anon_29)(unsafe.Pointer(p)) +} + +// SIGCHLD. +type _llcppg_anon_30 struct { + SiPid c.Int + SiUid c.Uint + SiStatus c.Int + SiUtime c.Long + SiStime c.Long +} + +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_30 { + return (*_llcppg_anon_30)(unsafe.Pointer(p)) +} + +// SIGILL, SIGFPE, SIGSEGV, SIGBUS. +type _llcppg_anon_31 struct { + SiAddr unsafe.Pointer + SiAddrLsb int16 + X_bounds _llcppg_anon_32 +} + +type _llcppg_anon_32 struct { + _xgo_union [2]uint64 +} + +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_31 { + return (*_llcppg_anon_31)(unsafe.Pointer(p)) +} + +// SIGPOLL. +type _llcppg_anon_33 struct { + SiBand c.Long + SiFd c.Int +} + +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_33 { + return (*_llcppg_anon_33)(unsafe.Pointer(p)) +} + +type _llcppg_anon_34 struct { + X_callAddr unsafe.Pointer + X_syscall c.Int + X_arch c.Uint +} + +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_34 { + return (*_llcppg_anon_34)(unsafe.Pointer(p)) +} + +// used when si_code=SEGV_BNDERR +type _llcppg_anon_36 struct { + X_lower unsafe.Pointer + X_upper unsafe.Pointer +} + +func (p *_llcppg_anon_32) XGof_ref__addr_bnd() *_llcppg_anon_36 { + return (*_llcppg_anon_36)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_32) XGof_ref__pkey() *c.Uint32T { + return (*c.Uint32T)(unsafe.Pointer(p)) +} diff --git a/c/signal/llcppg.pub b/c/signal/llcppg.pub new file mode 100644 index 00000000..54cad9f9 --- /dev/null +++ b/c/signal/llcppg.pub @@ -0,0 +1,5 @@ +D github.com/goplus/lib/c +T __sigval_t X__SigvalT +T siginfo_t SiginfoT +T sigset_t SigsetT +T sigval Sigval diff --git a/c/signal/types_darwin_arm64.go b/c/signal/types_darwin_arm64.go new file mode 100644 index 00000000..8889b06e --- /dev/null +++ b/c/signal/types_darwin_arm64.go @@ -0,0 +1,14 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import "github.com/goplus/lib/c" + +type X__Uint32T = c.Uint + +type SigsetT = X__DarwinSigsetT + +// [???] signal set +type X__DarwinSigsetT = X__Uint32T diff --git a/c/signal/types_linux_amd64.go b/c/signal/types_linux_amd64.go new file mode 100644 index 00000000..12fd44fc --- /dev/null +++ b/c/signal/types_linux_amd64.go @@ -0,0 +1,14 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import "github.com/goplus/lib/c" + +type X__SigsetT struct { + X__Val [16]c.Ulong +} + +// A set of signals to be blocked, unblocked, or waited for. +type SigsetT = X__SigsetT From d199721b69c2419c560646804ec219e7613df6bc Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 17:46:26 +0800 Subject: [PATCH 2/8] Regenerate c/signal independently with native platform inputs --- c/signal/arm-_types_darwin_arm64.go | 64 ++++ c/signal/bits-sigaction_linux_amd64.go | 72 ++++ c/signal/bits-sigaction_linux_arm64.go | 72 ++++ c/signal/bits-siginfo_linux_amd64.go | 246 +++++++++++++ c/signal/bits-siginfo_linux_arm64.go | 240 +++++++++++++ c/signal/bits-signum_linux_amd64.go | 84 +++++ c/signal/bits-signum_linux_arm64.go | 84 +++++ c/signal/bits-sigset_linux_amd64.go | 30 ++ c/signal/bits-sigset_linux_arm64.go | 30 ++ c/signal/bits-sigstack_linux_amd64.go | 38 ++ c/signal/bits-sigstack_linux_arm64.go | 38 ++ c/signal/bits-types_linux_amd64.go | 133 +++++++ c/signal/bits-types_linux_arm64.go | 133 +++++++ c/signal/libc_linux_amd64.go | 135 ------- c/signal/llcppg-linux_amd64.cfg | 26 ++ c/signal/llcppg-linux_arm64.cfg | 26 ++ c/signal/llcppg.cfg | 26 ++ c/signal/llcppg.pub | 112 +++++- c/signal/signal_darwin_arm64.go | 90 +++++ c/signal/signal_linux_amd64.go | 209 +++++++++++ c/signal/signal_linux_arm64.go | 209 +++++++++++ c/signal/sys-_types-_pid_t_darwin_arm64.go | 7 + .../sys-_types-_sigaltstack_darwin_arm64.go | 19 + c/signal/sys-_types-_sigset_t_darwin_arm64.go | 7 + ... => sys-_types-_u_int32_t_darwin_arm64.go} | 7 +- .../sys-_types-_u_int64_t_darwin_arm64.go | 9 + c/signal/sys-_types-_uid_t_darwin_arm64.go | 7 + c/signal/sys-_types_darwin_arm64.go | 63 ++++ c/signal/sys-signal_darwin_arm64.go | 338 ++++++++++++++++++ c/signal/types_linux_amd64.go | 14 - 30 files changed, 2411 insertions(+), 157 deletions(-) create mode 100644 c/signal/arm-_types_darwin_arm64.go create mode 100644 c/signal/bits-sigaction_linux_amd64.go create mode 100644 c/signal/bits-sigaction_linux_arm64.go create mode 100644 c/signal/bits-siginfo_linux_amd64.go create mode 100644 c/signal/bits-siginfo_linux_arm64.go create mode 100644 c/signal/bits-signum_linux_amd64.go create mode 100644 c/signal/bits-signum_linux_arm64.go create mode 100644 c/signal/bits-sigset_linux_amd64.go create mode 100644 c/signal/bits-sigset_linux_arm64.go create mode 100644 c/signal/bits-sigstack_linux_amd64.go create mode 100644 c/signal/bits-sigstack_linux_arm64.go create mode 100644 c/signal/bits-types_linux_amd64.go create mode 100644 c/signal/bits-types_linux_arm64.go delete mode 100644 c/signal/libc_linux_amd64.go create mode 100644 c/signal/llcppg-linux_amd64.cfg create mode 100644 c/signal/llcppg-linux_arm64.cfg create mode 100644 c/signal/llcppg.cfg create mode 100644 c/signal/signal_darwin_arm64.go create mode 100644 c/signal/signal_linux_amd64.go create mode 100644 c/signal/signal_linux_arm64.go create mode 100644 c/signal/sys-_types-_pid_t_darwin_arm64.go create mode 100644 c/signal/sys-_types-_sigaltstack_darwin_arm64.go create mode 100644 c/signal/sys-_types-_sigset_t_darwin_arm64.go rename c/signal/{types_darwin_arm64.go => sys-_types-_u_int32_t_darwin_arm64.go} (53%) create mode 100644 c/signal/sys-_types-_u_int64_t_darwin_arm64.go create mode 100644 c/signal/sys-_types-_uid_t_darwin_arm64.go create mode 100644 c/signal/sys-_types_darwin_arm64.go create mode 100644 c/signal/sys-signal_darwin_arm64.go delete mode 100644 c/signal/types_linux_amd64.go diff --git a/c/signal/arm-_types_darwin_arm64.go b/c/signal/arm-_types_darwin_arm64.go new file mode 100644 index 00000000..ab0fb789 --- /dev/null +++ b/c/signal/arm-_types_darwin_arm64.go @@ -0,0 +1,64 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +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/signal/bits-sigaction_linux_amd64.go b/c/signal/bits-sigaction_linux_amd64.go new file mode 100644 index 00000000..ee4ad760 --- /dev/null +++ b/c/signal/bits-sigaction_linux_amd64.go @@ -0,0 +1,72 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +// Bits in `sa_flags'. +const ( + SA_NOCLDSTOP = 1 + // Don't create zombie on child death. + SA_NOCLDWAIT = 2 + // Invoke signal-catching function with + // three arguments instead of one. + SA_SIGINFO = 4 +) + +// Use signal stack by using `sa_restorer'. +const SA_ONSTACK = 134217728 +const ( + // Restart syscall on signal return. + SA_RESTART = 268435456 + // Don't automatically block the signal when + // its handler is being executed. + SA_NODEFER = 1073741824 +) + +// Reset to SIG_DFL on entry to handler. +const SA_RESETHAND = 2147483648 + +// Historical no-op. +const SA_INTERRUPT = 536870912 + +// Some aliases for the SA_ constants. +const ( + SA_NOMASK = 1073741824 + SA_ONESHOT = 2147483648 + SA_STACK = 134217728 +) + +// Values for the HOW argument to `sigprocmask'. +const ( + SIG_BLOCK = 0 + // Unblock signals. + SIG_UNBLOCK = 1 + // Set the set of blocked signals. + SIG_SETMASK = 2 +) + +// Structure describing the action to be taken when a signal arrives. +// +// llgo:type C +type SigactionT struct { + X__SigactionTHandler _llcppg_anon_2 + SaMask X__SigsetT + SaFlags c.Int + SaRestorer func() +} +type _llcppg_anon_2 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_2) XGof_ref_sa_handler() *X__SighandlerT { + return (*X__SighandlerT)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_2) XGof_ref_sa_sigaction() *func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer) { + return (*func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer))(unsafe.Pointer(p)) +} diff --git a/c/signal/bits-sigaction_linux_arm64.go b/c/signal/bits-sigaction_linux_arm64.go new file mode 100644 index 00000000..64184a06 --- /dev/null +++ b/c/signal/bits-sigaction_linux_arm64.go @@ -0,0 +1,72 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +// Bits in `sa_flags'. +const ( + SA_NOCLDSTOP = 1 + // Don't create zombie on child death. + SA_NOCLDWAIT = 2 + // Invoke signal-catching function with + // three arguments instead of one. + SA_SIGINFO = 4 +) + +// Use signal stack by using `sa_restorer'. +const SA_ONSTACK = 134217728 +const ( + // Restart syscall on signal return. + SA_RESTART = 268435456 + // Don't automatically block the signal when + // its handler is being executed. + SA_NODEFER = 1073741824 +) + +// Reset to SIG_DFL on entry to handler. +const SA_RESETHAND = 2147483648 + +// Historical no-op. +const SA_INTERRUPT = 536870912 + +// Some aliases for the SA_ constants. +const ( + SA_NOMASK = 1073741824 + SA_ONESHOT = 2147483648 + SA_STACK = 134217728 +) + +// Values for the HOW argument to `sigprocmask'. +const ( + SIG_BLOCK = 0 + // Unblock signals. + SIG_UNBLOCK = 1 + // Set the set of blocked signals. + SIG_SETMASK = 2 +) + +// Structure describing the action to be taken when a signal arrives. +// +// llgo:type C +type SigactionT struct { + X__SigactionTHandler _llcppg_anon_2 + SaMask X__SigsetT + SaFlags c.Int + SaRestorer func() +} +type _llcppg_anon_2 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_2) XGof_ref_sa_handler() *X__SighandlerT { + return (*X__SighandlerT)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_2) XGof_ref_sa_sigaction() *func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer) { + return (*func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer))(unsafe.Pointer(p)) +} diff --git a/c/signal/bits-siginfo_linux_amd64.go b/c/signal/bits-siginfo_linux_amd64.go new file mode 100644 index 00000000..ef034a8a --- /dev/null +++ b/c/signal/bits-siginfo_linux_amd64.go @@ -0,0 +1,246 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +const X__HaveSigvalT = 1 +const X__HaveSiginfoT = 1 +const X__SI_MAX_SIZE = 128 +const X__HaveSigeventT = 1 + +// Structure to transport application-defined values with signals. +const X__SIGEV_MAX_SIZE = 64 +const X__HavePthreadAttrT = 1 + +type Sigval struct { + _xgo_union [1]uint64 +} +type SiginfoT struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + X_sifields _llcppg_anon_0 +} + +// Values for `si_code'. Positive values are reserved for kernel-generated +// signals. +const ( + SI_ASYNCNL = -60 + SI_TKILL = -6 + SI_SIGIO = -5 + SI_ASYNCIO = -4 + SI_MESGQ = -3 + SI_TIMER = -2 + SI_QUEUE = -1 + SI_USER = 0 + // Send by kernel. + SI_KERNEL = 128 +) + +// `si_code' values for SIGILL signal. +const ( + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + // Internal stack error. + ILL_BADSTK = 8 +) + +// `si_code' values for SIGFPE signal. +const ( + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + // Subscript out of range. + FPE_FLTSUB = 8 +) + +// `si_code' values for SIGSEGV signal. +const ( + SEGV_MAPERR = 1 + // Invalid permissions for mapped object. + SEGV_ACCERR = 2 +) + +// `si_code' values for SIGBUS signal. +const ( + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + BUS_MCEERR_AR = 4 + // Hardware memory error: action optional. + BUS_MCEERR_AO = 5 +) + +// `si_code' values for SIGCHLD signal. +const ( + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + // Stopped child has continued. + CLD_CONTINUED = 6 +) + +// `si_code' values for SIGPOLL signal. +const ( + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + // Device disconnected. + POLL_HUP = 6 +) + +type Sigevent struct { + SigevValue SigvalT + SigevSigno c.Int + SigevNotify c.Int + X_sigevUn _llcppg_anon_1 +} + +// `sigev_notify' values. +const ( + SIGEV_SIGNAL = 0 + SIGEV_NONE = 1 + SIGEV_THREAD = 2 + // Send signal to specific thread. + SIGEV_THREAD_ID = 4 +) + +type PthreadAttrT struct { +} + +// Type for data associated with a signal. +type SigvalT = Sigval +type X__SigchldClockT = X__ClockT +type _llcppg_anon_0 struct { + _xgo_union [14]uint64 +} +type _llcppg_anon_1 struct { + _xgo_union [6]uint64 +} +type SigeventT = Sigevent + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_0) XGof_ref__pad() *[28]c.Int { + return (*[28]c.Int)(unsafe.Pointer(p)) +} + +// kill(). +type _llcppg_anon_3 struct { + SiPid X__PidT + SiUid X__UidT +} + +func (p *_llcppg_anon_0) XGof_ref__kill() *_llcppg_anon_3 { + return (*_llcppg_anon_3)(unsafe.Pointer(p)) +} + +// POSIX.1b timers. +type _llcppg_anon_4 struct { + SiTid c.Int + SiOverrun c.Int + SiSigval SigvalT +} + +func (p *_llcppg_anon_0) XGof_ref__timer() *_llcppg_anon_4 { + return (*_llcppg_anon_4)(unsafe.Pointer(p)) +} + +// POSIX.1b signals. +type _llcppg_anon_5 struct { + SiPid X__PidT + SiUid X__UidT + SiSigval SigvalT +} + +func (p *_llcppg_anon_0) XGof_ref__rt() *_llcppg_anon_5 { + return (*_llcppg_anon_5)(unsafe.Pointer(p)) +} + +// SIGCHLD. +type _llcppg_anon_6 struct { + SiPid X__PidT + SiUid X__UidT + SiStatus c.Int + SiUtime X__SigchldClockT + SiStime X__SigchldClockT +} + +func (p *_llcppg_anon_0) XGof_ref__sigchld() *_llcppg_anon_6 { + return (*_llcppg_anon_6)(unsafe.Pointer(p)) +} + +// SIGILL, SIGFPE, SIGSEGV, SIGBUS. +type _llcppg_anon_7 struct { + SiAddr unsafe.Pointer + SiAddrLsb int16 + SiAddrBnd _llcppg_anon_8 +} +type _llcppg_anon_8 struct { + X_lower unsafe.Pointer + X_upper unsafe.Pointer +} + +func (p *_llcppg_anon_0) XGof_ref__sigfault() *_llcppg_anon_7 { + return (*_llcppg_anon_7)(unsafe.Pointer(p)) +} + +// SIGPOLL. +type _llcppg_anon_9 struct { + SiBand c.Long + SiFd c.Int +} + +func (p *_llcppg_anon_0) XGof_ref__sigpoll() *_llcppg_anon_9 { + return (*_llcppg_anon_9)(unsafe.Pointer(p)) +} + +// SIGSYS. +type _llcppg_anon_10 struct { + X_callAddr unsafe.Pointer + X_syscall c.Int + X_arch c.Uint +} + +func (p *_llcppg_anon_0) XGof_ref__sigsys() *_llcppg_anon_10 { + return (*_llcppg_anon_10)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_1) XGof_ref__pad() *[12]c.Int { + return (*[12]c.Int)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_1) XGof_ref__tid() *X__PidT { + return (*X__PidT)(unsafe.Pointer(p)) +} + +// llgo:type C +type _llcppg_anon_11 struct { + X_function func(_llcppg_param1 SigvalT) + X_attribute *PthreadAttrT +} + +func (p *_llcppg_anon_1) XGof_ref__sigev_thread() *_llcppg_anon_11 { + return (*_llcppg_anon_11)(unsafe.Pointer(p)) +} diff --git a/c/signal/bits-siginfo_linux_arm64.go b/c/signal/bits-siginfo_linux_arm64.go new file mode 100644 index 00000000..af69745d --- /dev/null +++ b/c/signal/bits-siginfo_linux_arm64.go @@ -0,0 +1,240 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +const X__HaveSigvalT = 1 +const X__HaveSiginfoT = 1 +const X__SI_MAX_SIZE = 128 +const X__HaveSigeventT = 1 + +// Structure to transport application-defined values with signals. +const X__SIGEV_MAX_SIZE = 64 +const X__HavePthreadAttrT = 1 + +type Sigval struct { + _xgo_union [1]uint64 +} +type SiginfoT struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + X_sifields _llcppg_anon_0 +} + +// Values for `si_code'. Positive values are reserved for kernel-generated +// signals. +const ( + SI_ASYNCNL = -60 + SI_TKILL = -6 + SI_SIGIO = -5 + SI_ASYNCIO = -4 + SI_MESGQ = -3 + SI_TIMER = -2 + SI_QUEUE = -1 + SI_USER = 0 + // Send by kernel. + SI_KERNEL = 128 +) + +// `si_code' values for SIGILL signal. +const ( + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + // Internal stack error. + ILL_BADSTK = 8 +) + +// `si_code' values for SIGFPE signal. +const ( + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + // Subscript out of range. + FPE_FLTSUB = 8 +) + +// `si_code' values for SIGSEGV signal. +const ( + SEGV_MAPERR = 1 + // Invalid permissions for mapped object. + SEGV_ACCERR = 2 +) + +// `si_code' values for SIGBUS signal. +const ( + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + BUS_MCEERR_AR = 4 + // Hardware memory error: action optional. + BUS_MCEERR_AO = 5 +) + +// `si_code' values for SIGCHLD signal. +const ( + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + // Stopped child has continued. + CLD_CONTINUED = 6 +) + +// `si_code' values for SIGPOLL signal. +const ( + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + // Device disconnected. + POLL_HUP = 6 +) + +type Sigevent struct { + SigevValue SigvalT + SigevSigno c.Int + SigevNotify c.Int + X_sigevUn _llcppg_anon_1 +} + +// `sigev_notify' values. +const ( + SIGEV_SIGNAL = 0 + SIGEV_NONE = 1 + SIGEV_THREAD = 2 + // Send signal to specific thread. + SIGEV_THREAD_ID = 4 +) + +type PthreadAttrT struct { +} + +// Type for data associated with a signal. +type SigvalT = Sigval +type _llcppg_anon_0 struct { + _xgo_union [14]uint64 +} +type _llcppg_anon_1 struct { + _xgo_union [6]uint64 +} +type SigeventT = Sigevent + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_0) XGof_ref__pad() *[28]c.Int { + return (*[28]c.Int)(unsafe.Pointer(p)) +} + +// kill(). +type _llcppg_anon_3 struct { + SiPid X__PidT + SiUid X__UidT +} + +func (p *_llcppg_anon_0) XGof_ref__kill() *_llcppg_anon_3 { + return (*_llcppg_anon_3)(unsafe.Pointer(p)) +} + +// POSIX.1b timers. +type _llcppg_anon_4 struct { + SiTid c.Int + SiOverrun c.Int + SiSigval SigvalT +} + +func (p *_llcppg_anon_0) XGof_ref__timer() *_llcppg_anon_4 { + return (*_llcppg_anon_4)(unsafe.Pointer(p)) +} + +// POSIX.1b signals. +type _llcppg_anon_5 struct { + SiPid X__PidT + SiUid X__UidT + SiSigval SigvalT +} + +func (p *_llcppg_anon_0) XGof_ref__rt() *_llcppg_anon_5 { + return (*_llcppg_anon_5)(unsafe.Pointer(p)) +} + +// SIGCHLD. +type _llcppg_anon_6 struct { + SiPid X__PidT + SiUid X__UidT + SiStatus c.Int + SiUtime X__ClockT + SiStime X__ClockT +} + +func (p *_llcppg_anon_0) XGof_ref__sigchld() *_llcppg_anon_6 { + return (*_llcppg_anon_6)(unsafe.Pointer(p)) +} + +// SIGILL, SIGFPE, SIGSEGV, SIGBUS. +type _llcppg_anon_7 struct { + SiAddr unsafe.Pointer + SiAddrLsb int16 +} + +func (p *_llcppg_anon_0) XGof_ref__sigfault() *_llcppg_anon_7 { + return (*_llcppg_anon_7)(unsafe.Pointer(p)) +} + +// SIGPOLL. +type _llcppg_anon_8 struct { + SiBand c.Long + SiFd c.Int +} + +func (p *_llcppg_anon_0) XGof_ref__sigpoll() *_llcppg_anon_8 { + return (*_llcppg_anon_8)(unsafe.Pointer(p)) +} + +// SIGSYS. +type _llcppg_anon_9 struct { + X_callAddr unsafe.Pointer + X_syscall c.Int + X_arch c.Uint +} + +func (p *_llcppg_anon_0) XGof_ref__sigsys() *_llcppg_anon_9 { + return (*_llcppg_anon_9)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_1) XGof_ref__pad() *[12]c.Int { + return (*[12]c.Int)(unsafe.Pointer(p)) +} +func (p *_llcppg_anon_1) XGof_ref__tid() *X__PidT { + return (*X__PidT)(unsafe.Pointer(p)) +} + +// llgo:type C +type _llcppg_anon_10 struct { + X_function func(_llcppg_param1 SigvalT) + X_attribute *PthreadAttrT +} + +func (p *_llcppg_anon_1) XGof_ref__sigev_thread() *_llcppg_anon_10 { + return (*_llcppg_anon_10)(unsafe.Pointer(p)) +} diff --git a/c/signal/bits-signum_linux_amd64.go b/c/signal/bits-signum_linux_amd64.go new file mode 100644 index 00000000..e69ba232 --- /dev/null +++ b/c/signal/bits-signum_linux_amd64.go @@ -0,0 +1,84 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +// Signals. +const ( + SIGHUP = 1 + // Interrupt (ANSI). + SIGINT = 2 + // Quit (POSIX). + SIGQUIT = 3 + // Illegal instruction (ANSI). + SIGILL = 4 + // Trace trap (POSIX). + SIGTRAP = 5 + // Abort (ANSI). + SIGABRT = 6 + // IOT trap (4.2 BSD). + SIGIOT = 6 + // BUS error (4.2 BSD). + SIGBUS = 7 + // Floating-point exception (ANSI). + SIGFPE = 8 + // Kill, unblockable (POSIX). + SIGKILL = 9 + // User-defined signal 1 (POSIX). + SIGUSR1 = 10 + // Segmentation violation (ANSI). + SIGSEGV = 11 + // User-defined signal 2 (POSIX). + SIGUSR2 = 12 + // Broken pipe (POSIX). + SIGPIPE = 13 + // Alarm clock (POSIX). + SIGALRM = 14 + // Termination (ANSI). + SIGTERM = 15 + // Stack fault. + SIGSTKFLT = 16 + // Child status has changed (POSIX). + SIGCHLD = 17 + // Continue (POSIX). + SIGCONT = 18 + // Stop, unblockable (POSIX). + SIGSTOP = 19 + // Keyboard stop (POSIX). + SIGTSTP = 20 + // Background read from tty (POSIX). + SIGTTIN = 21 + // Background write to tty (POSIX). + SIGTTOU = 22 + // Urgent condition on socket (4.2 BSD). + SIGURG = 23 + // CPU limit exceeded (4.2 BSD). + SIGXCPU = 24 + // File size limit exceeded (4.2 BSD). + SIGXFSZ = 25 + // Virtual alarm clock (4.2 BSD). + SIGVTALRM = 26 + // Profiling alarm clock (4.2 BSD). + SIGPROF = 27 + // Window size change (4.3 BSD, Sun). + SIGWINCH = 28 + // I/O now possible (4.2 BSD). + SIGIO = 29 + // Power failure restart (System V). + SIGPWR = 30 + // Bad system call. + SIGSYS = 31 + SIGUNUSED = 31 +) + +// Biggest signal number + 1 +// (including real-time signals). +const X_NSIG = 65 + +// These are the hard limits of the kernel. These values should not be +// used directly at user level. +const ( + X__SIGRTMIN = 32 + X__SIGRTMAX = 64 +) diff --git a/c/signal/bits-signum_linux_arm64.go b/c/signal/bits-signum_linux_arm64.go new file mode 100644 index 00000000..3ab63c66 --- /dev/null +++ b/c/signal/bits-signum_linux_arm64.go @@ -0,0 +1,84 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +// Signals. +const ( + SIGHUP = 1 + // Interrupt (ANSI). + SIGINT = 2 + // Quit (POSIX). + SIGQUIT = 3 + // Illegal instruction (ANSI). + SIGILL = 4 + // Trace trap (POSIX). + SIGTRAP = 5 + // Abort (ANSI). + SIGABRT = 6 + // IOT trap (4.2 BSD). + SIGIOT = 6 + // BUS error (4.2 BSD). + SIGBUS = 7 + // Floating-point exception (ANSI). + SIGFPE = 8 + // Kill, unblockable (POSIX). + SIGKILL = 9 + // User-defined signal 1 (POSIX). + SIGUSR1 = 10 + // Segmentation violation (ANSI). + SIGSEGV = 11 + // User-defined signal 2 (POSIX). + SIGUSR2 = 12 + // Broken pipe (POSIX). + SIGPIPE = 13 + // Alarm clock (POSIX). + SIGALRM = 14 + // Termination (ANSI). + SIGTERM = 15 + // Stack fault. + SIGSTKFLT = 16 + // Child status has changed (POSIX). + SIGCHLD = 17 + // Continue (POSIX). + SIGCONT = 18 + // Stop, unblockable (POSIX). + SIGSTOP = 19 + // Keyboard stop (POSIX). + SIGTSTP = 20 + // Background read from tty (POSIX). + SIGTTIN = 21 + // Background write to tty (POSIX). + SIGTTOU = 22 + // Urgent condition on socket (4.2 BSD). + SIGURG = 23 + // CPU limit exceeded (4.2 BSD). + SIGXCPU = 24 + // File size limit exceeded (4.2 BSD). + SIGXFSZ = 25 + // Virtual alarm clock (4.2 BSD). + SIGVTALRM = 26 + // Profiling alarm clock (4.2 BSD). + SIGPROF = 27 + // Window size change (4.3 BSD, Sun). + SIGWINCH = 28 + // I/O now possible (4.2 BSD). + SIGIO = 29 + // Power failure restart (System V). + SIGPWR = 30 + // Bad system call. + SIGSYS = 31 + SIGUNUSED = 31 +) + +// Biggest signal number + 1 +// (including real-time signals). +const X_NSIG = 65 + +// These are the hard limits of the kernel. These values should not be +// used directly at user level. +const ( + X__SIGRTMIN = 32 + X__SIGRTMAX = 64 +) diff --git a/c/signal/bits-sigset_linux_amd64.go b/c/signal/bits-sigset_linux_amd64.go new file mode 100644 index 00000000..f3d19750 --- /dev/null +++ b/c/signal/bits-sigset_linux_amd64.go @@ -0,0 +1,30 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import "github.com/goplus/lib/c" + +const X_SIGSET_H_types = 1 +const X_SIGSET_H_fns = 1 + +type X__SigsetT struct { + X__Val [16]c.Ulong +} +type X__SigAtomicT = c.Int + +// llgo:link (*X__SigsetT).X__Sigismember C.__sigismember +func (self *X__SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*X__SigsetT).X__Sigaddset C.__sigaddset +func (self *X__SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*X__SigsetT).X__Sigdelset C.__sigdelset +func (self *X__SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { + return 0 +} diff --git a/c/signal/bits-sigset_linux_arm64.go b/c/signal/bits-sigset_linux_arm64.go new file mode 100644 index 00000000..4e73ed47 --- /dev/null +++ b/c/signal/bits-sigset_linux_arm64.go @@ -0,0 +1,30 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import "github.com/goplus/lib/c" + +const X_SIGSET_H_types = 1 +const X_SIGSET_H_fns = 1 + +type X__SigsetT struct { + X__Val [16]c.Ulong +} +type X__SigAtomicT = c.Int + +// llgo:link (*X__SigsetT).X__Sigismember C.__sigismember +func (self *X__SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*X__SigsetT).X__Sigaddset C.__sigaddset +func (self *X__SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*X__SigsetT).X__Sigdelset C.__sigdelset +func (self *X__SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { + return 0 +} diff --git a/c/signal/bits-sigstack_linux_amd64.go b/c/signal/bits-sigstack_linux_amd64.go new file mode 100644 index 00000000..f3b8a9e5 --- /dev/null +++ b/c/signal/bits-sigstack_linux_amd64.go @@ -0,0 +1,38 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +// Minimum stack size for a signal handler. +const MINSIGSTKSZ = 2048 + +// System default stack size. +const SIGSTKSZ = 8192 + +// Structure describing a signal stack (obsolete). +type Sigstack struct { + SsSp unsafe.Pointer + SsOnstack c.Int +} + +// Possible values for `ss_flags.'. +const ( + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + +// Alternate, preferred interface. +type Sigaltstack struct { + SsSp unsafe.Pointer + SsFlags c.Int + SsSize c.SizeT +} + +// Alternate, preferred interface. +type StackT = Sigaltstack diff --git a/c/signal/bits-sigstack_linux_arm64.go b/c/signal/bits-sigstack_linux_arm64.go new file mode 100644 index 00000000..df897068 --- /dev/null +++ b/c/signal/bits-sigstack_linux_arm64.go @@ -0,0 +1,38 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +// Minimum stack size for a signal handler. +const MINSIGSTKSZ = 5120 + +// System default stack size. +const SIGSTKSZ = 16384 + +// Structure describing a signal stack (obsolete). +type Sigstack struct { + SsSp unsafe.Pointer + SsOnstack c.Int +} + +// Possible values for `ss_flags.'. +const ( + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + +// Alternate, preferred interface. +type Sigaltstack struct { + SsSp unsafe.Pointer + SsFlags c.Int + SsSize c.SizeT +} + +// Alternate, preferred interface. +type StackT = Sigaltstack diff --git a/c/signal/bits-types_linux_amd64.go b/c/signal/bits-types_linux_amd64.go new file mode 100644 index 00000000..baea4a6b --- /dev/null +++ b/c/signal/bits-types_linux_amd64.go @@ -0,0 +1,133 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +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/signal/bits-types_linux_arm64.go b/c/signal/bits-types_linux_arm64.go new file mode 100644 index 00000000..fe23c21a --- /dev/null +++ b/c/signal/bits-types_linux_arm64.go @@ -0,0 +1,133 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +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/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go deleted file mode 100644 index 743fceb4..00000000 --- a/c/signal/libc_linux_amd64.go +++ /dev/null @@ -1,135 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. -// Classified from the common libc binding. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -type Sigval struct { - _xgo_union [1]uint64 -} - -type X__SigvalT = Sigval - -func (p *Sigval) XGof_ref_sival_int() *c.Int { - return (*c.Int)(unsafe.Pointer(p)) -} - -func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { - return (*unsafe.Pointer)(unsafe.Pointer(p)) -} - -type SiginfoT struct { - SiSigno c.Int - SiErrno c.Int - SiCode c.Int - X__Pad0 c.Int - X_sifields _llcppg_anon_5 -} - -type _llcppg_anon_5 struct { - _xgo_union [14]uint64 -} - -func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { - return (*[28]c.Int)(unsafe.Pointer(p)) -} - -// kill(). -type _llcppg_anon_27 struct { - SiPid c.Int - SiUid c.Uint -} - -func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_27 { - return (*_llcppg_anon_27)(unsafe.Pointer(p)) -} - -// POSIX.1b timers. -type _llcppg_anon_28 struct { - SiTid c.Int - SiOverrun c.Int - SiSigval X__SigvalT -} - -func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_28 { - return (*_llcppg_anon_28)(unsafe.Pointer(p)) -} - -// POSIX.1b signals. -type _llcppg_anon_29 struct { - SiPid c.Int - SiUid c.Uint - SiSigval X__SigvalT -} - -func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_29 { - return (*_llcppg_anon_29)(unsafe.Pointer(p)) -} - -// SIGCHLD. -type _llcppg_anon_30 struct { - SiPid c.Int - SiUid c.Uint - SiStatus c.Int - SiUtime c.Long - SiStime c.Long -} - -func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_30 { - return (*_llcppg_anon_30)(unsafe.Pointer(p)) -} - -// SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_31 struct { - SiAddr unsafe.Pointer - SiAddrLsb int16 - X_bounds _llcppg_anon_32 -} - -type _llcppg_anon_32 struct { - _xgo_union [2]uint64 -} - -func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_31 { - return (*_llcppg_anon_31)(unsafe.Pointer(p)) -} - -// SIGPOLL. -type _llcppg_anon_33 struct { - SiBand c.Long - SiFd c.Int -} - -func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_33 { - return (*_llcppg_anon_33)(unsafe.Pointer(p)) -} - -type _llcppg_anon_34 struct { - X_callAddr unsafe.Pointer - X_syscall c.Int - X_arch c.Uint -} - -func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_34 { - return (*_llcppg_anon_34)(unsafe.Pointer(p)) -} - -// used when si_code=SEGV_BNDERR -type _llcppg_anon_36 struct { - X_lower unsafe.Pointer - X_upper unsafe.Pointer -} - -func (p *_llcppg_anon_32) XGof_ref__addr_bnd() *_llcppg_anon_36 { - return (*_llcppg_anon_36)(unsafe.Pointer(p)) -} - -func (p *_llcppg_anon_32) XGof_ref__pkey() *c.Uint32T { - return (*c.Uint32T)(unsafe.Pointer(p)) -} diff --git a/c/signal/llcppg-linux_amd64.cfg b/c/signal/llcppg-linux_amd64.cfg new file mode 100644 index 00000000..f72ada21 --- /dev/null +++ b/c/signal/llcppg-linux_amd64.cfg @@ -0,0 +1,26 @@ +{ + "Name": "signal", + "Language": "c", + "Dir": ".sysroot/include", + "Stdlib": ".sysroot/stdlib", + "Files": [ + "llcppg.h" + ], + "Deps": [ + "..", + "../time" + ], + "FailFast": 0, + "FuncIgnore": [ + "signal", + "sigaction", + "sigvec", + "sigstack" + ], + "TypeIgnore": [ + "va_list" + ], + "Rename": { + "sigaction": "SigactionT" + } +} diff --git a/c/signal/llcppg-linux_arm64.cfg b/c/signal/llcppg-linux_arm64.cfg new file mode 100644 index 00000000..f72ada21 --- /dev/null +++ b/c/signal/llcppg-linux_arm64.cfg @@ -0,0 +1,26 @@ +{ + "Name": "signal", + "Language": "c", + "Dir": ".sysroot/include", + "Stdlib": ".sysroot/stdlib", + "Files": [ + "llcppg.h" + ], + "Deps": [ + "..", + "../time" + ], + "FailFast": 0, + "FuncIgnore": [ + "signal", + "sigaction", + "sigvec", + "sigstack" + ], + "TypeIgnore": [ + "va_list" + ], + "Rename": { + "sigaction": "SigactionT" + } +} diff --git a/c/signal/llcppg.cfg b/c/signal/llcppg.cfg new file mode 100644 index 00000000..f72ada21 --- /dev/null +++ b/c/signal/llcppg.cfg @@ -0,0 +1,26 @@ +{ + "Name": "signal", + "Language": "c", + "Dir": ".sysroot/include", + "Stdlib": ".sysroot/stdlib", + "Files": [ + "llcppg.h" + ], + "Deps": [ + "..", + "../time" + ], + "FailFast": 0, + "FuncIgnore": [ + "signal", + "sigaction", + "sigvec", + "sigstack" + ], + "TypeIgnore": [ + "va_list" + ], + "Rename": { + "sigaction": "SigactionT" + } +} diff --git a/c/signal/llcppg.pub b/c/signal/llcppg.pub index 54cad9f9..1424b5aa 100644 --- a/c/signal/llcppg.pub +++ b/c/signal/llcppg.pub @@ -1,5 +1,113 @@ -D github.com/goplus/lib/c -T __sigval_t X__SigvalT +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_sigaltstack X__DarwinSigaltstack +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 __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 __sig_atomic_t X__SigAtomicT +T __sigaction X__SigactionT +T __sigaction_u X__SigactionT_U +T __sigchld_clock_t X__SigchldClockT +T __sighandler_t X__SighandlerT +T __siginfo X__Siginfo +T __sigset_t X__SigsetT +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 pid_t PidT +T pthread_attr_t PthreadAttrT +T sig_atomic_t SigAtomicT +T sig_t SigT +T sigaction SigactionT +T sigaltstack Sigaltstack +T sigevent Sigevent +T sigevent_t SigeventT T siginfo_t SiginfoT T sigset_t SigsetT +T sigstack Sigstack T sigval Sigval +T sigval_t SigvalT +T sigvec Sigvec +T stack_t StackT +T u_int32_t UInt32T +T u_int64_t UInt64T +T uid_t UidT diff --git a/c/signal/signal_darwin_arm64.go b/c/signal/signal_darwin_arm64.go new file mode 100644 index 00000000..d258314e --- /dev/null +++ b/c/signal/signal_darwin_arm64.go @@ -0,0 +1,90 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + _ "unsafe" +) + +//go:linkname SysSigname C.sys_signame +var SysSigname [32]*c.Char + +//go:linkname SysSiglist C.sys_siglist +var SysSiglist [32]*c.Char + +//go:linkname Raise C.raise +func Raise(_llcppg_param1 c.Int) c.Int + +//go:linkname BsdSignal C.bsd_signal +func BsdSignal(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) + +//go:linkname Kill C.kill +func Kill(_llcppg_param1 PidT, _llcppg_param2 c.Int) c.Int + +//go:linkname Killpg C.killpg +func Killpg(_llcppg_param1 PidT, _llcppg_param2 c.Int) c.Int + +//go:linkname PthreadSigmask C.pthread_sigmask +func PthreadSigmask(_llcppg_param1 c.Int, _llcppg_param2 *SigsetT, _llcppg_param3 *SigsetT) c.Int + +//go:linkname Sigaddset C.sigaddset +func Sigaddset(_llcppg_param1 *SigsetT, _llcppg_param2 c.Int) c.Int + +// llgo:link (*StackT).Sigaltstack C.sigaltstack +func (self *StackT) Sigaltstack(_llcppg_param2 *StackT) c.Int { + return 0 +} + +//go:linkname Sigdelset C.sigdelset +func Sigdelset(_llcppg_param1 *SigsetT, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigemptyset C.sigemptyset +func Sigemptyset(_llcppg_param1 *SigsetT) c.Int + +//go:linkname Sigfillset C.sigfillset +func Sigfillset(_llcppg_param1 *SigsetT) c.Int + +//go:linkname Sighold C.sighold +func Sighold(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigignore C.sigignore +func Sigignore(_llcppg_param1 c.Int) c.Int + +//go:linkname Siginterrupt C.siginterrupt +func Siginterrupt(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigismember C.sigismember +func Sigismember(_llcppg_param1 *SigsetT, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigpause C.sigpause +func Sigpause(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigpending C.sigpending +func Sigpending(_llcppg_param1 *SigsetT) c.Int + +//go:linkname Sigprocmask C.sigprocmask +func Sigprocmask(_llcppg_param1 c.Int, _llcppg_param2 *SigsetT, _llcppg_param3 *SigsetT) c.Int + +//go:linkname Sigrelse C.sigrelse +func Sigrelse(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigset C.sigset +func Sigset(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) + +//go:linkname Sigsuspend C.sigsuspend +func Sigsuspend(_llcppg_param1 *SigsetT) c.Int + +//go:linkname Sigwait C.sigwait +func Sigwait(_llcppg_param1 *SigsetT, _llcppg_param2 *c.Int) c.Int + +//go:linkname Psignal C.psignal +func Psignal(_llcppg_param1 c.Int, _llcppg_param2 *c.Char) + +//go:linkname Sigblock C.sigblock +func Sigblock(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigsetmask C.sigsetmask +func Sigsetmask(_llcppg_param1 c.Int) c.Int diff --git a/c/signal/signal_linux_amd64.go b/c/signal/signal_linux_amd64.go new file mode 100644 index 00000000..7ef1394f --- /dev/null +++ b/c/signal/signal_linux_amd64.go @@ -0,0 +1,209 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "github.com/goplus/lib/c/time" + _ "unsafe" +) + +const NSIG = 65 + +type SigAtomicT = X__SigAtomicT +type SigsetT = X__SigsetT +type PidT = X__PidT +type UidT = X__UidT + +// Type of a signal handler. +// +// llgo:type C +type X__SighandlerT = func(_llcppg_param1 c.Int) +type SigT = X__SighandlerT + +// The X/Open definition of `signal' specifies the SVID semantic. Use +// the additional function `sysv_signal' when X/Open compatibility is +// requested. +// +//go:linkname X__SysvSignal C.__sysv_signal +func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +//go:linkname Kill C.kill +func Kill(__pid X__PidT, __sig c.Int) c.Int + +// Send SIG to all processes in process group PGRP. +// If PGRP is zero, send SIG to all processes in +// the current process's process group. +// +//go:linkname Killpg C.killpg +func Killpg(__pgrp X__PidT, __sig c.Int) c.Int + +// Raise signal SIG, i.e., send SIG to yourself. +// +//go:linkname Raise C.raise +func Raise(__sig c.Int) c.Int + +// SVID names for the same things. +// +//go:linkname Ssignal C.ssignal +func Ssignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +//go:linkname Gsignal C.gsignal +func Gsignal(__sig c.Int) c.Int + +// Print a message describing the meaning of the given signal number. +// +//go:linkname Psignal C.psignal +func Psignal(__sig c.Int, __s *c.Char) + +// Print a message describing the meaning of the given signal information. +// +// llgo:link (*SiginfoT).Psiginfo C.psiginfo +func (self *SiginfoT) Psiginfo(__s *c.Char) { +} + +// Block signals in MASK, returning the old mask. +// +//go:linkname Sigblock C.sigblock +func Sigblock(__mask c.Int) c.Int + +// Set the mask of blocked signals to MASK, returning the old mask. +// +//go:linkname Sigsetmask C.sigsetmask +func Sigsetmask(__mask c.Int) c.Int + +// Return currently selected signal mask. +// +//go:linkname Siggetmask C.siggetmask +func Siggetmask() c.Int + +// Clear all signals from SET. +// +// llgo:link (*SigsetT).Sigemptyset C.sigemptyset +func (self *SigsetT) Sigemptyset() c.Int { + return 0 +} + +// Set all signals in SET. +// +// llgo:link (*SigsetT).Sigfillset C.sigfillset +func (self *SigsetT) Sigfillset() c.Int { + return 0 +} + +// Add SIGNO to SET. +// +// llgo:link (*SigsetT).Sigaddset C.sigaddset +func (self *SigsetT) Sigaddset(__signo c.Int) c.Int { + return 0 +} + +// Remove SIGNO from SET. +// +// llgo:link (*SigsetT).Sigdelset C.sigdelset +func (self *SigsetT) Sigdelset(__signo c.Int) c.Int { + return 0 +} + +// Return 1 if SIGNO is in SET, 0 if not. +// +// llgo:link (*SigsetT).Sigismember C.sigismember +func (self *SigsetT) Sigismember(__signo c.Int) c.Int { + return 0 +} + +// Get and/or change the set of blocked signals. +// +//go:linkname Sigprocmask C.sigprocmask +func Sigprocmask(__how c.Int, __set *SigsetT, __oset *SigsetT) c.Int + +// Change the set of blocked signals to SET, +// wait until a signal arrives, and restore the set of blocked signals. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigsuspend C.sigsuspend +func (self *SigsetT) Sigsuspend() c.Int { + return 0 +} + +// Put in SET all signals that are blocked and waiting to be delivered. +// +// llgo:link (*SigsetT).Sigpending C.sigpending +func (self *SigsetT) Sigpending() c.Int { + return 0 +} + +// Select any of pending signals from SET or wait for any to arrive. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwait C.sigwait +func (self *SigsetT) Sigwait(__sig *c.Int) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwaitinfo C.sigwaitinfo +func (self *SigsetT) Sigwaitinfo(__info *SiginfoT) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// Wait the time specified by TIMEOUT if no signal is pending. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigtimedwait C.sigtimedwait +func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *time.Timespec) c.Int { + return 0 +} + +// Send signal SIG to the process PID. Associate data in VAL with the +// signal. +// +//go:linkname Sigqueue C.sigqueue +func Sigqueue(__pid X__PidT, __sig c.Int, __val Sigval) c.Int + +// Names of the signals. This variable exists only for compatibility. +// Use `strsignal' instead (see ). +// +//go:linkname X_sysSiglist C._sys_siglist +var X_sysSiglist [65]*c.Char + +//go:linkname SysSiglist C.sys_siglist +var SysSiglist [65]*c.Char + +// If INTERRUPT is nonzero, make signal SIG interrupt system calls +// (causing them to fail with EINTR); if INTERRUPT is zero, make system +// calls be restarted after signal SIG. +// +//go:linkname Siginterrupt C.siginterrupt +func Siginterrupt(__sig c.Int, __interrupt c.Int) c.Int + +// Alternate signal handler stack interface. +// This interface should always be preferred over `sigstack'. +// +// llgo:link (*Sigaltstack).Sigaltstack C.sigaltstack +func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { + return 0 +} + +// Return number of available real-time signal with highest priority. +// +//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin +func X__LibcCurrentSigrtmin() c.Int + +// Return number of available real-time signal with lowest priority. +// +//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax +func X__LibcCurrentSigrtmax() c.Int diff --git a/c/signal/signal_linux_arm64.go b/c/signal/signal_linux_arm64.go new file mode 100644 index 00000000..6ea11186 --- /dev/null +++ b/c/signal/signal_linux_arm64.go @@ -0,0 +1,209 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "github.com/goplus/lib/c/time" + _ "unsafe" +) + +const NSIG = 65 + +type SigAtomicT = X__SigAtomicT +type SigsetT = X__SigsetT +type PidT = X__PidT +type UidT = X__UidT + +// Type of a signal handler. +// +// llgo:type C +type X__SighandlerT = func(_llcppg_param1 c.Int) +type SigT = X__SighandlerT + +// The X/Open definition of `signal' specifies the SVID semantic. Use +// the additional function `sysv_signal' when X/Open compatibility is +// requested. +// +//go:linkname X__SysvSignal C.__sysv_signal +func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +//go:linkname Kill C.kill +func Kill(__pid X__PidT, __sig c.Int) c.Int + +// Send SIG to all processes in process group PGRP. +// If PGRP is zero, send SIG to all processes in +// the current process's process group. +// +//go:linkname Killpg C.killpg +func Killpg(__pgrp X__PidT, __sig c.Int) c.Int + +// Raise signal SIG, i.e., send SIG to yourself. +// +//go:linkname Raise C.raise +func Raise(__sig c.Int) c.Int + +// SVID names for the same things. +// +//go:linkname Ssignal C.ssignal +func Ssignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +//go:linkname Gsignal C.gsignal +func Gsignal(__sig c.Int) c.Int + +// Print a message describing the meaning of the given signal number. +// +//go:linkname Psignal C.psignal +func Psignal(__sig c.Int, __s *uint8) + +// Print a message describing the meaning of the given signal information. +// +// llgo:link (*SiginfoT).Psiginfo C.psiginfo +func (self *SiginfoT) Psiginfo(__s *uint8) { +} + +// Block signals in MASK, returning the old mask. +// +//go:linkname Sigblock C.sigblock +func Sigblock(__mask c.Int) c.Int + +// Set the mask of blocked signals to MASK, returning the old mask. +// +//go:linkname Sigsetmask C.sigsetmask +func Sigsetmask(__mask c.Int) c.Int + +// Return currently selected signal mask. +// +//go:linkname Siggetmask C.siggetmask +func Siggetmask() c.Int + +// Clear all signals from SET. +// +// llgo:link (*SigsetT).Sigemptyset C.sigemptyset +func (self *SigsetT) Sigemptyset() c.Int { + return 0 +} + +// Set all signals in SET. +// +// llgo:link (*SigsetT).Sigfillset C.sigfillset +func (self *SigsetT) Sigfillset() c.Int { + return 0 +} + +// Add SIGNO to SET. +// +// llgo:link (*SigsetT).Sigaddset C.sigaddset +func (self *SigsetT) Sigaddset(__signo c.Int) c.Int { + return 0 +} + +// Remove SIGNO from SET. +// +// llgo:link (*SigsetT).Sigdelset C.sigdelset +func (self *SigsetT) Sigdelset(__signo c.Int) c.Int { + return 0 +} + +// Return 1 if SIGNO is in SET, 0 if not. +// +// llgo:link (*SigsetT).Sigismember C.sigismember +func (self *SigsetT) Sigismember(__signo c.Int) c.Int { + return 0 +} + +// Get and/or change the set of blocked signals. +// +//go:linkname Sigprocmask C.sigprocmask +func Sigprocmask(__how c.Int, __set *SigsetT, __oset *SigsetT) c.Int + +// Change the set of blocked signals to SET, +// wait until a signal arrives, and restore the set of blocked signals. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigsuspend C.sigsuspend +func (self *SigsetT) Sigsuspend() c.Int { + return 0 +} + +// Put in SET all signals that are blocked and waiting to be delivered. +// +// llgo:link (*SigsetT).Sigpending C.sigpending +func (self *SigsetT) Sigpending() c.Int { + return 0 +} + +// Select any of pending signals from SET or wait for any to arrive. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwait C.sigwait +func (self *SigsetT) Sigwait(__sig *c.Int) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwaitinfo C.sigwaitinfo +func (self *SigsetT) Sigwaitinfo(__info *SiginfoT) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// Wait the time specified by TIMEOUT if no signal is pending. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigtimedwait C.sigtimedwait +func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *time.Timespec) c.Int { + return 0 +} + +// Send signal SIG to the process PID. Associate data in VAL with the +// signal. +// +//go:linkname Sigqueue C.sigqueue +func Sigqueue(__pid X__PidT, __sig c.Int, __val Sigval) c.Int + +// Names of the signals. This variable exists only for compatibility. +// Use `strsignal' instead (see ). +// +//go:linkname X_sysSiglist C._sys_siglist +var X_sysSiglist [65]*uint8 + +//go:linkname SysSiglist C.sys_siglist +var SysSiglist [65]*uint8 + +// If INTERRUPT is nonzero, make signal SIG interrupt system calls +// (causing them to fail with EINTR); if INTERRUPT is zero, make system +// calls be restarted after signal SIG. +// +//go:linkname Siginterrupt C.siginterrupt +func Siginterrupt(__sig c.Int, __interrupt c.Int) c.Int + +// Alternate signal handler stack interface. +// This interface should always be preferred over `sigstack'. +// +// llgo:link (*Sigaltstack).Sigaltstack C.sigaltstack +func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { + return 0 +} + +// Return number of available real-time signal with highest priority. +// +//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin +func X__LibcCurrentSigrtmin() c.Int + +// Return number of available real-time signal with lowest priority. +// +//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax +func X__LibcCurrentSigrtmax() c.Int diff --git a/c/signal/sys-_types-_pid_t_darwin_arm64.go b/c/signal/sys-_types-_pid_t_darwin_arm64.go new file mode 100644 index 00000000..39024f66 --- /dev/null +++ b/c/signal/sys-_types-_pid_t_darwin_arm64.go @@ -0,0 +1,7 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +type PidT = X__DarwinPidT diff --git a/c/signal/sys-_types-_sigaltstack_darwin_arm64.go b/c/signal/sys-_types-_sigaltstack_darwin_arm64.go new file mode 100644 index 00000000..c589e75e --- /dev/null +++ b/c/signal/sys-_types-_sigaltstack_darwin_arm64.go @@ -0,0 +1,19 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +type X__DarwinSigaltstack struct { + SsSp unsafe.Pointer + SsSize X__DarwinSizeT + SsFlags c.Int +} + +// [???] signal stack +type StackT = X__DarwinSigaltstack diff --git a/c/signal/sys-_types-_sigset_t_darwin_arm64.go b/c/signal/sys-_types-_sigset_t_darwin_arm64.go new file mode 100644 index 00000000..fd252617 --- /dev/null +++ b/c/signal/sys-_types-_sigset_t_darwin_arm64.go @@ -0,0 +1,7 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +type SigsetT = X__DarwinSigsetT diff --git a/c/signal/types_darwin_arm64.go b/c/signal/sys-_types-_u_int32_t_darwin_arm64.go similarity index 53% rename from c/signal/types_darwin_arm64.go rename to c/signal/sys-_types-_u_int32_t_darwin_arm64.go index 8889b06e..6d960dac 100644 --- a/c/signal/types_darwin_arm64.go +++ b/c/signal/sys-_types-_u_int32_t_darwin_arm64.go @@ -6,9 +6,4 @@ package signal import "github.com/goplus/lib/c" -type X__Uint32T = c.Uint - -type SigsetT = X__DarwinSigsetT - -// [???] signal set -type X__DarwinSigsetT = X__Uint32T +type UInt32T = c.Uint diff --git a/c/signal/sys-_types-_u_int64_t_darwin_arm64.go b/c/signal/sys-_types-_u_int64_t_darwin_arm64.go new file mode 100644 index 00000000..b5dfa2c1 --- /dev/null +++ b/c/signal/sys-_types-_u_int64_t_darwin_arm64.go @@ -0,0 +1,9 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import "github.com/goplus/lib/c" + +type UInt64T = c.UlongLong diff --git a/c/signal/sys-_types-_uid_t_darwin_arm64.go b/c/signal/sys-_types-_uid_t_darwin_arm64.go new file mode 100644 index 00000000..59047fec --- /dev/null +++ b/c/signal/sys-_types-_uid_t_darwin_arm64.go @@ -0,0 +1,7 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +type UidT = X__DarwinUidT diff --git a/c/signal/sys-_types_darwin_arm64.go b/c/signal/sys-_types_darwin_arm64.go new file mode 100644 index 00000000..0f2039a9 --- /dev/null +++ b/c/signal/sys-_types_darwin_arm64.go @@ -0,0 +1,63 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +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/signal/sys-signal_darwin_arm64.go b/c/signal/sys-signal_darwin_arm64.go new file mode 100644 index 00000000..44df3b51 --- /dev/null +++ b/c/signal/sys-signal_darwin_arm64.go @@ -0,0 +1,338 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +// counting 0; could be 33 (mask is 1-32) +const X__DARWIN_NSIG = 32 +const NSIG = 32 +const ( + // hangup + SIGHUP = 1 + // interrupt + SIGINT = 2 + // quit + SIGQUIT = 3 + // illegal instruction (not reset when caught) + SIGILL = 4 + // trace trap (not reset when caught) + SIGTRAP = 5 + // abort() + SIGABRT = 6 +) +const ( + // compatibility + SIGIOT = 6 + // EMT instruction + SIGEMT = 7 +) +const ( + // floating point exception + SIGFPE = 8 + // kill (cannot be caught or ignored) + SIGKILL = 9 + // bus error + SIGBUS = 10 + // segmentation violation + SIGSEGV = 11 + // bad argument to system call + SIGSYS = 12 + // write on a pipe with no one to read it + SIGPIPE = 13 + // alarm clock + SIGALRM = 14 + // software termination signal from kill + SIGTERM = 15 + // urgent condition on IO channel + SIGURG = 16 + // sendable stop signal not from tty + SIGSTOP = 17 + // stop signal from tty + SIGTSTP = 18 + // continue a stopped process + SIGCONT = 19 + // to parent on child stop or exit + SIGCHLD = 20 + // to readers pgrp upon background tty read + SIGTTIN = 21 + // like TTIN for output if (tp->t_local<OSTOP) + SIGTTOU = 22 +) + +// input/output possible signal +const SIGIO = 23 +const ( + // exceeded CPU time limit + SIGXCPU = 24 + // exceeded file size limit + SIGXFSZ = 25 + // virtual time alarm + SIGVTALRM = 26 + // profiling time alarm + SIGPROF = 27 +) +const ( + // window size changes + SIGWINCH = 28 + // information request + SIGINFO = 29 +) +const ( + // user defined signal 1 + SIGUSR1 = 30 + // user defined signal 2 + SIGUSR2 = 31 +) +const ( + // No async notification + SIGEV_NONE = 0 + // aio - completion notification + SIGEV_SIGNAL = 1 + // [NOTIMP] [RTS] call notification function + SIGEV_THREAD = 3 +) + +// if only I knew... +const ILL_NOOP = 0 +const ( + // [XSI] illegal opcode + ILL_ILLOPC = 1 + // [XSI] illegal trap + ILL_ILLTRP = 2 + // [XSI] privileged opcode + ILL_PRVOPC = 3 + // [XSI] illegal operand -NOTIMP + ILL_ILLOPN = 4 + // [XSI] illegal addressing mode -NOTIMP + ILL_ILLADR = 5 + // [XSI] privileged register -NOTIMP + ILL_PRVREG = 6 + // [XSI] coprocessor error -NOTIMP + ILL_COPROC = 7 + // [XSI] internal stack error -NOTIMP + ILL_BADSTK = 8 +) + +// if only I knew... +const FPE_NOOP = 0 +const ( + // [XSI] floating point divide by zero + FPE_FLTDIV = 1 + // [XSI] floating point overflow + FPE_FLTOVF = 2 + // [XSI] floating point underflow + FPE_FLTUND = 3 + // [XSI] floating point inexact result + FPE_FLTRES = 4 + // [XSI] invalid floating point operation + FPE_FLTINV = 5 + // [XSI] subscript out of range -NOTIMP + FPE_FLTSUB = 6 + // [XSI] integer divide by zero + FPE_INTDIV = 7 + // [XSI] integer overflow + FPE_INTOVF = 8 +) + +// if only I knew... +const SEGV_NOOP = 0 +const ( + // [XSI] address not mapped to object + SEGV_MAPERR = 1 + // [XSI] invalid permission for mapped object + SEGV_ACCERR = 2 +) + +// if only I knew... +const BUS_NOOP = 0 +const ( + // [XSI] Invalid address alignment + BUS_ADRALN = 1 + // [XSI] Nonexistent physical address -NOTIMP + BUS_ADRERR = 2 + // [XSI] Object-specific HW error - NOTIMP + BUS_OBJERR = 3 +) + +// Codes for SIGTRAP +const ( + TRAP_BRKPT = 1 + // [XSI] Process trace trap -NOTIMP + TRAP_TRACE = 2 +) + +// if only I knew... +const CLD_NOOP = 0 +const ( + // [XSI] child has exited + CLD_EXITED = 1 + // [XSI] terminated abnormally, no core file + CLD_KILLED = 2 + // [XSI] terminated abnormally, core file + CLD_DUMPED = 3 + // [XSI] traced child has trapped + CLD_TRAPPED = 4 + // [XSI] child has stopped + CLD_STOPPED = 5 + // [XSI] stopped child has continued + CLD_CONTINUED = 6 +) + +// Codes for SIGPOLL +const ( + POLL_IN = 1 + // [XSR] Output buffers available + POLL_OUT = 2 + // [XSR] Input message available + POLL_MSG = 3 + // [XSR] I/O error + POLL_ERR = 4 + // [XSR] High priority input available + POLL_PRI = 5 + // [XSR] Device disconnected + POLL_HUP = 6 +) +const ( + // take signal on signal stack + SA_ONSTACK = 1 + // restart system on signal return + SA_RESTART = 2 + // reset to SIG_DFL when taking signal + SA_RESETHAND = 4 + // do not generate SIGCHLD on child stop + SA_NOCLDSTOP = 8 + // don't mask the signal we're delivering + SA_NODEFER = 16 + // don't keep zombies around + SA_NOCLDWAIT = 32 + // signal handler with SA_SIGINFO args + SA_SIGINFO = 64 +) + +// do not bounce off kernel's sigtramp +const SA_USERTRAMP = 256 + +// This will provide 64bit register set in a 32bit user address space +const SA_64REGSET = 512 + +// the following are the only bits we support from user space, the +// rest are for kernel use only. +const SA_USERSPACE_MASK = 127 + +// Flags for sigprocmask: +const ( + SIG_BLOCK = 1 + // unblock specified signal set + SIG_UNBLOCK = 2 + // set specified signal set + SIG_SETMASK = 3 +) + +// POSIX 1003.1b required values. +const ( + SI_USER = 65537 + // [CX] signal from sigqueue() + SI_QUEUE = 65538 + // [CX] timer expiration + SI_TIMER = 65539 + // [CX] aio request completion + SI_ASYNCIO = 65540 + // [CX] from message arrival on empty queue + SI_MESGQ = 65541 +) +const ( + // take signal on signal stack + SS_ONSTACK = 1 + // disable taking signals on alternate stack + SS_DISABLE = 4 + // (32K)minimum allowable stack + MINSIGSTKSZ = 32768 + // (128K)recommended stack size + SIGSTKSZ = 131072 +) +const ( + SV_ONSTACK = 1 + // same bit, opposite sense + SV_INTERRUPT = 2 + SV_RESETHAND = 4 + SV_NODEFER = 16 + SV_NOCLDSTOP = 8 + SV_SIGINFO = 64 +) + +type Sigval struct { + _xgo_union [1]uint64 +} +type X__Siginfo struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + SiPid PidT + SiUid UidT + SiStatus c.Int + SiAddr unsafe.Pointer + SiValue Sigval + SiBand c.Long + X__Pad [7]c.Ulong +} +type X__SigactionT_U struct { + _xgo_union [1]uint64 +} + +// Signal vector template for Kernel user boundary +// +// llgo:type C +type X__SigactionT struct { + X__SigactionT_U X__SigactionT_U + SaTramp func(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.Int, _llcppg_param3 c.Int, _llcppg_param4 *SiginfoT, _llcppg_param5 unsafe.Pointer) + SaMask SigsetT + SaFlags c.Int +} + +// Signal vector "template" used in sigaction call. +type SigactionT struct { + X__SigactionT_U X__SigactionT_U + SaMask SigsetT + SaFlags c.Int +} + +// 4.3 compatibility: +// Signal vector "template" used in sigvec call. +// +// llgo:type C +type Sigvec struct { + SvHandler func(_llcppg_param1 c.Int) + SvMask c.Int + SvFlags c.Int +} + +// Structure used in sigstack call. +type Sigstack struct { + SsSp *c.Char + SsOnstack c.Int +} +type SiginfoT = X__Siginfo + +// type of signal function +// +// llgo:type C +type SigT = func(_llcppg_param1 c.Int) + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} +func (p *X__SigactionT_U) XGof_ref___sa_handler() *func(_llcppg_param1 c.Int) { + return (*func(_llcppg_param1 c.Int))(unsafe.Pointer(p)) +} +func (p *X__SigactionT_U) XGof_ref___sa_sigaction() *func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer) { + return (*func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer))(unsafe.Pointer(p)) +} diff --git a/c/signal/types_linux_amd64.go b/c/signal/types_linux_amd64.go deleted file mode 100644 index 12fd44fc..00000000 --- a/c/signal/types_linux_amd64.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import "github.com/goplus/lib/c" - -type X__SigsetT struct { - X__Val [16]c.Ulong -} - -// A set of signals to be blocked, unblocked, or waited for. -type SigsetT = X__SigsetT From 3ba5359d4eb230e59dcaeb1459a74b4611713e4e Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 19:56:46 +0800 Subject: [PATCH 3/8] Classify unified libc output and skip unsupported layouts --- c/signal/arm-_types_darwin_arm64.go | 64 ---- c/signal/bits-sigaction_linux_amd64.go | 72 ---- c/signal/bits-sigaction_linux_arm64.go | 72 ---- c/signal/bits-siginfo_linux_amd64.go | 246 ------------- c/signal/bits-siginfo_linux_arm64.go | 240 ------------- c/signal/bits-signum_linux_amd64.go | 84 ----- c/signal/bits-signum_linux_arm64.go | 84 ----- c/signal/bits-sigset_linux_amd64.go | 30 -- c/signal/bits-sigset_linux_arm64.go | 30 -- c/signal/bits-sigstack_linux_amd64.go | 38 -- c/signal/bits-sigstack_linux_arm64.go | 38 -- c/signal/bits-types_linux_amd64.go | 133 ------- c/signal/bits-types_linux_arm64.go | 133 ------- c/signal/libc_darwin_arm64.go | 40 +++ c/signal/libc_linux_amd64.go | 129 +++++++ c/signal/libc_linux_arm64.go | 123 +++++++ c/signal/llcppg.pub | 107 ------ c/signal/signal_darwin_arm64.go | 90 ----- c/signal/signal_linux_amd64.go | 209 ----------- c/signal/signal_linux_arm64.go | 209 ----------- c/signal/sys-_types-_pid_t_darwin_arm64.go | 7 - .../sys-_types-_sigaltstack_darwin_arm64.go | 19 - c/signal/sys-_types-_sigset_t_darwin_arm64.go | 7 - .../sys-_types-_u_int32_t_darwin_arm64.go | 9 - .../sys-_types-_u_int64_t_darwin_arm64.go | 9 - c/signal/sys-_types-_uid_t_darwin_arm64.go | 7 - c/signal/sys-_types_darwin_arm64.go | 63 ---- c/signal/sys-signal_darwin_arm64.go | 338 ------------------ 28 files changed, 292 insertions(+), 2338 deletions(-) delete mode 100644 c/signal/arm-_types_darwin_arm64.go delete mode 100644 c/signal/bits-sigaction_linux_amd64.go delete mode 100644 c/signal/bits-sigaction_linux_arm64.go delete mode 100644 c/signal/bits-siginfo_linux_amd64.go delete mode 100644 c/signal/bits-siginfo_linux_arm64.go delete mode 100644 c/signal/bits-signum_linux_amd64.go delete mode 100644 c/signal/bits-signum_linux_arm64.go delete mode 100644 c/signal/bits-sigset_linux_amd64.go delete mode 100644 c/signal/bits-sigset_linux_arm64.go delete mode 100644 c/signal/bits-sigstack_linux_amd64.go delete mode 100644 c/signal/bits-sigstack_linux_arm64.go delete mode 100644 c/signal/bits-types_linux_amd64.go delete mode 100644 c/signal/bits-types_linux_arm64.go create mode 100644 c/signal/libc_darwin_arm64.go create mode 100644 c/signal/libc_linux_amd64.go create mode 100644 c/signal/libc_linux_arm64.go delete mode 100644 c/signal/signal_darwin_arm64.go delete mode 100644 c/signal/signal_linux_amd64.go delete mode 100644 c/signal/signal_linux_arm64.go delete mode 100644 c/signal/sys-_types-_pid_t_darwin_arm64.go delete mode 100644 c/signal/sys-_types-_sigaltstack_darwin_arm64.go delete mode 100644 c/signal/sys-_types-_sigset_t_darwin_arm64.go delete mode 100644 c/signal/sys-_types-_u_int32_t_darwin_arm64.go delete mode 100644 c/signal/sys-_types-_u_int64_t_darwin_arm64.go delete mode 100644 c/signal/sys-_types-_uid_t_darwin_arm64.go delete mode 100644 c/signal/sys-_types_darwin_arm64.go delete mode 100644 c/signal/sys-signal_darwin_arm64.go diff --git a/c/signal/arm-_types_darwin_arm64.go b/c/signal/arm-_types_darwin_arm64.go deleted file mode 100644 index ab0fb789..00000000 --- a/c/signal/arm-_types_darwin_arm64.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -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/signal/bits-sigaction_linux_amd64.go b/c/signal/bits-sigaction_linux_amd64.go deleted file mode 100644 index ee4ad760..00000000 --- a/c/signal/bits-sigaction_linux_amd64.go +++ /dev/null @@ -1,72 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -// Bits in `sa_flags'. -const ( - SA_NOCLDSTOP = 1 - // Don't create zombie on child death. - SA_NOCLDWAIT = 2 - // Invoke signal-catching function with - // three arguments instead of one. - SA_SIGINFO = 4 -) - -// Use signal stack by using `sa_restorer'. -const SA_ONSTACK = 134217728 -const ( - // Restart syscall on signal return. - SA_RESTART = 268435456 - // Don't automatically block the signal when - // its handler is being executed. - SA_NODEFER = 1073741824 -) - -// Reset to SIG_DFL on entry to handler. -const SA_RESETHAND = 2147483648 - -// Historical no-op. -const SA_INTERRUPT = 536870912 - -// Some aliases for the SA_ constants. -const ( - SA_NOMASK = 1073741824 - SA_ONESHOT = 2147483648 - SA_STACK = 134217728 -) - -// Values for the HOW argument to `sigprocmask'. -const ( - SIG_BLOCK = 0 - // Unblock signals. - SIG_UNBLOCK = 1 - // Set the set of blocked signals. - SIG_SETMASK = 2 -) - -// Structure describing the action to be taken when a signal arrives. -// -// llgo:type C -type SigactionT struct { - X__SigactionTHandler _llcppg_anon_2 - SaMask X__SigsetT - SaFlags c.Int - SaRestorer func() -} -type _llcppg_anon_2 struct { - _xgo_union [1]uint64 -} - -func (p *_llcppg_anon_2) XGof_ref_sa_handler() *X__SighandlerT { - return (*X__SighandlerT)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_2) XGof_ref_sa_sigaction() *func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer) { - return (*func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer))(unsafe.Pointer(p)) -} diff --git a/c/signal/bits-sigaction_linux_arm64.go b/c/signal/bits-sigaction_linux_arm64.go deleted file mode 100644 index 64184a06..00000000 --- a/c/signal/bits-sigaction_linux_arm64.go +++ /dev/null @@ -1,72 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -// Bits in `sa_flags'. -const ( - SA_NOCLDSTOP = 1 - // Don't create zombie on child death. - SA_NOCLDWAIT = 2 - // Invoke signal-catching function with - // three arguments instead of one. - SA_SIGINFO = 4 -) - -// Use signal stack by using `sa_restorer'. -const SA_ONSTACK = 134217728 -const ( - // Restart syscall on signal return. - SA_RESTART = 268435456 - // Don't automatically block the signal when - // its handler is being executed. - SA_NODEFER = 1073741824 -) - -// Reset to SIG_DFL on entry to handler. -const SA_RESETHAND = 2147483648 - -// Historical no-op. -const SA_INTERRUPT = 536870912 - -// Some aliases for the SA_ constants. -const ( - SA_NOMASK = 1073741824 - SA_ONESHOT = 2147483648 - SA_STACK = 134217728 -) - -// Values for the HOW argument to `sigprocmask'. -const ( - SIG_BLOCK = 0 - // Unblock signals. - SIG_UNBLOCK = 1 - // Set the set of blocked signals. - SIG_SETMASK = 2 -) - -// Structure describing the action to be taken when a signal arrives. -// -// llgo:type C -type SigactionT struct { - X__SigactionTHandler _llcppg_anon_2 - SaMask X__SigsetT - SaFlags c.Int - SaRestorer func() -} -type _llcppg_anon_2 struct { - _xgo_union [1]uint64 -} - -func (p *_llcppg_anon_2) XGof_ref_sa_handler() *X__SighandlerT { - return (*X__SighandlerT)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_2) XGof_ref_sa_sigaction() *func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer) { - return (*func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer))(unsafe.Pointer(p)) -} diff --git a/c/signal/bits-siginfo_linux_amd64.go b/c/signal/bits-siginfo_linux_amd64.go deleted file mode 100644 index ef034a8a..00000000 --- a/c/signal/bits-siginfo_linux_amd64.go +++ /dev/null @@ -1,246 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -const X__HaveSigvalT = 1 -const X__HaveSiginfoT = 1 -const X__SI_MAX_SIZE = 128 -const X__HaveSigeventT = 1 - -// Structure to transport application-defined values with signals. -const X__SIGEV_MAX_SIZE = 64 -const X__HavePthreadAttrT = 1 - -type Sigval struct { - _xgo_union [1]uint64 -} -type SiginfoT struct { - SiSigno c.Int - SiErrno c.Int - SiCode c.Int - X_sifields _llcppg_anon_0 -} - -// Values for `si_code'. Positive values are reserved for kernel-generated -// signals. -const ( - SI_ASYNCNL = -60 - SI_TKILL = -6 - SI_SIGIO = -5 - SI_ASYNCIO = -4 - SI_MESGQ = -3 - SI_TIMER = -2 - SI_QUEUE = -1 - SI_USER = 0 - // Send by kernel. - SI_KERNEL = 128 -) - -// `si_code' values for SIGILL signal. -const ( - ILL_ILLOPC = 1 - ILL_ILLOPN = 2 - ILL_ILLADR = 3 - ILL_ILLTRP = 4 - ILL_PRVOPC = 5 - ILL_PRVREG = 6 - ILL_COPROC = 7 - // Internal stack error. - ILL_BADSTK = 8 -) - -// `si_code' values for SIGFPE signal. -const ( - FPE_INTDIV = 1 - FPE_INTOVF = 2 - FPE_FLTDIV = 3 - FPE_FLTOVF = 4 - FPE_FLTUND = 5 - FPE_FLTRES = 6 - FPE_FLTINV = 7 - // Subscript out of range. - FPE_FLTSUB = 8 -) - -// `si_code' values for SIGSEGV signal. -const ( - SEGV_MAPERR = 1 - // Invalid permissions for mapped object. - SEGV_ACCERR = 2 -) - -// `si_code' values for SIGBUS signal. -const ( - BUS_ADRALN = 1 - BUS_ADRERR = 2 - BUS_OBJERR = 3 - BUS_MCEERR_AR = 4 - // Hardware memory error: action optional. - BUS_MCEERR_AO = 5 -) - -// `si_code' values for SIGCHLD signal. -const ( - CLD_EXITED = 1 - CLD_KILLED = 2 - CLD_DUMPED = 3 - CLD_TRAPPED = 4 - CLD_STOPPED = 5 - // Stopped child has continued. - CLD_CONTINUED = 6 -) - -// `si_code' values for SIGPOLL signal. -const ( - POLL_IN = 1 - POLL_OUT = 2 - POLL_MSG = 3 - POLL_ERR = 4 - POLL_PRI = 5 - // Device disconnected. - POLL_HUP = 6 -) - -type Sigevent struct { - SigevValue SigvalT - SigevSigno c.Int - SigevNotify c.Int - X_sigevUn _llcppg_anon_1 -} - -// `sigev_notify' values. -const ( - SIGEV_SIGNAL = 0 - SIGEV_NONE = 1 - SIGEV_THREAD = 2 - // Send signal to specific thread. - SIGEV_THREAD_ID = 4 -) - -type PthreadAttrT struct { -} - -// Type for data associated with a signal. -type SigvalT = Sigval -type X__SigchldClockT = X__ClockT -type _llcppg_anon_0 struct { - _xgo_union [14]uint64 -} -type _llcppg_anon_1 struct { - _xgo_union [6]uint64 -} -type SigeventT = Sigevent - -func (p *Sigval) XGof_ref_sival_int() *c.Int { - return (*c.Int)(unsafe.Pointer(p)) -} -func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { - return (*unsafe.Pointer)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_0) XGof_ref__pad() *[28]c.Int { - return (*[28]c.Int)(unsafe.Pointer(p)) -} - -// kill(). -type _llcppg_anon_3 struct { - SiPid X__PidT - SiUid X__UidT -} - -func (p *_llcppg_anon_0) XGof_ref__kill() *_llcppg_anon_3 { - return (*_llcppg_anon_3)(unsafe.Pointer(p)) -} - -// POSIX.1b timers. -type _llcppg_anon_4 struct { - SiTid c.Int - SiOverrun c.Int - SiSigval SigvalT -} - -func (p *_llcppg_anon_0) XGof_ref__timer() *_llcppg_anon_4 { - return (*_llcppg_anon_4)(unsafe.Pointer(p)) -} - -// POSIX.1b signals. -type _llcppg_anon_5 struct { - SiPid X__PidT - SiUid X__UidT - SiSigval SigvalT -} - -func (p *_llcppg_anon_0) XGof_ref__rt() *_llcppg_anon_5 { - return (*_llcppg_anon_5)(unsafe.Pointer(p)) -} - -// SIGCHLD. -type _llcppg_anon_6 struct { - SiPid X__PidT - SiUid X__UidT - SiStatus c.Int - SiUtime X__SigchldClockT - SiStime X__SigchldClockT -} - -func (p *_llcppg_anon_0) XGof_ref__sigchld() *_llcppg_anon_6 { - return (*_llcppg_anon_6)(unsafe.Pointer(p)) -} - -// SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_7 struct { - SiAddr unsafe.Pointer - SiAddrLsb int16 - SiAddrBnd _llcppg_anon_8 -} -type _llcppg_anon_8 struct { - X_lower unsafe.Pointer - X_upper unsafe.Pointer -} - -func (p *_llcppg_anon_0) XGof_ref__sigfault() *_llcppg_anon_7 { - return (*_llcppg_anon_7)(unsafe.Pointer(p)) -} - -// SIGPOLL. -type _llcppg_anon_9 struct { - SiBand c.Long - SiFd c.Int -} - -func (p *_llcppg_anon_0) XGof_ref__sigpoll() *_llcppg_anon_9 { - return (*_llcppg_anon_9)(unsafe.Pointer(p)) -} - -// SIGSYS. -type _llcppg_anon_10 struct { - X_callAddr unsafe.Pointer - X_syscall c.Int - X_arch c.Uint -} - -func (p *_llcppg_anon_0) XGof_ref__sigsys() *_llcppg_anon_10 { - return (*_llcppg_anon_10)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_1) XGof_ref__pad() *[12]c.Int { - return (*[12]c.Int)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_1) XGof_ref__tid() *X__PidT { - return (*X__PidT)(unsafe.Pointer(p)) -} - -// llgo:type C -type _llcppg_anon_11 struct { - X_function func(_llcppg_param1 SigvalT) - X_attribute *PthreadAttrT -} - -func (p *_llcppg_anon_1) XGof_ref__sigev_thread() *_llcppg_anon_11 { - return (*_llcppg_anon_11)(unsafe.Pointer(p)) -} diff --git a/c/signal/bits-siginfo_linux_arm64.go b/c/signal/bits-siginfo_linux_arm64.go deleted file mode 100644 index af69745d..00000000 --- a/c/signal/bits-siginfo_linux_arm64.go +++ /dev/null @@ -1,240 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -const X__HaveSigvalT = 1 -const X__HaveSiginfoT = 1 -const X__SI_MAX_SIZE = 128 -const X__HaveSigeventT = 1 - -// Structure to transport application-defined values with signals. -const X__SIGEV_MAX_SIZE = 64 -const X__HavePthreadAttrT = 1 - -type Sigval struct { - _xgo_union [1]uint64 -} -type SiginfoT struct { - SiSigno c.Int - SiErrno c.Int - SiCode c.Int - X_sifields _llcppg_anon_0 -} - -// Values for `si_code'. Positive values are reserved for kernel-generated -// signals. -const ( - SI_ASYNCNL = -60 - SI_TKILL = -6 - SI_SIGIO = -5 - SI_ASYNCIO = -4 - SI_MESGQ = -3 - SI_TIMER = -2 - SI_QUEUE = -1 - SI_USER = 0 - // Send by kernel. - SI_KERNEL = 128 -) - -// `si_code' values for SIGILL signal. -const ( - ILL_ILLOPC = 1 - ILL_ILLOPN = 2 - ILL_ILLADR = 3 - ILL_ILLTRP = 4 - ILL_PRVOPC = 5 - ILL_PRVREG = 6 - ILL_COPROC = 7 - // Internal stack error. - ILL_BADSTK = 8 -) - -// `si_code' values for SIGFPE signal. -const ( - FPE_INTDIV = 1 - FPE_INTOVF = 2 - FPE_FLTDIV = 3 - FPE_FLTOVF = 4 - FPE_FLTUND = 5 - FPE_FLTRES = 6 - FPE_FLTINV = 7 - // Subscript out of range. - FPE_FLTSUB = 8 -) - -// `si_code' values for SIGSEGV signal. -const ( - SEGV_MAPERR = 1 - // Invalid permissions for mapped object. - SEGV_ACCERR = 2 -) - -// `si_code' values for SIGBUS signal. -const ( - BUS_ADRALN = 1 - BUS_ADRERR = 2 - BUS_OBJERR = 3 - BUS_MCEERR_AR = 4 - // Hardware memory error: action optional. - BUS_MCEERR_AO = 5 -) - -// `si_code' values for SIGCHLD signal. -const ( - CLD_EXITED = 1 - CLD_KILLED = 2 - CLD_DUMPED = 3 - CLD_TRAPPED = 4 - CLD_STOPPED = 5 - // Stopped child has continued. - CLD_CONTINUED = 6 -) - -// `si_code' values for SIGPOLL signal. -const ( - POLL_IN = 1 - POLL_OUT = 2 - POLL_MSG = 3 - POLL_ERR = 4 - POLL_PRI = 5 - // Device disconnected. - POLL_HUP = 6 -) - -type Sigevent struct { - SigevValue SigvalT - SigevSigno c.Int - SigevNotify c.Int - X_sigevUn _llcppg_anon_1 -} - -// `sigev_notify' values. -const ( - SIGEV_SIGNAL = 0 - SIGEV_NONE = 1 - SIGEV_THREAD = 2 - // Send signal to specific thread. - SIGEV_THREAD_ID = 4 -) - -type PthreadAttrT struct { -} - -// Type for data associated with a signal. -type SigvalT = Sigval -type _llcppg_anon_0 struct { - _xgo_union [14]uint64 -} -type _llcppg_anon_1 struct { - _xgo_union [6]uint64 -} -type SigeventT = Sigevent - -func (p *Sigval) XGof_ref_sival_int() *c.Int { - return (*c.Int)(unsafe.Pointer(p)) -} -func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { - return (*unsafe.Pointer)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_0) XGof_ref__pad() *[28]c.Int { - return (*[28]c.Int)(unsafe.Pointer(p)) -} - -// kill(). -type _llcppg_anon_3 struct { - SiPid X__PidT - SiUid X__UidT -} - -func (p *_llcppg_anon_0) XGof_ref__kill() *_llcppg_anon_3 { - return (*_llcppg_anon_3)(unsafe.Pointer(p)) -} - -// POSIX.1b timers. -type _llcppg_anon_4 struct { - SiTid c.Int - SiOverrun c.Int - SiSigval SigvalT -} - -func (p *_llcppg_anon_0) XGof_ref__timer() *_llcppg_anon_4 { - return (*_llcppg_anon_4)(unsafe.Pointer(p)) -} - -// POSIX.1b signals. -type _llcppg_anon_5 struct { - SiPid X__PidT - SiUid X__UidT - SiSigval SigvalT -} - -func (p *_llcppg_anon_0) XGof_ref__rt() *_llcppg_anon_5 { - return (*_llcppg_anon_5)(unsafe.Pointer(p)) -} - -// SIGCHLD. -type _llcppg_anon_6 struct { - SiPid X__PidT - SiUid X__UidT - SiStatus c.Int - SiUtime X__ClockT - SiStime X__ClockT -} - -func (p *_llcppg_anon_0) XGof_ref__sigchld() *_llcppg_anon_6 { - return (*_llcppg_anon_6)(unsafe.Pointer(p)) -} - -// SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_7 struct { - SiAddr unsafe.Pointer - SiAddrLsb int16 -} - -func (p *_llcppg_anon_0) XGof_ref__sigfault() *_llcppg_anon_7 { - return (*_llcppg_anon_7)(unsafe.Pointer(p)) -} - -// SIGPOLL. -type _llcppg_anon_8 struct { - SiBand c.Long - SiFd c.Int -} - -func (p *_llcppg_anon_0) XGof_ref__sigpoll() *_llcppg_anon_8 { - return (*_llcppg_anon_8)(unsafe.Pointer(p)) -} - -// SIGSYS. -type _llcppg_anon_9 struct { - X_callAddr unsafe.Pointer - X_syscall c.Int - X_arch c.Uint -} - -func (p *_llcppg_anon_0) XGof_ref__sigsys() *_llcppg_anon_9 { - return (*_llcppg_anon_9)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_1) XGof_ref__pad() *[12]c.Int { - return (*[12]c.Int)(unsafe.Pointer(p)) -} -func (p *_llcppg_anon_1) XGof_ref__tid() *X__PidT { - return (*X__PidT)(unsafe.Pointer(p)) -} - -// llgo:type C -type _llcppg_anon_10 struct { - X_function func(_llcppg_param1 SigvalT) - X_attribute *PthreadAttrT -} - -func (p *_llcppg_anon_1) XGof_ref__sigev_thread() *_llcppg_anon_10 { - return (*_llcppg_anon_10)(unsafe.Pointer(p)) -} diff --git a/c/signal/bits-signum_linux_amd64.go b/c/signal/bits-signum_linux_amd64.go deleted file mode 100644 index e69ba232..00000000 --- a/c/signal/bits-signum_linux_amd64.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -// Signals. -const ( - SIGHUP = 1 - // Interrupt (ANSI). - SIGINT = 2 - // Quit (POSIX). - SIGQUIT = 3 - // Illegal instruction (ANSI). - SIGILL = 4 - // Trace trap (POSIX). - SIGTRAP = 5 - // Abort (ANSI). - SIGABRT = 6 - // IOT trap (4.2 BSD). - SIGIOT = 6 - // BUS error (4.2 BSD). - SIGBUS = 7 - // Floating-point exception (ANSI). - SIGFPE = 8 - // Kill, unblockable (POSIX). - SIGKILL = 9 - // User-defined signal 1 (POSIX). - SIGUSR1 = 10 - // Segmentation violation (ANSI). - SIGSEGV = 11 - // User-defined signal 2 (POSIX). - SIGUSR2 = 12 - // Broken pipe (POSIX). - SIGPIPE = 13 - // Alarm clock (POSIX). - SIGALRM = 14 - // Termination (ANSI). - SIGTERM = 15 - // Stack fault. - SIGSTKFLT = 16 - // Child status has changed (POSIX). - SIGCHLD = 17 - // Continue (POSIX). - SIGCONT = 18 - // Stop, unblockable (POSIX). - SIGSTOP = 19 - // Keyboard stop (POSIX). - SIGTSTP = 20 - // Background read from tty (POSIX). - SIGTTIN = 21 - // Background write to tty (POSIX). - SIGTTOU = 22 - // Urgent condition on socket (4.2 BSD). - SIGURG = 23 - // CPU limit exceeded (4.2 BSD). - SIGXCPU = 24 - // File size limit exceeded (4.2 BSD). - SIGXFSZ = 25 - // Virtual alarm clock (4.2 BSD). - SIGVTALRM = 26 - // Profiling alarm clock (4.2 BSD). - SIGPROF = 27 - // Window size change (4.3 BSD, Sun). - SIGWINCH = 28 - // I/O now possible (4.2 BSD). - SIGIO = 29 - // Power failure restart (System V). - SIGPWR = 30 - // Bad system call. - SIGSYS = 31 - SIGUNUSED = 31 -) - -// Biggest signal number + 1 -// (including real-time signals). -const X_NSIG = 65 - -// These are the hard limits of the kernel. These values should not be -// used directly at user level. -const ( - X__SIGRTMIN = 32 - X__SIGRTMAX = 64 -) diff --git a/c/signal/bits-signum_linux_arm64.go b/c/signal/bits-signum_linux_arm64.go deleted file mode 100644 index 3ab63c66..00000000 --- a/c/signal/bits-signum_linux_arm64.go +++ /dev/null @@ -1,84 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -// Signals. -const ( - SIGHUP = 1 - // Interrupt (ANSI). - SIGINT = 2 - // Quit (POSIX). - SIGQUIT = 3 - // Illegal instruction (ANSI). - SIGILL = 4 - // Trace trap (POSIX). - SIGTRAP = 5 - // Abort (ANSI). - SIGABRT = 6 - // IOT trap (4.2 BSD). - SIGIOT = 6 - // BUS error (4.2 BSD). - SIGBUS = 7 - // Floating-point exception (ANSI). - SIGFPE = 8 - // Kill, unblockable (POSIX). - SIGKILL = 9 - // User-defined signal 1 (POSIX). - SIGUSR1 = 10 - // Segmentation violation (ANSI). - SIGSEGV = 11 - // User-defined signal 2 (POSIX). - SIGUSR2 = 12 - // Broken pipe (POSIX). - SIGPIPE = 13 - // Alarm clock (POSIX). - SIGALRM = 14 - // Termination (ANSI). - SIGTERM = 15 - // Stack fault. - SIGSTKFLT = 16 - // Child status has changed (POSIX). - SIGCHLD = 17 - // Continue (POSIX). - SIGCONT = 18 - // Stop, unblockable (POSIX). - SIGSTOP = 19 - // Keyboard stop (POSIX). - SIGTSTP = 20 - // Background read from tty (POSIX). - SIGTTIN = 21 - // Background write to tty (POSIX). - SIGTTOU = 22 - // Urgent condition on socket (4.2 BSD). - SIGURG = 23 - // CPU limit exceeded (4.2 BSD). - SIGXCPU = 24 - // File size limit exceeded (4.2 BSD). - SIGXFSZ = 25 - // Virtual alarm clock (4.2 BSD). - SIGVTALRM = 26 - // Profiling alarm clock (4.2 BSD). - SIGPROF = 27 - // Window size change (4.3 BSD, Sun). - SIGWINCH = 28 - // I/O now possible (4.2 BSD). - SIGIO = 29 - // Power failure restart (System V). - SIGPWR = 30 - // Bad system call. - SIGSYS = 31 - SIGUNUSED = 31 -) - -// Biggest signal number + 1 -// (including real-time signals). -const X_NSIG = 65 - -// These are the hard limits of the kernel. These values should not be -// used directly at user level. -const ( - X__SIGRTMIN = 32 - X__SIGRTMAX = 64 -) diff --git a/c/signal/bits-sigset_linux_amd64.go b/c/signal/bits-sigset_linux_amd64.go deleted file mode 100644 index f3d19750..00000000 --- a/c/signal/bits-sigset_linux_amd64.go +++ /dev/null @@ -1,30 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import "github.com/goplus/lib/c" - -const X_SIGSET_H_types = 1 -const X_SIGSET_H_fns = 1 - -type X__SigsetT struct { - X__Val [16]c.Ulong -} -type X__SigAtomicT = c.Int - -// llgo:link (*X__SigsetT).X__Sigismember C.__sigismember -func (self *X__SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*X__SigsetT).X__Sigaddset C.__sigaddset -func (self *X__SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*X__SigsetT).X__Sigdelset C.__sigdelset -func (self *X__SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { - return 0 -} diff --git a/c/signal/bits-sigset_linux_arm64.go b/c/signal/bits-sigset_linux_arm64.go deleted file mode 100644 index 4e73ed47..00000000 --- a/c/signal/bits-sigset_linux_arm64.go +++ /dev/null @@ -1,30 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import "github.com/goplus/lib/c" - -const X_SIGSET_H_types = 1 -const X_SIGSET_H_fns = 1 - -type X__SigsetT struct { - X__Val [16]c.Ulong -} -type X__SigAtomicT = c.Int - -// llgo:link (*X__SigsetT).X__Sigismember C.__sigismember -func (self *X__SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*X__SigsetT).X__Sigaddset C.__sigaddset -func (self *X__SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*X__SigsetT).X__Sigdelset C.__sigdelset -func (self *X__SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { - return 0 -} diff --git a/c/signal/bits-sigstack_linux_amd64.go b/c/signal/bits-sigstack_linux_amd64.go deleted file mode 100644 index f3b8a9e5..00000000 --- a/c/signal/bits-sigstack_linux_amd64.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -// Minimum stack size for a signal handler. -const MINSIGSTKSZ = 2048 - -// System default stack size. -const SIGSTKSZ = 8192 - -// Structure describing a signal stack (obsolete). -type Sigstack struct { - SsSp unsafe.Pointer - SsOnstack c.Int -} - -// Possible values for `ss_flags.'. -const ( - SS_ONSTACK = 1 - SS_DISABLE = 2 -) - -// Alternate, preferred interface. -type Sigaltstack struct { - SsSp unsafe.Pointer - SsFlags c.Int - SsSize c.SizeT -} - -// Alternate, preferred interface. -type StackT = Sigaltstack diff --git a/c/signal/bits-sigstack_linux_arm64.go b/c/signal/bits-sigstack_linux_arm64.go deleted file mode 100644 index df897068..00000000 --- a/c/signal/bits-sigstack_linux_arm64.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -// Minimum stack size for a signal handler. -const MINSIGSTKSZ = 5120 - -// System default stack size. -const SIGSTKSZ = 16384 - -// Structure describing a signal stack (obsolete). -type Sigstack struct { - SsSp unsafe.Pointer - SsOnstack c.Int -} - -// Possible values for `ss_flags.'. -const ( - SS_ONSTACK = 1 - SS_DISABLE = 2 -) - -// Alternate, preferred interface. -type Sigaltstack struct { - SsSp unsafe.Pointer - SsFlags c.Int - SsSize c.SizeT -} - -// Alternate, preferred interface. -type StackT = Sigaltstack diff --git a/c/signal/bits-types_linux_amd64.go b/c/signal/bits-types_linux_amd64.go deleted file mode 100644 index baea4a6b..00000000 --- a/c/signal/bits-types_linux_amd64.go +++ /dev/null @@ -1,133 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -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/signal/bits-types_linux_arm64.go b/c/signal/bits-types_linux_arm64.go deleted file mode 100644 index fe23c21a..00000000 --- a/c/signal/bits-types_linux_arm64.go +++ /dev/null @@ -1,133 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -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/signal/libc_darwin_arm64.go b/c/signal/libc_darwin_arm64.go new file mode 100644 index 00000000..2776eeba --- /dev/null +++ b/c/signal/libc_darwin_arm64.go @@ -0,0 +1,40 @@ +//go:build darwin && arm64 && !ios + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +type Sigval struct { + _xgo_union [1]uint64 +} + +type X__Siginfo struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + SiPid c.Int + SiUid c.Uint + SiStatus c.Int + SiAddr unsafe.Pointer + SiValue Sigval + SiBand c.Long + X__Pad [7]c.Ulong +} + +type SiginfoT = X__Siginfo + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} + +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} + +type SigsetT = c.Uint diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go new file mode 100644 index 00000000..99ab4564 --- /dev/null +++ b/c/signal/libc_linux_amd64.go @@ -0,0 +1,129 @@ +//go:build linux && amd64 && !android + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +type Sigval struct { + _xgo_union [1]uint64 +} + +type SiginfoT struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + X_sifields _llcppg_anon_5 +} + +// Type for data associated with a signal. +type SigvalT = Sigval + +type _llcppg_anon_5 struct { + _xgo_union [14]uint64 +} + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} + +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { + return (*[28]c.Int)(unsafe.Pointer(p)) +} + +// kill(). +type _llcppg_anon_22 struct { + SiPid c.Int + SiUid c.Uint +} + +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_22 { + return (*_llcppg_anon_22)(unsafe.Pointer(p)) +} + +// POSIX.1b timers. +type _llcppg_anon_23 struct { + SiTid c.Int + SiOverrun c.Int + SiSigval SigvalT +} + +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_23 { + return (*_llcppg_anon_23)(unsafe.Pointer(p)) +} + +// POSIX.1b signals. +type _llcppg_anon_24 struct { + SiPid c.Int + SiUid c.Uint + SiSigval SigvalT +} + +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_24 { + return (*_llcppg_anon_24)(unsafe.Pointer(p)) +} + +// SIGCHLD. +type _llcppg_anon_25 struct { + SiPid c.Int + SiUid c.Uint + SiStatus c.Int + SiUtime c.Long + SiStime c.Long +} + +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_25 { + return (*_llcppg_anon_25)(unsafe.Pointer(p)) +} + +// SIGILL, SIGFPE, SIGSEGV, SIGBUS. +type _llcppg_anon_26 struct { + SiAddr unsafe.Pointer + SiAddrLsb int16 + SiAddrBnd _llcppg_anon_27 +} + +type _llcppg_anon_27 struct { + X_lower unsafe.Pointer + X_upper unsafe.Pointer +} + +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_26 { + return (*_llcppg_anon_26)(unsafe.Pointer(p)) +} + +// SIGPOLL. +type _llcppg_anon_28 struct { + SiBand c.Long + SiFd c.Int +} + +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_28 { + return (*_llcppg_anon_28)(unsafe.Pointer(p)) +} + +// SIGSYS. +type _llcppg_anon_29 struct { + X_callAddr unsafe.Pointer + X_syscall c.Int + X_arch c.Uint +} + +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_29 { + return (*_llcppg_anon_29)(unsafe.Pointer(p)) +} + +type SigsetT = X__SigsetT + +type X__SigsetT struct { + X__Val [16]c.Ulong +} diff --git a/c/signal/libc_linux_arm64.go b/c/signal/libc_linux_arm64.go new file mode 100644 index 00000000..a0688ee5 --- /dev/null +++ b/c/signal/libc_linux_arm64.go @@ -0,0 +1,123 @@ +//go:build linux && arm64 && !android + +// Code generated by llcppg; DO NOT EDIT. +// Classified from the common libc binding. + +package signal + +import ( + "github.com/goplus/lib/c" + "unsafe" +) + +type Sigval struct { + _xgo_union [1]uint64 +} + +type SiginfoT struct { + SiSigno c.Int + SiErrno c.Int + SiCode c.Int + X_sifields _llcppg_anon_5 +} + +// Type for data associated with a signal. +type SigvalT = Sigval + +type _llcppg_anon_5 struct { + _xgo_union [14]uint64 +} + +func (p *Sigval) XGof_ref_sival_int() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} + +func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { + return (*unsafe.Pointer)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { + return (*[28]c.Int)(unsafe.Pointer(p)) +} + +// kill(). +type _llcppg_anon_21 struct { + SiPid c.Int + SiUid c.Uint +} + +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_21 { + return (*_llcppg_anon_21)(unsafe.Pointer(p)) +} + +// POSIX.1b timers. +type _llcppg_anon_22 struct { + SiTid c.Int + SiOverrun c.Int + SiSigval SigvalT +} + +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_22 { + return (*_llcppg_anon_22)(unsafe.Pointer(p)) +} + +// POSIX.1b signals. +type _llcppg_anon_23 struct { + SiPid c.Int + SiUid c.Uint + SiSigval SigvalT +} + +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_23 { + return (*_llcppg_anon_23)(unsafe.Pointer(p)) +} + +// SIGCHLD. +type _llcppg_anon_24 struct { + SiPid c.Int + SiUid c.Uint + SiStatus c.Int + SiUtime c.Long + SiStime c.Long +} + +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_24 { + return (*_llcppg_anon_24)(unsafe.Pointer(p)) +} + +// SIGILL, SIGFPE, SIGSEGV, SIGBUS. +type _llcppg_anon_25 struct { + SiAddr unsafe.Pointer + SiAddrLsb int16 +} + +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_25 { + return (*_llcppg_anon_25)(unsafe.Pointer(p)) +} + +// SIGPOLL. +type _llcppg_anon_26 struct { + SiBand c.Long + SiFd c.Int +} + +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_26 { + return (*_llcppg_anon_26)(unsafe.Pointer(p)) +} + +// SIGSYS. +type _llcppg_anon_27 struct { + X_callAddr unsafe.Pointer + X_syscall c.Int + X_arch c.Uint +} + +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_27 { + return (*_llcppg_anon_27)(unsafe.Pointer(p)) +} + +type SigsetT = X__SigsetT + +type X__SigsetT struct { + X__Val [16]c.Ulong +} diff --git a/c/signal/llcppg.pub b/c/signal/llcppg.pub index 1424b5aa..fbd03fd9 100644 --- a/c/signal/llcppg.pub +++ b/c/signal/llcppg.pub @@ -1,113 +1,6 @@ -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_sigaltstack X__DarwinSigaltstack -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 __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 __sig_atomic_t X__SigAtomicT -T __sigaction X__SigactionT -T __sigaction_u X__SigactionT_U -T __sigchld_clock_t X__SigchldClockT -T __sighandler_t X__SighandlerT T __siginfo X__Siginfo T __sigset_t X__SigsetT -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 pid_t PidT -T pthread_attr_t PthreadAttrT -T sig_atomic_t SigAtomicT -T sig_t SigT -T sigaction SigactionT -T sigaltstack Sigaltstack -T sigevent Sigevent -T sigevent_t SigeventT T siginfo_t SiginfoT T sigset_t SigsetT -T sigstack Sigstack T sigval Sigval T sigval_t SigvalT -T sigvec Sigvec -T stack_t StackT -T u_int32_t UInt32T -T u_int64_t UInt64T -T uid_t UidT diff --git a/c/signal/signal_darwin_arm64.go b/c/signal/signal_darwin_arm64.go deleted file mode 100644 index d258314e..00000000 --- a/c/signal/signal_darwin_arm64.go +++ /dev/null @@ -1,90 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - _ "unsafe" -) - -//go:linkname SysSigname C.sys_signame -var SysSigname [32]*c.Char - -//go:linkname SysSiglist C.sys_siglist -var SysSiglist [32]*c.Char - -//go:linkname Raise C.raise -func Raise(_llcppg_param1 c.Int) c.Int - -//go:linkname BsdSignal C.bsd_signal -func BsdSignal(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) - -//go:linkname Kill C.kill -func Kill(_llcppg_param1 PidT, _llcppg_param2 c.Int) c.Int - -//go:linkname Killpg C.killpg -func Killpg(_llcppg_param1 PidT, _llcppg_param2 c.Int) c.Int - -//go:linkname PthreadSigmask C.pthread_sigmask -func PthreadSigmask(_llcppg_param1 c.Int, _llcppg_param2 *SigsetT, _llcppg_param3 *SigsetT) c.Int - -//go:linkname Sigaddset C.sigaddset -func Sigaddset(_llcppg_param1 *SigsetT, _llcppg_param2 c.Int) c.Int - -// llgo:link (*StackT).Sigaltstack C.sigaltstack -func (self *StackT) Sigaltstack(_llcppg_param2 *StackT) c.Int { - return 0 -} - -//go:linkname Sigdelset C.sigdelset -func Sigdelset(_llcppg_param1 *SigsetT, _llcppg_param2 c.Int) c.Int - -//go:linkname Sigemptyset C.sigemptyset -func Sigemptyset(_llcppg_param1 *SigsetT) c.Int - -//go:linkname Sigfillset C.sigfillset -func Sigfillset(_llcppg_param1 *SigsetT) c.Int - -//go:linkname Sighold C.sighold -func Sighold(_llcppg_param1 c.Int) c.Int - -//go:linkname Sigignore C.sigignore -func Sigignore(_llcppg_param1 c.Int) c.Int - -//go:linkname Siginterrupt C.siginterrupt -func Siginterrupt(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int - -//go:linkname Sigismember C.sigismember -func Sigismember(_llcppg_param1 *SigsetT, _llcppg_param2 c.Int) c.Int - -//go:linkname Sigpause C.sigpause -func Sigpause(_llcppg_param1 c.Int) c.Int - -//go:linkname Sigpending C.sigpending -func Sigpending(_llcppg_param1 *SigsetT) c.Int - -//go:linkname Sigprocmask C.sigprocmask -func Sigprocmask(_llcppg_param1 c.Int, _llcppg_param2 *SigsetT, _llcppg_param3 *SigsetT) c.Int - -//go:linkname Sigrelse C.sigrelse -func Sigrelse(_llcppg_param1 c.Int) c.Int - -//go:linkname Sigset C.sigset -func Sigset(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) - -//go:linkname Sigsuspend C.sigsuspend -func Sigsuspend(_llcppg_param1 *SigsetT) c.Int - -//go:linkname Sigwait C.sigwait -func Sigwait(_llcppg_param1 *SigsetT, _llcppg_param2 *c.Int) c.Int - -//go:linkname Psignal C.psignal -func Psignal(_llcppg_param1 c.Int, _llcppg_param2 *c.Char) - -//go:linkname Sigblock C.sigblock -func Sigblock(_llcppg_param1 c.Int) c.Int - -//go:linkname Sigsetmask C.sigsetmask -func Sigsetmask(_llcppg_param1 c.Int) c.Int diff --git a/c/signal/signal_linux_amd64.go b/c/signal/signal_linux_amd64.go deleted file mode 100644 index 7ef1394f..00000000 --- a/c/signal/signal_linux_amd64.go +++ /dev/null @@ -1,209 +0,0 @@ -//go:build linux && amd64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "github.com/goplus/lib/c/time" - _ "unsafe" -) - -const NSIG = 65 - -type SigAtomicT = X__SigAtomicT -type SigsetT = X__SigsetT -type PidT = X__PidT -type UidT = X__UidT - -// Type of a signal handler. -// -// llgo:type C -type X__SighandlerT = func(_llcppg_param1 c.Int) -type SigT = X__SighandlerT - -// The X/Open definition of `signal' specifies the SVID semantic. Use -// the additional function `sysv_signal' when X/Open compatibility is -// requested. -// -//go:linkname X__SysvSignal C.__sysv_signal -func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT - -//go:linkname Kill C.kill -func Kill(__pid X__PidT, __sig c.Int) c.Int - -// Send SIG to all processes in process group PGRP. -// If PGRP is zero, send SIG to all processes in -// the current process's process group. -// -//go:linkname Killpg C.killpg -func Killpg(__pgrp X__PidT, __sig c.Int) c.Int - -// Raise signal SIG, i.e., send SIG to yourself. -// -//go:linkname Raise C.raise -func Raise(__sig c.Int) c.Int - -// SVID names for the same things. -// -//go:linkname Ssignal C.ssignal -func Ssignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT - -//go:linkname Gsignal C.gsignal -func Gsignal(__sig c.Int) c.Int - -// Print a message describing the meaning of the given signal number. -// -//go:linkname Psignal C.psignal -func Psignal(__sig c.Int, __s *c.Char) - -// Print a message describing the meaning of the given signal information. -// -// llgo:link (*SiginfoT).Psiginfo C.psiginfo -func (self *SiginfoT) Psiginfo(__s *c.Char) { -} - -// Block signals in MASK, returning the old mask. -// -//go:linkname Sigblock C.sigblock -func Sigblock(__mask c.Int) c.Int - -// Set the mask of blocked signals to MASK, returning the old mask. -// -//go:linkname Sigsetmask C.sigsetmask -func Sigsetmask(__mask c.Int) c.Int - -// Return currently selected signal mask. -// -//go:linkname Siggetmask C.siggetmask -func Siggetmask() c.Int - -// Clear all signals from SET. -// -// llgo:link (*SigsetT).Sigemptyset C.sigemptyset -func (self *SigsetT) Sigemptyset() c.Int { - return 0 -} - -// Set all signals in SET. -// -// llgo:link (*SigsetT).Sigfillset C.sigfillset -func (self *SigsetT) Sigfillset() c.Int { - return 0 -} - -// Add SIGNO to SET. -// -// llgo:link (*SigsetT).Sigaddset C.sigaddset -func (self *SigsetT) Sigaddset(__signo c.Int) c.Int { - return 0 -} - -// Remove SIGNO from SET. -// -// llgo:link (*SigsetT).Sigdelset C.sigdelset -func (self *SigsetT) Sigdelset(__signo c.Int) c.Int { - return 0 -} - -// Return 1 if SIGNO is in SET, 0 if not. -// -// llgo:link (*SigsetT).Sigismember C.sigismember -func (self *SigsetT) Sigismember(__signo c.Int) c.Int { - return 0 -} - -// Get and/or change the set of blocked signals. -// -//go:linkname Sigprocmask C.sigprocmask -func Sigprocmask(__how c.Int, __set *SigsetT, __oset *SigsetT) c.Int - -// Change the set of blocked signals to SET, -// wait until a signal arrives, and restore the set of blocked signals. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigsuspend C.sigsuspend -func (self *SigsetT) Sigsuspend() c.Int { - return 0 -} - -// Put in SET all signals that are blocked and waiting to be delivered. -// -// llgo:link (*SigsetT).Sigpending C.sigpending -func (self *SigsetT) Sigpending() c.Int { - return 0 -} - -// Select any of pending signals from SET or wait for any to arrive. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigwait C.sigwait -func (self *SigsetT) Sigwait(__sig *c.Int) c.Int { - return 0 -} - -// Select any of pending signals from SET and place information in INFO. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigwaitinfo C.sigwaitinfo -func (self *SigsetT) Sigwaitinfo(__info *SiginfoT) c.Int { - return 0 -} - -// Select any of pending signals from SET and place information in INFO. -// Wait the time specified by TIMEOUT if no signal is pending. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigtimedwait C.sigtimedwait -func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *time.Timespec) c.Int { - return 0 -} - -// Send signal SIG to the process PID. Associate data in VAL with the -// signal. -// -//go:linkname Sigqueue C.sigqueue -func Sigqueue(__pid X__PidT, __sig c.Int, __val Sigval) c.Int - -// Names of the signals. This variable exists only for compatibility. -// Use `strsignal' instead (see ). -// -//go:linkname X_sysSiglist C._sys_siglist -var X_sysSiglist [65]*c.Char - -//go:linkname SysSiglist C.sys_siglist -var SysSiglist [65]*c.Char - -// If INTERRUPT is nonzero, make signal SIG interrupt system calls -// (causing them to fail with EINTR); if INTERRUPT is zero, make system -// calls be restarted after signal SIG. -// -//go:linkname Siginterrupt C.siginterrupt -func Siginterrupt(__sig c.Int, __interrupt c.Int) c.Int - -// Alternate signal handler stack interface. -// This interface should always be preferred over `sigstack'. -// -// llgo:link (*Sigaltstack).Sigaltstack C.sigaltstack -func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { - return 0 -} - -// Return number of available real-time signal with highest priority. -// -//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin -func X__LibcCurrentSigrtmin() c.Int - -// Return number of available real-time signal with lowest priority. -// -//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax -func X__LibcCurrentSigrtmax() c.Int diff --git a/c/signal/signal_linux_arm64.go b/c/signal/signal_linux_arm64.go deleted file mode 100644 index 6ea11186..00000000 --- a/c/signal/signal_linux_arm64.go +++ /dev/null @@ -1,209 +0,0 @@ -//go:build linux && arm64 && !android - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "github.com/goplus/lib/c/time" - _ "unsafe" -) - -const NSIG = 65 - -type SigAtomicT = X__SigAtomicT -type SigsetT = X__SigsetT -type PidT = X__PidT -type UidT = X__UidT - -// Type of a signal handler. -// -// llgo:type C -type X__SighandlerT = func(_llcppg_param1 c.Int) -type SigT = X__SighandlerT - -// The X/Open definition of `signal' specifies the SVID semantic. Use -// the additional function `sysv_signal' when X/Open compatibility is -// requested. -// -//go:linkname X__SysvSignal C.__sysv_signal -func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT - -//go:linkname Kill C.kill -func Kill(__pid X__PidT, __sig c.Int) c.Int - -// Send SIG to all processes in process group PGRP. -// If PGRP is zero, send SIG to all processes in -// the current process's process group. -// -//go:linkname Killpg C.killpg -func Killpg(__pgrp X__PidT, __sig c.Int) c.Int - -// Raise signal SIG, i.e., send SIG to yourself. -// -//go:linkname Raise C.raise -func Raise(__sig c.Int) c.Int - -// SVID names for the same things. -// -//go:linkname Ssignal C.ssignal -func Ssignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT - -//go:linkname Gsignal C.gsignal -func Gsignal(__sig c.Int) c.Int - -// Print a message describing the meaning of the given signal number. -// -//go:linkname Psignal C.psignal -func Psignal(__sig c.Int, __s *uint8) - -// Print a message describing the meaning of the given signal information. -// -// llgo:link (*SiginfoT).Psiginfo C.psiginfo -func (self *SiginfoT) Psiginfo(__s *uint8) { -} - -// Block signals in MASK, returning the old mask. -// -//go:linkname Sigblock C.sigblock -func Sigblock(__mask c.Int) c.Int - -// Set the mask of blocked signals to MASK, returning the old mask. -// -//go:linkname Sigsetmask C.sigsetmask -func Sigsetmask(__mask c.Int) c.Int - -// Return currently selected signal mask. -// -//go:linkname Siggetmask C.siggetmask -func Siggetmask() c.Int - -// Clear all signals from SET. -// -// llgo:link (*SigsetT).Sigemptyset C.sigemptyset -func (self *SigsetT) Sigemptyset() c.Int { - return 0 -} - -// Set all signals in SET. -// -// llgo:link (*SigsetT).Sigfillset C.sigfillset -func (self *SigsetT) Sigfillset() c.Int { - return 0 -} - -// Add SIGNO to SET. -// -// llgo:link (*SigsetT).Sigaddset C.sigaddset -func (self *SigsetT) Sigaddset(__signo c.Int) c.Int { - return 0 -} - -// Remove SIGNO from SET. -// -// llgo:link (*SigsetT).Sigdelset C.sigdelset -func (self *SigsetT) Sigdelset(__signo c.Int) c.Int { - return 0 -} - -// Return 1 if SIGNO is in SET, 0 if not. -// -// llgo:link (*SigsetT).Sigismember C.sigismember -func (self *SigsetT) Sigismember(__signo c.Int) c.Int { - return 0 -} - -// Get and/or change the set of blocked signals. -// -//go:linkname Sigprocmask C.sigprocmask -func Sigprocmask(__how c.Int, __set *SigsetT, __oset *SigsetT) c.Int - -// Change the set of blocked signals to SET, -// wait until a signal arrives, and restore the set of blocked signals. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigsuspend C.sigsuspend -func (self *SigsetT) Sigsuspend() c.Int { - return 0 -} - -// Put in SET all signals that are blocked and waiting to be delivered. -// -// llgo:link (*SigsetT).Sigpending C.sigpending -func (self *SigsetT) Sigpending() c.Int { - return 0 -} - -// Select any of pending signals from SET or wait for any to arrive. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigwait C.sigwait -func (self *SigsetT) Sigwait(__sig *c.Int) c.Int { - return 0 -} - -// Select any of pending signals from SET and place information in INFO. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigwaitinfo C.sigwaitinfo -func (self *SigsetT) Sigwaitinfo(__info *SiginfoT) c.Int { - return 0 -} - -// Select any of pending signals from SET and place information in INFO. -// Wait the time specified by TIMEOUT if no signal is pending. -// -// This function is a cancellation point and therefore not marked with -// __THROW. -// -// llgo:link (*SigsetT).Sigtimedwait C.sigtimedwait -func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *time.Timespec) c.Int { - return 0 -} - -// Send signal SIG to the process PID. Associate data in VAL with the -// signal. -// -//go:linkname Sigqueue C.sigqueue -func Sigqueue(__pid X__PidT, __sig c.Int, __val Sigval) c.Int - -// Names of the signals. This variable exists only for compatibility. -// Use `strsignal' instead (see ). -// -//go:linkname X_sysSiglist C._sys_siglist -var X_sysSiglist [65]*uint8 - -//go:linkname SysSiglist C.sys_siglist -var SysSiglist [65]*uint8 - -// If INTERRUPT is nonzero, make signal SIG interrupt system calls -// (causing them to fail with EINTR); if INTERRUPT is zero, make system -// calls be restarted after signal SIG. -// -//go:linkname Siginterrupt C.siginterrupt -func Siginterrupt(__sig c.Int, __interrupt c.Int) c.Int - -// Alternate signal handler stack interface. -// This interface should always be preferred over `sigstack'. -// -// llgo:link (*Sigaltstack).Sigaltstack C.sigaltstack -func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { - return 0 -} - -// Return number of available real-time signal with highest priority. -// -//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin -func X__LibcCurrentSigrtmin() c.Int - -// Return number of available real-time signal with lowest priority. -// -//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax -func X__LibcCurrentSigrtmax() c.Int diff --git a/c/signal/sys-_types-_pid_t_darwin_arm64.go b/c/signal/sys-_types-_pid_t_darwin_arm64.go deleted file mode 100644 index 39024f66..00000000 --- a/c/signal/sys-_types-_pid_t_darwin_arm64.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -type PidT = X__DarwinPidT diff --git a/c/signal/sys-_types-_sigaltstack_darwin_arm64.go b/c/signal/sys-_types-_sigaltstack_darwin_arm64.go deleted file mode 100644 index c589e75e..00000000 --- a/c/signal/sys-_types-_sigaltstack_darwin_arm64.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -type X__DarwinSigaltstack struct { - SsSp unsafe.Pointer - SsSize X__DarwinSizeT - SsFlags c.Int -} - -// [???] signal stack -type StackT = X__DarwinSigaltstack diff --git a/c/signal/sys-_types-_sigset_t_darwin_arm64.go b/c/signal/sys-_types-_sigset_t_darwin_arm64.go deleted file mode 100644 index fd252617..00000000 --- a/c/signal/sys-_types-_sigset_t_darwin_arm64.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -type SigsetT = X__DarwinSigsetT diff --git a/c/signal/sys-_types-_u_int32_t_darwin_arm64.go b/c/signal/sys-_types-_u_int32_t_darwin_arm64.go deleted file mode 100644 index 6d960dac..00000000 --- a/c/signal/sys-_types-_u_int32_t_darwin_arm64.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import "github.com/goplus/lib/c" - -type UInt32T = c.Uint diff --git a/c/signal/sys-_types-_u_int64_t_darwin_arm64.go b/c/signal/sys-_types-_u_int64_t_darwin_arm64.go deleted file mode 100644 index b5dfa2c1..00000000 --- a/c/signal/sys-_types-_u_int64_t_darwin_arm64.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import "github.com/goplus/lib/c" - -type UInt64T = c.UlongLong diff --git a/c/signal/sys-_types-_uid_t_darwin_arm64.go b/c/signal/sys-_types-_uid_t_darwin_arm64.go deleted file mode 100644 index 59047fec..00000000 --- a/c/signal/sys-_types-_uid_t_darwin_arm64.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -type UidT = X__DarwinUidT diff --git a/c/signal/sys-_types_darwin_arm64.go b/c/signal/sys-_types_darwin_arm64.go deleted file mode 100644 index 0f2039a9..00000000 --- a/c/signal/sys-_types_darwin_arm64.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -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/signal/sys-signal_darwin_arm64.go b/c/signal/sys-signal_darwin_arm64.go deleted file mode 100644 index 44df3b51..00000000 --- a/c/signal/sys-signal_darwin_arm64.go +++ /dev/null @@ -1,338 +0,0 @@ -//go:build darwin && arm64 && !ios - -// Code generated by llcppg; DO NOT EDIT. - -package signal - -import ( - "github.com/goplus/lib/c" - "unsafe" -) - -// counting 0; could be 33 (mask is 1-32) -const X__DARWIN_NSIG = 32 -const NSIG = 32 -const ( - // hangup - SIGHUP = 1 - // interrupt - SIGINT = 2 - // quit - SIGQUIT = 3 - // illegal instruction (not reset when caught) - SIGILL = 4 - // trace trap (not reset when caught) - SIGTRAP = 5 - // abort() - SIGABRT = 6 -) -const ( - // compatibility - SIGIOT = 6 - // EMT instruction - SIGEMT = 7 -) -const ( - // floating point exception - SIGFPE = 8 - // kill (cannot be caught or ignored) - SIGKILL = 9 - // bus error - SIGBUS = 10 - // segmentation violation - SIGSEGV = 11 - // bad argument to system call - SIGSYS = 12 - // write on a pipe with no one to read it - SIGPIPE = 13 - // alarm clock - SIGALRM = 14 - // software termination signal from kill - SIGTERM = 15 - // urgent condition on IO channel - SIGURG = 16 - // sendable stop signal not from tty - SIGSTOP = 17 - // stop signal from tty - SIGTSTP = 18 - // continue a stopped process - SIGCONT = 19 - // to parent on child stop or exit - SIGCHLD = 20 - // to readers pgrp upon background tty read - SIGTTIN = 21 - // like TTIN for output if (tp->t_local<OSTOP) - SIGTTOU = 22 -) - -// input/output possible signal -const SIGIO = 23 -const ( - // exceeded CPU time limit - SIGXCPU = 24 - // exceeded file size limit - SIGXFSZ = 25 - // virtual time alarm - SIGVTALRM = 26 - // profiling time alarm - SIGPROF = 27 -) -const ( - // window size changes - SIGWINCH = 28 - // information request - SIGINFO = 29 -) -const ( - // user defined signal 1 - SIGUSR1 = 30 - // user defined signal 2 - SIGUSR2 = 31 -) -const ( - // No async notification - SIGEV_NONE = 0 - // aio - completion notification - SIGEV_SIGNAL = 1 - // [NOTIMP] [RTS] call notification function - SIGEV_THREAD = 3 -) - -// if only I knew... -const ILL_NOOP = 0 -const ( - // [XSI] illegal opcode - ILL_ILLOPC = 1 - // [XSI] illegal trap - ILL_ILLTRP = 2 - // [XSI] privileged opcode - ILL_PRVOPC = 3 - // [XSI] illegal operand -NOTIMP - ILL_ILLOPN = 4 - // [XSI] illegal addressing mode -NOTIMP - ILL_ILLADR = 5 - // [XSI] privileged register -NOTIMP - ILL_PRVREG = 6 - // [XSI] coprocessor error -NOTIMP - ILL_COPROC = 7 - // [XSI] internal stack error -NOTIMP - ILL_BADSTK = 8 -) - -// if only I knew... -const FPE_NOOP = 0 -const ( - // [XSI] floating point divide by zero - FPE_FLTDIV = 1 - // [XSI] floating point overflow - FPE_FLTOVF = 2 - // [XSI] floating point underflow - FPE_FLTUND = 3 - // [XSI] floating point inexact result - FPE_FLTRES = 4 - // [XSI] invalid floating point operation - FPE_FLTINV = 5 - // [XSI] subscript out of range -NOTIMP - FPE_FLTSUB = 6 - // [XSI] integer divide by zero - FPE_INTDIV = 7 - // [XSI] integer overflow - FPE_INTOVF = 8 -) - -// if only I knew... -const SEGV_NOOP = 0 -const ( - // [XSI] address not mapped to object - SEGV_MAPERR = 1 - // [XSI] invalid permission for mapped object - SEGV_ACCERR = 2 -) - -// if only I knew... -const BUS_NOOP = 0 -const ( - // [XSI] Invalid address alignment - BUS_ADRALN = 1 - // [XSI] Nonexistent physical address -NOTIMP - BUS_ADRERR = 2 - // [XSI] Object-specific HW error - NOTIMP - BUS_OBJERR = 3 -) - -// Codes for SIGTRAP -const ( - TRAP_BRKPT = 1 - // [XSI] Process trace trap -NOTIMP - TRAP_TRACE = 2 -) - -// if only I knew... -const CLD_NOOP = 0 -const ( - // [XSI] child has exited - CLD_EXITED = 1 - // [XSI] terminated abnormally, no core file - CLD_KILLED = 2 - // [XSI] terminated abnormally, core file - CLD_DUMPED = 3 - // [XSI] traced child has trapped - CLD_TRAPPED = 4 - // [XSI] child has stopped - CLD_STOPPED = 5 - // [XSI] stopped child has continued - CLD_CONTINUED = 6 -) - -// Codes for SIGPOLL -const ( - POLL_IN = 1 - // [XSR] Output buffers available - POLL_OUT = 2 - // [XSR] Input message available - POLL_MSG = 3 - // [XSR] I/O error - POLL_ERR = 4 - // [XSR] High priority input available - POLL_PRI = 5 - // [XSR] Device disconnected - POLL_HUP = 6 -) -const ( - // take signal on signal stack - SA_ONSTACK = 1 - // restart system on signal return - SA_RESTART = 2 - // reset to SIG_DFL when taking signal - SA_RESETHAND = 4 - // do not generate SIGCHLD on child stop - SA_NOCLDSTOP = 8 - // don't mask the signal we're delivering - SA_NODEFER = 16 - // don't keep zombies around - SA_NOCLDWAIT = 32 - // signal handler with SA_SIGINFO args - SA_SIGINFO = 64 -) - -// do not bounce off kernel's sigtramp -const SA_USERTRAMP = 256 - -// This will provide 64bit register set in a 32bit user address space -const SA_64REGSET = 512 - -// the following are the only bits we support from user space, the -// rest are for kernel use only. -const SA_USERSPACE_MASK = 127 - -// Flags for sigprocmask: -const ( - SIG_BLOCK = 1 - // unblock specified signal set - SIG_UNBLOCK = 2 - // set specified signal set - SIG_SETMASK = 3 -) - -// POSIX 1003.1b required values. -const ( - SI_USER = 65537 - // [CX] signal from sigqueue() - SI_QUEUE = 65538 - // [CX] timer expiration - SI_TIMER = 65539 - // [CX] aio request completion - SI_ASYNCIO = 65540 - // [CX] from message arrival on empty queue - SI_MESGQ = 65541 -) -const ( - // take signal on signal stack - SS_ONSTACK = 1 - // disable taking signals on alternate stack - SS_DISABLE = 4 - // (32K)minimum allowable stack - MINSIGSTKSZ = 32768 - // (128K)recommended stack size - SIGSTKSZ = 131072 -) -const ( - SV_ONSTACK = 1 - // same bit, opposite sense - SV_INTERRUPT = 2 - SV_RESETHAND = 4 - SV_NODEFER = 16 - SV_NOCLDSTOP = 8 - SV_SIGINFO = 64 -) - -type Sigval struct { - _xgo_union [1]uint64 -} -type X__Siginfo struct { - SiSigno c.Int - SiErrno c.Int - SiCode c.Int - SiPid PidT - SiUid UidT - SiStatus c.Int - SiAddr unsafe.Pointer - SiValue Sigval - SiBand c.Long - X__Pad [7]c.Ulong -} -type X__SigactionT_U struct { - _xgo_union [1]uint64 -} - -// Signal vector template for Kernel user boundary -// -// llgo:type C -type X__SigactionT struct { - X__SigactionT_U X__SigactionT_U - SaTramp func(_llcppg_param1 unsafe.Pointer, _llcppg_param2 c.Int, _llcppg_param3 c.Int, _llcppg_param4 *SiginfoT, _llcppg_param5 unsafe.Pointer) - SaMask SigsetT - SaFlags c.Int -} - -// Signal vector "template" used in sigaction call. -type SigactionT struct { - X__SigactionT_U X__SigactionT_U - SaMask SigsetT - SaFlags c.Int -} - -// 4.3 compatibility: -// Signal vector "template" used in sigvec call. -// -// llgo:type C -type Sigvec struct { - SvHandler func(_llcppg_param1 c.Int) - SvMask c.Int - SvFlags c.Int -} - -// Structure used in sigstack call. -type Sigstack struct { - SsSp *c.Char - SsOnstack c.Int -} -type SiginfoT = X__Siginfo - -// type of signal function -// -// llgo:type C -type SigT = func(_llcppg_param1 c.Int) - -func (p *Sigval) XGof_ref_sival_int() *c.Int { - return (*c.Int)(unsafe.Pointer(p)) -} -func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { - return (*unsafe.Pointer)(unsafe.Pointer(p)) -} -func (p *X__SigactionT_U) XGof_ref___sa_handler() *func(_llcppg_param1 c.Int) { - return (*func(_llcppg_param1 c.Int))(unsafe.Pointer(p)) -} -func (p *X__SigactionT_U) XGof_ref___sa_sigaction() *func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer) { - return (*func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer))(unsafe.Pointer(p)) -} From 1b363194e3e34358a621370b81df7722ed52f093 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Mon, 19 Oct 2026 22:38:35 +0800 Subject: [PATCH 4/8] Restore Linux sigevent with opaque pthread attributes --- c/signal/libc_linux_amd64.go | 33 +++++++++++++++++++++++++++++++++ c/signal/libc_linux_arm64.go | 33 +++++++++++++++++++++++++++++++++ c/signal/llcppg.pub | 2 ++ 3 files changed, 68 insertions(+) diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go index 99ab4564..bc42ce8c 100644 --- a/c/signal/libc_linux_amd64.go +++ b/c/signal/libc_linux_amd64.go @@ -127,3 +127,36 @@ type SigsetT = X__SigsetT type X__SigsetT struct { X__Val [16]c.Ulong } + +type Sigevent struct { + SigevValue SigvalT + SigevSigno c.Int + SigevNotify c.Int + X_sigevUn _llcppg_anon_6 +} + +// llgo:type C +type llcppgCallback2 = func(_llcppg_param1 SigvalT) + +type _llcppg_anon_6 struct { + _xgo_union [6]uint64 +} + +func (p *_llcppg_anon_6) XGof_ref__pad() *[12]c.Int { + return (*[12]c.Int)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_6) XGof_ref__tid() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} + +type _llcppg_anon_31 struct { + X_function llcppgCallback2 + X_attribute c.Pointer +} + +func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_31 { + return (*_llcppg_anon_31)(unsafe.Pointer(p)) +} + +type SigeventT = Sigevent diff --git a/c/signal/libc_linux_arm64.go b/c/signal/libc_linux_arm64.go index a0688ee5..3cad4d79 100644 --- a/c/signal/libc_linux_arm64.go +++ b/c/signal/libc_linux_arm64.go @@ -121,3 +121,36 @@ type SigsetT = X__SigsetT type X__SigsetT struct { X__Val [16]c.Ulong } + +type Sigevent struct { + SigevValue SigvalT + SigevSigno c.Int + SigevNotify c.Int + X_sigevUn _llcppg_anon_6 +} + +// llgo:type C +type llcppgCallback2 = func(_llcppg_param1 SigvalT) + +type _llcppg_anon_6 struct { + _xgo_union [6]uint64 +} + +func (p *_llcppg_anon_6) XGof_ref__pad() *[12]c.Int { + return (*[12]c.Int)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_6) XGof_ref__tid() *c.Int { + return (*c.Int)(unsafe.Pointer(p)) +} + +type _llcppg_anon_29 struct { + X_function llcppgCallback2 + X_attribute c.Pointer +} + +func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_29 { + return (*_llcppg_anon_29)(unsafe.Pointer(p)) +} + +type SigeventT = Sigevent diff --git a/c/signal/llcppg.pub b/c/signal/llcppg.pub index fbd03fd9..726d8ece 100644 --- a/c/signal/llcppg.pub +++ b/c/signal/llcppg.pub @@ -1,5 +1,7 @@ T __siginfo X__Siginfo T __sigset_t X__SigsetT +T sigevent Sigevent +T sigevent_t SigeventT T siginfo_t SiginfoT T sigset_t SigsetT T sigval Sigval From 90820fb598ba6096e1850dc09d035a4bc9e3ad39 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 20 Oct 2026 00:21:45 +0800 Subject: [PATCH 5/8] Publish expanded unified libc classification for c/signal --- c/signal/libc_darwin_arm64.go | 401 ++++++++++++++++++++++++++++++++ c/signal/libc_linux_amd64.go | 355 ++++++++++++++++++++++++---- c/signal/libc_linux_arm64.go | 277 ++++++++++++++++++---- c/signal/llcppg-linux_amd64.cfg | 26 --- c/signal/llcppg-linux_arm64.cfg | 26 --- c/signal/llcppg.cfg | 25 +- c/signal/llcppg.pub | 12 + 7 files changed, 962 insertions(+), 160 deletions(-) delete mode 100644 c/signal/llcppg-linux_amd64.cfg delete mode 100644 c/signal/llcppg-linux_arm64.cfg diff --git a/c/signal/libc_darwin_arm64.go b/c/signal/libc_darwin_arm64.go index 2776eeba..34568774 100644 --- a/c/signal/libc_darwin_arm64.go +++ b/c/signal/libc_darwin_arm64.go @@ -10,6 +10,365 @@ import ( "unsafe" ) +//go:linkname SysSigname C.sys_signame +var SysSigname [32]*c.Char + +//go:linkname SysSiglist C.sys_siglist +var SysSiglist [32]*c.Char + +//go:linkname Raise C.raise +func Raise(_llcppg_param1 c.Int) c.Int + +//go:linkname BsdSignal C.bsd_signal +func BsdSignal(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) + +//go:linkname Killpg C.killpg +func Killpg(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigaction C.sigaction +func Sigaction(_llcppg_param1 c.Int, _llcppg_param2 *SigactionT, _llcppg_param3 *SigactionT) c.Int + +//go:linkname Sigaddset C.sigaddset +func Sigaddset(_llcppg_param1 *c.Uint, _llcppg_param2 c.Int) c.Int + +// llgo:link (*StackT).Sigaltstack C.sigaltstack +func (self *StackT) Sigaltstack(_llcppg_param2 *StackT) c.Int { + return 0 +} + +//go:linkname Sigdelset C.sigdelset +func Sigdelset(_llcppg_param1 *c.Uint, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigemptyset C.sigemptyset +func Sigemptyset(_llcppg_param1 *c.Uint) c.Int + +//go:linkname Sigfillset C.sigfillset +func Sigfillset(_llcppg_param1 *c.Uint) c.Int + +//go:linkname Sighold C.sighold +func Sighold(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigignore C.sigignore +func Sigignore(_llcppg_param1 c.Int) c.Int + +//go:linkname Siginterrupt C.siginterrupt +func Siginterrupt(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigismember C.sigismember +func Sigismember(_llcppg_param1 *c.Uint, _llcppg_param2 c.Int) c.Int + +//go:linkname Sigpause C.sigpause +func Sigpause(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigpending C.sigpending +func Sigpending(_llcppg_param1 *c.Uint) c.Int + +//go:linkname Sigprocmask C.sigprocmask +func Sigprocmask(_llcppg_param1 c.Int, _llcppg_param2 *c.Uint, _llcppg_param3 *c.Uint) c.Int + +//go:linkname Sigrelse C.sigrelse +func Sigrelse(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigset C.sigset +func Sigset(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) + +//go:linkname Sigsuspend C.sigsuspend +func Sigsuspend(_llcppg_param1 *c.Uint) c.Int + +//go:linkname Sigwait C.sigwait +func Sigwait(_llcppg_param1 *c.Uint, _llcppg_param2 *c.Int) c.Int + +//go:linkname Psignal C.psignal +func Psignal(_llcppg_param1 c.Int, _llcppg_param2 *c.Char) + +//go:linkname Sigblock C.sigblock +func Sigblock(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigsetmask C.sigsetmask +func Sigsetmask(_llcppg_param1 c.Int) c.Int + +//go:linkname Sigvec C.sigvec +func Sigvec(_llcppg_param1 c.Int, _llcppg_param2 *SigvecT, _llcppg_param3 *SigvecT) c.Int + +type X__DarwinSigaltstack struct { + SsSp unsafe.Pointer + SsSize c.Ulong + SsFlags c.Int +} + +// [???] signal stack +type StackT = X__DarwinSigaltstack + +const NSIG = 32 + +const ( + // hangup + SIGHUP = 1 + // interrupt + SIGINT = 2 + // quit + SIGQUIT = 3 + // illegal instruction (not reset when caught) + SIGILL = 4 + // trace trap (not reset when caught) + SIGTRAP = 5 + // abort() + SIGABRT = 6 +) + +const ( + // compatibility + SIGIOT = 6 + // EMT instruction + SIGEMT = 7 +) + +const ( + // floating point exception + SIGFPE = 8 + // kill (cannot be caught or ignored) + SIGKILL = 9 + // bus error + SIGBUS = 10 + // segmentation violation + SIGSEGV = 11 + // bad argument to system call + SIGSYS = 12 + // write on a pipe with no one to read it + SIGPIPE = 13 + // alarm clock + SIGALRM = 14 + // software termination signal from kill + SIGTERM = 15 + // urgent condition on IO channel + SIGURG = 16 + // sendable stop signal not from tty + SIGSTOP = 17 + // stop signal from tty + SIGTSTP = 18 + // continue a stopped process + SIGCONT = 19 + // to parent on child stop or exit + SIGCHLD = 20 + // to readers pgrp upon background tty read + SIGTTIN = 21 + // like TTIN for output if (tp->t_local<OSTOP) + SIGTTOU = 22 +) + +// input/output possible signal +const SIGIO = 23 + +const ( + // exceeded CPU time limit + SIGXCPU = 24 + // exceeded file size limit + SIGXFSZ = 25 + // virtual time alarm + SIGVTALRM = 26 + // profiling time alarm + SIGPROF = 27 +) + +const ( + // window size changes + SIGWINCH = 28 + // information request + SIGINFO = 29 +) + +const ( + // user defined signal 1 + SIGUSR1 = 30 + // user defined signal 2 + SIGUSR2 = 31 +) + +const ( + // No async notification + SIGEV_NONE = 0 + // aio - completion notification + SIGEV_SIGNAL = 1 + // [NOTIMP] [RTS] call notification function + SIGEV_THREAD = 3 +) + +// if only I knew... +const ILL_NOOP = 0 + +const ( + // [XSI] illegal opcode + ILL_ILLOPC = 1 + // [XSI] illegal trap + ILL_ILLTRP = 2 + // [XSI] privileged opcode + ILL_PRVOPC = 3 + // [XSI] illegal operand -NOTIMP + ILL_ILLOPN = 4 + // [XSI] illegal addressing mode -NOTIMP + ILL_ILLADR = 5 + // [XSI] privileged register -NOTIMP + ILL_PRVREG = 6 + // [XSI] coprocessor error -NOTIMP + ILL_COPROC = 7 + // [XSI] internal stack error -NOTIMP + ILL_BADSTK = 8 +) + +// if only I knew... +const FPE_NOOP = 0 + +const ( + // [XSI] floating point divide by zero + FPE_FLTDIV = 1 + // [XSI] floating point overflow + FPE_FLTOVF = 2 + // [XSI] floating point underflow + FPE_FLTUND = 3 + // [XSI] floating point inexact result + FPE_FLTRES = 4 + // [XSI] invalid floating point operation + FPE_FLTINV = 5 + // [XSI] subscript out of range -NOTIMP + FPE_FLTSUB = 6 + // [XSI] integer divide by zero + FPE_INTDIV = 7 + // [XSI] integer overflow + FPE_INTOVF = 8 +) + +// if only I knew... +const SEGV_NOOP = 0 + +const ( + // [XSI] address not mapped to object + SEGV_MAPERR = 1 + // [XSI] invalid permission for mapped object + SEGV_ACCERR = 2 +) + +// if only I knew... +const BUS_NOOP = 0 + +const ( + // [XSI] Invalid address alignment + BUS_ADRALN = 1 + // [XSI] Nonexistent physical address -NOTIMP + BUS_ADRERR = 2 + // [XSI] Object-specific HW error - NOTIMP + BUS_OBJERR = 3 +) + +// Codes for SIGTRAP +const ( + TRAP_BRKPT = 1 + // [XSI] Process trace trap -NOTIMP + TRAP_TRACE = 2 +) + +// if only I knew... +const CLD_NOOP = 0 + +const ( + // [XSI] child has exited + CLD_EXITED = 1 + // [XSI] terminated abnormally, no core file + CLD_KILLED = 2 + // [XSI] terminated abnormally, core file + CLD_DUMPED = 3 + // [XSI] traced child has trapped + CLD_TRAPPED = 4 + // [XSI] child has stopped + CLD_STOPPED = 5 + // [XSI] stopped child has continued + CLD_CONTINUED = 6 +) + +// Codes for SIGPOLL +const ( + POLL_IN = 1 + // [XSR] Output buffers available + POLL_OUT = 2 + // [XSR] Input message available + POLL_MSG = 3 + // [XSR] I/O error + POLL_ERR = 4 + // [XSR] High priority input available + POLL_PRI = 5 + // [XSR] Device disconnected + POLL_HUP = 6 +) + +const ( + // take signal on signal stack + SA_ONSTACK = 1 + // restart system on signal return + SA_RESTART = 2 + // reset to SIG_DFL when taking signal + SA_RESETHAND = 4 + // do not generate SIGCHLD on child stop + SA_NOCLDSTOP = 8 + // don't mask the signal we're delivering + SA_NODEFER = 16 + // don't keep zombies around + SA_NOCLDWAIT = 32 + // signal handler with SA_SIGINFO args + SA_SIGINFO = 64 +) + +// do not bounce off kernel's sigtramp +const SA_USERTRAMP = 256 + +// This will provide 64bit register set in a 32bit user address space +const SA_64REGSET = 512 + +// the following are the only bits we support from user space, the +// rest are for kernel use only. +const SA_USERSPACE_MASK = 127 + +// Flags for sigprocmask: +const ( + SIG_BLOCK = 1 + // unblock specified signal set + SIG_UNBLOCK = 2 + // set specified signal set + SIG_SETMASK = 3 +) + +// POSIX 1003.1b required values. +const ( + SI_USER = 65537 + // [CX] signal from sigqueue() + SI_QUEUE = 65538 + // [CX] timer expiration + SI_TIMER = 65539 + // [CX] aio request completion + SI_ASYNCIO = 65540 + // [CX] from message arrival on empty queue + SI_MESGQ = 65541 +) + +const ( + // take signal on signal stack + SS_ONSTACK = 1 + // disable taking signals on alternate stack + SS_DISABLE = 4 + // (32K)minimum allowable stack + MINSIGSTKSZ = 32768 + // (128K)recommended stack size + SIGSTKSZ = 131072 +) + +const ( + SV_ONSTACK = 1 + // same bit, opposite sense + SV_INTERRUPT = 2 + SV_RESETHAND = 4 + SV_NODEFER = 16 + SV_NOCLDSTOP = 8 + SV_SIGINFO = 64 +) + type Sigval struct { _xgo_union [1]uint64 } @@ -27,8 +386,39 @@ type X__Siginfo struct { X__Pad [7]c.Ulong } +type X__SigactionU struct { + _xgo_union [1]uint64 +} + +// Signal vector "template" used in sigaction call. +type SigactionT struct { + X__SigactionU X__SigactionU + SaMask c.Uint + SaFlags c.Int +} + +type SigvecT struct { + SvHandler llcppgCallback4 + SvMask c.Int + SvFlags c.Int +} + type SiginfoT = X__Siginfo +// union for signal handlers +// +// llgo:type C +type llcppgCallback6 = func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer) + +// llgo:type C +type llcppgCallback7 = func(_llcppg_param1 c.Int) + +// 4.3 compatibility: +// Signal vector "template" used in sigvec call. +// +// llgo:type C +type llcppgCallback4 = func(_llcppg_param1 c.Int) + func (p *Sigval) XGof_ref_sival_int() *c.Int { return (*c.Int)(unsafe.Pointer(p)) } @@ -37,4 +427,15 @@ func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { return (*unsafe.Pointer)(unsafe.Pointer(p)) } +func (p *X__SigactionU) XGof_ref___sa_handler() *llcppgCallback7 { + return (*llcppgCallback7)(unsafe.Pointer(p)) +} + +func (p *X__SigactionU) XGof_ref___sa_sigaction() *llcppgCallback6 { + return (*llcppgCallback6)(unsafe.Pointer(p)) +} + +//go:linkname NativeSignal C.signal +func NativeSignal(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) + type SigsetT = c.Uint diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go index bc42ce8c..473cead3 100644 --- a/c/signal/libc_linux_amd64.go +++ b/c/signal/libc_linux_amd64.go @@ -7,9 +7,77 @@ package signal import ( "github.com/goplus/lib/c" + lltime "github.com/goplus/lib/c/time" "unsafe" ) +type X_fpxreg struct { + Significand [4]uint16 + Exponent uint16 + Padding [3]uint16 +} + +type X_xmmreg struct { + Element [4]c.Uint +} + +type X_fpstate struct { + Cwd c.Uint16T + Swd c.Uint16T + Ftw c.Uint16T + Fop c.Uint16T + Rip c.Ulong + Rdp c.Ulong + Mxcsr c.Uint + MxcrMask c.Uint + X_st [8]X_fpxreg + X_xmm [16]X_xmmreg + Padding [24]c.Uint +} + +type Sigcontext struct { + R8 c.Ulong + R9 c.Ulong + R10 c.Ulong + R11 c.Ulong + R12 c.Ulong + R13 c.Ulong + R14 c.Ulong + R15 c.Ulong + Rdi c.Ulong + Rsi c.Ulong + Rbp c.Ulong + Rbx c.Ulong + Rdx c.Ulong + Rax c.Ulong + Rcx c.Ulong + Rsp c.Ulong + Rip c.Ulong + Eflags c.Ulong + Cs uint16 + Gs uint16 + Fs uint16 + X__Pad0 uint16 + Err c.Ulong + Trapno c.Ulong + Oldmask c.Ulong + Cr2 c.Ulong + _llcppg_anon_7 + X__Reserved1 [8]c.Ulong +} + +type _llcppg_anon_7 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_7) XGof_ref_fpstate() **X_fpstate { + return (**X_fpstate)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_7) XGof_ref___fpstate_word() *c.Ulong { + return (*c.Ulong)(unsafe.Pointer(p)) +} + type Sigval struct { _xgo_union [1]uint64 } @@ -21,6 +89,13 @@ type SiginfoT struct { X_sifields _llcppg_anon_5 } +type Sigevent struct { + SigevValue SigvalT + SigevSigno c.Int + SigevNotify c.Int + X_sigevUn _llcppg_anon_6 +} + // Type for data associated with a signal. type SigvalT = Sigval @@ -28,6 +103,13 @@ type _llcppg_anon_5 struct { _xgo_union [14]uint64 } +// llgo:type C +type llcppgCallback2 = func(_llcppg_param1 SigvalT) + +type _llcppg_anon_6 struct { + _xgo_union [6]uint64 +} + func (p *Sigval) XGof_ref_sival_int() *c.Int { return (*c.Int)(unsafe.Pointer(p)) } @@ -41,39 +123,39 @@ func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { } // kill(). -type _llcppg_anon_22 struct { +type _llcppg_anon_23 struct { SiPid c.Int SiUid c.Uint } -func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_22 { - return (*_llcppg_anon_22)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_23 { + return (*_llcppg_anon_23)(unsafe.Pointer(p)) } // POSIX.1b timers. -type _llcppg_anon_23 struct { +type _llcppg_anon_24 struct { SiTid c.Int SiOverrun c.Int SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_23 { - return (*_llcppg_anon_23)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_24 { + return (*_llcppg_anon_24)(unsafe.Pointer(p)) } // POSIX.1b signals. -type _llcppg_anon_24 struct { +type _llcppg_anon_25 struct { SiPid c.Int SiUid c.Uint SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_24 { - return (*_llcppg_anon_24)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_25 { + return (*_llcppg_anon_25)(unsafe.Pointer(p)) } // SIGCHLD. -type _llcppg_anon_25 struct { +type _llcppg_anon_26 struct { SiPid c.Int SiUid c.Uint SiStatus c.Int @@ -81,65 +163,45 @@ type _llcppg_anon_25 struct { SiStime c.Long } -func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_25 { - return (*_llcppg_anon_25)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_26 { + return (*_llcppg_anon_26)(unsafe.Pointer(p)) } // SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_26 struct { +type _llcppg_anon_27 struct { SiAddr unsafe.Pointer SiAddrLsb int16 - SiAddrBnd _llcppg_anon_27 + SiAddrBnd _llcppg_anon_28 } -type _llcppg_anon_27 struct { +type _llcppg_anon_28 struct { X_lower unsafe.Pointer X_upper unsafe.Pointer } -func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_26 { - return (*_llcppg_anon_26)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_27 { + return (*_llcppg_anon_27)(unsafe.Pointer(p)) } // SIGPOLL. -type _llcppg_anon_28 struct { +type _llcppg_anon_29 struct { SiBand c.Long SiFd c.Int } -func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_28 { - return (*_llcppg_anon_28)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_29 { + return (*_llcppg_anon_29)(unsafe.Pointer(p)) } // SIGSYS. -type _llcppg_anon_29 struct { +type _llcppg_anon_30 struct { X_callAddr unsafe.Pointer X_syscall c.Int X_arch c.Uint } -func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_29 { - return (*_llcppg_anon_29)(unsafe.Pointer(p)) -} - -type SigsetT = X__SigsetT - -type X__SigsetT struct { - X__Val [16]c.Ulong -} - -type Sigevent struct { - SigevValue SigvalT - SigevSigno c.Int - SigevNotify c.Int - X_sigevUn _llcppg_anon_6 -} - -// llgo:type C -type llcppgCallback2 = func(_llcppg_param1 SigvalT) - -type _llcppg_anon_6 struct { - _xgo_union [6]uint64 +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_30 { + return (*_llcppg_anon_30)(unsafe.Pointer(p)) } func (p *_llcppg_anon_6) XGof_ref__pad() *[12]c.Int { @@ -159,4 +221,211 @@ func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_31 { return (*_llcppg_anon_31)(unsafe.Pointer(p)) } +// Structure describing a signal stack (obsolete). +type SigstackT struct { + SsSp unsafe.Pointer + SsOnstack c.Int +} + +// Alternate, preferred interface. +type Sigaltstack struct { + SsSp unsafe.Pointer + SsFlags c.Int + SsSize c.SizeT +} + +const NSIG = 65 + +// Type of a signal handler. +// +// llgo:type C +type X__SighandlerT = func(_llcppg_param1 c.Int) + +//go:linkname NativeSignal C.signal +func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +// Send SIG to all processes in process group PGRP. +// If PGRP is zero, send SIG to all processes in +// the current process's process group. +// +//go:linkname Killpg C.killpg +func Killpg(__pgrp c.Int, __sig c.Int) c.Int + +// Raise signal SIG, i.e., send SIG to yourself. +// +//go:linkname Raise C.raise +func Raise(__sig c.Int) c.Int + +// SVID names for the same things. +// +//go:linkname Ssignal C.ssignal +func Ssignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +//go:linkname Gsignal C.gsignal +func Gsignal(__sig c.Int) c.Int + +// Print a message describing the meaning of the given signal number. +// +//go:linkname Psignal C.psignal +func Psignal(__sig c.Int, __s *c.Char) + +// Print a message describing the meaning of the given signal information. +// +// llgo:link (*SiginfoT).Psiginfo C.psiginfo +func (self *SiginfoT) Psiginfo(__s *c.Char) { +} + +// Block signals in MASK, returning the old mask. +// +//go:linkname Sigblock C.sigblock +func Sigblock(__mask c.Int) c.Int + +// Set the mask of blocked signals to MASK, returning the old mask. +// +//go:linkname Sigsetmask C.sigsetmask +func Sigsetmask(__mask c.Int) c.Int + +// Return currently selected signal mask. +// +//go:linkname Siggetmask C.siggetmask +func Siggetmask() c.Int + +// Clear all signals from SET. +// +// llgo:link (*SigsetT).Sigemptyset C.sigemptyset +func (self *SigsetT) Sigemptyset() c.Int { + return 0 +} + +// Set all signals in SET. +// +// llgo:link (*SigsetT).Sigfillset C.sigfillset +func (self *SigsetT) Sigfillset() c.Int { + return 0 +} + +// Add SIGNO to SET. +// +// llgo:link (*SigsetT).Sigaddset C.sigaddset +func (self *SigsetT) Sigaddset(__signo c.Int) c.Int { + return 0 +} + +// Remove SIGNO from SET. +// +// llgo:link (*SigsetT).Sigdelset C.sigdelset +func (self *SigsetT) Sigdelset(__signo c.Int) c.Int { + return 0 +} + +// Return 1 if SIGNO is in SET, 0 if not. +// +// llgo:link (*SigsetT).Sigismember C.sigismember +func (self *SigsetT) Sigismember(__signo c.Int) c.Int { + return 0 +} + +// Get and/or change the set of blocked signals. +// +//go:linkname Sigprocmask C.sigprocmask +func Sigprocmask(__how c.Int, __set *SigsetT, __oset *SigsetT) c.Int + +// Change the set of blocked signals to SET, +// wait until a signal arrives, and restore the set of blocked signals. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigsuspend C.sigsuspend +func (self *SigsetT) Sigsuspend() c.Int { + return 0 +} + +// Put in SET all signals that are blocked and waiting to be delivered. +// +// llgo:link (*SigsetT).Sigpending C.sigpending +func (self *SigsetT) Sigpending() c.Int { + return 0 +} + +// Select any of pending signals from SET or wait for any to arrive. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwait C.sigwait +func (self *SigsetT) Sigwait(__sig *c.Int) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwaitinfo C.sigwaitinfo +func (self *SigsetT) Sigwaitinfo(__info *SiginfoT) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// Wait the time specified by TIMEOUT if no signal is pending. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigtimedwait C.sigtimedwait +func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *lltime.Timespec) c.Int { + return 0 +} + +// Send signal SIG to the process PID. Associate data in VAL with the +// signal. +// +//go:linkname Sigqueue C.sigqueue +func Sigqueue(__pid c.Int, __sig c.Int, __val Sigval) c.Int + +//go:linkname SysSiglist C.sys_siglist +var SysSiglist [65]*c.Char + +// Restore the state saved in SCP. +// +// llgo:link (*Sigcontext).Sigreturn C.sigreturn +func (self *Sigcontext) Sigreturn() c.Int { + return 0 +} + +// If INTERRUPT is nonzero, make signal SIG interrupt system calls +// (causing them to fail with EINTR); if INTERRUPT is zero, make system +// calls be restarted after signal SIG. +// +//go:linkname Siginterrupt C.siginterrupt +func Siginterrupt(__sig c.Int, __interrupt c.Int) c.Int + +// Run signals handlers on the stack specified by SS (if not NULL). +// If OSS is not NULL, it is filled in with the old signal stack status. +// This interface is obsolete and on many platform not implemented. +// +//go:linkname Sigstack C.sigstack +func Sigstack(__ss *SigstackT, __oss *SigstackT) c.Int + +// Alternate signal handler stack interface. +// This interface should always be preferred over `sigstack'. +// +// llgo:link (*Sigaltstack).Sigaltstack C.sigaltstack +func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { + return 0 +} + +// Create new per-process timer using CLOCK_ID. +// +//go:linkname TimerCreate C.timer_create +func TimerCreate(__clock_id lltime.ClockidT, __evp *Sigevent, __timerid *lltime.TimerT) c.Int + +type SigsetT = X__SigsetT + +type X__SigsetT struct { + X__Val [16]c.Ulong +} + type SigeventT = Sigevent diff --git a/c/signal/libc_linux_arm64.go b/c/signal/libc_linux_arm64.go index 3cad4d79..50e969bd 100644 --- a/c/signal/libc_linux_arm64.go +++ b/c/signal/libc_linux_arm64.go @@ -7,6 +7,7 @@ package signal import ( "github.com/goplus/lib/c" + lltime "github.com/goplus/lib/c/time" "unsafe" ) @@ -21,6 +22,13 @@ type SiginfoT struct { X_sifields _llcppg_anon_5 } +type Sigevent struct { + SigevValue SigvalT + SigevSigno c.Int + SigevNotify c.Int + X_sigevUn _llcppg_anon_6 +} + // Type for data associated with a signal. type SigvalT = Sigval @@ -28,6 +36,13 @@ type _llcppg_anon_5 struct { _xgo_union [14]uint64 } +// llgo:type C +type llcppgCallback2 = func(_llcppg_param1 SigvalT) + +type _llcppg_anon_6 struct { + _xgo_union [6]uint64 +} + func (p *Sigval) XGof_ref_sival_int() *c.Int { return (*c.Int)(unsafe.Pointer(p)) } @@ -41,39 +56,39 @@ func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { } // kill(). -type _llcppg_anon_21 struct { +type _llcppg_anon_22 struct { SiPid c.Int SiUid c.Uint } -func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_21 { - return (*_llcppg_anon_21)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_22 { + return (*_llcppg_anon_22)(unsafe.Pointer(p)) } // POSIX.1b timers. -type _llcppg_anon_22 struct { +type _llcppg_anon_23 struct { SiTid c.Int SiOverrun c.Int SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_22 { - return (*_llcppg_anon_22)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_23 { + return (*_llcppg_anon_23)(unsafe.Pointer(p)) } // POSIX.1b signals. -type _llcppg_anon_23 struct { +type _llcppg_anon_24 struct { SiPid c.Int SiUid c.Uint SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_23 { - return (*_llcppg_anon_23)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_24 { + return (*_llcppg_anon_24)(unsafe.Pointer(p)) } // SIGCHLD. -type _llcppg_anon_24 struct { +type _llcppg_anon_25 struct { SiPid c.Int SiUid c.Uint SiStatus c.Int @@ -81,59 +96,39 @@ type _llcppg_anon_24 struct { SiStime c.Long } -func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_24 { - return (*_llcppg_anon_24)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_25 { + return (*_llcppg_anon_25)(unsafe.Pointer(p)) } // SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_25 struct { +type _llcppg_anon_26 struct { SiAddr unsafe.Pointer SiAddrLsb int16 } -func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_25 { - return (*_llcppg_anon_25)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_26 { + return (*_llcppg_anon_26)(unsafe.Pointer(p)) } // SIGPOLL. -type _llcppg_anon_26 struct { +type _llcppg_anon_27 struct { SiBand c.Long SiFd c.Int } -func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_26 { - return (*_llcppg_anon_26)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_27 { + return (*_llcppg_anon_27)(unsafe.Pointer(p)) } // SIGSYS. -type _llcppg_anon_27 struct { +type _llcppg_anon_28 struct { X_callAddr unsafe.Pointer X_syscall c.Int X_arch c.Uint } -func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_27 { - return (*_llcppg_anon_27)(unsafe.Pointer(p)) -} - -type SigsetT = X__SigsetT - -type X__SigsetT struct { - X__Val [16]c.Ulong -} - -type Sigevent struct { - SigevValue SigvalT - SigevSigno c.Int - SigevNotify c.Int - X_sigevUn _llcppg_anon_6 -} - -// llgo:type C -type llcppgCallback2 = func(_llcppg_param1 SigvalT) - -type _llcppg_anon_6 struct { - _xgo_union [6]uint64 +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_28 { + return (*_llcppg_anon_28)(unsafe.Pointer(p)) } func (p *_llcppg_anon_6) XGof_ref__pad() *[12]c.Int { @@ -153,4 +148,204 @@ func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_29 { return (*_llcppg_anon_29)(unsafe.Pointer(p)) } +// Structure describing a signal stack (obsolete). +type SigstackT struct { + SsSp unsafe.Pointer + SsOnstack c.Int +} + +// Alternate, preferred interface. +type Sigaltstack struct { + SsSp unsafe.Pointer + SsFlags c.Int + SsSize c.SizeT +} + +const NSIG = 65 + +// Type of a signal handler. +// +// llgo:type C +type X__SighandlerT = func(_llcppg_param1 c.Int) + +//go:linkname NativeSignal C.signal +func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +// Send SIG to all processes in process group PGRP. +// If PGRP is zero, send SIG to all processes in +// the current process's process group. +// +//go:linkname Killpg C.killpg +func Killpg(__pgrp c.Int, __sig c.Int) c.Int + +// Raise signal SIG, i.e., send SIG to yourself. +// +//go:linkname Raise C.raise +func Raise(__sig c.Int) c.Int + +// SVID names for the same things. +// +//go:linkname Ssignal C.ssignal +func Ssignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + +//go:linkname Gsignal C.gsignal +func Gsignal(__sig c.Int) c.Int + +// Print a message describing the meaning of the given signal number. +// +//go:linkname Psignal C.psignal +func Psignal(__sig c.Int, __s *uint8) + +// Print a message describing the meaning of the given signal information. +// +// llgo:link (*SiginfoT).Psiginfo C.psiginfo +func (self *SiginfoT) Psiginfo(__s *uint8) { +} + +// Block signals in MASK, returning the old mask. +// +//go:linkname Sigblock C.sigblock +func Sigblock(__mask c.Int) c.Int + +// Set the mask of blocked signals to MASK, returning the old mask. +// +//go:linkname Sigsetmask C.sigsetmask +func Sigsetmask(__mask c.Int) c.Int + +// Return currently selected signal mask. +// +//go:linkname Siggetmask C.siggetmask +func Siggetmask() c.Int + +// Clear all signals from SET. +// +// llgo:link (*SigsetT).Sigemptyset C.sigemptyset +func (self *SigsetT) Sigemptyset() c.Int { + return 0 +} + +// Set all signals in SET. +// +// llgo:link (*SigsetT).Sigfillset C.sigfillset +func (self *SigsetT) Sigfillset() c.Int { + return 0 +} + +// Add SIGNO to SET. +// +// llgo:link (*SigsetT).Sigaddset C.sigaddset +func (self *SigsetT) Sigaddset(__signo c.Int) c.Int { + return 0 +} + +// Remove SIGNO from SET. +// +// llgo:link (*SigsetT).Sigdelset C.sigdelset +func (self *SigsetT) Sigdelset(__signo c.Int) c.Int { + return 0 +} + +// Return 1 if SIGNO is in SET, 0 if not. +// +// llgo:link (*SigsetT).Sigismember C.sigismember +func (self *SigsetT) Sigismember(__signo c.Int) c.Int { + return 0 +} + +// Get and/or change the set of blocked signals. +// +//go:linkname Sigprocmask C.sigprocmask +func Sigprocmask(__how c.Int, __set *SigsetT, __oset *SigsetT) c.Int + +// Change the set of blocked signals to SET, +// wait until a signal arrives, and restore the set of blocked signals. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigsuspend C.sigsuspend +func (self *SigsetT) Sigsuspend() c.Int { + return 0 +} + +// Put in SET all signals that are blocked and waiting to be delivered. +// +// llgo:link (*SigsetT).Sigpending C.sigpending +func (self *SigsetT) Sigpending() c.Int { + return 0 +} + +// Select any of pending signals from SET or wait for any to arrive. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwait C.sigwait +func (self *SigsetT) Sigwait(__sig *c.Int) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigwaitinfo C.sigwaitinfo +func (self *SigsetT) Sigwaitinfo(__info *SiginfoT) c.Int { + return 0 +} + +// Select any of pending signals from SET and place information in INFO. +// Wait the time specified by TIMEOUT if no signal is pending. +// +// This function is a cancellation point and therefore not marked with +// __THROW. +// +// llgo:link (*SigsetT).Sigtimedwait C.sigtimedwait +func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *lltime.Timespec) c.Int { + return 0 +} + +// Send signal SIG to the process PID. Associate data in VAL with the +// signal. +// +//go:linkname Sigqueue C.sigqueue +func Sigqueue(__pid c.Int, __sig c.Int, __val Sigval) c.Int + +//go:linkname SysSiglist C.sys_siglist +var SysSiglist [65]*uint8 + +// If INTERRUPT is nonzero, make signal SIG interrupt system calls +// (causing them to fail with EINTR); if INTERRUPT is zero, make system +// calls be restarted after signal SIG. +// +//go:linkname Siginterrupt C.siginterrupt +func Siginterrupt(__sig c.Int, __interrupt c.Int) c.Int + +// Run signals handlers on the stack specified by SS (if not NULL). +// If OSS is not NULL, it is filled in with the old signal stack status. +// This interface is obsolete and on many platform not implemented. +// +//go:linkname Sigstack C.sigstack +func Sigstack(__ss *SigstackT, __oss *SigstackT) c.Int + +// Alternate signal handler stack interface. +// This interface should always be preferred over `sigstack'. +// +// llgo:link (*Sigaltstack).Sigaltstack C.sigaltstack +func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { + return 0 +} + +// Create new per-process timer using CLOCK_ID. +// +//go:linkname TimerCreate C.timer_create +func TimerCreate(__clock_id lltime.ClockidT, __evp *Sigevent, __timerid *lltime.TimerT) c.Int + +type SigsetT = X__SigsetT + +type X__SigsetT struct { + X__Val [16]c.Ulong +} + type SigeventT = Sigevent diff --git a/c/signal/llcppg-linux_amd64.cfg b/c/signal/llcppg-linux_amd64.cfg deleted file mode 100644 index f72ada21..00000000 --- a/c/signal/llcppg-linux_amd64.cfg +++ /dev/null @@ -1,26 +0,0 @@ -{ - "Name": "signal", - "Language": "c", - "Dir": ".sysroot/include", - "Stdlib": ".sysroot/stdlib", - "Files": [ - "llcppg.h" - ], - "Deps": [ - "..", - "../time" - ], - "FailFast": 0, - "FuncIgnore": [ - "signal", - "sigaction", - "sigvec", - "sigstack" - ], - "TypeIgnore": [ - "va_list" - ], - "Rename": { - "sigaction": "SigactionT" - } -} diff --git a/c/signal/llcppg-linux_arm64.cfg b/c/signal/llcppg-linux_arm64.cfg deleted file mode 100644 index f72ada21..00000000 --- a/c/signal/llcppg-linux_arm64.cfg +++ /dev/null @@ -1,26 +0,0 @@ -{ - "Name": "signal", - "Language": "c", - "Dir": ".sysroot/include", - "Stdlib": ".sysroot/stdlib", - "Files": [ - "llcppg.h" - ], - "Deps": [ - "..", - "../time" - ], - "FailFast": 0, - "FuncIgnore": [ - "signal", - "sigaction", - "sigvec", - "sigstack" - ], - "TypeIgnore": [ - "va_list" - ], - "Rename": { - "sigaction": "SigactionT" - } -} diff --git a/c/signal/llcppg.cfg b/c/signal/llcppg.cfg index f72ada21..75e27be3 100644 --- a/c/signal/llcppg.cfg +++ b/c/signal/llcppg.cfg @@ -1,26 +1,3 @@ { - "Name": "signal", - "Language": "c", - "Dir": ".sysroot/include", - "Stdlib": ".sysroot/stdlib", - "Files": [ - "llcppg.h" - ], - "Deps": [ - "..", - "../time" - ], - "FailFast": 0, - "FuncIgnore": [ - "signal", - "sigaction", - "sigvec", - "sigstack" - ], - "TypeIgnore": [ - "va_list" - ], - "Rename": { - "sigaction": "SigactionT" - } + "Dir": ".sysroot/include" } diff --git a/c/signal/llcppg.pub b/c/signal/llcppg.pub index 726d8ece..a1d5ed3f 100644 --- a/c/signal/llcppg.pub +++ b/c/signal/llcppg.pub @@ -1,8 +1,20 @@ +T __darwin_sigaltstack X__DarwinSigaltstack +T __sigaction_u X__SigactionU +T __sighandler_t X__SighandlerT T __siginfo X__Siginfo T __sigset_t X__SigsetT +T _fpstate X_fpstate +T _fpxreg X_fpxreg +T _xmmreg X_xmmreg +T sigaction SigactionT +T sigaltstack Sigaltstack +T sigcontext Sigcontext T sigevent Sigevent T sigevent_t SigeventT T siginfo_t SiginfoT T sigset_t SigsetT +T sigstack SigstackT T sigval Sigval T sigval_t SigvalT +T sigvec SigvecT +T stack_t StackT From 651f597ff3fc6263b212b62b6147b929e358c490 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 20 Oct 2026 14:03:33 +0800 Subject: [PATCH 6/8] Regenerate c/signal native APIs and verify native calls --- c/signal/_libc_darwin_arm64.c | 56 ++++ c/signal/libc_darwin_arm64.go | 52 +++- c/signal/libc_linux_amd64.go | 342 ++++++++++++++++++++-- c/signal/libc_linux_arm64.go | 330 +++++++++++++++++++-- c/signal/native_darwin_arm64_llgo_test.go | 95 ++++++ c/signal/native_linux_llgo_test.go | 144 +++++++++ c/signal/native_llgo_test.go | 76 +++++ c/signal/signal.go | 2 + 8 files changed, 1028 insertions(+), 69 deletions(-) create mode 100644 c/signal/_libc_darwin_arm64.c create mode 100644 c/signal/native_darwin_arm64_llgo_test.go create mode 100644 c/signal/native_linux_llgo_test.go create mode 100644 c/signal/native_llgo_test.go diff --git a/c/signal/_libc_darwin_arm64.c b/c/signal/_libc_darwin_arm64.c new file mode 100644 index 00000000..8a019b33 --- /dev/null +++ b/c/signal/_libc_darwin_arm64.c @@ -0,0 +1,56 @@ +// 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___sigbits(int __signo) { + return __sigbits(__signo); +} diff --git a/c/signal/libc_darwin_arm64.go b/c/signal/libc_darwin_arm64.go index 34568774..91420a85 100644 --- a/c/signal/libc_darwin_arm64.go +++ b/c/signal/libc_darwin_arm64.go @@ -10,6 +10,12 @@ import ( "unsafe" ) +// llgo:type C +type llcppgCallback17 = func(_llcppg_param1 c.Int) + +// llgo:type C +type llcppgCallback16 = func(_llcppg_param1 c.Int) + //go:linkname SysSigname C.sys_signame var SysSigname [32]*c.Char @@ -20,7 +26,10 @@ var SysSiglist [32]*c.Char func Raise(_llcppg_param1 c.Int) c.Int //go:linkname BsdSignal C.bsd_signal -func BsdSignal(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) +func BsdSignal(_llcppg_param1 c.Int, _llcppg_param2 llcppgCallback17) func(_llcppg_param1 c.Int) + +//go:linkname NativeKill C.kill +func NativeKill(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int //go:linkname Killpg C.killpg func Killpg(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int @@ -70,7 +79,7 @@ func Sigprocmask(_llcppg_param1 c.Int, _llcppg_param2 *c.Uint, _llcppg_param3 *c func Sigrelse(_llcppg_param1 c.Int) c.Int //go:linkname Sigset C.sigset -func Sigset(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) +func Sigset(_llcppg_param1 c.Int, _llcppg_param2 llcppgCallback16) func(_llcppg_param1 c.Int) //go:linkname Sigsuspend C.sigsuspend func Sigsuspend(_llcppg_param1 *c.Uint) c.Int @@ -90,6 +99,11 @@ func Sigsetmask(_llcppg_param1 c.Int) c.Int //go:linkname Sigvec C.sigvec func Sigvec(_llcppg_param1 c.Int, _llcppg_param2 *SigvecT, _llcppg_param3 *SigvecT) c.Int +// List definitions after function declarations, or Reiser cpp gets upset. +// +//go:linkname X__Sigbits C._llcppg___sigbits +func X__Sigbits(__signo c.Int) c.Int + type X__DarwinSigaltstack struct { SsSp unsafe.Pointer SsSize c.Ulong @@ -398,7 +412,7 @@ type SigactionT struct { } type SigvecT struct { - SvHandler llcppgCallback4 + SvHandler llcppgCallback19 SvMask c.Int SvFlags c.Int } @@ -408,16 +422,19 @@ type SiginfoT = X__Siginfo // union for signal handlers // // llgo:type C -type llcppgCallback6 = func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer) +type llcppgCallback21 = func(_llcppg_param1 c.Int, _llcppg_param2 *X__Siginfo, _llcppg_param3 unsafe.Pointer) // llgo:type C -type llcppgCallback7 = func(_llcppg_param1 c.Int) +type llcppgCallback22 = func(_llcppg_param1 c.Int) // 4.3 compatibility: // Signal vector "template" used in sigvec call. // // llgo:type C -type llcppgCallback4 = func(_llcppg_param1 c.Int) +type llcppgCallback19 = func(_llcppg_param1 c.Int) + +// llgo:type C +type llcppgCallback18 = func(_llcppg_param1 c.Int) func (p *Sigval) XGof_ref_sival_int() *c.Int { return (*c.Int)(unsafe.Pointer(p)) @@ -427,15 +444,28 @@ func (p *Sigval) XGof_ref_sival_ptr() *unsafe.Pointer { return (*unsafe.Pointer)(unsafe.Pointer(p)) } -func (p *X__SigactionU) XGof_ref___sa_handler() *llcppgCallback7 { - return (*llcppgCallback7)(unsafe.Pointer(p)) +func (p *X__SigactionU) XGof_ref___sa_handler() *llcppgCallback22 { + return (*llcppgCallback22)(unsafe.Pointer(p)) } -func (p *X__SigactionU) XGof_ref___sa_sigaction() *llcppgCallback6 { - return (*llcppgCallback6)(unsafe.Pointer(p)) +func (p *X__SigactionU) XGof_ref___sa_sigaction() *llcppgCallback21 { + return (*llcppgCallback21)(unsafe.Pointer(p)) } //go:linkname NativeSignal C.signal -func NativeSignal(_llcppg_param1 c.Int, _llcppg_param2 func(_llcppg_param1 c.Int)) func(_llcppg_param1 c.Int) +func NativeSignal(_llcppg_param1 c.Int, _llcppg_param2 llcppgCallback18) func(_llcppg_param1 c.Int) type SigsetT = c.Uint + +const LLGoPackage = "link" + +//llgo:type C +type SignalHandler func(c.Int) + +func Signal(sig c.Int, handler SignalHandler) c.Int { + var action SigactionT + *action.X__SigactionU.XGof_ref___sa_handler() = handler + return Sigaction(sig, &action, nil) +} + +const LLGoFiles = "$LIBC_CC_FLAGS: _libc_darwin_arm64.c" diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go index 473cead3..db229de3 100644 --- a/c/signal/libc_linux_amd64.go +++ b/c/signal/libc_linux_amd64.go @@ -11,6 +11,76 @@ import ( "unsafe" ) +// Bits in `sa_flags'. +const ( + SA_NOCLDSTOP = 1 + // Don't create zombie on child death. + SA_NOCLDWAIT = 2 + // Invoke signal-catching function with + // three arguments instead of one. + SA_SIGINFO = 4 +) + +// Use signal stack by using `sa_restorer'. +const SA_ONSTACK = 134217728 + +const ( + // Restart syscall on signal return. + SA_RESTART = 268435456 + // Don't automatically block the signal when + // its handler is being executed. + SA_NODEFER = 1073741824 +) + +// Reset to SIG_DFL on entry to handler. +const SA_RESETHAND = 2147483648 + +// Historical no-op. +const SA_INTERRUPT = 536870912 + +// Some aliases for the SA_ constants. +const ( + SA_NOMASK = 1073741824 + SA_ONESHOT = 2147483648 + SA_STACK = 134217728 +) + +// Values for the HOW argument to `sigprocmask'. +const ( + SIG_BLOCK = 0 + // Unblock signals. + SIG_UNBLOCK = 1 + // Set the set of blocked signals. + SIG_SETMASK = 2 +) + +type SigactionT struct { + X__SigactionHandler _llcppg_anon_7 + SaMask SigsetT + SaFlags c.Int + SaRestorer llcppgCallback3 +} + +// Structure describing the action to be taken when a signal arrives. +// +// llgo:type C +type llcppgCallback3 = func() + +// llgo:type C +type llcppgCallback4 = func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer) + +type _llcppg_anon_7 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_7) XGof_ref_sa_handler() *X__SighandlerT { + return (*X__SighandlerT)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_7) XGof_ref_sa_sigaction() *llcppgCallback4 { + return (*llcppgCallback4)(unsafe.Pointer(p)) +} + type X_fpxreg struct { Significand [4]uint16 Exponent uint16 @@ -62,19 +132,19 @@ type Sigcontext struct { Trapno c.Ulong Oldmask c.Ulong Cr2 c.Ulong - _llcppg_anon_7 + _llcppg_anon_8 X__Reserved1 [8]c.Ulong } -type _llcppg_anon_7 struct { +type _llcppg_anon_8 struct { _xgo_union [1]uint64 } -func (p *_llcppg_anon_7) XGof_ref_fpstate() **X_fpstate { +func (p *_llcppg_anon_8) XGof_ref_fpstate() **X_fpstate { return (**X_fpstate)(unsafe.Pointer(p)) } -func (p *_llcppg_anon_7) XGof_ref___fpstate_word() *c.Ulong { +func (p *_llcppg_anon_8) XGof_ref___fpstate_word() *c.Ulong { return (*c.Ulong)(unsafe.Pointer(p)) } @@ -89,6 +159,86 @@ type SiginfoT struct { X_sifields _llcppg_anon_5 } +// Values for `si_code'. Positive values are reserved for kernel-generated +// signals. +const ( + SI_ASYNCNL = -60 + SI_TKILL = -6 + SI_SIGIO = -5 + SI_ASYNCIO = -4 + SI_MESGQ = -3 + SI_TIMER = -2 + SI_QUEUE = -1 + SI_USER = 0 + // Send by kernel. + SI_KERNEL = 128 +) + +// `si_code' values for SIGILL signal. +const ( + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + // Internal stack error. + ILL_BADSTK = 8 +) + +// `si_code' values for SIGFPE signal. +const ( + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + // Subscript out of range. + FPE_FLTSUB = 8 +) + +// `si_code' values for SIGSEGV signal. +const ( + SEGV_MAPERR = 1 + // Invalid permissions for mapped object. + SEGV_ACCERR = 2 +) + +// `si_code' values for SIGBUS signal. +const ( + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + BUS_MCEERR_AR = 4 + // Hardware memory error: action optional. + BUS_MCEERR_AO = 5 +) + +// `si_code' values for SIGCHLD signal. +const ( + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + // Stopped child has continued. + CLD_CONTINUED = 6 +) + +// `si_code' values for SIGPOLL signal. +const ( + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + // Device disconnected. + POLL_HUP = 6 +) + type Sigevent struct { SigevValue SigvalT SigevSigno c.Int @@ -96,6 +246,15 @@ type Sigevent struct { X_sigevUn _llcppg_anon_6 } +// `sigev_notify' values. +const ( + SIGEV_SIGNAL = 0 + SIGEV_NONE = 1 + SIGEV_THREAD = 2 + // Send signal to specific thread. + SIGEV_THREAD_ID = 4 +) + // Type for data associated with a signal. type SigvalT = Sigval @@ -104,7 +263,7 @@ type _llcppg_anon_5 struct { } // llgo:type C -type llcppgCallback2 = func(_llcppg_param1 SigvalT) +type llcppgCallback5 = func(_llcppg_param1 SigvalT) type _llcppg_anon_6 struct { _xgo_union [6]uint64 @@ -123,39 +282,39 @@ func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { } // kill(). -type _llcppg_anon_23 struct { +type _llcppg_anon_24 struct { SiPid c.Int SiUid c.Uint } -func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_23 { - return (*_llcppg_anon_23)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_24 { + return (*_llcppg_anon_24)(unsafe.Pointer(p)) } // POSIX.1b timers. -type _llcppg_anon_24 struct { +type _llcppg_anon_25 struct { SiTid c.Int SiOverrun c.Int SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_24 { - return (*_llcppg_anon_24)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_25 { + return (*_llcppg_anon_25)(unsafe.Pointer(p)) } // POSIX.1b signals. -type _llcppg_anon_25 struct { +type _llcppg_anon_26 struct { SiPid c.Int SiUid c.Uint SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_25 { - return (*_llcppg_anon_25)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_26 { + return (*_llcppg_anon_26)(unsafe.Pointer(p)) } // SIGCHLD. -type _llcppg_anon_26 struct { +type _llcppg_anon_27 struct { SiPid c.Int SiUid c.Uint SiStatus c.Int @@ -163,45 +322,45 @@ type _llcppg_anon_26 struct { SiStime c.Long } -func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_26 { - return (*_llcppg_anon_26)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_27 { + return (*_llcppg_anon_27)(unsafe.Pointer(p)) } // SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_27 struct { +type _llcppg_anon_28 struct { SiAddr unsafe.Pointer SiAddrLsb int16 - SiAddrBnd _llcppg_anon_28 + SiAddrBnd _llcppg_anon_29 } -type _llcppg_anon_28 struct { +type _llcppg_anon_29 struct { X_lower unsafe.Pointer X_upper unsafe.Pointer } -func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_27 { - return (*_llcppg_anon_27)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_28 { + return (*_llcppg_anon_28)(unsafe.Pointer(p)) } // SIGPOLL. -type _llcppg_anon_29 struct { +type _llcppg_anon_30 struct { SiBand c.Long SiFd c.Int } -func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_29 { - return (*_llcppg_anon_29)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_30 { + return (*_llcppg_anon_30)(unsafe.Pointer(p)) } // SIGSYS. -type _llcppg_anon_30 struct { +type _llcppg_anon_31 struct { X_callAddr unsafe.Pointer X_syscall c.Int X_arch c.Uint } -func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_30 { - return (*_llcppg_anon_30)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_31 { + return (*_llcppg_anon_31)(unsafe.Pointer(p)) } func (p *_llcppg_anon_6) XGof_ref__pad() *[12]c.Int { @@ -212,13 +371,96 @@ func (p *_llcppg_anon_6) XGof_ref__tid() *c.Int { return (*c.Int)(unsafe.Pointer(p)) } -type _llcppg_anon_31 struct { - X_function llcppgCallback2 +type _llcppg_anon_32 struct { + X_function llcppgCallback5 X_attribute c.Pointer } -func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_31 { - return (*_llcppg_anon_31)(unsafe.Pointer(p)) +func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_32 { + return (*_llcppg_anon_32)(unsafe.Pointer(p)) +} + +// Signals. +const ( + SIGHUP = 1 + // Interrupt (ANSI). + SIGINT = 2 + // Quit (POSIX). + SIGQUIT = 3 + // Illegal instruction (ANSI). + SIGILL = 4 + // Trace trap (POSIX). + SIGTRAP = 5 + // Abort (ANSI). + SIGABRT = 6 + // IOT trap (4.2 BSD). + SIGIOT = 6 + // BUS error (4.2 BSD). + SIGBUS = 7 + // Floating-point exception (ANSI). + SIGFPE = 8 + // Kill, unblockable (POSIX). + SIGKILL = 9 + // User-defined signal 1 (POSIX). + SIGUSR1 = 10 + // Segmentation violation (ANSI). + SIGSEGV = 11 + // User-defined signal 2 (POSIX). + SIGUSR2 = 12 + // Broken pipe (POSIX). + SIGPIPE = 13 + // Alarm clock (POSIX). + SIGALRM = 14 + // Termination (ANSI). + SIGTERM = 15 + // Stack fault. + SIGSTKFLT = 16 + // Child status has changed (POSIX). + SIGCHLD = 17 + // Continue (POSIX). + SIGCONT = 18 + // Stop, unblockable (POSIX). + SIGSTOP = 19 + // Keyboard stop (POSIX). + SIGTSTP = 20 + // Background read from tty (POSIX). + SIGTTIN = 21 + // Background write to tty (POSIX). + SIGTTOU = 22 + // Urgent condition on socket (4.2 BSD). + SIGURG = 23 + // CPU limit exceeded (4.2 BSD). + SIGXCPU = 24 + // File size limit exceeded (4.2 BSD). + SIGXFSZ = 25 + // Virtual alarm clock (4.2 BSD). + SIGVTALRM = 26 + // Profiling alarm clock (4.2 BSD). + SIGPROF = 27 + // Window size change (4.3 BSD, Sun). + SIGWINCH = 28 + // I/O now possible (4.2 BSD). + SIGIO = 29 + // Power failure restart (System V). + SIGPWR = 30 + // Bad system call. + SIGSYS = 31 + SIGUNUSED = 31 +) + +// llgo:link (*SigsetT).X__Sigismember C.__sigismember +func (self *SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*SigsetT).X__Sigaddset C.__sigaddset +func (self *SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*SigsetT).X__Sigdelset C.__sigdelset +func (self *SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { + return 0 } // Structure describing a signal stack (obsolete). @@ -241,9 +483,19 @@ const NSIG = 65 // llgo:type C type X__SighandlerT = func(_llcppg_param1 c.Int) +// The X/Open definition of `signal' specifies the SVID semantic. Use +// the additional function `sysv_signal' when X/Open compatibility is +// requested. +// +//go:linkname X__SysvSignal C.__sysv_signal +func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + //go:linkname NativeSignal C.signal func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT +//go:linkname NativeKill C.kill +func NativeKill(__pid c.Int, __sig c.Int) c.Int + // Send SIG to all processes in process group PGRP. // If PGRP is zero, send SIG to all processes in // the current process's process group. @@ -341,6 +593,11 @@ func (self *SigsetT) Sigsuspend() c.Int { return 0 } +// Get and/or set the action for signal SIG. +// +//go:linkname Sigaction C.sigaction +func Sigaction(__sig c.Int, __act *SigactionT, __oact *SigactionT) c.Int + // Put in SET all signals that are blocked and waiting to be delivered. // // llgo:link (*SigsetT).Sigpending C.sigpending @@ -417,6 +674,16 @@ func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { return 0 } +// Return number of available real-time signal with highest priority. +// +//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin +func X__LibcCurrentSigrtmin() c.Int + +// Return number of available real-time signal with lowest priority. +// +//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax +func X__LibcCurrentSigrtmax() c.Int + // Create new per-process timer using CLOCK_ID. // //go:linkname TimerCreate C.timer_create @@ -428,4 +695,15 @@ type X__SigsetT struct { X__Val [16]c.Ulong } +const LLGoPackage = "link" + +//llgo:type C +type SignalHandler func(c.Int) + +func Signal(sig c.Int, handler SignalHandler) c.Int { + var action SigactionT + *action.X__SigactionHandler.XGof_ref_sa_handler() = handler + return Sigaction(sig, &action, nil) +} + type SigeventT = Sigevent diff --git a/c/signal/libc_linux_arm64.go b/c/signal/libc_linux_arm64.go index 50e969bd..837ca72c 100644 --- a/c/signal/libc_linux_arm64.go +++ b/c/signal/libc_linux_arm64.go @@ -11,6 +11,76 @@ import ( "unsafe" ) +// Bits in `sa_flags'. +const ( + SA_NOCLDSTOP = 1 + // Don't create zombie on child death. + SA_NOCLDWAIT = 2 + // Invoke signal-catching function with + // three arguments instead of one. + SA_SIGINFO = 4 +) + +// Use signal stack by using `sa_restorer'. +const SA_ONSTACK = 134217728 + +const ( + // Restart syscall on signal return. + SA_RESTART = 268435456 + // Don't automatically block the signal when + // its handler is being executed. + SA_NODEFER = 1073741824 +) + +// Reset to SIG_DFL on entry to handler. +const SA_RESETHAND = 2147483648 + +// Historical no-op. +const SA_INTERRUPT = 536870912 + +// Some aliases for the SA_ constants. +const ( + SA_NOMASK = 1073741824 + SA_ONESHOT = 2147483648 + SA_STACK = 134217728 +) + +// Values for the HOW argument to `sigprocmask'. +const ( + SIG_BLOCK = 0 + // Unblock signals. + SIG_UNBLOCK = 1 + // Set the set of blocked signals. + SIG_SETMASK = 2 +) + +type SigactionT struct { + X__SigactionHandler _llcppg_anon_7 + SaMask SigsetT + SaFlags c.Int + SaRestorer llcppgCallback3 +} + +// Structure describing the action to be taken when a signal arrives. +// +// llgo:type C +type llcppgCallback3 = func() + +// llgo:type C +type llcppgCallback4 = func(_llcppg_param1 c.Int, _llcppg_param2 *SiginfoT, _llcppg_param3 unsafe.Pointer) + +type _llcppg_anon_7 struct { + _xgo_union [1]uint64 +} + +func (p *_llcppg_anon_7) XGof_ref_sa_handler() *X__SighandlerT { + return (*X__SighandlerT)(unsafe.Pointer(p)) +} + +func (p *_llcppg_anon_7) XGof_ref_sa_sigaction() *llcppgCallback4 { + return (*llcppgCallback4)(unsafe.Pointer(p)) +} + type Sigval struct { _xgo_union [1]uint64 } @@ -22,6 +92,86 @@ type SiginfoT struct { X_sifields _llcppg_anon_5 } +// Values for `si_code'. Positive values are reserved for kernel-generated +// signals. +const ( + SI_ASYNCNL = -60 + SI_TKILL = -6 + SI_SIGIO = -5 + SI_ASYNCIO = -4 + SI_MESGQ = -3 + SI_TIMER = -2 + SI_QUEUE = -1 + SI_USER = 0 + // Send by kernel. + SI_KERNEL = 128 +) + +// `si_code' values for SIGILL signal. +const ( + ILL_ILLOPC = 1 + ILL_ILLOPN = 2 + ILL_ILLADR = 3 + ILL_ILLTRP = 4 + ILL_PRVOPC = 5 + ILL_PRVREG = 6 + ILL_COPROC = 7 + // Internal stack error. + ILL_BADSTK = 8 +) + +// `si_code' values for SIGFPE signal. +const ( + FPE_INTDIV = 1 + FPE_INTOVF = 2 + FPE_FLTDIV = 3 + FPE_FLTOVF = 4 + FPE_FLTUND = 5 + FPE_FLTRES = 6 + FPE_FLTINV = 7 + // Subscript out of range. + FPE_FLTSUB = 8 +) + +// `si_code' values for SIGSEGV signal. +const ( + SEGV_MAPERR = 1 + // Invalid permissions for mapped object. + SEGV_ACCERR = 2 +) + +// `si_code' values for SIGBUS signal. +const ( + BUS_ADRALN = 1 + BUS_ADRERR = 2 + BUS_OBJERR = 3 + BUS_MCEERR_AR = 4 + // Hardware memory error: action optional. + BUS_MCEERR_AO = 5 +) + +// `si_code' values for SIGCHLD signal. +const ( + CLD_EXITED = 1 + CLD_KILLED = 2 + CLD_DUMPED = 3 + CLD_TRAPPED = 4 + CLD_STOPPED = 5 + // Stopped child has continued. + CLD_CONTINUED = 6 +) + +// `si_code' values for SIGPOLL signal. +const ( + POLL_IN = 1 + POLL_OUT = 2 + POLL_MSG = 3 + POLL_ERR = 4 + POLL_PRI = 5 + // Device disconnected. + POLL_HUP = 6 +) + type Sigevent struct { SigevValue SigvalT SigevSigno c.Int @@ -29,6 +179,15 @@ type Sigevent struct { X_sigevUn _llcppg_anon_6 } +// `sigev_notify' values. +const ( + SIGEV_SIGNAL = 0 + SIGEV_NONE = 1 + SIGEV_THREAD = 2 + // Send signal to specific thread. + SIGEV_THREAD_ID = 4 +) + // Type for data associated with a signal. type SigvalT = Sigval @@ -37,7 +196,7 @@ type _llcppg_anon_5 struct { } // llgo:type C -type llcppgCallback2 = func(_llcppg_param1 SigvalT) +type llcppgCallback5 = func(_llcppg_param1 SigvalT) type _llcppg_anon_6 struct { _xgo_union [6]uint64 @@ -56,39 +215,39 @@ func (p *_llcppg_anon_5) XGof_ref__pad() *[28]c.Int { } // kill(). -type _llcppg_anon_22 struct { +type _llcppg_anon_23 struct { SiPid c.Int SiUid c.Uint } -func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_22 { - return (*_llcppg_anon_22)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__kill() *_llcppg_anon_23 { + return (*_llcppg_anon_23)(unsafe.Pointer(p)) } // POSIX.1b timers. -type _llcppg_anon_23 struct { +type _llcppg_anon_24 struct { SiTid c.Int SiOverrun c.Int SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_23 { - return (*_llcppg_anon_23)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__timer() *_llcppg_anon_24 { + return (*_llcppg_anon_24)(unsafe.Pointer(p)) } // POSIX.1b signals. -type _llcppg_anon_24 struct { +type _llcppg_anon_25 struct { SiPid c.Int SiUid c.Uint SiSigval SigvalT } -func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_24 { - return (*_llcppg_anon_24)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__rt() *_llcppg_anon_25 { + return (*_llcppg_anon_25)(unsafe.Pointer(p)) } // SIGCHLD. -type _llcppg_anon_25 struct { +type _llcppg_anon_26 struct { SiPid c.Int SiUid c.Uint SiStatus c.Int @@ -96,39 +255,39 @@ type _llcppg_anon_25 struct { SiStime c.Long } -func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_25 { - return (*_llcppg_anon_25)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigchld() *_llcppg_anon_26 { + return (*_llcppg_anon_26)(unsafe.Pointer(p)) } // SIGILL, SIGFPE, SIGSEGV, SIGBUS. -type _llcppg_anon_26 struct { +type _llcppg_anon_27 struct { SiAddr unsafe.Pointer SiAddrLsb int16 } -func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_26 { - return (*_llcppg_anon_26)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigfault() *_llcppg_anon_27 { + return (*_llcppg_anon_27)(unsafe.Pointer(p)) } // SIGPOLL. -type _llcppg_anon_27 struct { +type _llcppg_anon_28 struct { SiBand c.Long SiFd c.Int } -func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_27 { - return (*_llcppg_anon_27)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigpoll() *_llcppg_anon_28 { + return (*_llcppg_anon_28)(unsafe.Pointer(p)) } // SIGSYS. -type _llcppg_anon_28 struct { +type _llcppg_anon_29 struct { X_callAddr unsafe.Pointer X_syscall c.Int X_arch c.Uint } -func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_28 { - return (*_llcppg_anon_28)(unsafe.Pointer(p)) +func (p *_llcppg_anon_5) XGof_ref__sigsys() *_llcppg_anon_29 { + return (*_llcppg_anon_29)(unsafe.Pointer(p)) } func (p *_llcppg_anon_6) XGof_ref__pad() *[12]c.Int { @@ -139,13 +298,96 @@ func (p *_llcppg_anon_6) XGof_ref__tid() *c.Int { return (*c.Int)(unsafe.Pointer(p)) } -type _llcppg_anon_29 struct { - X_function llcppgCallback2 +type _llcppg_anon_30 struct { + X_function llcppgCallback5 X_attribute c.Pointer } -func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_29 { - return (*_llcppg_anon_29)(unsafe.Pointer(p)) +func (p *_llcppg_anon_6) XGof_ref__sigev_thread() *_llcppg_anon_30 { + return (*_llcppg_anon_30)(unsafe.Pointer(p)) +} + +// Signals. +const ( + SIGHUP = 1 + // Interrupt (ANSI). + SIGINT = 2 + // Quit (POSIX). + SIGQUIT = 3 + // Illegal instruction (ANSI). + SIGILL = 4 + // Trace trap (POSIX). + SIGTRAP = 5 + // Abort (ANSI). + SIGABRT = 6 + // IOT trap (4.2 BSD). + SIGIOT = 6 + // BUS error (4.2 BSD). + SIGBUS = 7 + // Floating-point exception (ANSI). + SIGFPE = 8 + // Kill, unblockable (POSIX). + SIGKILL = 9 + // User-defined signal 1 (POSIX). + SIGUSR1 = 10 + // Segmentation violation (ANSI). + SIGSEGV = 11 + // User-defined signal 2 (POSIX). + SIGUSR2 = 12 + // Broken pipe (POSIX). + SIGPIPE = 13 + // Alarm clock (POSIX). + SIGALRM = 14 + // Termination (ANSI). + SIGTERM = 15 + // Stack fault. + SIGSTKFLT = 16 + // Child status has changed (POSIX). + SIGCHLD = 17 + // Continue (POSIX). + SIGCONT = 18 + // Stop, unblockable (POSIX). + SIGSTOP = 19 + // Keyboard stop (POSIX). + SIGTSTP = 20 + // Background read from tty (POSIX). + SIGTTIN = 21 + // Background write to tty (POSIX). + SIGTTOU = 22 + // Urgent condition on socket (4.2 BSD). + SIGURG = 23 + // CPU limit exceeded (4.2 BSD). + SIGXCPU = 24 + // File size limit exceeded (4.2 BSD). + SIGXFSZ = 25 + // Virtual alarm clock (4.2 BSD). + SIGVTALRM = 26 + // Profiling alarm clock (4.2 BSD). + SIGPROF = 27 + // Window size change (4.3 BSD, Sun). + SIGWINCH = 28 + // I/O now possible (4.2 BSD). + SIGIO = 29 + // Power failure restart (System V). + SIGPWR = 30 + // Bad system call. + SIGSYS = 31 + SIGUNUSED = 31 +) + +// llgo:link (*SigsetT).X__Sigismember C.__sigismember +func (self *SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*SigsetT).X__Sigaddset C.__sigaddset +func (self *SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { + return 0 +} + +// llgo:link (*SigsetT).X__Sigdelset C.__sigdelset +func (self *SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { + return 0 } // Structure describing a signal stack (obsolete). @@ -168,9 +410,19 @@ const NSIG = 65 // llgo:type C type X__SighandlerT = func(_llcppg_param1 c.Int) +// The X/Open definition of `signal' specifies the SVID semantic. Use +// the additional function `sysv_signal' when X/Open compatibility is +// requested. +// +//go:linkname X__SysvSignal C.__sysv_signal +func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT + //go:linkname NativeSignal C.signal func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT +//go:linkname NativeKill C.kill +func NativeKill(__pid c.Int, __sig c.Int) c.Int + // Send SIG to all processes in process group PGRP. // If PGRP is zero, send SIG to all processes in // the current process's process group. @@ -268,6 +520,11 @@ func (self *SigsetT) Sigsuspend() c.Int { return 0 } +// Get and/or set the action for signal SIG. +// +//go:linkname Sigaction C.sigaction +func Sigaction(__sig c.Int, __act *SigactionT, __oact *SigactionT) c.Int + // Put in SET all signals that are blocked and waiting to be delivered. // // llgo:link (*SigsetT).Sigpending C.sigpending @@ -337,6 +594,16 @@ func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { return 0 } +// Return number of available real-time signal with highest priority. +// +//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin +func X__LibcCurrentSigrtmin() c.Int + +// Return number of available real-time signal with lowest priority. +// +//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax +func X__LibcCurrentSigrtmax() c.Int + // Create new per-process timer using CLOCK_ID. // //go:linkname TimerCreate C.timer_create @@ -348,4 +615,15 @@ type X__SigsetT struct { X__Val [16]c.Ulong } +const LLGoPackage = "link" + +//llgo:type C +type SignalHandler func(c.Int) + +func Signal(sig c.Int, handler SignalHandler) c.Int { + var action SigactionT + *action.X__SigactionHandler.XGof_ref_sa_handler() = handler + return Sigaction(sig, &action, nil) +} + type SigeventT = Sigevent diff --git a/c/signal/native_darwin_arm64_llgo_test.go b/c/signal/native_darwin_arm64_llgo_test.go new file mode 100644 index 00000000..04c57b64 --- /dev/null +++ b/c/signal/native_darwin_arm64_llgo_test.go @@ -0,0 +1,95 @@ +//go:build llgo && darwin && arm64 && !ios + +package signal + +import ( + "testing" + "unsafe" + + "github.com/goplus/lib/c" +) + +const ( + nativeActionSize = 16 + nativeActionFlagsOffset = 12 + nativeSigsetSize = 4 + nativeSigsetAlign = 4 + nativeSiginfoSize = 104 + nativeUserSignal = 30 + nativeNoNotification = 0 +) + +func nativeEmptySet(set *SigsetT) c.Int { return Sigemptyset(set) } +func nativeFillSet(set *SigsetT) c.Int { return Sigfillset(set) } +func nativeAddSet(set *SigsetT, number c.Int) c.Int { return Sigaddset(set, number) } +func nativeDeleteSet(set *SigsetT, number c.Int) c.Int { return Sigdelset(set, number) } +func nativeSetMember(set *SigsetT, number c.Int) c.Int { return Sigismember(set, number) } + +func TestNativeSignalActionLayout(t *testing.T) { + var action SigactionT + checks := []struct { + name string + got, want uintptr + }{ + {"size", unsafe.Sizeof(action), nativeActionSize}, + {"alignment", unsafe.Alignof(action), 8}, + {"handler offset", unsafe.Offsetof(action.X__SigactionU), 0}, + {"handler width", unsafe.Sizeof(*action.X__SigactionU.XGof_ref___sa_handler()), 8}, + {"mask offset", unsafe.Offsetof(action.SaMask), 8}, + {"mask width", unsafe.Sizeof(action.SaMask), nativeSigsetSize}, + {"flags offset", unsafe.Offsetof(action.SaFlags), nativeActionFlagsOffset}, + } + for _, check := range checks { + if check.got != check.want { + t.Errorf("%s = %d, want %d", check.name, check.got, check.want) + } + } + if t.Failed() { + return + } + var query struct { + before [8]byte + action SigactionT + after [8]byte + } + for i := range query.before { + query.before[i] = 0xa5 + query.after[i] = 0xa5 + } + if result := Sigaction(nativeUserSignal, nil, &query.action); result != 0 { + t.Fatalf("sigaction query = %d", result) + } + for i := range query.before { + if query.before[i] != 0xa5 || query.after[i] != 0xa5 { + t.Fatalf("sigaction query overwrote a boundary guard at %d", i) + } + } +} + +func TestNativeSignalWrapper(t *testing.T) { + var original SigactionT + if result := Sigaction(nativeUserSignal, nil, &original); result != 0 { + t.Fatalf("read original action = %d", result) + } + defer func() { + if result := Sigaction(nativeUserSignal, &original, nil); result != 0 { + t.Errorf("restore original action = %d", result) + } + }() + handler := SignalHandler(func(c.Int) {}) + if result := Signal(nativeUserSignal, handler); result != 0 { + t.Fatalf("Signal = %d", result) + } + var actual SigactionT + if result := Sigaction(nativeUserSignal, nil, &actual); result != 0 { + t.Fatalf("read installed action = %d", result) + } + want := *(*unsafe.Pointer)(unsafe.Pointer(&handler)) + got := *(*unsafe.Pointer)(unsafe.Pointer(actual.X__SigactionU.XGof_ref___sa_handler())) + if got != want { + t.Fatalf("installed handler = %p, want %p", got, want) + } + if actual.SaMask != 0 || actual.SaFlags != 0 { + t.Fatalf("installed mask/flags = %d/%d, want 0/0", actual.SaMask, actual.SaFlags) + } +} diff --git a/c/signal/native_linux_llgo_test.go b/c/signal/native_linux_llgo_test.go new file mode 100644 index 00000000..3e83e2d4 --- /dev/null +++ b/c/signal/native_linux_llgo_test.go @@ -0,0 +1,144 @@ +//go:build llgo && linux && (amd64 || arm64) && !android + +package signal + +import ( + "testing" + "unsafe" + + "github.com/goplus/lib/c" + lltime "github.com/goplus/lib/c/time" +) + +const ( + nativeActionSize = 152 + nativeActionFlagsOffset = 136 + nativeSigsetSize = 128 + nativeSigsetAlign = 8 + nativeSiginfoSize = 128 + nativeUserSignal = 10 + nativeNoNotification = 1 +) + +func nativeEmptySet(set *SigsetT) c.Int { return set.Sigemptyset() } +func nativeFillSet(set *SigsetT) c.Int { return set.Sigfillset() } +func nativeAddSet(set *SigsetT, number c.Int) c.Int { return set.Sigaddset(number) } +func nativeDeleteSet(set *SigsetT, number c.Int) c.Int { return set.Sigdelset(number) } +func nativeSetMember(set *SigsetT, number c.Int) c.Int { return set.Sigismember(number) } + +func TestNativeSigeventLayout(t *testing.T) { + var event Sigevent + if unsafe.Sizeof(event) != 64 || unsafe.Alignof(event) != 8 { + t.Fatalf("sigevent = %d/%d, want 64/8", unsafe.Sizeof(event), unsafe.Alignof(event)) + } + thread := event.X_sigevUn.XGof_ref__sigev_thread() + offset := unsafe.Offsetof(event.X_sigevUn) + unsafe.Offsetof(thread.X_attribute) + if unsafe.Sizeof(*thread) != 16 || unsafe.Sizeof(thread.X_function) != 8 || offset != 24 { + t.Fatalf("sigevent thread layout: size=%d function=%d attribute offset=%d", unsafe.Sizeof(*thread), unsafe.Sizeof(thread.X_function), offset) + } + var marker uintptr + thread.X_attribute = c.Pointer(&marker) + if got := *(*c.Pointer)(unsafe.Add(unsafe.Pointer(&event), offset)); got != c.Pointer(&marker) { + t.Fatalf("attribute pointer = %p, want %p", got, &marker) + } +} + +func TestNativeSignalTimerLifecycle(t *testing.T) { + var event Sigevent + event.SigevNotify = SIGEV_NONE + var timer lltime.TimerT + if result := TimerCreate(lltime.CLOCK_MONOTONIC, &event, &timer); result != 0 { + t.Fatalf("timer_create = %d", result) + } + defer func() { + if result := timer.TimerDelete(); result != 0 { + t.Errorf("timer_delete = %d", result) + } + }() + state := lltime.Itimerspec{ItInterval: lltime.Timespec{Sec: 123, Nsec: 456}, ItValue: lltime.Timespec{Sec: 789, Nsec: 123}} + if result := timer.TimerGettime(&state); result != 0 { + t.Fatalf("timer_gettime = %d", result) + } + if state.ItInterval.Sec != 0 || state.ItInterval.Nsec != 0 || state.ItValue.Sec != 0 || state.ItValue.Nsec != 0 { + t.Fatalf("new timer is not disarmed: %+v", state) + } + disabled := lltime.Itimerspec{} + old := lltime.Itimerspec{ItValue: lltime.Timespec{Sec: 123, Nsec: 456}} + if result := timer.TimerSettime(0, &disabled, &old); result != 0 { + t.Fatalf("timer_settime(disarm) = %d", result) + } + if old.ItValue.Sec != 0 || old.ItValue.Nsec != 0 { + t.Fatalf("old timer value = %+v, want zero", old) + } +} + +func TestNativeSignalActionLayout(t *testing.T) { + var action SigactionT + checks := []struct { + name string + got, want uintptr + }{ + {"size", unsafe.Sizeof(action), nativeActionSize}, + {"alignment", unsafe.Alignof(action), 8}, + {"handler offset", unsafe.Offsetof(action.X__SigactionHandler), 0}, + {"handler width", unsafe.Sizeof(action.X__SigactionHandler), 8}, + {"mask offset", unsafe.Offsetof(action.SaMask), 8}, + {"mask width", unsafe.Sizeof(action.SaMask), nativeSigsetSize}, + {"flags offset", unsafe.Offsetof(action.SaFlags), nativeActionFlagsOffset}, + {"restorer offset", unsafe.Offsetof(action.SaRestorer), 144}, + {"restorer width", unsafe.Sizeof(action.SaRestorer), 8}, + } + for _, check := range checks { + if check.got != check.want { + t.Errorf("%s = %d, want %d", check.name, check.got, check.want) + } + } + if t.Failed() { + return // The current smaller layout must not be passed to a C output parameter. + } + var query struct { + before [8]byte + action SigactionT + after [8]byte + } + for i := range query.before { + query.before[i] = 0xa5 + query.after[i] = 0xa5 + } + if result := Sigaction(nativeUserSignal, nil, &query.action); result != 0 { + t.Fatalf("sigaction query = %d", result) + } + for i := range query.before { + if query.before[i] != 0xa5 || query.after[i] != 0xa5 { + t.Fatalf("sigaction query overwrote a boundary guard at %d", i) + } + } +} + +func TestNativeSignalWrapper(t *testing.T) { + var original SigactionT + if result := Sigaction(nativeUserSignal, nil, &original); result != 0 { + t.Fatalf("read original signal action = %d", result) + } + defer func() { + if result := Sigaction(nativeUserSignal, &original, nil); result != 0 { + t.Errorf("restore original signal action = %d", result) + } + }() + handler := SignalHandler(func(c.Int) {}) + if result := Signal(nativeUserSignal, handler); result != 0 { + t.Fatalf("Signal = %d", result) + } + var actual SigactionT + if result := Sigaction(nativeUserSignal, nil, &actual); result != 0 { + t.Fatalf("read installed signal action = %d", result) + } + got := *(*unsafe.Pointer)(unsafe.Pointer(actual.X__SigactionHandler.XGof_ref_sa_handler())) + want := *(*unsafe.Pointer)(unsafe.Pointer(&handler)) + if got != want { + t.Fatalf("handler = %p, want %p", got, want) + } + if member := actual.SaMask.Sigismember(nativeUserSignal); member != 0 { + t.Fatalf("signal mask membership = %d, want 0", member) + } +} diff --git a/c/signal/native_llgo_test.go b/c/signal/native_llgo_test.go new file mode 100644 index 00000000..a932dfae --- /dev/null +++ b/c/signal/native_llgo_test.go @@ -0,0 +1,76 @@ +//go:build llgo && ((darwin && arm64 && !ios) || (linux && (amd64 || arm64) && !android)) + +// Copyright (c) 2026 The XGo Authors. Licensed under the Apache License 2.0. + +package signal + +import ( + "testing" + "unsafe" + + "github.com/goplus/lib/c" +) + +func TestNativeSignalDataLayouts(t *testing.T) { + var set SigsetT + var info SiginfoT + var value Sigval + if unsafe.Sizeof(set) != nativeSigsetSize || unsafe.Alignof(set) != nativeSigsetAlign { + t.Fatalf("sigset_t = %d/%d, want %d/%d", unsafe.Sizeof(set), unsafe.Alignof(set), nativeSigsetSize, nativeSigsetAlign) + } + if unsafe.Sizeof(info) != nativeSiginfoSize || unsafe.Alignof(info) != 8 { + t.Fatalf("siginfo_t = %d/%d, want %d/8", unsafe.Sizeof(info), unsafe.Alignof(info), nativeSiginfoSize) + } + if unsafe.Offsetof(info.SiSigno) != 0 || unsafe.Offsetof(info.SiErrno) != 4 || unsafe.Offsetof(info.SiCode) != 8 { + t.Fatalf("siginfo_t header offsets = %d/%d/%d", unsafe.Offsetof(info.SiSigno), unsafe.Offsetof(info.SiErrno), unsafe.Offsetof(info.SiCode)) + } + if unsafe.Sizeof(value) != 8 || unsafe.Alignof(value) != 8 { + t.Fatalf("sigval = %d/%d, want 8/8", unsafe.Sizeof(value), unsafe.Alignof(value)) + } + *value.XGof_ref_sival_int() = -7 + if got := *(*c.Int)(unsafe.Pointer(&value)); got != -7 { + t.Fatalf("sigval integer storage = %d, want -7", got) + } + var marker uintptr + *value.XGof_ref_sival_ptr() = unsafe.Pointer(&marker) + if got := *(*unsafe.Pointer)(unsafe.Pointer(&value)); got != unsafe.Pointer(&marker) { + t.Fatalf("sigval pointer storage = %p, want %p", got, &marker) + } +} + +func TestNativeSignalConstants(t *testing.T) { + if SIGUSR1 != nativeUserSignal { + t.Fatalf("SIGUSR1 = %d, want %d", SIGUSR1, nativeUserSignal) + } + if SIGEV_NONE != nativeNoNotification { + t.Fatalf("SIGEV_NONE = %d, want %d", SIGEV_NONE, nativeNoNotification) + } +} + +func TestNativeSignalSetOperations(t *testing.T) { + var set SigsetT + if result := nativeEmptySet(&set); result != 0 { + t.Fatalf("sigemptyset = %d", result) + } + if got := nativeSetMember(&set, nativeUserSignal); got != 0 { + t.Fatalf("empty membership = %d, want 0", got) + } + if result := nativeAddSet(&set, nativeUserSignal); result != 0 { + t.Fatalf("sigaddset = %d", result) + } + if got := nativeSetMember(&set, nativeUserSignal); got != 1 { + t.Fatalf("added membership = %d, want 1", got) + } + if result := nativeDeleteSet(&set, nativeUserSignal); result != 0 { + t.Fatalf("sigdelset = %d", result) + } + if got := nativeSetMember(&set, nativeUserSignal); got != 0 { + t.Fatalf("deleted membership = %d, want 0", got) + } + if result := nativeFillSet(&set); result != 0 { + t.Fatalf("sigfillset = %d", result) + } + if got := nativeSetMember(&set, nativeUserSignal); got != 1 { + t.Fatalf("filled membership = %d, want 1", got) + } +} diff --git a/c/signal/signal.go b/c/signal/signal.go index 250241e0..fe8d12fe 100644 --- a/c/signal/signal.go +++ b/c/signal/signal.go @@ -1,3 +1,5 @@ +//go:build !((darwin && arm64 && !ios) || (linux && (amd64 || arm64) && !android)) + package signal import ( From 77695e10184628e3459571f0116dd806bca6f5a0 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 20 Oct 2026 15:18:11 +0800 Subject: [PATCH 7/8] Replace redundant Native bindings while preserving public contracts --- c/signal/libc_darwin_arm64.go | 4 ++-- c/signal/libc_linux_amd64.go | 4 ++-- c/signal/libc_linux_arm64.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/c/signal/libc_darwin_arm64.go b/c/signal/libc_darwin_arm64.go index 91420a85..e12ad912 100644 --- a/c/signal/libc_darwin_arm64.go +++ b/c/signal/libc_darwin_arm64.go @@ -28,8 +28,8 @@ func Raise(_llcppg_param1 c.Int) c.Int //go:linkname BsdSignal C.bsd_signal func BsdSignal(_llcppg_param1 c.Int, _llcppg_param2 llcppgCallback17) func(_llcppg_param1 c.Int) -//go:linkname NativeKill C.kill -func NativeKill(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int +//go:linkname Kill C.kill +func Kill(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int //go:linkname Killpg C.killpg func Killpg(_llcppg_param1 c.Int, _llcppg_param2 c.Int) c.Int diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go index db229de3..97cb4b4f 100644 --- a/c/signal/libc_linux_amd64.go +++ b/c/signal/libc_linux_amd64.go @@ -493,8 +493,8 @@ func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT //go:linkname NativeSignal C.signal func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT -//go:linkname NativeKill C.kill -func NativeKill(__pid c.Int, __sig c.Int) c.Int +//go:linkname Kill C.kill +func Kill(__pid c.Int, __sig c.Int) c.Int // Send SIG to all processes in process group PGRP. // If PGRP is zero, send SIG to all processes in diff --git a/c/signal/libc_linux_arm64.go b/c/signal/libc_linux_arm64.go index 837ca72c..f5cba607 100644 --- a/c/signal/libc_linux_arm64.go +++ b/c/signal/libc_linux_arm64.go @@ -420,8 +420,8 @@ func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT //go:linkname NativeSignal C.signal func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT -//go:linkname NativeKill C.kill -func NativeKill(__pid c.Int, __sig c.Int) c.Int +//go:linkname Kill C.kill +func Kill(__pid c.Int, __sig c.Int) c.Int // Send SIG to all processes in process group PGRP. // If PGRP is zero, send SIG to all processes in From 45790aefb15479c445554a7e0b9a86a3f8f9bcd8 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Thu, 22 Oct 2026 13:47:15 +0800 Subject: [PATCH 8/8] Cover native signal symbols and exercise handler delivery --- c/signal/README.md | 25 + c/signal/_libc_darwin_arm64.c | 56 -- c/signal/libc_darwin_arm64.go | 7 - c/signal/libc_linux_amd64.go | 35 - c/signal/libc_linux_arm64.go | 35 - c/signal/native_darwin_arm64_llgo_test.go | 14 +- c/signal/native_linux_llgo_test.go | 14 +- c/signal/native_llgo_test.go | 32 +- c/signal/symbols_darwin_arm64_llgo_test.go | 545 +++++++++++++ c/signal/symbols_linux_amd64_llgo_test.go | 849 +++++++++++++++++++++ c/signal/symbols_linux_arm64_llgo_test.go | 692 +++++++++++++++++ 11 files changed, 2143 insertions(+), 161 deletions(-) create mode 100644 c/signal/README.md delete mode 100644 c/signal/_libc_darwin_arm64.c create mode 100644 c/signal/symbols_darwin_arm64_llgo_test.go create mode 100644 c/signal/symbols_linux_amd64_llgo_test.go create mode 100644 c/signal/symbols_linux_arm64_llgo_test.go diff --git a/c/signal/README.md b/c/signal/README.md new file mode 100644 index 00000000..c262c316 --- /dev/null +++ b/c/signal/README.md @@ -0,0 +1,25 @@ +# Native signal bindings + +The macOS arm64 and Linux amd64/arm64 bindings are classified from a unified libc generation using unmodified llcppg commit `da227ff4aaf07718d7ec0dea62e23dab03ac57fb`. The header baselines are macOS 14.0 and Bootlin stable 2017.05 with glibc 2.24. Other targets keep the existing implementation. + +| Target | Build constraint | Direct Go dependencies | +| --- | --- | --- | +| macOS arm64 | `darwin && arm64 && !ios` | `c`, `unsafe` | +| Linux amd64 | `linux && amd64 && !android` | `c`, `c/time`, `unsafe` | +| Linux arm64 | `linux && arm64 && !android` | `c`, `c/time`, `unsafe` | + +`Signal(sig c.Int, handler SignalHandler) c.Int` retains its existing contract: it installs the handler through `Sigaction` and returns that call's status. Its implementation uses the generated `SigactionT` and union accessors. `NativeSignal` binds C `signal` and returns the previous handler, so it remains a distinct API rather than replacing `Signal`. The generated `Kill` declaration keeps its established public name. No existing public function signature changes in this update. + +Native signal records and their field accessors retain their original sizes, alignments and offsets. The previously approved opaque `c.Pointer` for Linux sigevent's optional pthread attributes avoids a package dependency cycle. Necessary implementation types and generated anonymous union storage remain present; their names do not introduce private C runtime entry points. + +Private C implementation entry points are excluded: macOS `__sigbits` and its generated C wrapper, and Linux `__sigismember`, `__sigaddset`, `__sigdelset`, `__sysv_signal`, `__libc_current_sigrtmin` and `__libc_current_sigrtmax`. The private macOS wrapper source and its `LLGoFiles` metadata are removed. Linux also excludes `SysSiglist` with explicit approval: the old headers declare `sys_siglist`, but current glibc retains only versioned compatibility exports and cannot resolve an ordinary reference. macOS keeps `SysSiglist` and `SysSigname`. Legacy public C functions retain their native behavior; Linux amd64 `Sigreturn` is a glibc stub and has link/prototype coverage. + +Each retained C function has a live symbol-address check and a prototype check against facts independently compiled from the original headers. Types, fields, constants, native globals and every generated union accessor are checked as well. The source inventory test rejects missing public symbol coverage. Go storage records whose sole field is `_xgo_union` are classified as C unions; their original size and alignment checks still apply. + +Linux `TimerCreate` uses a compile-time function-signature assignment and per-slot ABI checks. Its link-address and complete timer lifecycle tests remain enabled. This avoids reflecting the full signature, which currently requires missing `c/time` method wrappers while that dependency uses `LLGoPackage="decl"`. The dependency and compiler are unchanged; this test accommodation does not repair that reflection limitation. + +Runtime tests exercise empty/fill/add/delete/member signal-set operations, guarded `sigaction` output, handler installation and restoration, real delivery with `Raise`, and `Kill(self, 0)`. Linux additionally exercises sigevent layout and a non-notifying timer's create/query/disarm/delete lifecycle. Handler callbacks only store the received signal number and do not allocate. These tests run with GC and `nogc` on all three targets. + +Validation composes the root `c` files from PR #45 at `99ddac92c7335a53a1c996174e1753bcd72c5050` and `c/time` from PR #51 at `855f0c294499b32a0d3380d1d608592255155e89`. Merge those prerequisites first; this PR changes only `c/signal`. Tests use LLGo v1.0.8 (`c171abfa130108bc6451e01fcf15a8a3474eb0a7`), with LLVM 22 and LLD 23.1.3 for native macOS linking. The header baselines do not establish a minimum supported executable runtime version. + +`llcppg.cfg` contains only the prepared-header directory for local dependency discovery; it is not a standalone generation recipe. Actual generation uses the unified libc inputs followed by classification. `llcppg.pub` describes the classified public C type mappings. Inputs, scripts and header caches remain local and are not included in this PR. diff --git a/c/signal/_libc_darwin_arm64.c b/c/signal/_libc_darwin_arm64.c deleted file mode 100644 index 8a019b33..00000000 --- a/c/signal/_libc_darwin_arm64.c +++ /dev/null @@ -1,56 +0,0 @@ -// 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___sigbits(int __signo) { - return __sigbits(__signo); -} diff --git a/c/signal/libc_darwin_arm64.go b/c/signal/libc_darwin_arm64.go index e12ad912..9af90a76 100644 --- a/c/signal/libc_darwin_arm64.go +++ b/c/signal/libc_darwin_arm64.go @@ -99,11 +99,6 @@ func Sigsetmask(_llcppg_param1 c.Int) c.Int //go:linkname Sigvec C.sigvec func Sigvec(_llcppg_param1 c.Int, _llcppg_param2 *SigvecT, _llcppg_param3 *SigvecT) c.Int -// List definitions after function declarations, or Reiser cpp gets upset. -// -//go:linkname X__Sigbits C._llcppg___sigbits -func X__Sigbits(__signo c.Int) c.Int - type X__DarwinSigaltstack struct { SsSp unsafe.Pointer SsSize c.Ulong @@ -467,5 +462,3 @@ func Signal(sig c.Int, handler SignalHandler) c.Int { *action.X__SigactionU.XGof_ref___sa_handler() = handler return Sigaction(sig, &action, nil) } - -const LLGoFiles = "$LIBC_CC_FLAGS: _libc_darwin_arm64.c" diff --git a/c/signal/libc_linux_amd64.go b/c/signal/libc_linux_amd64.go index 97cb4b4f..ae674b93 100644 --- a/c/signal/libc_linux_amd64.go +++ b/c/signal/libc_linux_amd64.go @@ -448,21 +448,6 @@ const ( SIGUNUSED = 31 ) -// llgo:link (*SigsetT).X__Sigismember C.__sigismember -func (self *SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*SigsetT).X__Sigaddset C.__sigaddset -func (self *SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*SigsetT).X__Sigdelset C.__sigdelset -func (self *SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { - return 0 -} - // Structure describing a signal stack (obsolete). type SigstackT struct { SsSp unsafe.Pointer @@ -483,13 +468,6 @@ const NSIG = 65 // llgo:type C type X__SighandlerT = func(_llcppg_param1 c.Int) -// The X/Open definition of `signal' specifies the SVID semantic. Use -// the additional function `sysv_signal' when X/Open compatibility is -// requested. -// -//go:linkname X__SysvSignal C.__sysv_signal -func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT - //go:linkname NativeSignal C.signal func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT @@ -642,9 +620,6 @@ func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *lltime.Timespec) //go:linkname Sigqueue C.sigqueue func Sigqueue(__pid c.Int, __sig c.Int, __val Sigval) c.Int -//go:linkname SysSiglist C.sys_siglist -var SysSiglist [65]*c.Char - // Restore the state saved in SCP. // // llgo:link (*Sigcontext).Sigreturn C.sigreturn @@ -674,16 +649,6 @@ func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { return 0 } -// Return number of available real-time signal with highest priority. -// -//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin -func X__LibcCurrentSigrtmin() c.Int - -// Return number of available real-time signal with lowest priority. -// -//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax -func X__LibcCurrentSigrtmax() c.Int - // Create new per-process timer using CLOCK_ID. // //go:linkname TimerCreate C.timer_create diff --git a/c/signal/libc_linux_arm64.go b/c/signal/libc_linux_arm64.go index f5cba607..70c23330 100644 --- a/c/signal/libc_linux_arm64.go +++ b/c/signal/libc_linux_arm64.go @@ -375,21 +375,6 @@ const ( SIGUNUSED = 31 ) -// llgo:link (*SigsetT).X__Sigismember C.__sigismember -func (self *SigsetT) X__Sigismember(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*SigsetT).X__Sigaddset C.__sigaddset -func (self *SigsetT) X__Sigaddset(_llcppg_param2 c.Int) c.Int { - return 0 -} - -// llgo:link (*SigsetT).X__Sigdelset C.__sigdelset -func (self *SigsetT) X__Sigdelset(_llcppg_param2 c.Int) c.Int { - return 0 -} - // Structure describing a signal stack (obsolete). type SigstackT struct { SsSp unsafe.Pointer @@ -410,13 +395,6 @@ const NSIG = 65 // llgo:type C type X__SighandlerT = func(_llcppg_param1 c.Int) -// The X/Open definition of `signal' specifies the SVID semantic. Use -// the additional function `sysv_signal' when X/Open compatibility is -// requested. -// -//go:linkname X__SysvSignal C.__sysv_signal -func X__SysvSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT - //go:linkname NativeSignal C.signal func NativeSignal(__sig c.Int, __handler X__SighandlerT) X__SighandlerT @@ -569,9 +547,6 @@ func (self *SigsetT) Sigtimedwait(__info *SiginfoT, __timeout *lltime.Timespec) //go:linkname Sigqueue C.sigqueue func Sigqueue(__pid c.Int, __sig c.Int, __val Sigval) c.Int -//go:linkname SysSiglist C.sys_siglist -var SysSiglist [65]*uint8 - // If INTERRUPT is nonzero, make signal SIG interrupt system calls // (causing them to fail with EINTR); if INTERRUPT is zero, make system // calls be restarted after signal SIG. @@ -594,16 +569,6 @@ func (self *Sigaltstack) Sigaltstack(__oss *Sigaltstack) c.Int { return 0 } -// Return number of available real-time signal with highest priority. -// -//go:linkname X__LibcCurrentSigrtmin C.__libc_current_sigrtmin -func X__LibcCurrentSigrtmin() c.Int - -// Return number of available real-time signal with lowest priority. -// -//go:linkname X__LibcCurrentSigrtmax C.__libc_current_sigrtmax -func X__LibcCurrentSigrtmax() c.Int - // Create new per-process timer using CLOCK_ID. // //go:linkname TimerCreate C.timer_create diff --git a/c/signal/native_darwin_arm64_llgo_test.go b/c/signal/native_darwin_arm64_llgo_test.go index 04c57b64..43d3b599 100644 --- a/c/signal/native_darwin_arm64_llgo_test.go +++ b/c/signal/native_darwin_arm64_llgo_test.go @@ -3,6 +3,7 @@ package signal import ( + "os" "testing" "unsafe" @@ -76,7 +77,8 @@ func TestNativeSignalWrapper(t *testing.T) { t.Errorf("restore original action = %d", result) } }() - handler := SignalHandler(func(c.Int) {}) + deliveredSignal = 0 + handler := SignalHandler(func(number c.Int) { deliveredSignal = number }) if result := Signal(nativeUserSignal, handler); result != 0 { t.Fatalf("Signal = %d", result) } @@ -92,4 +94,14 @@ func TestNativeSignalWrapper(t *testing.T) { if actual.SaMask != 0 || actual.SaFlags != 0 { t.Fatalf("installed mask/flags = %d/%d, want 0/0", actual.SaMask, actual.SaFlags) } + if result := Raise(nativeUserSignal); result != 0 { + t.Fatalf("raise = %d", result) + } + if deliveredSignal != nativeUserSignal { + t.Fatalf("delivered signal = %d, want %d", deliveredSignal, nativeUserSignal) + } + if result := Kill(c.Int(os.Getpid()), 0); result != 0 { + t.Fatalf("kill(self, 0) = %d", result) + } + } diff --git a/c/signal/native_linux_llgo_test.go b/c/signal/native_linux_llgo_test.go index 3e83e2d4..b364fa5c 100644 --- a/c/signal/native_linux_llgo_test.go +++ b/c/signal/native_linux_llgo_test.go @@ -3,6 +3,7 @@ package signal import ( + "os" "testing" "unsafe" @@ -125,7 +126,8 @@ func TestNativeSignalWrapper(t *testing.T) { t.Errorf("restore original signal action = %d", result) } }() - handler := SignalHandler(func(c.Int) {}) + deliveredSignal = 0 + handler := SignalHandler(func(number c.Int) { deliveredSignal = number }) if result := Signal(nativeUserSignal, handler); result != 0 { t.Fatalf("Signal = %d", result) } @@ -141,4 +143,14 @@ func TestNativeSignalWrapper(t *testing.T) { if member := actual.SaMask.Sigismember(nativeUserSignal); member != 0 { t.Fatalf("signal mask membership = %d, want 0", member) } + if result := Raise(nativeUserSignal); result != 0 { + t.Fatalf("raise = %d", result) + } + if deliveredSignal != nativeUserSignal { + t.Fatalf("delivered signal = %d, want %d", deliveredSignal, nativeUserSignal) + } + if result := Kill(c.Int(os.Getpid()), 0); result != 0 { + t.Fatalf("kill(self, 0) = %d", result) + } + } diff --git a/c/signal/native_llgo_test.go b/c/signal/native_llgo_test.go index a932dfae..69ec5229 100644 --- a/c/signal/native_llgo_test.go +++ b/c/signal/native_llgo_test.go @@ -6,36 +6,16 @@ package signal import ( "testing" - "unsafe" "github.com/goplus/lib/c" ) -func TestNativeSignalDataLayouts(t *testing.T) { - var set SigsetT - var info SiginfoT - var value Sigval - if unsafe.Sizeof(set) != nativeSigsetSize || unsafe.Alignof(set) != nativeSigsetAlign { - t.Fatalf("sigset_t = %d/%d, want %d/%d", unsafe.Sizeof(set), unsafe.Alignof(set), nativeSigsetSize, nativeSigsetAlign) - } - if unsafe.Sizeof(info) != nativeSiginfoSize || unsafe.Alignof(info) != 8 { - t.Fatalf("siginfo_t = %d/%d, want %d/8", unsafe.Sizeof(info), unsafe.Alignof(info), nativeSiginfoSize) - } - if unsafe.Offsetof(info.SiSigno) != 0 || unsafe.Offsetof(info.SiErrno) != 4 || unsafe.Offsetof(info.SiCode) != 8 { - t.Fatalf("siginfo_t header offsets = %d/%d/%d", unsafe.Offsetof(info.SiSigno), unsafe.Offsetof(info.SiErrno), unsafe.Offsetof(info.SiCode)) - } - if unsafe.Sizeof(value) != 8 || unsafe.Alignof(value) != 8 { - t.Fatalf("sigval = %d/%d, want 8/8", unsafe.Sizeof(value), unsafe.Alignof(value)) - } - *value.XGof_ref_sival_int() = -7 - if got := *(*c.Int)(unsafe.Pointer(&value)); got != -7 { - t.Fatalf("sigval integer storage = %d, want -7", got) - } - var marker uintptr - *value.XGof_ref_sival_ptr() = unsafe.Pointer(&marker) - if got := *(*unsafe.Pointer)(unsafe.Pointer(&value)); got != unsafe.Pointer(&marker) { - t.Fatalf("sigval pointer storage = %p, want %p", got, &marker) - } +// The C signal callback only stores the signal number; it does not allocate. +var deliveredSignal c.Int + +type signalABISlot struct { + size, align uintptr + class int } func TestNativeSignalConstants(t *testing.T) { diff --git a/c/signal/symbols_darwin_arm64_llgo_test.go b/c/signal/symbols_darwin_arm64_llgo_test.go new file mode 100644 index 00000000..73de1302 --- /dev/null +++ b/c/signal/symbols_darwin_arm64_llgo_test.go @@ -0,0 +1,545 @@ +//go:build llgo && darwin && arm64 && !ios + +package signal + +import ( + "github.com/goplus/lib/c" + "go/ast" + "go/parser" + "go/token" + "reflect" + "runtime" + "strings" + "testing" + "unsafe" +) + +func TestNativeSignalDataLayouts(t *testing.T) { + // Expected values are compiled from original macOS 14 SDK headers. + var signalFunctionSymbols = []struct { + name string + address unsafe.Pointer + }{ + {"Raise", c.Func(Raise)}, + {"BsdSignal", c.Func(BsdSignal)}, + {"Kill", c.Func(Kill)}, + {"Killpg", c.Func(Killpg)}, + {"Sigaction", c.Func(Sigaction)}, + {"Sigaddset", c.Func(Sigaddset)}, + {"*StackT.Sigaltstack", c.Func((*StackT).Sigaltstack)}, + {"Sigdelset", c.Func(Sigdelset)}, + {"Sigemptyset", c.Func(Sigemptyset)}, + {"Sigfillset", c.Func(Sigfillset)}, + {"Sighold", c.Func(Sighold)}, + {"Sigignore", c.Func(Sigignore)}, + {"Siginterrupt", c.Func(Siginterrupt)}, + {"Sigismember", c.Func(Sigismember)}, + {"Sigpause", c.Func(Sigpause)}, + {"Sigpending", c.Func(Sigpending)}, + {"Sigprocmask", c.Func(Sigprocmask)}, + {"Sigrelse", c.Func(Sigrelse)}, + {"Sigset", c.Func(Sigset)}, + {"Sigsuspend", c.Func(Sigsuspend)}, + {"Sigwait", c.Func(Sigwait)}, + {"Psignal", c.Func(Psignal)}, + {"Sigblock", c.Func(Sigblock)}, + {"Sigsetmask", c.Func(Sigsetmask)}, + {"Sigvec", c.Func(Sigvec)}, + {"NativeSignal", c.Func(NativeSignal)}, + } + var signalFunctionPrototypes = []struct { + name string + signature reflect.Type + inputs []signalABISlot + output *signalABISlot + variadic bool + }{ + {"Raise", reflect.TypeOf(Raise), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"BsdSignal", reflect.TypeOf(BsdSignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + {"Kill", reflect.TypeOf(Kill), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Killpg", reflect.TypeOf(Killpg), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigaction", reflect.TypeOf(Sigaction), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigaddset", reflect.TypeOf(Sigaddset), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"*StackT.Sigaltstack", reflect.TypeOf((*StackT).Sigaltstack), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigdelset", reflect.TypeOf(Sigdelset), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigemptyset", reflect.TypeOf(Sigemptyset), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigfillset", reflect.TypeOf(Sigfillset), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sighold", reflect.TypeOf(Sighold), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigignore", reflect.TypeOf(Sigignore), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Siginterrupt", reflect.TypeOf(Siginterrupt), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigismember", reflect.TypeOf(Sigismember), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigpause", reflect.TypeOf(Sigpause), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigpending", reflect.TypeOf(Sigpending), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigprocmask", reflect.TypeOf(Sigprocmask), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigrelse", reflect.TypeOf(Sigrelse), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigset", reflect.TypeOf(Sigset), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + {"Sigsuspend", reflect.TypeOf(Sigsuspend), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigwait", reflect.TypeOf(Sigwait), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Psignal", reflect.TypeOf(Psignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, nil, false}, + {"Sigblock", reflect.TypeOf(Sigblock), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigsetmask", reflect.TypeOf(Sigsetmask), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigvec", reflect.TypeOf(Sigvec), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"NativeSignal", reflect.TypeOf(NativeSignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + } + var signalStaticFunctionPrototypes = []struct { + name string + slots []struct { + label string + goType reflect.Type + got, want signalABISlot + } + }{} + var signalTypeLayouts = []struct { + symbol, property string + got, want uintptr + }{ + {"X__DarwinSigaltstack", "size", unsafe.Sizeof(*new(X__DarwinSigaltstack)), 24}, + {"X__DarwinSigaltstack", "alignment", unsafe.Alignof(*new(X__DarwinSigaltstack)), 8}, + {"X__DarwinSigaltstack", "SsSp offset", unsafe.Offsetof((*new(X__DarwinSigaltstack)).SsSp), 0}, + {"X__DarwinSigaltstack", "SsSp size", unsafe.Sizeof((*new(X__DarwinSigaltstack)).SsSp), 8}, + {"X__DarwinSigaltstack", "SsSp alignment", unsafe.Alignof((*new(X__DarwinSigaltstack)).SsSp), 8}, + {"X__DarwinSigaltstack", "SsSize offset", unsafe.Offsetof((*new(X__DarwinSigaltstack)).SsSize), 8}, + {"X__DarwinSigaltstack", "SsSize size", unsafe.Sizeof((*new(X__DarwinSigaltstack)).SsSize), 8}, + {"X__DarwinSigaltstack", "SsSize alignment", unsafe.Alignof((*new(X__DarwinSigaltstack)).SsSize), 8}, + {"X__DarwinSigaltstack", "SsFlags offset", unsafe.Offsetof((*new(X__DarwinSigaltstack)).SsFlags), 16}, + {"X__DarwinSigaltstack", "SsFlags size", unsafe.Sizeof((*new(X__DarwinSigaltstack)).SsFlags), 4}, + {"X__DarwinSigaltstack", "SsFlags alignment", unsafe.Alignof((*new(X__DarwinSigaltstack)).SsFlags), 4}, + {"StackT", "size", unsafe.Sizeof(*new(StackT)), 24}, + {"StackT", "alignment", unsafe.Alignof(*new(StackT)), 8}, + {"Sigval", "size", unsafe.Sizeof(*new(Sigval)), 8}, + {"Sigval", "alignment", unsafe.Alignof(*new(Sigval)), 8}, + {"X__Siginfo", "size", unsafe.Sizeof(*new(X__Siginfo)), 104}, + {"X__Siginfo", "alignment", unsafe.Alignof(*new(X__Siginfo)), 8}, + {"X__Siginfo", "SiSigno offset", unsafe.Offsetof((*new(X__Siginfo)).SiSigno), 0}, + {"X__Siginfo", "SiSigno size", unsafe.Sizeof((*new(X__Siginfo)).SiSigno), 4}, + {"X__Siginfo", "SiSigno alignment", unsafe.Alignof((*new(X__Siginfo)).SiSigno), 4}, + {"X__Siginfo", "SiErrno offset", unsafe.Offsetof((*new(X__Siginfo)).SiErrno), 4}, + {"X__Siginfo", "SiErrno size", unsafe.Sizeof((*new(X__Siginfo)).SiErrno), 4}, + {"X__Siginfo", "SiErrno alignment", unsafe.Alignof((*new(X__Siginfo)).SiErrno), 4}, + {"X__Siginfo", "SiCode offset", unsafe.Offsetof((*new(X__Siginfo)).SiCode), 8}, + {"X__Siginfo", "SiCode size", unsafe.Sizeof((*new(X__Siginfo)).SiCode), 4}, + {"X__Siginfo", "SiCode alignment", unsafe.Alignof((*new(X__Siginfo)).SiCode), 4}, + {"X__Siginfo", "SiPid offset", unsafe.Offsetof((*new(X__Siginfo)).SiPid), 12}, + {"X__Siginfo", "SiPid size", unsafe.Sizeof((*new(X__Siginfo)).SiPid), 4}, + {"X__Siginfo", "SiPid alignment", unsafe.Alignof((*new(X__Siginfo)).SiPid), 4}, + {"X__Siginfo", "SiUid offset", unsafe.Offsetof((*new(X__Siginfo)).SiUid), 16}, + {"X__Siginfo", "SiUid size", unsafe.Sizeof((*new(X__Siginfo)).SiUid), 4}, + {"X__Siginfo", "SiUid alignment", unsafe.Alignof((*new(X__Siginfo)).SiUid), 4}, + {"X__Siginfo", "SiStatus offset", unsafe.Offsetof((*new(X__Siginfo)).SiStatus), 20}, + {"X__Siginfo", "SiStatus size", unsafe.Sizeof((*new(X__Siginfo)).SiStatus), 4}, + {"X__Siginfo", "SiStatus alignment", unsafe.Alignof((*new(X__Siginfo)).SiStatus), 4}, + {"X__Siginfo", "SiAddr offset", unsafe.Offsetof((*new(X__Siginfo)).SiAddr), 24}, + {"X__Siginfo", "SiAddr size", unsafe.Sizeof((*new(X__Siginfo)).SiAddr), 8}, + {"X__Siginfo", "SiAddr alignment", unsafe.Alignof((*new(X__Siginfo)).SiAddr), 8}, + {"X__Siginfo", "SiValue offset", unsafe.Offsetof((*new(X__Siginfo)).SiValue), 32}, + {"X__Siginfo", "SiValue size", unsafe.Sizeof((*new(X__Siginfo)).SiValue), 8}, + {"X__Siginfo", "SiValue alignment", unsafe.Alignof((*new(X__Siginfo)).SiValue), 8}, + {"X__Siginfo", "SiBand offset", unsafe.Offsetof((*new(X__Siginfo)).SiBand), 40}, + {"X__Siginfo", "SiBand size", unsafe.Sizeof((*new(X__Siginfo)).SiBand), 8}, + {"X__Siginfo", "SiBand alignment", unsafe.Alignof((*new(X__Siginfo)).SiBand), 8}, + {"X__Siginfo", "X__Pad offset", unsafe.Offsetof((*new(X__Siginfo)).X__Pad), 48}, + {"X__Siginfo", "X__Pad size", unsafe.Sizeof((*new(X__Siginfo)).X__Pad), 56}, + {"X__Siginfo", "X__Pad alignment", unsafe.Alignof((*new(X__Siginfo)).X__Pad), 8}, + {"X__SigactionU", "size", unsafe.Sizeof(*new(X__SigactionU)), 8}, + {"X__SigactionU", "alignment", unsafe.Alignof(*new(X__SigactionU)), 8}, + {"SigactionT", "size", unsafe.Sizeof(*new(SigactionT)), 16}, + {"SigactionT", "alignment", unsafe.Alignof(*new(SigactionT)), 8}, + {"SigactionT", "X__SigactionU offset", unsafe.Offsetof((*new(SigactionT)).X__SigactionU), 0}, + {"SigactionT", "X__SigactionU size", unsafe.Sizeof((*new(SigactionT)).X__SigactionU), 8}, + {"SigactionT", "X__SigactionU alignment", unsafe.Alignof((*new(SigactionT)).X__SigactionU), 8}, + {"SigactionT", "SaMask offset", unsafe.Offsetof((*new(SigactionT)).SaMask), 8}, + {"SigactionT", "SaMask size", unsafe.Sizeof((*new(SigactionT)).SaMask), 4}, + {"SigactionT", "SaMask alignment", unsafe.Alignof((*new(SigactionT)).SaMask), 4}, + {"SigactionT", "SaFlags offset", unsafe.Offsetof((*new(SigactionT)).SaFlags), 12}, + {"SigactionT", "SaFlags size", unsafe.Sizeof((*new(SigactionT)).SaFlags), 4}, + {"SigactionT", "SaFlags alignment", unsafe.Alignof((*new(SigactionT)).SaFlags), 4}, + {"SigvecT", "size", unsafe.Sizeof(*new(SigvecT)), 16}, + {"SigvecT", "alignment", unsafe.Alignof(*new(SigvecT)), 8}, + {"SigvecT", "SvHandler offset", unsafe.Offsetof((*new(SigvecT)).SvHandler), 0}, + {"SigvecT", "SvHandler size", unsafe.Sizeof((*new(SigvecT)).SvHandler), 8}, + {"SigvecT", "SvHandler alignment", unsafe.Alignof((*new(SigvecT)).SvHandler), 8}, + {"SigvecT", "SvMask offset", unsafe.Offsetof((*new(SigvecT)).SvMask), 8}, + {"SigvecT", "SvMask size", unsafe.Sizeof((*new(SigvecT)).SvMask), 4}, + {"SigvecT", "SvMask alignment", unsafe.Alignof((*new(SigvecT)).SvMask), 4}, + {"SigvecT", "SvFlags offset", unsafe.Offsetof((*new(SigvecT)).SvFlags), 12}, + {"SigvecT", "SvFlags size", unsafe.Sizeof((*new(SigvecT)).SvFlags), 4}, + {"SigvecT", "SvFlags alignment", unsafe.Alignof((*new(SigvecT)).SvFlags), 4}, + {"SiginfoT", "size", unsafe.Sizeof(*new(SiginfoT)), 104}, + {"SiginfoT", "alignment", unsafe.Alignof(*new(SiginfoT)), 8}, + {"SigsetT", "size", unsafe.Sizeof(*new(SigsetT)), 4}, + {"SigsetT", "alignment", unsafe.Alignof(*new(SigsetT)), 4}, + {"SignalHandler", "size", unsafe.Sizeof(*new(SignalHandler)), 8}, + {"SignalHandler", "alignment", unsafe.Alignof(*new(SignalHandler)), 8}, + {"SysSigname", "global size", unsafe.Sizeof(SysSigname), 256}, + {"SysSigname", "global alignment", unsafe.Alignof(SysSigname), 8}, + {"SysSiglist", "global size", unsafe.Sizeof(SysSiglist), 256}, + {"SysSiglist", "global alignment", unsafe.Alignof(SysSiglist), 8}, + } + var signalIntegerConstants = []struct { + name string + got, want int64 + }{ + {"NSIG", int64(NSIG), 32}, + {"SIGHUP", int64(SIGHUP), 1}, + {"SIGINT", int64(SIGINT), 2}, + {"SIGQUIT", int64(SIGQUIT), 3}, + {"SIGILL", int64(SIGILL), 4}, + {"SIGTRAP", int64(SIGTRAP), 5}, + {"SIGABRT", int64(SIGABRT), 6}, + {"SIGIOT", int64(SIGIOT), 6}, + {"SIGEMT", int64(SIGEMT), 7}, + {"SIGFPE", int64(SIGFPE), 8}, + {"SIGKILL", int64(SIGKILL), 9}, + {"SIGBUS", int64(SIGBUS), 10}, + {"SIGSEGV", int64(SIGSEGV), 11}, + {"SIGSYS", int64(SIGSYS), 12}, + {"SIGPIPE", int64(SIGPIPE), 13}, + {"SIGALRM", int64(SIGALRM), 14}, + {"SIGTERM", int64(SIGTERM), 15}, + {"SIGURG", int64(SIGURG), 16}, + {"SIGSTOP", int64(SIGSTOP), 17}, + {"SIGTSTP", int64(SIGTSTP), 18}, + {"SIGCONT", int64(SIGCONT), 19}, + {"SIGCHLD", int64(SIGCHLD), 20}, + {"SIGTTIN", int64(SIGTTIN), 21}, + {"SIGTTOU", int64(SIGTTOU), 22}, + {"SIGIO", int64(SIGIO), 23}, + {"SIGXCPU", int64(SIGXCPU), 24}, + {"SIGXFSZ", int64(SIGXFSZ), 25}, + {"SIGVTALRM", int64(SIGVTALRM), 26}, + {"SIGPROF", int64(SIGPROF), 27}, + {"SIGWINCH", int64(SIGWINCH), 28}, + {"SIGINFO", int64(SIGINFO), 29}, + {"SIGUSR1", int64(SIGUSR1), 30}, + {"SIGUSR2", int64(SIGUSR2), 31}, + {"SIGEV_NONE", int64(SIGEV_NONE), 0}, + {"SIGEV_SIGNAL", int64(SIGEV_SIGNAL), 1}, + {"SIGEV_THREAD", int64(SIGEV_THREAD), 3}, + {"ILL_NOOP", int64(ILL_NOOP), 0}, + {"ILL_ILLOPC", int64(ILL_ILLOPC), 1}, + {"ILL_ILLTRP", int64(ILL_ILLTRP), 2}, + {"ILL_PRVOPC", int64(ILL_PRVOPC), 3}, + {"ILL_ILLOPN", int64(ILL_ILLOPN), 4}, + {"ILL_ILLADR", int64(ILL_ILLADR), 5}, + {"ILL_PRVREG", int64(ILL_PRVREG), 6}, + {"ILL_COPROC", int64(ILL_COPROC), 7}, + {"ILL_BADSTK", int64(ILL_BADSTK), 8}, + {"FPE_NOOP", int64(FPE_NOOP), 0}, + {"FPE_FLTDIV", int64(FPE_FLTDIV), 1}, + {"FPE_FLTOVF", int64(FPE_FLTOVF), 2}, + {"FPE_FLTUND", int64(FPE_FLTUND), 3}, + {"FPE_FLTRES", int64(FPE_FLTRES), 4}, + {"FPE_FLTINV", int64(FPE_FLTINV), 5}, + {"FPE_FLTSUB", int64(FPE_FLTSUB), 6}, + {"FPE_INTDIV", int64(FPE_INTDIV), 7}, + {"FPE_INTOVF", int64(FPE_INTOVF), 8}, + {"SEGV_NOOP", int64(SEGV_NOOP), 0}, + {"SEGV_MAPERR", int64(SEGV_MAPERR), 1}, + {"SEGV_ACCERR", int64(SEGV_ACCERR), 2}, + {"BUS_NOOP", int64(BUS_NOOP), 0}, + {"BUS_ADRALN", int64(BUS_ADRALN), 1}, + {"BUS_ADRERR", int64(BUS_ADRERR), 2}, + {"BUS_OBJERR", int64(BUS_OBJERR), 3}, + {"TRAP_BRKPT", int64(TRAP_BRKPT), 1}, + {"TRAP_TRACE", int64(TRAP_TRACE), 2}, + {"CLD_NOOP", int64(CLD_NOOP), 0}, + {"CLD_EXITED", int64(CLD_EXITED), 1}, + {"CLD_KILLED", int64(CLD_KILLED), 2}, + {"CLD_DUMPED", int64(CLD_DUMPED), 3}, + {"CLD_TRAPPED", int64(CLD_TRAPPED), 4}, + {"CLD_STOPPED", int64(CLD_STOPPED), 5}, + {"CLD_CONTINUED", int64(CLD_CONTINUED), 6}, + {"POLL_IN", int64(POLL_IN), 1}, + {"POLL_OUT", int64(POLL_OUT), 2}, + {"POLL_MSG", int64(POLL_MSG), 3}, + {"POLL_ERR", int64(POLL_ERR), 4}, + {"POLL_PRI", int64(POLL_PRI), 5}, + {"POLL_HUP", int64(POLL_HUP), 6}, + {"SA_ONSTACK", int64(SA_ONSTACK), 1}, + {"SA_RESTART", int64(SA_RESTART), 2}, + {"SA_RESETHAND", int64(SA_RESETHAND), 4}, + {"SA_NOCLDSTOP", int64(SA_NOCLDSTOP), 8}, + {"SA_NODEFER", int64(SA_NODEFER), 16}, + {"SA_NOCLDWAIT", int64(SA_NOCLDWAIT), 32}, + {"SA_SIGINFO", int64(SA_SIGINFO), 64}, + {"SA_USERTRAMP", int64(SA_USERTRAMP), 256}, + {"SA_64REGSET", int64(SA_64REGSET), 512}, + {"SA_USERSPACE_MASK", int64(SA_USERSPACE_MASK), 127}, + {"SIG_BLOCK", int64(SIG_BLOCK), 1}, + {"SIG_UNBLOCK", int64(SIG_UNBLOCK), 2}, + {"SIG_SETMASK", int64(SIG_SETMASK), 3}, + {"SI_USER", int64(SI_USER), 65537}, + {"SI_QUEUE", int64(SI_QUEUE), 65538}, + {"SI_TIMER", int64(SI_TIMER), 65539}, + {"SI_ASYNCIO", int64(SI_ASYNCIO), 65540}, + {"SI_MESGQ", int64(SI_MESGQ), 65541}, + {"SS_ONSTACK", int64(SS_ONSTACK), 1}, + {"SS_DISABLE", int64(SS_DISABLE), 4}, + {"MINSIGSTKSZ", int64(MINSIGSTKSZ), 32768}, + {"SIGSTKSZ", int64(SIGSTKSZ), 131072}, + {"SV_ONSTACK", int64(SV_ONSTACK), 1}, + {"SV_INTERRUPT", int64(SV_INTERRUPT), 2}, + {"SV_RESETHAND", int64(SV_RESETHAND), 4}, + {"SV_NODEFER", int64(SV_NODEFER), 16}, + {"SV_NOCLDSTOP", int64(SV_NOCLDSTOP), 8}, + {"SV_SIGINFO", int64(SV_SIGINFO), 64}, + } + var signalVariableSymbols = []struct { + name string + address unsafe.Pointer + }{ + {"SysSigname", unsafe.Pointer(&SysSigname)}, + {"SysSiglist", unsafe.Pointer(&SysSiglist)}, + } + var signalAccessorChecks = []struct { + name string + check func() (uintptr, uintptr, uintptr) + offset, size, align uintptr + }{ + {"*Sigval.XGof_ref_sival_int", func() (uintptr, uintptr, uintptr) { + var value Sigval + view := value.XGof_ref_sival_int() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 4, 4}, + {"*Sigval.XGof_ref_sival_ptr", func() (uintptr, uintptr, uintptr) { + var value Sigval + view := value.XGof_ref_sival_ptr() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*X__SigactionU.XGof_ref___sa_handler", func() (uintptr, uintptr, uintptr) { + var value X__SigactionU + view := value.XGof_ref___sa_handler() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*X__SigactionU.XGof_ref___sa_sigaction", func() (uintptr, uintptr, uintptr) { + var value X__SigactionU + view := value.XGof_ref___sa_sigaction() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + } + + t.Run("function symbols", func(t *testing.T) { + for _, symbol := range signalFunctionSymbols { + t.Run(symbol.name, func(t *testing.T) { + if symbol.address == nil { + t.Fatal("C function address is nil") + } + t.Logf("C function address: %p", symbol.address) + }) + } + }) + t.Run("native prototypes", func(t *testing.T) { + check := func(name string, got reflect.Type, want signalABISlot) { + if got.Size() != want.size || uintptr(got.Align()) != want.align { + t.Errorf("%s size/alignment = %d/%d, C = %d/%d", name, got.Size(), got.Align(), want.size, want.align) + } + class := 0 + switch got.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + class = 1 + case reflect.Ptr, reflect.UnsafePointer, reflect.Func: + class = 5 + case reflect.Float32, reflect.Float64: + class = 8 + case reflect.Struct: + class = 12 + if got.NumField() == 1 && got.Field(0).Name == "_xgo_union" { + class = 13 + } + } + if class != want.class { + t.Errorf("%s ABI class = %d (%v), C = %d", name, class, got.Kind(), want.class) + } + } + for _, tc := range signalFunctionPrototypes { + t.Run(tc.name, func(t *testing.T) { + inputs := len(tc.inputs) + if tc.variadic { + inputs++ + } + if tc.signature.Kind() != reflect.Func || tc.signature.NumIn() != inputs || tc.signature.IsVariadic() != tc.variadic { + t.Fatalf("Go signature = %v, C fixed parameters = %d, variadic = %v", tc.signature, len(tc.inputs), tc.variadic) + } + for i, slot := range tc.inputs { + check(tc.name+" parameter", tc.signature.In(i), slot) + } + outputs := 0 + if tc.output != nil { + outputs = 1 + } + if tc.signature.NumOut() != outputs { + t.Fatalf("Go result count = %d, C = %d", tc.signature.NumOut(), outputs) + } + if tc.output != nil { + check(tc.name+" result", tc.signature.Out(0), *tc.output) + } + }) + } + for _, tc := range signalStaticFunctionPrototypes { + t.Run(tc.name, func(t *testing.T) { + for _, slot := range tc.slots { + if slot.goType != nil { + check(tc.name+" "+slot.label, slot.goType, slot.want) + } else if slot.got != slot.want { + t.Errorf("%s %s ABI = %+v, C = %+v", tc.name, slot.label, slot.got, slot.want) + } + } + }) + } + + }) + t.Run("native types and globals", func(t *testing.T) { + for _, tc := range signalTypeLayouts { + t.Run(tc.symbol+"/"+tc.property, func(t *testing.T) { + if tc.got != tc.want { + t.Fatalf("Go layout = %d, C headers = %d", tc.got, tc.want) + } + }) + } + for _, symbol := range signalVariableSymbols { + if symbol.address == nil { + t.Errorf("%s C variable address is nil", symbol.name) + } + t.Logf("%s C variable address: %p", symbol.name, symbol.address) + } + }) + t.Run("native constants", func(t *testing.T) { + for _, tc := range signalIntegerConstants { + t.Run(tc.name, func(t *testing.T) { + if tc.got != tc.want { + t.Fatalf("Go constant = %d, C headers = %d", tc.got, tc.want) + } + }) + } + }) + t.Run("union accessors", func(t *testing.T) { + for _, tc := range signalAccessorChecks { + t.Run(tc.name, func(t *testing.T) { + offset, size, align := tc.check() + if offset != tc.offset || size != tc.size || align != tc.align { + t.Fatalf("Go field offset/size/alignment = %d/%d/%d, C = %d/%d/%d", offset, size, align, tc.offset, tc.size, tc.align) + } + }) + } + }) + t.Run("symbol inventory", func(t *testing.T) { + functions, prototypes, types, constants, variables := map[string]bool{}, map[string]bool{}, map[string]bool{}, map[string]bool{}, map[string]bool{} + for _, tc := range signalFunctionPrototypes { + prototypes[tc.name] = true + } + for _, tc := range signalStaticFunctionPrototypes { + prototypes[tc.name] = true + } + + for _, symbol := range signalFunctionSymbols { + functions[symbol.name] = true + if !prototypes[symbol.name] { + t.Errorf("%s has no native prototype test", symbol.name) + } + } + for _, tc := range signalAccessorChecks { + functions[tc.name] = true + } + for _, tc := range signalTypeLayouts { + types[tc.symbol] = true + } + for _, tc := range signalIntegerConstants { + constants[tc.name] = true + } + for _, symbol := range signalVariableSymbols { + variables[symbol.name] = true + } + constants["LLGoPackage"] = true + functions["Signal"] = true + if LLGoPackage != "link" { + t.Errorf("LLGoPackage = %q, want link", LLGoPackage) + } + files := []string{"libc_" + runtime.GOOS + "_" + runtime.GOARCH + ".go"} + + for _, filename := range files { + source, err := parser.ParseFile(token.NewFileSet(), filename, nil, parser.ParseComments) + if err != nil { + t.Fatal(err) + } + for _, declaration := range source.Decls { + switch decl := declaration.(type) { + case *ast.FuncDecl: + name := decl.Name.Name + if !ast.IsExported(name) { + continue + } + if decl.Recv != nil { + receiver, prefix := decl.Recv.List[0].Type, "" + if pointer, ok := receiver.(*ast.StarExpr); ok { + receiver, prefix = pointer.X, "*" + } + name = prefix + receiver.(*ast.Ident).Name + "." + name + } + if !functions[name] { + t.Errorf("%s: function %s has no test", filename, name) + } + if strings.HasPrefix(decl.Name.Name, "Native") && decl.Name.Name != "NativeSignal" { + t.Errorf("%s retains duplicate %s", filename, name) + } + if decl.Doc != nil { + for _, comment := range decl.Doc.List { + for _, private := range []string{"C._llcppg_", "C.__sig", "C.__sysv_signal", "C.__libc_current_sigrt"} { + if strings.Contains(comment.Text, private) { + t.Errorf("%s still exposes private C entry point %s", filename, private) + } + } + } + } + case *ast.GenDecl: + for _, specification := range decl.Specs { + switch spec := specification.(type) { + case *ast.TypeSpec: + if ast.IsExported(spec.Name.Name) && !types[spec.Name.Name] { + t.Errorf("%s: type %s has no ABI test", filename, spec.Name.Name) + } + case *ast.ValueSpec: + for _, name := range spec.Names { + if !ast.IsExported(name.Name) { + continue + } + if decl.Tok == token.CONST && !constants[name.Name] { + t.Errorf("%s: constant %s has no test", filename, name.Name) + } + if decl.Tok == token.VAR && !variables[name.Name] { + t.Errorf("%s: variable %s has no test", filename, name.Name) + } + } + } + } + } + } + } + t.Logf("coverage: %d C functions, %d Go union accessors, %d types/global layouts, %d constants, %d globals", len(signalFunctionSymbols), len(signalAccessorChecks), len(signalTypeLayouts), len(constants), len(signalVariableSymbols)) + }) + + var set SigsetT + var info SiginfoT + var value Sigval + if unsafe.Sizeof(set) != nativeSigsetSize || unsafe.Alignof(set) != nativeSigsetAlign { + t.Fatalf("sigset_t = %d/%d, want %d/%d", unsafe.Sizeof(set), unsafe.Alignof(set), nativeSigsetSize, nativeSigsetAlign) + } + if unsafe.Sizeof(info) != nativeSiginfoSize || unsafe.Alignof(info) != 8 { + t.Fatalf("siginfo_t = %d/%d, want %d/8", unsafe.Sizeof(info), unsafe.Alignof(info), nativeSiginfoSize) + } + if unsafe.Offsetof(info.SiSigno) != 0 || unsafe.Offsetof(info.SiErrno) != 4 || unsafe.Offsetof(info.SiCode) != 8 { + t.Fatalf("siginfo_t header offsets = %d/%d/%d", unsafe.Offsetof(info.SiSigno), unsafe.Offsetof(info.SiErrno), unsafe.Offsetof(info.SiCode)) + } + if unsafe.Sizeof(value) != 8 || unsafe.Alignof(value) != 8 { + t.Fatalf("sigval = %d/%d, want 8/8", unsafe.Sizeof(value), unsafe.Alignof(value)) + } + *value.XGof_ref_sival_int() = -7 + if got := *(*c.Int)(unsafe.Pointer(&value)); got != -7 { + t.Fatalf("sigval integer storage = %d, want -7", got) + } + var marker uintptr + *value.XGof_ref_sival_ptr() = unsafe.Pointer(&marker) + if got := *(*unsafe.Pointer)(unsafe.Pointer(&value)); got != unsafe.Pointer(&marker) { + t.Fatalf("sigval pointer storage = %p, want %p", got, &marker) + } + +} diff --git a/c/signal/symbols_linux_amd64_llgo_test.go b/c/signal/symbols_linux_amd64_llgo_test.go new file mode 100644 index 00000000..be639b40 --- /dev/null +++ b/c/signal/symbols_linux_amd64_llgo_test.go @@ -0,0 +1,849 @@ +//go:build llgo && linux && amd64 && !android + +package signal + +import ( + "github.com/goplus/lib/c" + lltime "github.com/goplus/lib/c/time" + "go/ast" + "go/parser" + "go/token" + "reflect" + "runtime" + "strings" + "testing" + "unsafe" +) + +func TestNativeSignalDataLayouts(t *testing.T) { + // Expected values are compiled from original Bootlin glibc 2.24 headers. + var signalFunctionSymbols = []struct { + name string + address unsafe.Pointer + }{ + {"NativeSignal", c.Func(NativeSignal)}, + {"Kill", c.Func(Kill)}, + {"Killpg", c.Func(Killpg)}, + {"Raise", c.Func(Raise)}, + {"Ssignal", c.Func(Ssignal)}, + {"Gsignal", c.Func(Gsignal)}, + {"Psignal", c.Func(Psignal)}, + {"*SiginfoT.Psiginfo", c.Func((*SiginfoT).Psiginfo)}, + {"Sigblock", c.Func(Sigblock)}, + {"Sigsetmask", c.Func(Sigsetmask)}, + {"Siggetmask", c.Func(Siggetmask)}, + {"*SigsetT.Sigemptyset", c.Func((*SigsetT).Sigemptyset)}, + {"*SigsetT.Sigfillset", c.Func((*SigsetT).Sigfillset)}, + {"*SigsetT.Sigaddset", c.Func((*SigsetT).Sigaddset)}, + {"*SigsetT.Sigdelset", c.Func((*SigsetT).Sigdelset)}, + {"*SigsetT.Sigismember", c.Func((*SigsetT).Sigismember)}, + {"Sigprocmask", c.Func(Sigprocmask)}, + {"*SigsetT.Sigsuspend", c.Func((*SigsetT).Sigsuspend)}, + {"Sigaction", c.Func(Sigaction)}, + {"*SigsetT.Sigpending", c.Func((*SigsetT).Sigpending)}, + {"*SigsetT.Sigwait", c.Func((*SigsetT).Sigwait)}, + {"*SigsetT.Sigwaitinfo", c.Func((*SigsetT).Sigwaitinfo)}, + {"*SigsetT.Sigtimedwait", c.Func((*SigsetT).Sigtimedwait)}, + {"Sigqueue", c.Func(Sigqueue)}, + {"*Sigcontext.Sigreturn", c.Func((*Sigcontext).Sigreturn)}, + {"Siginterrupt", c.Func(Siginterrupt)}, + {"Sigstack", c.Func(Sigstack)}, + {"*Sigaltstack.Sigaltstack", c.Func((*Sigaltstack).Sigaltstack)}, + {"TimerCreate", c.Func(TimerCreate)}, + } + var signalFunctionPrototypes = []struct { + name string + signature reflect.Type + inputs []signalABISlot + output *signalABISlot + variadic bool + }{ + {"NativeSignal", reflect.TypeOf(NativeSignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + {"Kill", reflect.TypeOf(Kill), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Killpg", reflect.TypeOf(Killpg), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Raise", reflect.TypeOf(Raise), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Ssignal", reflect.TypeOf(Ssignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + {"Gsignal", reflect.TypeOf(Gsignal), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Psignal", reflect.TypeOf(Psignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, nil, false}, + {"*SiginfoT.Psiginfo", reflect.TypeOf((*SiginfoT).Psiginfo), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, nil, false}, + {"Sigblock", reflect.TypeOf(Sigblock), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigsetmask", reflect.TypeOf(Sigsetmask), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Siggetmask", reflect.TypeOf(Siggetmask), []signalABISlot{}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigemptyset", reflect.TypeOf((*SigsetT).Sigemptyset), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigfillset", reflect.TypeOf((*SigsetT).Sigfillset), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigaddset", reflect.TypeOf((*SigsetT).Sigaddset), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigdelset", reflect.TypeOf((*SigsetT).Sigdelset), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigismember", reflect.TypeOf((*SigsetT).Sigismember), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigprocmask", reflect.TypeOf(Sigprocmask), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigsuspend", reflect.TypeOf((*SigsetT).Sigsuspend), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigaction", reflect.TypeOf(Sigaction), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigpending", reflect.TypeOf((*SigsetT).Sigpending), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigwait", reflect.TypeOf((*SigsetT).Sigwait), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigwaitinfo", reflect.TypeOf((*SigsetT).Sigwaitinfo), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigtimedwait", reflect.TypeOf((*SigsetT).Sigtimedwait), []signalABISlot{{8, 8, 5}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigqueue", reflect.TypeOf(Sigqueue), []signalABISlot{{4, 4, 1}, {4, 4, 1}, {8, 8, 13}}, &signalABISlot{4, 4, 1}, false}, + {"*Sigcontext.Sigreturn", reflect.TypeOf((*Sigcontext).Sigreturn), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Siginterrupt", reflect.TypeOf(Siginterrupt), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigstack", reflect.TypeOf(Sigstack), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*Sigaltstack.Sigaltstack", reflect.TypeOf((*Sigaltstack).Sigaltstack), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + } + // The static assignment checks arity, result, and exact Go parameter types. + // Reflecting the full signature would require missing c/time decl-mode method wrappers. + var _ func(lltime.ClockidT, *Sigevent, *lltime.TimerT) c.Int = TimerCreate + var signalStaticFunctionPrototypes = []struct { + name string + slots []struct { + label string + goType reflect.Type + got, want signalABISlot + } + }{ + {"TimerCreate", []struct { + label string + goType reflect.Type + got, want signalABISlot + }{ + {"clock", reflect.TypeOf(lltime.ClockidT(0)), signalABISlot{}, signalABISlot{4, 4, 1}}, + {"event", nil, signalABISlot{unsafe.Sizeof((*Sigevent)(nil)), unsafe.Alignof((*Sigevent)(nil)), 5}, signalABISlot{8, 8, 5}}, + {"timer", nil, signalABISlot{unsafe.Sizeof((*lltime.TimerT)(nil)), unsafe.Alignof((*lltime.TimerT)(nil)), 5}, signalABISlot{8, 8, 5}}, + {"result", reflect.TypeOf(c.Int(0)), signalABISlot{}, signalABISlot{4, 4, 1}}, + }}, + } + var signalTypeLayouts = []struct { + symbol, property string + got, want uintptr + }{ + {"SigactionT", "size", unsafe.Sizeof(*new(SigactionT)), 152}, + {"SigactionT", "alignment", unsafe.Alignof(*new(SigactionT)), 8}, + {"SigactionT", "X__SigactionHandler offset", unsafe.Offsetof((*new(SigactionT)).X__SigactionHandler), 0}, + {"SigactionT", "X__SigactionHandler size", unsafe.Sizeof((*new(SigactionT)).X__SigactionHandler), 8}, + {"SigactionT", "X__SigactionHandler alignment", unsafe.Alignof((*new(SigactionT)).X__SigactionHandler), 8}, + {"SigactionT", "SaMask offset", unsafe.Offsetof((*new(SigactionT)).SaMask), 8}, + {"SigactionT", "SaMask size", unsafe.Sizeof((*new(SigactionT)).SaMask), 128}, + {"SigactionT", "SaMask alignment", unsafe.Alignof((*new(SigactionT)).SaMask), 8}, + {"SigactionT", "SaFlags offset", unsafe.Offsetof((*new(SigactionT)).SaFlags), 136}, + {"SigactionT", "SaFlags size", unsafe.Sizeof((*new(SigactionT)).SaFlags), 4}, + {"SigactionT", "SaFlags alignment", unsafe.Alignof((*new(SigactionT)).SaFlags), 4}, + {"SigactionT", "SaRestorer offset", unsafe.Offsetof((*new(SigactionT)).SaRestorer), 144}, + {"SigactionT", "SaRestorer size", unsafe.Sizeof((*new(SigactionT)).SaRestorer), 8}, + {"SigactionT", "SaRestorer alignment", unsafe.Alignof((*new(SigactionT)).SaRestorer), 8}, + {"X_fpxreg", "size", unsafe.Sizeof(*new(X_fpxreg)), 16}, + {"X_fpxreg", "alignment", unsafe.Alignof(*new(X_fpxreg)), 2}, + {"X_fpxreg", "Significand offset", unsafe.Offsetof((*new(X_fpxreg)).Significand), 0}, + {"X_fpxreg", "Significand size", unsafe.Sizeof((*new(X_fpxreg)).Significand), 8}, + {"X_fpxreg", "Significand alignment", unsafe.Alignof((*new(X_fpxreg)).Significand), 2}, + {"X_fpxreg", "Exponent offset", unsafe.Offsetof((*new(X_fpxreg)).Exponent), 8}, + {"X_fpxreg", "Exponent size", unsafe.Sizeof((*new(X_fpxreg)).Exponent), 2}, + {"X_fpxreg", "Exponent alignment", unsafe.Alignof((*new(X_fpxreg)).Exponent), 2}, + {"X_fpxreg", "Padding offset", unsafe.Offsetof((*new(X_fpxreg)).Padding), 10}, + {"X_fpxreg", "Padding size", unsafe.Sizeof((*new(X_fpxreg)).Padding), 6}, + {"X_fpxreg", "Padding alignment", unsafe.Alignof((*new(X_fpxreg)).Padding), 2}, + {"X_xmmreg", "size", unsafe.Sizeof(*new(X_xmmreg)), 16}, + {"X_xmmreg", "alignment", unsafe.Alignof(*new(X_xmmreg)), 4}, + {"X_xmmreg", "Element offset", unsafe.Offsetof((*new(X_xmmreg)).Element), 0}, + {"X_xmmreg", "Element size", unsafe.Sizeof((*new(X_xmmreg)).Element), 16}, + {"X_xmmreg", "Element alignment", unsafe.Alignof((*new(X_xmmreg)).Element), 4}, + {"X_fpstate", "size", unsafe.Sizeof(*new(X_fpstate)), 512}, + {"X_fpstate", "alignment", unsafe.Alignof(*new(X_fpstate)), 8}, + {"X_fpstate", "Cwd offset", unsafe.Offsetof((*new(X_fpstate)).Cwd), 0}, + {"X_fpstate", "Cwd size", unsafe.Sizeof((*new(X_fpstate)).Cwd), 2}, + {"X_fpstate", "Cwd alignment", unsafe.Alignof((*new(X_fpstate)).Cwd), 2}, + {"X_fpstate", "Swd offset", unsafe.Offsetof((*new(X_fpstate)).Swd), 2}, + {"X_fpstate", "Swd size", unsafe.Sizeof((*new(X_fpstate)).Swd), 2}, + {"X_fpstate", "Swd alignment", unsafe.Alignof((*new(X_fpstate)).Swd), 2}, + {"X_fpstate", "Ftw offset", unsafe.Offsetof((*new(X_fpstate)).Ftw), 4}, + {"X_fpstate", "Ftw size", unsafe.Sizeof((*new(X_fpstate)).Ftw), 2}, + {"X_fpstate", "Ftw alignment", unsafe.Alignof((*new(X_fpstate)).Ftw), 2}, + {"X_fpstate", "Fop offset", unsafe.Offsetof((*new(X_fpstate)).Fop), 6}, + {"X_fpstate", "Fop size", unsafe.Sizeof((*new(X_fpstate)).Fop), 2}, + {"X_fpstate", "Fop alignment", unsafe.Alignof((*new(X_fpstate)).Fop), 2}, + {"X_fpstate", "Rip offset", unsafe.Offsetof((*new(X_fpstate)).Rip), 8}, + {"X_fpstate", "Rip size", unsafe.Sizeof((*new(X_fpstate)).Rip), 8}, + {"X_fpstate", "Rip alignment", unsafe.Alignof((*new(X_fpstate)).Rip), 8}, + {"X_fpstate", "Rdp offset", unsafe.Offsetof((*new(X_fpstate)).Rdp), 16}, + {"X_fpstate", "Rdp size", unsafe.Sizeof((*new(X_fpstate)).Rdp), 8}, + {"X_fpstate", "Rdp alignment", unsafe.Alignof((*new(X_fpstate)).Rdp), 8}, + {"X_fpstate", "Mxcsr offset", unsafe.Offsetof((*new(X_fpstate)).Mxcsr), 24}, + {"X_fpstate", "Mxcsr size", unsafe.Sizeof((*new(X_fpstate)).Mxcsr), 4}, + {"X_fpstate", "Mxcsr alignment", unsafe.Alignof((*new(X_fpstate)).Mxcsr), 4}, + {"X_fpstate", "MxcrMask offset", unsafe.Offsetof((*new(X_fpstate)).MxcrMask), 28}, + {"X_fpstate", "MxcrMask size", unsafe.Sizeof((*new(X_fpstate)).MxcrMask), 4}, + {"X_fpstate", "MxcrMask alignment", unsafe.Alignof((*new(X_fpstate)).MxcrMask), 4}, + {"X_fpstate", "X_st offset", unsafe.Offsetof((*new(X_fpstate)).X_st), 32}, + {"X_fpstate", "X_st size", unsafe.Sizeof((*new(X_fpstate)).X_st), 128}, + {"X_fpstate", "X_st alignment", unsafe.Alignof((*new(X_fpstate)).X_st), 2}, + {"X_fpstate", "X_xmm offset", unsafe.Offsetof((*new(X_fpstate)).X_xmm), 160}, + {"X_fpstate", "X_xmm size", unsafe.Sizeof((*new(X_fpstate)).X_xmm), 256}, + {"X_fpstate", "X_xmm alignment", unsafe.Alignof((*new(X_fpstate)).X_xmm), 4}, + {"X_fpstate", "Padding offset", unsafe.Offsetof((*new(X_fpstate)).Padding), 416}, + {"X_fpstate", "Padding size", unsafe.Sizeof((*new(X_fpstate)).Padding), 96}, + {"X_fpstate", "Padding alignment", unsafe.Alignof((*new(X_fpstate)).Padding), 4}, + {"Sigcontext", "size", unsafe.Sizeof(*new(Sigcontext)), 256}, + {"Sigcontext", "alignment", unsafe.Alignof(*new(Sigcontext)), 8}, + {"Sigcontext", "R8 offset", unsafe.Offsetof((*new(Sigcontext)).R8), 0}, + {"Sigcontext", "R8 size", unsafe.Sizeof((*new(Sigcontext)).R8), 8}, + {"Sigcontext", "R8 alignment", unsafe.Alignof((*new(Sigcontext)).R8), 8}, + {"Sigcontext", "R9 offset", unsafe.Offsetof((*new(Sigcontext)).R9), 8}, + {"Sigcontext", "R9 size", unsafe.Sizeof((*new(Sigcontext)).R9), 8}, + {"Sigcontext", "R9 alignment", unsafe.Alignof((*new(Sigcontext)).R9), 8}, + {"Sigcontext", "R10 offset", unsafe.Offsetof((*new(Sigcontext)).R10), 16}, + {"Sigcontext", "R10 size", unsafe.Sizeof((*new(Sigcontext)).R10), 8}, + {"Sigcontext", "R10 alignment", unsafe.Alignof((*new(Sigcontext)).R10), 8}, + {"Sigcontext", "R11 offset", unsafe.Offsetof((*new(Sigcontext)).R11), 24}, + {"Sigcontext", "R11 size", unsafe.Sizeof((*new(Sigcontext)).R11), 8}, + {"Sigcontext", "R11 alignment", unsafe.Alignof((*new(Sigcontext)).R11), 8}, + {"Sigcontext", "R12 offset", unsafe.Offsetof((*new(Sigcontext)).R12), 32}, + {"Sigcontext", "R12 size", unsafe.Sizeof((*new(Sigcontext)).R12), 8}, + {"Sigcontext", "R12 alignment", unsafe.Alignof((*new(Sigcontext)).R12), 8}, + {"Sigcontext", "R13 offset", unsafe.Offsetof((*new(Sigcontext)).R13), 40}, + {"Sigcontext", "R13 size", unsafe.Sizeof((*new(Sigcontext)).R13), 8}, + {"Sigcontext", "R13 alignment", unsafe.Alignof((*new(Sigcontext)).R13), 8}, + {"Sigcontext", "R14 offset", unsafe.Offsetof((*new(Sigcontext)).R14), 48}, + {"Sigcontext", "R14 size", unsafe.Sizeof((*new(Sigcontext)).R14), 8}, + {"Sigcontext", "R14 alignment", unsafe.Alignof((*new(Sigcontext)).R14), 8}, + {"Sigcontext", "R15 offset", unsafe.Offsetof((*new(Sigcontext)).R15), 56}, + {"Sigcontext", "R15 size", unsafe.Sizeof((*new(Sigcontext)).R15), 8}, + {"Sigcontext", "R15 alignment", unsafe.Alignof((*new(Sigcontext)).R15), 8}, + {"Sigcontext", "Rdi offset", unsafe.Offsetof((*new(Sigcontext)).Rdi), 64}, + {"Sigcontext", "Rdi size", unsafe.Sizeof((*new(Sigcontext)).Rdi), 8}, + {"Sigcontext", "Rdi alignment", unsafe.Alignof((*new(Sigcontext)).Rdi), 8}, + {"Sigcontext", "Rsi offset", unsafe.Offsetof((*new(Sigcontext)).Rsi), 72}, + {"Sigcontext", "Rsi size", unsafe.Sizeof((*new(Sigcontext)).Rsi), 8}, + {"Sigcontext", "Rsi alignment", unsafe.Alignof((*new(Sigcontext)).Rsi), 8}, + {"Sigcontext", "Rbp offset", unsafe.Offsetof((*new(Sigcontext)).Rbp), 80}, + {"Sigcontext", "Rbp size", unsafe.Sizeof((*new(Sigcontext)).Rbp), 8}, + {"Sigcontext", "Rbp alignment", unsafe.Alignof((*new(Sigcontext)).Rbp), 8}, + {"Sigcontext", "Rbx offset", unsafe.Offsetof((*new(Sigcontext)).Rbx), 88}, + {"Sigcontext", "Rbx size", unsafe.Sizeof((*new(Sigcontext)).Rbx), 8}, + {"Sigcontext", "Rbx alignment", unsafe.Alignof((*new(Sigcontext)).Rbx), 8}, + {"Sigcontext", "Rdx offset", unsafe.Offsetof((*new(Sigcontext)).Rdx), 96}, + {"Sigcontext", "Rdx size", unsafe.Sizeof((*new(Sigcontext)).Rdx), 8}, + {"Sigcontext", "Rdx alignment", unsafe.Alignof((*new(Sigcontext)).Rdx), 8}, + {"Sigcontext", "Rax offset", unsafe.Offsetof((*new(Sigcontext)).Rax), 104}, + {"Sigcontext", "Rax size", unsafe.Sizeof((*new(Sigcontext)).Rax), 8}, + {"Sigcontext", "Rax alignment", unsafe.Alignof((*new(Sigcontext)).Rax), 8}, + {"Sigcontext", "Rcx offset", unsafe.Offsetof((*new(Sigcontext)).Rcx), 112}, + {"Sigcontext", "Rcx size", unsafe.Sizeof((*new(Sigcontext)).Rcx), 8}, + {"Sigcontext", "Rcx alignment", unsafe.Alignof((*new(Sigcontext)).Rcx), 8}, + {"Sigcontext", "Rsp offset", unsafe.Offsetof((*new(Sigcontext)).Rsp), 120}, + {"Sigcontext", "Rsp size", unsafe.Sizeof((*new(Sigcontext)).Rsp), 8}, + {"Sigcontext", "Rsp alignment", unsafe.Alignof((*new(Sigcontext)).Rsp), 8}, + {"Sigcontext", "Rip offset", unsafe.Offsetof((*new(Sigcontext)).Rip), 128}, + {"Sigcontext", "Rip size", unsafe.Sizeof((*new(Sigcontext)).Rip), 8}, + {"Sigcontext", "Rip alignment", unsafe.Alignof((*new(Sigcontext)).Rip), 8}, + {"Sigcontext", "Eflags offset", unsafe.Offsetof((*new(Sigcontext)).Eflags), 136}, + {"Sigcontext", "Eflags size", unsafe.Sizeof((*new(Sigcontext)).Eflags), 8}, + {"Sigcontext", "Eflags alignment", unsafe.Alignof((*new(Sigcontext)).Eflags), 8}, + {"Sigcontext", "Cs offset", unsafe.Offsetof((*new(Sigcontext)).Cs), 144}, + {"Sigcontext", "Cs size", unsafe.Sizeof((*new(Sigcontext)).Cs), 2}, + {"Sigcontext", "Cs alignment", unsafe.Alignof((*new(Sigcontext)).Cs), 2}, + {"Sigcontext", "Gs offset", unsafe.Offsetof((*new(Sigcontext)).Gs), 146}, + {"Sigcontext", "Gs size", unsafe.Sizeof((*new(Sigcontext)).Gs), 2}, + {"Sigcontext", "Gs alignment", unsafe.Alignof((*new(Sigcontext)).Gs), 2}, + {"Sigcontext", "Fs offset", unsafe.Offsetof((*new(Sigcontext)).Fs), 148}, + {"Sigcontext", "Fs size", unsafe.Sizeof((*new(Sigcontext)).Fs), 2}, + {"Sigcontext", "Fs alignment", unsafe.Alignof((*new(Sigcontext)).Fs), 2}, + {"Sigcontext", "X__Pad0 offset", unsafe.Offsetof((*new(Sigcontext)).X__Pad0), 150}, + {"Sigcontext", "X__Pad0 size", unsafe.Sizeof((*new(Sigcontext)).X__Pad0), 2}, + {"Sigcontext", "X__Pad0 alignment", unsafe.Alignof((*new(Sigcontext)).X__Pad0), 2}, + {"Sigcontext", "Err offset", unsafe.Offsetof((*new(Sigcontext)).Err), 152}, + {"Sigcontext", "Err size", unsafe.Sizeof((*new(Sigcontext)).Err), 8}, + {"Sigcontext", "Err alignment", unsafe.Alignof((*new(Sigcontext)).Err), 8}, + {"Sigcontext", "Trapno offset", unsafe.Offsetof((*new(Sigcontext)).Trapno), 160}, + {"Sigcontext", "Trapno size", unsafe.Sizeof((*new(Sigcontext)).Trapno), 8}, + {"Sigcontext", "Trapno alignment", unsafe.Alignof((*new(Sigcontext)).Trapno), 8}, + {"Sigcontext", "Oldmask offset", unsafe.Offsetof((*new(Sigcontext)).Oldmask), 168}, + {"Sigcontext", "Oldmask size", unsafe.Sizeof((*new(Sigcontext)).Oldmask), 8}, + {"Sigcontext", "Oldmask alignment", unsafe.Alignof((*new(Sigcontext)).Oldmask), 8}, + {"Sigcontext", "Cr2 offset", unsafe.Offsetof((*new(Sigcontext)).Cr2), 176}, + {"Sigcontext", "Cr2 size", unsafe.Sizeof((*new(Sigcontext)).Cr2), 8}, + {"Sigcontext", "Cr2 alignment", unsafe.Alignof((*new(Sigcontext)).Cr2), 8}, + {"Sigcontext", "X__Reserved1 offset", unsafe.Offsetof((*new(Sigcontext)).X__Reserved1), 192}, + {"Sigcontext", "X__Reserved1 size", unsafe.Sizeof((*new(Sigcontext)).X__Reserved1), 64}, + {"Sigcontext", "X__Reserved1 alignment", unsafe.Alignof((*new(Sigcontext)).X__Reserved1), 8}, + {"Sigval", "size", unsafe.Sizeof(*new(Sigval)), 8}, + {"Sigval", "alignment", unsafe.Alignof(*new(Sigval)), 8}, + {"SiginfoT", "size", unsafe.Sizeof(*new(SiginfoT)), 128}, + {"SiginfoT", "alignment", unsafe.Alignof(*new(SiginfoT)), 8}, + {"SiginfoT", "SiSigno offset", unsafe.Offsetof((*new(SiginfoT)).SiSigno), 0}, + {"SiginfoT", "SiSigno size", unsafe.Sizeof((*new(SiginfoT)).SiSigno), 4}, + {"SiginfoT", "SiSigno alignment", unsafe.Alignof((*new(SiginfoT)).SiSigno), 4}, + {"SiginfoT", "SiErrno offset", unsafe.Offsetof((*new(SiginfoT)).SiErrno), 4}, + {"SiginfoT", "SiErrno size", unsafe.Sizeof((*new(SiginfoT)).SiErrno), 4}, + {"SiginfoT", "SiErrno alignment", unsafe.Alignof((*new(SiginfoT)).SiErrno), 4}, + {"SiginfoT", "SiCode offset", unsafe.Offsetof((*new(SiginfoT)).SiCode), 8}, + {"SiginfoT", "SiCode size", unsafe.Sizeof((*new(SiginfoT)).SiCode), 4}, + {"SiginfoT", "SiCode alignment", unsafe.Alignof((*new(SiginfoT)).SiCode), 4}, + {"SiginfoT", "X_sifields offset", unsafe.Offsetof((*new(SiginfoT)).X_sifields), 16}, + {"SiginfoT", "X_sifields size", unsafe.Sizeof((*new(SiginfoT)).X_sifields), 112}, + {"SiginfoT", "X_sifields alignment", unsafe.Alignof((*new(SiginfoT)).X_sifields), 8}, + {"Sigevent", "size", unsafe.Sizeof(*new(Sigevent)), 64}, + {"Sigevent", "alignment", unsafe.Alignof(*new(Sigevent)), 8}, + {"Sigevent", "SigevValue offset", unsafe.Offsetof((*new(Sigevent)).SigevValue), 0}, + {"Sigevent", "SigevValue size", unsafe.Sizeof((*new(Sigevent)).SigevValue), 8}, + {"Sigevent", "SigevValue alignment", unsafe.Alignof((*new(Sigevent)).SigevValue), 8}, + {"Sigevent", "SigevSigno offset", unsafe.Offsetof((*new(Sigevent)).SigevSigno), 8}, + {"Sigevent", "SigevSigno size", unsafe.Sizeof((*new(Sigevent)).SigevSigno), 4}, + {"Sigevent", "SigevSigno alignment", unsafe.Alignof((*new(Sigevent)).SigevSigno), 4}, + {"Sigevent", "SigevNotify offset", unsafe.Offsetof((*new(Sigevent)).SigevNotify), 12}, + {"Sigevent", "SigevNotify size", unsafe.Sizeof((*new(Sigevent)).SigevNotify), 4}, + {"Sigevent", "SigevNotify alignment", unsafe.Alignof((*new(Sigevent)).SigevNotify), 4}, + {"Sigevent", "X_sigevUn offset", unsafe.Offsetof((*new(Sigevent)).X_sigevUn), 16}, + {"Sigevent", "X_sigevUn size", unsafe.Sizeof((*new(Sigevent)).X_sigevUn), 48}, + {"Sigevent", "X_sigevUn alignment", unsafe.Alignof((*new(Sigevent)).X_sigevUn), 8}, + {"SigvalT", "size", unsafe.Sizeof(*new(SigvalT)), 8}, + {"SigvalT", "alignment", unsafe.Alignof(*new(SigvalT)), 8}, + {"SigstackT", "size", unsafe.Sizeof(*new(SigstackT)), 16}, + {"SigstackT", "alignment", unsafe.Alignof(*new(SigstackT)), 8}, + {"SigstackT", "SsSp offset", unsafe.Offsetof((*new(SigstackT)).SsSp), 0}, + {"SigstackT", "SsSp size", unsafe.Sizeof((*new(SigstackT)).SsSp), 8}, + {"SigstackT", "SsSp alignment", unsafe.Alignof((*new(SigstackT)).SsSp), 8}, + {"SigstackT", "SsOnstack offset", unsafe.Offsetof((*new(SigstackT)).SsOnstack), 8}, + {"SigstackT", "SsOnstack size", unsafe.Sizeof((*new(SigstackT)).SsOnstack), 4}, + {"SigstackT", "SsOnstack alignment", unsafe.Alignof((*new(SigstackT)).SsOnstack), 4}, + {"Sigaltstack", "size", unsafe.Sizeof(*new(Sigaltstack)), 24}, + {"Sigaltstack", "alignment", unsafe.Alignof(*new(Sigaltstack)), 8}, + {"Sigaltstack", "SsSp offset", unsafe.Offsetof((*new(Sigaltstack)).SsSp), 0}, + {"Sigaltstack", "SsSp size", unsafe.Sizeof((*new(Sigaltstack)).SsSp), 8}, + {"Sigaltstack", "SsSp alignment", unsafe.Alignof((*new(Sigaltstack)).SsSp), 8}, + {"Sigaltstack", "SsFlags offset", unsafe.Offsetof((*new(Sigaltstack)).SsFlags), 8}, + {"Sigaltstack", "SsFlags size", unsafe.Sizeof((*new(Sigaltstack)).SsFlags), 4}, + {"Sigaltstack", "SsFlags alignment", unsafe.Alignof((*new(Sigaltstack)).SsFlags), 4}, + {"Sigaltstack", "SsSize offset", unsafe.Offsetof((*new(Sigaltstack)).SsSize), 16}, + {"Sigaltstack", "SsSize size", unsafe.Sizeof((*new(Sigaltstack)).SsSize), 8}, + {"Sigaltstack", "SsSize alignment", unsafe.Alignof((*new(Sigaltstack)).SsSize), 8}, + {"X__SighandlerT", "size", unsafe.Sizeof(*new(X__SighandlerT)), 8}, + {"X__SighandlerT", "alignment", unsafe.Alignof(*new(X__SighandlerT)), 8}, + {"SigsetT", "size", unsafe.Sizeof(*new(SigsetT)), 128}, + {"SigsetT", "alignment", unsafe.Alignof(*new(SigsetT)), 8}, + {"X__SigsetT", "size", unsafe.Sizeof(*new(X__SigsetT)), 128}, + {"X__SigsetT", "alignment", unsafe.Alignof(*new(X__SigsetT)), 8}, + {"X__SigsetT", "X__Val offset", unsafe.Offsetof((*new(X__SigsetT)).X__Val), 0}, + {"X__SigsetT", "X__Val size", unsafe.Sizeof((*new(X__SigsetT)).X__Val), 128}, + {"X__SigsetT", "X__Val alignment", unsafe.Alignof((*new(X__SigsetT)).X__Val), 8}, + {"SignalHandler", "size", unsafe.Sizeof(*new(SignalHandler)), 8}, + {"SignalHandler", "alignment", unsafe.Alignof(*new(SignalHandler)), 8}, + {"SigeventT", "size", unsafe.Sizeof(*new(SigeventT)), 64}, + {"SigeventT", "alignment", unsafe.Alignof(*new(SigeventT)), 8}, + {"_llcppg_anon_7", "size", unsafe.Sizeof(*new(_llcppg_anon_7)), 8}, + {"_llcppg_anon_7", "alignment", unsafe.Alignof(*new(_llcppg_anon_7)), 8}, + {"_llcppg_anon_5", "size", unsafe.Sizeof(*new(_llcppg_anon_5)), 112}, + {"_llcppg_anon_5", "alignment", unsafe.Alignof(*new(_llcppg_anon_5)), 8}, + {"_llcppg_anon_6", "size", unsafe.Sizeof(*new(_llcppg_anon_6)), 48}, + {"_llcppg_anon_6", "alignment", unsafe.Alignof(*new(_llcppg_anon_6)), 8}, + {"_llcppg_anon_24", "size", unsafe.Sizeof(*new(_llcppg_anon_24)), 8}, + {"_llcppg_anon_24", "alignment", unsafe.Alignof(*new(_llcppg_anon_24)), 4}, + {"_llcppg_anon_24", "SiPid offset", unsafe.Offsetof((*new(_llcppg_anon_24)).SiPid), 0}, + {"_llcppg_anon_24", "SiPid size", unsafe.Sizeof((*new(_llcppg_anon_24)).SiPid), 4}, + {"_llcppg_anon_24", "SiPid alignment", unsafe.Alignof((*new(_llcppg_anon_24)).SiPid), 4}, + {"_llcppg_anon_24", "SiUid offset", unsafe.Offsetof((*new(_llcppg_anon_24)).SiUid), 4}, + {"_llcppg_anon_24", "SiUid size", unsafe.Sizeof((*new(_llcppg_anon_24)).SiUid), 4}, + {"_llcppg_anon_24", "SiUid alignment", unsafe.Alignof((*new(_llcppg_anon_24)).SiUid), 4}, + {"_llcppg_anon_25", "size", unsafe.Sizeof(*new(_llcppg_anon_25)), 16}, + {"_llcppg_anon_25", "alignment", unsafe.Alignof(*new(_llcppg_anon_25)), 8}, + {"_llcppg_anon_25", "SiTid offset", unsafe.Offsetof((*new(_llcppg_anon_25)).SiTid), 0}, + {"_llcppg_anon_25", "SiTid size", unsafe.Sizeof((*new(_llcppg_anon_25)).SiTid), 4}, + {"_llcppg_anon_25", "SiTid alignment", unsafe.Alignof((*new(_llcppg_anon_25)).SiTid), 4}, + {"_llcppg_anon_25", "SiOverrun offset", unsafe.Offsetof((*new(_llcppg_anon_25)).SiOverrun), 4}, + {"_llcppg_anon_25", "SiOverrun size", unsafe.Sizeof((*new(_llcppg_anon_25)).SiOverrun), 4}, + {"_llcppg_anon_25", "SiOverrun alignment", unsafe.Alignof((*new(_llcppg_anon_25)).SiOverrun), 4}, + {"_llcppg_anon_25", "SiSigval offset", unsafe.Offsetof((*new(_llcppg_anon_25)).SiSigval), 8}, + {"_llcppg_anon_25", "SiSigval size", unsafe.Sizeof((*new(_llcppg_anon_25)).SiSigval), 8}, + {"_llcppg_anon_25", "SiSigval alignment", unsafe.Alignof((*new(_llcppg_anon_25)).SiSigval), 8}, + {"_llcppg_anon_26", "size", unsafe.Sizeof(*new(_llcppg_anon_26)), 16}, + {"_llcppg_anon_26", "alignment", unsafe.Alignof(*new(_llcppg_anon_26)), 8}, + {"_llcppg_anon_26", "SiPid offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiPid), 0}, + {"_llcppg_anon_26", "SiPid size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiPid), 4}, + {"_llcppg_anon_26", "SiPid alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiPid), 4}, + {"_llcppg_anon_26", "SiUid offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiUid), 4}, + {"_llcppg_anon_26", "SiUid size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiUid), 4}, + {"_llcppg_anon_26", "SiUid alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiUid), 4}, + {"_llcppg_anon_26", "SiSigval offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiSigval), 8}, + {"_llcppg_anon_26", "SiSigval size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiSigval), 8}, + {"_llcppg_anon_26", "SiSigval alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiSigval), 8}, + {"_llcppg_anon_27", "size", unsafe.Sizeof(*new(_llcppg_anon_27)), 32}, + {"_llcppg_anon_27", "alignment", unsafe.Alignof(*new(_llcppg_anon_27)), 8}, + {"_llcppg_anon_27", "SiPid offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiPid), 0}, + {"_llcppg_anon_27", "SiPid size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiPid), 4}, + {"_llcppg_anon_27", "SiPid alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiPid), 4}, + {"_llcppg_anon_27", "SiUid offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiUid), 4}, + {"_llcppg_anon_27", "SiUid size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiUid), 4}, + {"_llcppg_anon_27", "SiUid alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiUid), 4}, + {"_llcppg_anon_27", "SiStatus offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiStatus), 8}, + {"_llcppg_anon_27", "SiStatus size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiStatus), 4}, + {"_llcppg_anon_27", "SiStatus alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiStatus), 4}, + {"_llcppg_anon_27", "SiUtime offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiUtime), 16}, + {"_llcppg_anon_27", "SiUtime size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiUtime), 8}, + {"_llcppg_anon_27", "SiUtime alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiUtime), 8}, + {"_llcppg_anon_27", "SiStime offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiStime), 24}, + {"_llcppg_anon_27", "SiStime size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiStime), 8}, + {"_llcppg_anon_27", "SiStime alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiStime), 8}, + {"_llcppg_anon_28", "size", unsafe.Sizeof(*new(_llcppg_anon_28)), 32}, + {"_llcppg_anon_28", "alignment", unsafe.Alignof(*new(_llcppg_anon_28)), 8}, + {"_llcppg_anon_28", "SiAddr offset", unsafe.Offsetof((*new(_llcppg_anon_28)).SiAddr), 0}, + {"_llcppg_anon_28", "SiAddr size", unsafe.Sizeof((*new(_llcppg_anon_28)).SiAddr), 8}, + {"_llcppg_anon_28", "SiAddr alignment", unsafe.Alignof((*new(_llcppg_anon_28)).SiAddr), 8}, + {"_llcppg_anon_28", "SiAddrLsb offset", unsafe.Offsetof((*new(_llcppg_anon_28)).SiAddrLsb), 8}, + {"_llcppg_anon_28", "SiAddrLsb size", unsafe.Sizeof((*new(_llcppg_anon_28)).SiAddrLsb), 2}, + {"_llcppg_anon_28", "SiAddrLsb alignment", unsafe.Alignof((*new(_llcppg_anon_28)).SiAddrLsb), 2}, + {"_llcppg_anon_28", "SiAddrBnd offset", unsafe.Offsetof((*new(_llcppg_anon_28)).SiAddrBnd), 16}, + {"_llcppg_anon_28", "SiAddrBnd size", unsafe.Sizeof((*new(_llcppg_anon_28)).SiAddrBnd), 16}, + {"_llcppg_anon_28", "SiAddrBnd alignment", unsafe.Alignof((*new(_llcppg_anon_28)).SiAddrBnd), 8}, + {"_llcppg_anon_30", "size", unsafe.Sizeof(*new(_llcppg_anon_30)), 16}, + {"_llcppg_anon_30", "alignment", unsafe.Alignof(*new(_llcppg_anon_30)), 8}, + {"_llcppg_anon_30", "SiBand offset", unsafe.Offsetof((*new(_llcppg_anon_30)).SiBand), 0}, + {"_llcppg_anon_30", "SiBand size", unsafe.Sizeof((*new(_llcppg_anon_30)).SiBand), 8}, + {"_llcppg_anon_30", "SiBand alignment", unsafe.Alignof((*new(_llcppg_anon_30)).SiBand), 8}, + {"_llcppg_anon_30", "SiFd offset", unsafe.Offsetof((*new(_llcppg_anon_30)).SiFd), 8}, + {"_llcppg_anon_30", "SiFd size", unsafe.Sizeof((*new(_llcppg_anon_30)).SiFd), 4}, + {"_llcppg_anon_30", "SiFd alignment", unsafe.Alignof((*new(_llcppg_anon_30)).SiFd), 4}, + {"_llcppg_anon_31", "size", unsafe.Sizeof(*new(_llcppg_anon_31)), 16}, + {"_llcppg_anon_31", "alignment", unsafe.Alignof(*new(_llcppg_anon_31)), 8}, + {"_llcppg_anon_31", "X_callAddr offset", unsafe.Offsetof((*new(_llcppg_anon_31)).X_callAddr), 0}, + {"_llcppg_anon_31", "X_callAddr size", unsafe.Sizeof((*new(_llcppg_anon_31)).X_callAddr), 8}, + {"_llcppg_anon_31", "X_callAddr alignment", unsafe.Alignof((*new(_llcppg_anon_31)).X_callAddr), 8}, + {"_llcppg_anon_31", "X_syscall offset", unsafe.Offsetof((*new(_llcppg_anon_31)).X_syscall), 8}, + {"_llcppg_anon_31", "X_syscall size", unsafe.Sizeof((*new(_llcppg_anon_31)).X_syscall), 4}, + {"_llcppg_anon_31", "X_syscall alignment", unsafe.Alignof((*new(_llcppg_anon_31)).X_syscall), 4}, + {"_llcppg_anon_31", "X_arch offset", unsafe.Offsetof((*new(_llcppg_anon_31)).X_arch), 12}, + {"_llcppg_anon_31", "X_arch size", unsafe.Sizeof((*new(_llcppg_anon_31)).X_arch), 4}, + {"_llcppg_anon_31", "X_arch alignment", unsafe.Alignof((*new(_llcppg_anon_31)).X_arch), 4}, + {"_llcppg_anon_32", "size", unsafe.Sizeof(*new(_llcppg_anon_32)), 16}, + {"_llcppg_anon_32", "alignment", unsafe.Alignof(*new(_llcppg_anon_32)), 8}, + {"_llcppg_anon_32", "X_function offset", unsafe.Offsetof((*new(_llcppg_anon_32)).X_function), 0}, + {"_llcppg_anon_32", "X_function size", unsafe.Sizeof((*new(_llcppg_anon_32)).X_function), 8}, + {"_llcppg_anon_32", "X_function alignment", unsafe.Alignof((*new(_llcppg_anon_32)).X_function), 8}, + {"_llcppg_anon_32", "X_attribute offset", unsafe.Offsetof((*new(_llcppg_anon_32)).X_attribute), 8}, + {"_llcppg_anon_32", "X_attribute size", unsafe.Sizeof((*new(_llcppg_anon_32)).X_attribute), 8}, + {"_llcppg_anon_32", "X_attribute alignment", unsafe.Alignof((*new(_llcppg_anon_32)).X_attribute), 8}, + {"_llcppg_anon_29", "size", unsafe.Sizeof(*new(_llcppg_anon_29)), 16}, + {"_llcppg_anon_29", "alignment", unsafe.Alignof(*new(_llcppg_anon_29)), 8}, + {"_llcppg_anon_29", "X_lower offset", unsafe.Offsetof((*new(_llcppg_anon_29)).X_lower), 0}, + {"_llcppg_anon_29", "X_lower size", unsafe.Sizeof((*new(_llcppg_anon_29)).X_lower), 8}, + {"_llcppg_anon_29", "X_lower alignment", unsafe.Alignof((*new(_llcppg_anon_29)).X_lower), 8}, + {"_llcppg_anon_29", "X_upper offset", unsafe.Offsetof((*new(_llcppg_anon_29)).X_upper), 8}, + {"_llcppg_anon_29", "X_upper size", unsafe.Sizeof((*new(_llcppg_anon_29)).X_upper), 8}, + {"_llcppg_anon_29", "X_upper alignment", unsafe.Alignof((*new(_llcppg_anon_29)).X_upper), 8}, + } + var signalIntegerConstants = []struct { + name string + got, want int64 + }{ + {"SA_NOCLDSTOP", int64(SA_NOCLDSTOP), 1}, + {"SA_NOCLDWAIT", int64(SA_NOCLDWAIT), 2}, + {"SA_SIGINFO", int64(SA_SIGINFO), 4}, + {"SA_ONSTACK", int64(SA_ONSTACK), 134217728}, + {"SA_RESTART", int64(SA_RESTART), 268435456}, + {"SA_NODEFER", int64(SA_NODEFER), 1073741824}, + {"SA_RESETHAND", int64(SA_RESETHAND), 2147483648}, + {"SA_INTERRUPT", int64(SA_INTERRUPT), 536870912}, + {"SA_NOMASK", int64(SA_NOMASK), 1073741824}, + {"SA_ONESHOT", int64(SA_ONESHOT), 2147483648}, + {"SA_STACK", int64(SA_STACK), 134217728}, + {"SIG_BLOCK", int64(SIG_BLOCK), 0}, + {"SIG_UNBLOCK", int64(SIG_UNBLOCK), 1}, + {"SIG_SETMASK", int64(SIG_SETMASK), 2}, + {"SI_ASYNCNL", int64(SI_ASYNCNL), -60}, + {"SI_TKILL", int64(SI_TKILL), -6}, + {"SI_SIGIO", int64(SI_SIGIO), -5}, + {"SI_ASYNCIO", int64(SI_ASYNCIO), -4}, + {"SI_MESGQ", int64(SI_MESGQ), -3}, + {"SI_TIMER", int64(SI_TIMER), -2}, + {"SI_QUEUE", int64(SI_QUEUE), -1}, + {"SI_USER", int64(SI_USER), 0}, + {"SI_KERNEL", int64(SI_KERNEL), 128}, + {"ILL_ILLOPC", int64(ILL_ILLOPC), 1}, + {"ILL_ILLOPN", int64(ILL_ILLOPN), 2}, + {"ILL_ILLADR", int64(ILL_ILLADR), 3}, + {"ILL_ILLTRP", int64(ILL_ILLTRP), 4}, + {"ILL_PRVOPC", int64(ILL_PRVOPC), 5}, + {"ILL_PRVREG", int64(ILL_PRVREG), 6}, + {"ILL_COPROC", int64(ILL_COPROC), 7}, + {"ILL_BADSTK", int64(ILL_BADSTK), 8}, + {"FPE_INTDIV", int64(FPE_INTDIV), 1}, + {"FPE_INTOVF", int64(FPE_INTOVF), 2}, + {"FPE_FLTDIV", int64(FPE_FLTDIV), 3}, + {"FPE_FLTOVF", int64(FPE_FLTOVF), 4}, + {"FPE_FLTUND", int64(FPE_FLTUND), 5}, + {"FPE_FLTRES", int64(FPE_FLTRES), 6}, + {"FPE_FLTINV", int64(FPE_FLTINV), 7}, + {"FPE_FLTSUB", int64(FPE_FLTSUB), 8}, + {"SEGV_MAPERR", int64(SEGV_MAPERR), 1}, + {"SEGV_ACCERR", int64(SEGV_ACCERR), 2}, + {"BUS_ADRALN", int64(BUS_ADRALN), 1}, + {"BUS_ADRERR", int64(BUS_ADRERR), 2}, + {"BUS_OBJERR", int64(BUS_OBJERR), 3}, + {"BUS_MCEERR_AR", int64(BUS_MCEERR_AR), 4}, + {"BUS_MCEERR_AO", int64(BUS_MCEERR_AO), 5}, + {"CLD_EXITED", int64(CLD_EXITED), 1}, + {"CLD_KILLED", int64(CLD_KILLED), 2}, + {"CLD_DUMPED", int64(CLD_DUMPED), 3}, + {"CLD_TRAPPED", int64(CLD_TRAPPED), 4}, + {"CLD_STOPPED", int64(CLD_STOPPED), 5}, + {"CLD_CONTINUED", int64(CLD_CONTINUED), 6}, + {"POLL_IN", int64(POLL_IN), 1}, + {"POLL_OUT", int64(POLL_OUT), 2}, + {"POLL_MSG", int64(POLL_MSG), 3}, + {"POLL_ERR", int64(POLL_ERR), 4}, + {"POLL_PRI", int64(POLL_PRI), 5}, + {"POLL_HUP", int64(POLL_HUP), 6}, + {"SIGEV_SIGNAL", int64(SIGEV_SIGNAL), 0}, + {"SIGEV_NONE", int64(SIGEV_NONE), 1}, + {"SIGEV_THREAD", int64(SIGEV_THREAD), 2}, + {"SIGEV_THREAD_ID", int64(SIGEV_THREAD_ID), 4}, + {"SIGHUP", int64(SIGHUP), 1}, + {"SIGINT", int64(SIGINT), 2}, + {"SIGQUIT", int64(SIGQUIT), 3}, + {"SIGILL", int64(SIGILL), 4}, + {"SIGTRAP", int64(SIGTRAP), 5}, + {"SIGABRT", int64(SIGABRT), 6}, + {"SIGIOT", int64(SIGIOT), 6}, + {"SIGBUS", int64(SIGBUS), 7}, + {"SIGFPE", int64(SIGFPE), 8}, + {"SIGKILL", int64(SIGKILL), 9}, + {"SIGUSR1", int64(SIGUSR1), 10}, + {"SIGSEGV", int64(SIGSEGV), 11}, + {"SIGUSR2", int64(SIGUSR2), 12}, + {"SIGPIPE", int64(SIGPIPE), 13}, + {"SIGALRM", int64(SIGALRM), 14}, + {"SIGTERM", int64(SIGTERM), 15}, + {"SIGSTKFLT", int64(SIGSTKFLT), 16}, + {"SIGCHLD", int64(SIGCHLD), 17}, + {"SIGCONT", int64(SIGCONT), 18}, + {"SIGSTOP", int64(SIGSTOP), 19}, + {"SIGTSTP", int64(SIGTSTP), 20}, + {"SIGTTIN", int64(SIGTTIN), 21}, + {"SIGTTOU", int64(SIGTTOU), 22}, + {"SIGURG", int64(SIGURG), 23}, + {"SIGXCPU", int64(SIGXCPU), 24}, + {"SIGXFSZ", int64(SIGXFSZ), 25}, + {"SIGVTALRM", int64(SIGVTALRM), 26}, + {"SIGPROF", int64(SIGPROF), 27}, + {"SIGWINCH", int64(SIGWINCH), 28}, + {"SIGIO", int64(SIGIO), 29}, + {"SIGPWR", int64(SIGPWR), 30}, + {"SIGSYS", int64(SIGSYS), 31}, + {"SIGUNUSED", int64(SIGUNUSED), 31}, + {"NSIG", int64(NSIG), 65}, + } + var signalVariableSymbols = []struct { + name string + address unsafe.Pointer + }{} + var signalAccessorChecks = []struct { + name string + check func() (uintptr, uintptr, uintptr) + offset, size, align uintptr + }{ + {"*_llcppg_anon_7.XGof_ref_sa_handler", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_7 + view := value.XGof_ref_sa_handler() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*_llcppg_anon_7.XGof_ref_sa_sigaction", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_7 + view := value.XGof_ref_sa_sigaction() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*_llcppg_anon_8.XGof_ref_fpstate", func() (uintptr, uintptr, uintptr) { + var value Sigcontext + view := value._llcppg_anon_8.XGof_ref_fpstate() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 184, 8, 8}, + {"*_llcppg_anon_8.XGof_ref___fpstate_word", func() (uintptr, uintptr, uintptr) { + var value Sigcontext + view := value._llcppg_anon_8.XGof_ref___fpstate_word() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 184, 8, 8}, + {"*Sigval.XGof_ref_sival_int", func() (uintptr, uintptr, uintptr) { + var value Sigval + view := value.XGof_ref_sival_int() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 4, 4}, + {"*Sigval.XGof_ref_sival_ptr", func() (uintptr, uintptr, uintptr) { + var value Sigval + view := value.XGof_ref_sival_ptr() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*_llcppg_anon_5.XGof_ref__pad", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__pad() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 112, 4}, + {"*_llcppg_anon_5.XGof_ref__kill", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__kill() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 4}, + {"*_llcppg_anon_5.XGof_ref__timer", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__timer() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__rt", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__rt() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__sigchld", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigchld() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 32, 8}, + {"*_llcppg_anon_5.XGof_ref__sigfault", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigfault() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 32, 8}, + {"*_llcppg_anon_5.XGof_ref__sigpoll", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigpoll() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__sigsys", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigsys() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_6.XGof_ref__pad", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_6 + view := value.XGof_ref__pad() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 48, 4}, + {"*_llcppg_anon_6.XGof_ref__tid", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_6 + view := value.XGof_ref__tid() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 4, 4}, + {"*_llcppg_anon_6.XGof_ref__sigev_thread", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_6 + view := value.XGof_ref__sigev_thread() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + } + + t.Run("function symbols", func(t *testing.T) { + for _, symbol := range signalFunctionSymbols { + t.Run(symbol.name, func(t *testing.T) { + if symbol.address == nil { + t.Fatal("C function address is nil") + } + t.Logf("C function address: %p", symbol.address) + }) + } + }) + t.Run("native prototypes", func(t *testing.T) { + check := func(name string, got reflect.Type, want signalABISlot) { + if got.Size() != want.size || uintptr(got.Align()) != want.align { + t.Errorf("%s size/alignment = %d/%d, C = %d/%d", name, got.Size(), got.Align(), want.size, want.align) + } + class := 0 + switch got.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + class = 1 + case reflect.Ptr, reflect.UnsafePointer, reflect.Func: + class = 5 + case reflect.Float32, reflect.Float64: + class = 8 + case reflect.Struct: + class = 12 + if got.NumField() == 1 && got.Field(0).Name == "_xgo_union" { + class = 13 + } + } + if class != want.class { + t.Errorf("%s ABI class = %d (%v), C = %d", name, class, got.Kind(), want.class) + } + } + for _, tc := range signalFunctionPrototypes { + t.Run(tc.name, func(t *testing.T) { + inputs := len(tc.inputs) + if tc.variadic { + inputs++ + } + if tc.signature.Kind() != reflect.Func || tc.signature.NumIn() != inputs || tc.signature.IsVariadic() != tc.variadic { + t.Fatalf("Go signature = %v, C fixed parameters = %d, variadic = %v", tc.signature, len(tc.inputs), tc.variadic) + } + for i, slot := range tc.inputs { + check(tc.name+" parameter", tc.signature.In(i), slot) + } + outputs := 0 + if tc.output != nil { + outputs = 1 + } + if tc.signature.NumOut() != outputs { + t.Fatalf("Go result count = %d, C = %d", tc.signature.NumOut(), outputs) + } + if tc.output != nil { + check(tc.name+" result", tc.signature.Out(0), *tc.output) + } + }) + } + for _, tc := range signalStaticFunctionPrototypes { + t.Run(tc.name, func(t *testing.T) { + for _, slot := range tc.slots { + if slot.goType != nil { + check(tc.name+" "+slot.label, slot.goType, slot.want) + } else if slot.got != slot.want { + t.Errorf("%s %s ABI = %+v, C = %+v", tc.name, slot.label, slot.got, slot.want) + } + } + }) + } + + }) + t.Run("native types and globals", func(t *testing.T) { + for _, tc := range signalTypeLayouts { + t.Run(tc.symbol+"/"+tc.property, func(t *testing.T) { + if tc.got != tc.want { + t.Fatalf("Go layout = %d, C headers = %d", tc.got, tc.want) + } + }) + } + for _, symbol := range signalVariableSymbols { + if symbol.address == nil { + t.Errorf("%s C variable address is nil", symbol.name) + } + t.Logf("%s C variable address: %p", symbol.name, symbol.address) + } + }) + t.Run("native constants", func(t *testing.T) { + for _, tc := range signalIntegerConstants { + t.Run(tc.name, func(t *testing.T) { + if tc.got != tc.want { + t.Fatalf("Go constant = %d, C headers = %d", tc.got, tc.want) + } + }) + } + }) + t.Run("union accessors", func(t *testing.T) { + for _, tc := range signalAccessorChecks { + t.Run(tc.name, func(t *testing.T) { + offset, size, align := tc.check() + if offset != tc.offset || size != tc.size || align != tc.align { + t.Fatalf("Go field offset/size/alignment = %d/%d/%d, C = %d/%d/%d", offset, size, align, tc.offset, tc.size, tc.align) + } + }) + } + }) + t.Run("symbol inventory", func(t *testing.T) { + functions, prototypes, types, constants, variables := map[string]bool{}, map[string]bool{}, map[string]bool{}, map[string]bool{}, map[string]bool{} + for _, tc := range signalFunctionPrototypes { + prototypes[tc.name] = true + } + for _, tc := range signalStaticFunctionPrototypes { + prototypes[tc.name] = true + } + + for _, symbol := range signalFunctionSymbols { + functions[symbol.name] = true + if !prototypes[symbol.name] { + t.Errorf("%s has no native prototype test", symbol.name) + } + } + for _, tc := range signalAccessorChecks { + functions[tc.name] = true + } + for _, tc := range signalTypeLayouts { + types[tc.symbol] = true + } + for _, tc := range signalIntegerConstants { + constants[tc.name] = true + } + for _, symbol := range signalVariableSymbols { + variables[symbol.name] = true + } + constants["LLGoPackage"] = true + functions["Signal"] = true + if LLGoPackage != "link" { + t.Errorf("LLGoPackage = %q, want link", LLGoPackage) + } + files := []string{"libc_" + runtime.GOOS + "_" + runtime.GOARCH + ".go"} + + for _, filename := range files { + source, err := parser.ParseFile(token.NewFileSet(), filename, nil, parser.ParseComments) + if err != nil { + t.Fatal(err) + } + for _, declaration := range source.Decls { + switch decl := declaration.(type) { + case *ast.FuncDecl: + name := decl.Name.Name + if !ast.IsExported(name) { + continue + } + if decl.Recv != nil { + receiver, prefix := decl.Recv.List[0].Type, "" + if pointer, ok := receiver.(*ast.StarExpr); ok { + receiver, prefix = pointer.X, "*" + } + name = prefix + receiver.(*ast.Ident).Name + "." + name + } + if !functions[name] { + t.Errorf("%s: function %s has no test", filename, name) + } + if strings.HasPrefix(decl.Name.Name, "Native") && decl.Name.Name != "NativeSignal" { + t.Errorf("%s retains duplicate %s", filename, name) + } + if decl.Doc != nil { + for _, comment := range decl.Doc.List { + for _, private := range []string{"C._llcppg_", "C.__sig", "C.__sysv_signal", "C.__libc_current_sigrt"} { + if strings.Contains(comment.Text, private) { + t.Errorf("%s still exposes private C entry point %s", filename, private) + } + } + } + } + case *ast.GenDecl: + for _, specification := range decl.Specs { + switch spec := specification.(type) { + case *ast.TypeSpec: + if ast.IsExported(spec.Name.Name) && !types[spec.Name.Name] { + t.Errorf("%s: type %s has no ABI test", filename, spec.Name.Name) + } + case *ast.ValueSpec: + for _, name := range spec.Names { + if !ast.IsExported(name.Name) { + continue + } + if decl.Tok == token.CONST && !constants[name.Name] { + t.Errorf("%s: constant %s has no test", filename, name.Name) + } + if decl.Tok == token.VAR && !variables[name.Name] { + t.Errorf("%s: variable %s has no test", filename, name.Name) + } + } + } + } + } + } + } + t.Logf("coverage: %d C functions, %d Go union accessors, %d types/global layouts, %d constants, %d globals", len(signalFunctionSymbols), len(signalAccessorChecks), len(signalTypeLayouts), len(constants), len(signalVariableSymbols)) + }) + + var set SigsetT + var info SiginfoT + var value Sigval + if unsafe.Sizeof(set) != nativeSigsetSize || unsafe.Alignof(set) != nativeSigsetAlign { + t.Fatalf("sigset_t = %d/%d, want %d/%d", unsafe.Sizeof(set), unsafe.Alignof(set), nativeSigsetSize, nativeSigsetAlign) + } + if unsafe.Sizeof(info) != nativeSiginfoSize || unsafe.Alignof(info) != 8 { + t.Fatalf("siginfo_t = %d/%d, want %d/8", unsafe.Sizeof(info), unsafe.Alignof(info), nativeSiginfoSize) + } + if unsafe.Offsetof(info.SiSigno) != 0 || unsafe.Offsetof(info.SiErrno) != 4 || unsafe.Offsetof(info.SiCode) != 8 { + t.Fatalf("siginfo_t header offsets = %d/%d/%d", unsafe.Offsetof(info.SiSigno), unsafe.Offsetof(info.SiErrno), unsafe.Offsetof(info.SiCode)) + } + if unsafe.Sizeof(value) != 8 || unsafe.Alignof(value) != 8 { + t.Fatalf("sigval = %d/%d, want 8/8", unsafe.Sizeof(value), unsafe.Alignof(value)) + } + *value.XGof_ref_sival_int() = -7 + if got := *(*c.Int)(unsafe.Pointer(&value)); got != -7 { + t.Fatalf("sigval integer storage = %d, want -7", got) + } + var marker uintptr + *value.XGof_ref_sival_ptr() = unsafe.Pointer(&marker) + if got := *(*unsafe.Pointer)(unsafe.Pointer(&value)); got != unsafe.Pointer(&marker) { + t.Fatalf("sigval pointer storage = %p, want %p", got, &marker) + } + +} diff --git a/c/signal/symbols_linux_arm64_llgo_test.go b/c/signal/symbols_linux_arm64_llgo_test.go new file mode 100644 index 00000000..c814fb96 --- /dev/null +++ b/c/signal/symbols_linux_arm64_llgo_test.go @@ -0,0 +1,692 @@ +//go:build llgo && linux && arm64 && !android + +package signal + +import ( + "github.com/goplus/lib/c" + lltime "github.com/goplus/lib/c/time" + "go/ast" + "go/parser" + "go/token" + "reflect" + "runtime" + "strings" + "testing" + "unsafe" +) + +func TestNativeSignalDataLayouts(t *testing.T) { + // Expected values are compiled from original Bootlin glibc 2.24 headers. + var signalFunctionSymbols = []struct { + name string + address unsafe.Pointer + }{ + {"NativeSignal", c.Func(NativeSignal)}, + {"Kill", c.Func(Kill)}, + {"Killpg", c.Func(Killpg)}, + {"Raise", c.Func(Raise)}, + {"Ssignal", c.Func(Ssignal)}, + {"Gsignal", c.Func(Gsignal)}, + {"Psignal", c.Func(Psignal)}, + {"*SiginfoT.Psiginfo", c.Func((*SiginfoT).Psiginfo)}, + {"Sigblock", c.Func(Sigblock)}, + {"Sigsetmask", c.Func(Sigsetmask)}, + {"Siggetmask", c.Func(Siggetmask)}, + {"*SigsetT.Sigemptyset", c.Func((*SigsetT).Sigemptyset)}, + {"*SigsetT.Sigfillset", c.Func((*SigsetT).Sigfillset)}, + {"*SigsetT.Sigaddset", c.Func((*SigsetT).Sigaddset)}, + {"*SigsetT.Sigdelset", c.Func((*SigsetT).Sigdelset)}, + {"*SigsetT.Sigismember", c.Func((*SigsetT).Sigismember)}, + {"Sigprocmask", c.Func(Sigprocmask)}, + {"*SigsetT.Sigsuspend", c.Func((*SigsetT).Sigsuspend)}, + {"Sigaction", c.Func(Sigaction)}, + {"*SigsetT.Sigpending", c.Func((*SigsetT).Sigpending)}, + {"*SigsetT.Sigwait", c.Func((*SigsetT).Sigwait)}, + {"*SigsetT.Sigwaitinfo", c.Func((*SigsetT).Sigwaitinfo)}, + {"*SigsetT.Sigtimedwait", c.Func((*SigsetT).Sigtimedwait)}, + {"Sigqueue", c.Func(Sigqueue)}, + {"Siginterrupt", c.Func(Siginterrupt)}, + {"Sigstack", c.Func(Sigstack)}, + {"*Sigaltstack.Sigaltstack", c.Func((*Sigaltstack).Sigaltstack)}, + {"TimerCreate", c.Func(TimerCreate)}, + } + var signalFunctionPrototypes = []struct { + name string + signature reflect.Type + inputs []signalABISlot + output *signalABISlot + variadic bool + }{ + {"NativeSignal", reflect.TypeOf(NativeSignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + {"Kill", reflect.TypeOf(Kill), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Killpg", reflect.TypeOf(Killpg), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Raise", reflect.TypeOf(Raise), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Ssignal", reflect.TypeOf(Ssignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, &signalABISlot{8, 8, 5}, false}, + {"Gsignal", reflect.TypeOf(Gsignal), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Psignal", reflect.TypeOf(Psignal), []signalABISlot{{4, 4, 1}, {8, 8, 5}}, nil, false}, + {"*SiginfoT.Psiginfo", reflect.TypeOf((*SiginfoT).Psiginfo), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, nil, false}, + {"Sigblock", reflect.TypeOf(Sigblock), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigsetmask", reflect.TypeOf(Sigsetmask), []signalABISlot{{4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Siggetmask", reflect.TypeOf(Siggetmask), []signalABISlot{}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigemptyset", reflect.TypeOf((*SigsetT).Sigemptyset), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigfillset", reflect.TypeOf((*SigsetT).Sigfillset), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigaddset", reflect.TypeOf((*SigsetT).Sigaddset), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigdelset", reflect.TypeOf((*SigsetT).Sigdelset), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigismember", reflect.TypeOf((*SigsetT).Sigismember), []signalABISlot{{8, 8, 5}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigprocmask", reflect.TypeOf(Sigprocmask), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigsuspend", reflect.TypeOf((*SigsetT).Sigsuspend), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigaction", reflect.TypeOf(Sigaction), []signalABISlot{{4, 4, 1}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigpending", reflect.TypeOf((*SigsetT).Sigpending), []signalABISlot{{8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigwait", reflect.TypeOf((*SigsetT).Sigwait), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigwaitinfo", reflect.TypeOf((*SigsetT).Sigwaitinfo), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*SigsetT.Sigtimedwait", reflect.TypeOf((*SigsetT).Sigtimedwait), []signalABISlot{{8, 8, 5}, {8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"Sigqueue", reflect.TypeOf(Sigqueue), []signalABISlot{{4, 4, 1}, {4, 4, 1}, {8, 8, 13}}, &signalABISlot{4, 4, 1}, false}, + {"Siginterrupt", reflect.TypeOf(Siginterrupt), []signalABISlot{{4, 4, 1}, {4, 4, 1}}, &signalABISlot{4, 4, 1}, false}, + {"Sigstack", reflect.TypeOf(Sigstack), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + {"*Sigaltstack.Sigaltstack", reflect.TypeOf((*Sigaltstack).Sigaltstack), []signalABISlot{{8, 8, 5}, {8, 8, 5}}, &signalABISlot{4, 4, 1}, false}, + } + // The static assignment checks arity, result, and exact Go parameter types. + // Reflecting the full signature would require missing c/time decl-mode method wrappers. + var _ func(lltime.ClockidT, *Sigevent, *lltime.TimerT) c.Int = TimerCreate + var signalStaticFunctionPrototypes = []struct { + name string + slots []struct { + label string + goType reflect.Type + got, want signalABISlot + } + }{ + {"TimerCreate", []struct { + label string + goType reflect.Type + got, want signalABISlot + }{ + {"clock", reflect.TypeOf(lltime.ClockidT(0)), signalABISlot{}, signalABISlot{4, 4, 1}}, + {"event", nil, signalABISlot{unsafe.Sizeof((*Sigevent)(nil)), unsafe.Alignof((*Sigevent)(nil)), 5}, signalABISlot{8, 8, 5}}, + {"timer", nil, signalABISlot{unsafe.Sizeof((*lltime.TimerT)(nil)), unsafe.Alignof((*lltime.TimerT)(nil)), 5}, signalABISlot{8, 8, 5}}, + {"result", reflect.TypeOf(c.Int(0)), signalABISlot{}, signalABISlot{4, 4, 1}}, + }}, + } + var signalTypeLayouts = []struct { + symbol, property string + got, want uintptr + }{ + {"SigactionT", "size", unsafe.Sizeof(*new(SigactionT)), 152}, + {"SigactionT", "alignment", unsafe.Alignof(*new(SigactionT)), 8}, + {"SigactionT", "X__SigactionHandler offset", unsafe.Offsetof((*new(SigactionT)).X__SigactionHandler), 0}, + {"SigactionT", "X__SigactionHandler size", unsafe.Sizeof((*new(SigactionT)).X__SigactionHandler), 8}, + {"SigactionT", "X__SigactionHandler alignment", unsafe.Alignof((*new(SigactionT)).X__SigactionHandler), 8}, + {"SigactionT", "SaMask offset", unsafe.Offsetof((*new(SigactionT)).SaMask), 8}, + {"SigactionT", "SaMask size", unsafe.Sizeof((*new(SigactionT)).SaMask), 128}, + {"SigactionT", "SaMask alignment", unsafe.Alignof((*new(SigactionT)).SaMask), 8}, + {"SigactionT", "SaFlags offset", unsafe.Offsetof((*new(SigactionT)).SaFlags), 136}, + {"SigactionT", "SaFlags size", unsafe.Sizeof((*new(SigactionT)).SaFlags), 4}, + {"SigactionT", "SaFlags alignment", unsafe.Alignof((*new(SigactionT)).SaFlags), 4}, + {"SigactionT", "SaRestorer offset", unsafe.Offsetof((*new(SigactionT)).SaRestorer), 144}, + {"SigactionT", "SaRestorer size", unsafe.Sizeof((*new(SigactionT)).SaRestorer), 8}, + {"SigactionT", "SaRestorer alignment", unsafe.Alignof((*new(SigactionT)).SaRestorer), 8}, + {"Sigval", "size", unsafe.Sizeof(*new(Sigval)), 8}, + {"Sigval", "alignment", unsafe.Alignof(*new(Sigval)), 8}, + {"SiginfoT", "size", unsafe.Sizeof(*new(SiginfoT)), 128}, + {"SiginfoT", "alignment", unsafe.Alignof(*new(SiginfoT)), 8}, + {"SiginfoT", "SiSigno offset", unsafe.Offsetof((*new(SiginfoT)).SiSigno), 0}, + {"SiginfoT", "SiSigno size", unsafe.Sizeof((*new(SiginfoT)).SiSigno), 4}, + {"SiginfoT", "SiSigno alignment", unsafe.Alignof((*new(SiginfoT)).SiSigno), 4}, + {"SiginfoT", "SiErrno offset", unsafe.Offsetof((*new(SiginfoT)).SiErrno), 4}, + {"SiginfoT", "SiErrno size", unsafe.Sizeof((*new(SiginfoT)).SiErrno), 4}, + {"SiginfoT", "SiErrno alignment", unsafe.Alignof((*new(SiginfoT)).SiErrno), 4}, + {"SiginfoT", "SiCode offset", unsafe.Offsetof((*new(SiginfoT)).SiCode), 8}, + {"SiginfoT", "SiCode size", unsafe.Sizeof((*new(SiginfoT)).SiCode), 4}, + {"SiginfoT", "SiCode alignment", unsafe.Alignof((*new(SiginfoT)).SiCode), 4}, + {"SiginfoT", "X_sifields offset", unsafe.Offsetof((*new(SiginfoT)).X_sifields), 16}, + {"SiginfoT", "X_sifields size", unsafe.Sizeof((*new(SiginfoT)).X_sifields), 112}, + {"SiginfoT", "X_sifields alignment", unsafe.Alignof((*new(SiginfoT)).X_sifields), 8}, + {"Sigevent", "size", unsafe.Sizeof(*new(Sigevent)), 64}, + {"Sigevent", "alignment", unsafe.Alignof(*new(Sigevent)), 8}, + {"Sigevent", "SigevValue offset", unsafe.Offsetof((*new(Sigevent)).SigevValue), 0}, + {"Sigevent", "SigevValue size", unsafe.Sizeof((*new(Sigevent)).SigevValue), 8}, + {"Sigevent", "SigevValue alignment", unsafe.Alignof((*new(Sigevent)).SigevValue), 8}, + {"Sigevent", "SigevSigno offset", unsafe.Offsetof((*new(Sigevent)).SigevSigno), 8}, + {"Sigevent", "SigevSigno size", unsafe.Sizeof((*new(Sigevent)).SigevSigno), 4}, + {"Sigevent", "SigevSigno alignment", unsafe.Alignof((*new(Sigevent)).SigevSigno), 4}, + {"Sigevent", "SigevNotify offset", unsafe.Offsetof((*new(Sigevent)).SigevNotify), 12}, + {"Sigevent", "SigevNotify size", unsafe.Sizeof((*new(Sigevent)).SigevNotify), 4}, + {"Sigevent", "SigevNotify alignment", unsafe.Alignof((*new(Sigevent)).SigevNotify), 4}, + {"Sigevent", "X_sigevUn offset", unsafe.Offsetof((*new(Sigevent)).X_sigevUn), 16}, + {"Sigevent", "X_sigevUn size", unsafe.Sizeof((*new(Sigevent)).X_sigevUn), 48}, + {"Sigevent", "X_sigevUn alignment", unsafe.Alignof((*new(Sigevent)).X_sigevUn), 8}, + {"SigvalT", "size", unsafe.Sizeof(*new(SigvalT)), 8}, + {"SigvalT", "alignment", unsafe.Alignof(*new(SigvalT)), 8}, + {"SigstackT", "size", unsafe.Sizeof(*new(SigstackT)), 16}, + {"SigstackT", "alignment", unsafe.Alignof(*new(SigstackT)), 8}, + {"SigstackT", "SsSp offset", unsafe.Offsetof((*new(SigstackT)).SsSp), 0}, + {"SigstackT", "SsSp size", unsafe.Sizeof((*new(SigstackT)).SsSp), 8}, + {"SigstackT", "SsSp alignment", unsafe.Alignof((*new(SigstackT)).SsSp), 8}, + {"SigstackT", "SsOnstack offset", unsafe.Offsetof((*new(SigstackT)).SsOnstack), 8}, + {"SigstackT", "SsOnstack size", unsafe.Sizeof((*new(SigstackT)).SsOnstack), 4}, + {"SigstackT", "SsOnstack alignment", unsafe.Alignof((*new(SigstackT)).SsOnstack), 4}, + {"Sigaltstack", "size", unsafe.Sizeof(*new(Sigaltstack)), 24}, + {"Sigaltstack", "alignment", unsafe.Alignof(*new(Sigaltstack)), 8}, + {"Sigaltstack", "SsSp offset", unsafe.Offsetof((*new(Sigaltstack)).SsSp), 0}, + {"Sigaltstack", "SsSp size", unsafe.Sizeof((*new(Sigaltstack)).SsSp), 8}, + {"Sigaltstack", "SsSp alignment", unsafe.Alignof((*new(Sigaltstack)).SsSp), 8}, + {"Sigaltstack", "SsFlags offset", unsafe.Offsetof((*new(Sigaltstack)).SsFlags), 8}, + {"Sigaltstack", "SsFlags size", unsafe.Sizeof((*new(Sigaltstack)).SsFlags), 4}, + {"Sigaltstack", "SsFlags alignment", unsafe.Alignof((*new(Sigaltstack)).SsFlags), 4}, + {"Sigaltstack", "SsSize offset", unsafe.Offsetof((*new(Sigaltstack)).SsSize), 16}, + {"Sigaltstack", "SsSize size", unsafe.Sizeof((*new(Sigaltstack)).SsSize), 8}, + {"Sigaltstack", "SsSize alignment", unsafe.Alignof((*new(Sigaltstack)).SsSize), 8}, + {"X__SighandlerT", "size", unsafe.Sizeof(*new(X__SighandlerT)), 8}, + {"X__SighandlerT", "alignment", unsafe.Alignof(*new(X__SighandlerT)), 8}, + {"SigsetT", "size", unsafe.Sizeof(*new(SigsetT)), 128}, + {"SigsetT", "alignment", unsafe.Alignof(*new(SigsetT)), 8}, + {"X__SigsetT", "size", unsafe.Sizeof(*new(X__SigsetT)), 128}, + {"X__SigsetT", "alignment", unsafe.Alignof(*new(X__SigsetT)), 8}, + {"X__SigsetT", "X__Val offset", unsafe.Offsetof((*new(X__SigsetT)).X__Val), 0}, + {"X__SigsetT", "X__Val size", unsafe.Sizeof((*new(X__SigsetT)).X__Val), 128}, + {"X__SigsetT", "X__Val alignment", unsafe.Alignof((*new(X__SigsetT)).X__Val), 8}, + {"SignalHandler", "size", unsafe.Sizeof(*new(SignalHandler)), 8}, + {"SignalHandler", "alignment", unsafe.Alignof(*new(SignalHandler)), 8}, + {"SigeventT", "size", unsafe.Sizeof(*new(SigeventT)), 64}, + {"SigeventT", "alignment", unsafe.Alignof(*new(SigeventT)), 8}, + {"_llcppg_anon_7", "size", unsafe.Sizeof(*new(_llcppg_anon_7)), 8}, + {"_llcppg_anon_7", "alignment", unsafe.Alignof(*new(_llcppg_anon_7)), 8}, + {"_llcppg_anon_5", "size", unsafe.Sizeof(*new(_llcppg_anon_5)), 112}, + {"_llcppg_anon_5", "alignment", unsafe.Alignof(*new(_llcppg_anon_5)), 8}, + {"_llcppg_anon_6", "size", unsafe.Sizeof(*new(_llcppg_anon_6)), 48}, + {"_llcppg_anon_6", "alignment", unsafe.Alignof(*new(_llcppg_anon_6)), 8}, + {"_llcppg_anon_23", "size", unsafe.Sizeof(*new(_llcppg_anon_23)), 8}, + {"_llcppg_anon_23", "alignment", unsafe.Alignof(*new(_llcppg_anon_23)), 4}, + {"_llcppg_anon_23", "SiPid offset", unsafe.Offsetof((*new(_llcppg_anon_23)).SiPid), 0}, + {"_llcppg_anon_23", "SiPid size", unsafe.Sizeof((*new(_llcppg_anon_23)).SiPid), 4}, + {"_llcppg_anon_23", "SiPid alignment", unsafe.Alignof((*new(_llcppg_anon_23)).SiPid), 4}, + {"_llcppg_anon_23", "SiUid offset", unsafe.Offsetof((*new(_llcppg_anon_23)).SiUid), 4}, + {"_llcppg_anon_23", "SiUid size", unsafe.Sizeof((*new(_llcppg_anon_23)).SiUid), 4}, + {"_llcppg_anon_23", "SiUid alignment", unsafe.Alignof((*new(_llcppg_anon_23)).SiUid), 4}, + {"_llcppg_anon_24", "size", unsafe.Sizeof(*new(_llcppg_anon_24)), 16}, + {"_llcppg_anon_24", "alignment", unsafe.Alignof(*new(_llcppg_anon_24)), 8}, + {"_llcppg_anon_24", "SiTid offset", unsafe.Offsetof((*new(_llcppg_anon_24)).SiTid), 0}, + {"_llcppg_anon_24", "SiTid size", unsafe.Sizeof((*new(_llcppg_anon_24)).SiTid), 4}, + {"_llcppg_anon_24", "SiTid alignment", unsafe.Alignof((*new(_llcppg_anon_24)).SiTid), 4}, + {"_llcppg_anon_24", "SiOverrun offset", unsafe.Offsetof((*new(_llcppg_anon_24)).SiOverrun), 4}, + {"_llcppg_anon_24", "SiOverrun size", unsafe.Sizeof((*new(_llcppg_anon_24)).SiOverrun), 4}, + {"_llcppg_anon_24", "SiOverrun alignment", unsafe.Alignof((*new(_llcppg_anon_24)).SiOverrun), 4}, + {"_llcppg_anon_24", "SiSigval offset", unsafe.Offsetof((*new(_llcppg_anon_24)).SiSigval), 8}, + {"_llcppg_anon_24", "SiSigval size", unsafe.Sizeof((*new(_llcppg_anon_24)).SiSigval), 8}, + {"_llcppg_anon_24", "SiSigval alignment", unsafe.Alignof((*new(_llcppg_anon_24)).SiSigval), 8}, + {"_llcppg_anon_25", "size", unsafe.Sizeof(*new(_llcppg_anon_25)), 16}, + {"_llcppg_anon_25", "alignment", unsafe.Alignof(*new(_llcppg_anon_25)), 8}, + {"_llcppg_anon_25", "SiPid offset", unsafe.Offsetof((*new(_llcppg_anon_25)).SiPid), 0}, + {"_llcppg_anon_25", "SiPid size", unsafe.Sizeof((*new(_llcppg_anon_25)).SiPid), 4}, + {"_llcppg_anon_25", "SiPid alignment", unsafe.Alignof((*new(_llcppg_anon_25)).SiPid), 4}, + {"_llcppg_anon_25", "SiUid offset", unsafe.Offsetof((*new(_llcppg_anon_25)).SiUid), 4}, + {"_llcppg_anon_25", "SiUid size", unsafe.Sizeof((*new(_llcppg_anon_25)).SiUid), 4}, + {"_llcppg_anon_25", "SiUid alignment", unsafe.Alignof((*new(_llcppg_anon_25)).SiUid), 4}, + {"_llcppg_anon_25", "SiSigval offset", unsafe.Offsetof((*new(_llcppg_anon_25)).SiSigval), 8}, + {"_llcppg_anon_25", "SiSigval size", unsafe.Sizeof((*new(_llcppg_anon_25)).SiSigval), 8}, + {"_llcppg_anon_25", "SiSigval alignment", unsafe.Alignof((*new(_llcppg_anon_25)).SiSigval), 8}, + {"_llcppg_anon_26", "size", unsafe.Sizeof(*new(_llcppg_anon_26)), 32}, + {"_llcppg_anon_26", "alignment", unsafe.Alignof(*new(_llcppg_anon_26)), 8}, + {"_llcppg_anon_26", "SiPid offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiPid), 0}, + {"_llcppg_anon_26", "SiPid size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiPid), 4}, + {"_llcppg_anon_26", "SiPid alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiPid), 4}, + {"_llcppg_anon_26", "SiUid offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiUid), 4}, + {"_llcppg_anon_26", "SiUid size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiUid), 4}, + {"_llcppg_anon_26", "SiUid alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiUid), 4}, + {"_llcppg_anon_26", "SiStatus offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiStatus), 8}, + {"_llcppg_anon_26", "SiStatus size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiStatus), 4}, + {"_llcppg_anon_26", "SiStatus alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiStatus), 4}, + {"_llcppg_anon_26", "SiUtime offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiUtime), 16}, + {"_llcppg_anon_26", "SiUtime size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiUtime), 8}, + {"_llcppg_anon_26", "SiUtime alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiUtime), 8}, + {"_llcppg_anon_26", "SiStime offset", unsafe.Offsetof((*new(_llcppg_anon_26)).SiStime), 24}, + {"_llcppg_anon_26", "SiStime size", unsafe.Sizeof((*new(_llcppg_anon_26)).SiStime), 8}, + {"_llcppg_anon_26", "SiStime alignment", unsafe.Alignof((*new(_llcppg_anon_26)).SiStime), 8}, + {"_llcppg_anon_27", "size", unsafe.Sizeof(*new(_llcppg_anon_27)), 16}, + {"_llcppg_anon_27", "alignment", unsafe.Alignof(*new(_llcppg_anon_27)), 8}, + {"_llcppg_anon_27", "SiAddr offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiAddr), 0}, + {"_llcppg_anon_27", "SiAddr size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiAddr), 8}, + {"_llcppg_anon_27", "SiAddr alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiAddr), 8}, + {"_llcppg_anon_27", "SiAddrLsb offset", unsafe.Offsetof((*new(_llcppg_anon_27)).SiAddrLsb), 8}, + {"_llcppg_anon_27", "SiAddrLsb size", unsafe.Sizeof((*new(_llcppg_anon_27)).SiAddrLsb), 2}, + {"_llcppg_anon_27", "SiAddrLsb alignment", unsafe.Alignof((*new(_llcppg_anon_27)).SiAddrLsb), 2}, + {"_llcppg_anon_28", "size", unsafe.Sizeof(*new(_llcppg_anon_28)), 16}, + {"_llcppg_anon_28", "alignment", unsafe.Alignof(*new(_llcppg_anon_28)), 8}, + {"_llcppg_anon_28", "SiBand offset", unsafe.Offsetof((*new(_llcppg_anon_28)).SiBand), 0}, + {"_llcppg_anon_28", "SiBand size", unsafe.Sizeof((*new(_llcppg_anon_28)).SiBand), 8}, + {"_llcppg_anon_28", "SiBand alignment", unsafe.Alignof((*new(_llcppg_anon_28)).SiBand), 8}, + {"_llcppg_anon_28", "SiFd offset", unsafe.Offsetof((*new(_llcppg_anon_28)).SiFd), 8}, + {"_llcppg_anon_28", "SiFd size", unsafe.Sizeof((*new(_llcppg_anon_28)).SiFd), 4}, + {"_llcppg_anon_28", "SiFd alignment", unsafe.Alignof((*new(_llcppg_anon_28)).SiFd), 4}, + {"_llcppg_anon_29", "size", unsafe.Sizeof(*new(_llcppg_anon_29)), 16}, + {"_llcppg_anon_29", "alignment", unsafe.Alignof(*new(_llcppg_anon_29)), 8}, + {"_llcppg_anon_29", "X_callAddr offset", unsafe.Offsetof((*new(_llcppg_anon_29)).X_callAddr), 0}, + {"_llcppg_anon_29", "X_callAddr size", unsafe.Sizeof((*new(_llcppg_anon_29)).X_callAddr), 8}, + {"_llcppg_anon_29", "X_callAddr alignment", unsafe.Alignof((*new(_llcppg_anon_29)).X_callAddr), 8}, + {"_llcppg_anon_29", "X_syscall offset", unsafe.Offsetof((*new(_llcppg_anon_29)).X_syscall), 8}, + {"_llcppg_anon_29", "X_syscall size", unsafe.Sizeof((*new(_llcppg_anon_29)).X_syscall), 4}, + {"_llcppg_anon_29", "X_syscall alignment", unsafe.Alignof((*new(_llcppg_anon_29)).X_syscall), 4}, + {"_llcppg_anon_29", "X_arch offset", unsafe.Offsetof((*new(_llcppg_anon_29)).X_arch), 12}, + {"_llcppg_anon_29", "X_arch size", unsafe.Sizeof((*new(_llcppg_anon_29)).X_arch), 4}, + {"_llcppg_anon_29", "X_arch alignment", unsafe.Alignof((*new(_llcppg_anon_29)).X_arch), 4}, + {"_llcppg_anon_30", "size", unsafe.Sizeof(*new(_llcppg_anon_30)), 16}, + {"_llcppg_anon_30", "alignment", unsafe.Alignof(*new(_llcppg_anon_30)), 8}, + {"_llcppg_anon_30", "X_function offset", unsafe.Offsetof((*new(_llcppg_anon_30)).X_function), 0}, + {"_llcppg_anon_30", "X_function size", unsafe.Sizeof((*new(_llcppg_anon_30)).X_function), 8}, + {"_llcppg_anon_30", "X_function alignment", unsafe.Alignof((*new(_llcppg_anon_30)).X_function), 8}, + {"_llcppg_anon_30", "X_attribute offset", unsafe.Offsetof((*new(_llcppg_anon_30)).X_attribute), 8}, + {"_llcppg_anon_30", "X_attribute size", unsafe.Sizeof((*new(_llcppg_anon_30)).X_attribute), 8}, + {"_llcppg_anon_30", "X_attribute alignment", unsafe.Alignof((*new(_llcppg_anon_30)).X_attribute), 8}, + } + var signalIntegerConstants = []struct { + name string + got, want int64 + }{ + {"SA_NOCLDSTOP", int64(SA_NOCLDSTOP), 1}, + {"SA_NOCLDWAIT", int64(SA_NOCLDWAIT), 2}, + {"SA_SIGINFO", int64(SA_SIGINFO), 4}, + {"SA_ONSTACK", int64(SA_ONSTACK), 134217728}, + {"SA_RESTART", int64(SA_RESTART), 268435456}, + {"SA_NODEFER", int64(SA_NODEFER), 1073741824}, + {"SA_RESETHAND", int64(SA_RESETHAND), 2147483648}, + {"SA_INTERRUPT", int64(SA_INTERRUPT), 536870912}, + {"SA_NOMASK", int64(SA_NOMASK), 1073741824}, + {"SA_ONESHOT", int64(SA_ONESHOT), 2147483648}, + {"SA_STACK", int64(SA_STACK), 134217728}, + {"SIG_BLOCK", int64(SIG_BLOCK), 0}, + {"SIG_UNBLOCK", int64(SIG_UNBLOCK), 1}, + {"SIG_SETMASK", int64(SIG_SETMASK), 2}, + {"SI_ASYNCNL", int64(SI_ASYNCNL), -60}, + {"SI_TKILL", int64(SI_TKILL), -6}, + {"SI_SIGIO", int64(SI_SIGIO), -5}, + {"SI_ASYNCIO", int64(SI_ASYNCIO), -4}, + {"SI_MESGQ", int64(SI_MESGQ), -3}, + {"SI_TIMER", int64(SI_TIMER), -2}, + {"SI_QUEUE", int64(SI_QUEUE), -1}, + {"SI_USER", int64(SI_USER), 0}, + {"SI_KERNEL", int64(SI_KERNEL), 128}, + {"ILL_ILLOPC", int64(ILL_ILLOPC), 1}, + {"ILL_ILLOPN", int64(ILL_ILLOPN), 2}, + {"ILL_ILLADR", int64(ILL_ILLADR), 3}, + {"ILL_ILLTRP", int64(ILL_ILLTRP), 4}, + {"ILL_PRVOPC", int64(ILL_PRVOPC), 5}, + {"ILL_PRVREG", int64(ILL_PRVREG), 6}, + {"ILL_COPROC", int64(ILL_COPROC), 7}, + {"ILL_BADSTK", int64(ILL_BADSTK), 8}, + {"FPE_INTDIV", int64(FPE_INTDIV), 1}, + {"FPE_INTOVF", int64(FPE_INTOVF), 2}, + {"FPE_FLTDIV", int64(FPE_FLTDIV), 3}, + {"FPE_FLTOVF", int64(FPE_FLTOVF), 4}, + {"FPE_FLTUND", int64(FPE_FLTUND), 5}, + {"FPE_FLTRES", int64(FPE_FLTRES), 6}, + {"FPE_FLTINV", int64(FPE_FLTINV), 7}, + {"FPE_FLTSUB", int64(FPE_FLTSUB), 8}, + {"SEGV_MAPERR", int64(SEGV_MAPERR), 1}, + {"SEGV_ACCERR", int64(SEGV_ACCERR), 2}, + {"BUS_ADRALN", int64(BUS_ADRALN), 1}, + {"BUS_ADRERR", int64(BUS_ADRERR), 2}, + {"BUS_OBJERR", int64(BUS_OBJERR), 3}, + {"BUS_MCEERR_AR", int64(BUS_MCEERR_AR), 4}, + {"BUS_MCEERR_AO", int64(BUS_MCEERR_AO), 5}, + {"CLD_EXITED", int64(CLD_EXITED), 1}, + {"CLD_KILLED", int64(CLD_KILLED), 2}, + {"CLD_DUMPED", int64(CLD_DUMPED), 3}, + {"CLD_TRAPPED", int64(CLD_TRAPPED), 4}, + {"CLD_STOPPED", int64(CLD_STOPPED), 5}, + {"CLD_CONTINUED", int64(CLD_CONTINUED), 6}, + {"POLL_IN", int64(POLL_IN), 1}, + {"POLL_OUT", int64(POLL_OUT), 2}, + {"POLL_MSG", int64(POLL_MSG), 3}, + {"POLL_ERR", int64(POLL_ERR), 4}, + {"POLL_PRI", int64(POLL_PRI), 5}, + {"POLL_HUP", int64(POLL_HUP), 6}, + {"SIGEV_SIGNAL", int64(SIGEV_SIGNAL), 0}, + {"SIGEV_NONE", int64(SIGEV_NONE), 1}, + {"SIGEV_THREAD", int64(SIGEV_THREAD), 2}, + {"SIGEV_THREAD_ID", int64(SIGEV_THREAD_ID), 4}, + {"SIGHUP", int64(SIGHUP), 1}, + {"SIGINT", int64(SIGINT), 2}, + {"SIGQUIT", int64(SIGQUIT), 3}, + {"SIGILL", int64(SIGILL), 4}, + {"SIGTRAP", int64(SIGTRAP), 5}, + {"SIGABRT", int64(SIGABRT), 6}, + {"SIGIOT", int64(SIGIOT), 6}, + {"SIGBUS", int64(SIGBUS), 7}, + {"SIGFPE", int64(SIGFPE), 8}, + {"SIGKILL", int64(SIGKILL), 9}, + {"SIGUSR1", int64(SIGUSR1), 10}, + {"SIGSEGV", int64(SIGSEGV), 11}, + {"SIGUSR2", int64(SIGUSR2), 12}, + {"SIGPIPE", int64(SIGPIPE), 13}, + {"SIGALRM", int64(SIGALRM), 14}, + {"SIGTERM", int64(SIGTERM), 15}, + {"SIGSTKFLT", int64(SIGSTKFLT), 16}, + {"SIGCHLD", int64(SIGCHLD), 17}, + {"SIGCONT", int64(SIGCONT), 18}, + {"SIGSTOP", int64(SIGSTOP), 19}, + {"SIGTSTP", int64(SIGTSTP), 20}, + {"SIGTTIN", int64(SIGTTIN), 21}, + {"SIGTTOU", int64(SIGTTOU), 22}, + {"SIGURG", int64(SIGURG), 23}, + {"SIGXCPU", int64(SIGXCPU), 24}, + {"SIGXFSZ", int64(SIGXFSZ), 25}, + {"SIGVTALRM", int64(SIGVTALRM), 26}, + {"SIGPROF", int64(SIGPROF), 27}, + {"SIGWINCH", int64(SIGWINCH), 28}, + {"SIGIO", int64(SIGIO), 29}, + {"SIGPWR", int64(SIGPWR), 30}, + {"SIGSYS", int64(SIGSYS), 31}, + {"SIGUNUSED", int64(SIGUNUSED), 31}, + {"NSIG", int64(NSIG), 65}, + } + var signalVariableSymbols = []struct { + name string + address unsafe.Pointer + }{} + var signalAccessorChecks = []struct { + name string + check func() (uintptr, uintptr, uintptr) + offset, size, align uintptr + }{ + {"*_llcppg_anon_7.XGof_ref_sa_handler", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_7 + view := value.XGof_ref_sa_handler() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*_llcppg_anon_7.XGof_ref_sa_sigaction", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_7 + view := value.XGof_ref_sa_sigaction() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*Sigval.XGof_ref_sival_int", func() (uintptr, uintptr, uintptr) { + var value Sigval + view := value.XGof_ref_sival_int() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 4, 4}, + {"*Sigval.XGof_ref_sival_ptr", func() (uintptr, uintptr, uintptr) { + var value Sigval + view := value.XGof_ref_sival_ptr() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 8}, + {"*_llcppg_anon_5.XGof_ref__pad", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__pad() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 112, 4}, + {"*_llcppg_anon_5.XGof_ref__kill", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__kill() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 8, 4}, + {"*_llcppg_anon_5.XGof_ref__timer", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__timer() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__rt", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__rt() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__sigchld", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigchld() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 32, 8}, + {"*_llcppg_anon_5.XGof_ref__sigfault", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigfault() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__sigpoll", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigpoll() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_5.XGof_ref__sigsys", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_5 + view := value.XGof_ref__sigsys() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + {"*_llcppg_anon_6.XGof_ref__pad", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_6 + view := value.XGof_ref__pad() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 48, 4}, + {"*_llcppg_anon_6.XGof_ref__tid", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_6 + view := value.XGof_ref__tid() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 4, 4}, + {"*_llcppg_anon_6.XGof_ref__sigev_thread", func() (uintptr, uintptr, uintptr) { + var value _llcppg_anon_6 + view := value.XGof_ref__sigev_thread() + return uintptr(unsafe.Pointer(view)) - uintptr(unsafe.Pointer(&value)), unsafe.Sizeof(*view), unsafe.Alignof(*view) + }, 0, 16, 8}, + } + + t.Run("function symbols", func(t *testing.T) { + for _, symbol := range signalFunctionSymbols { + t.Run(symbol.name, func(t *testing.T) { + if symbol.address == nil { + t.Fatal("C function address is nil") + } + t.Logf("C function address: %p", symbol.address) + }) + } + }) + t.Run("native prototypes", func(t *testing.T) { + check := func(name string, got reflect.Type, want signalABISlot) { + if got.Size() != want.size || uintptr(got.Align()) != want.align { + t.Errorf("%s size/alignment = %d/%d, C = %d/%d", name, got.Size(), got.Align(), want.size, want.align) + } + class := 0 + switch got.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + class = 1 + case reflect.Ptr, reflect.UnsafePointer, reflect.Func: + class = 5 + case reflect.Float32, reflect.Float64: + class = 8 + case reflect.Struct: + class = 12 + if got.NumField() == 1 && got.Field(0).Name == "_xgo_union" { + class = 13 + } + } + if class != want.class { + t.Errorf("%s ABI class = %d (%v), C = %d", name, class, got.Kind(), want.class) + } + } + for _, tc := range signalFunctionPrototypes { + t.Run(tc.name, func(t *testing.T) { + inputs := len(tc.inputs) + if tc.variadic { + inputs++ + } + if tc.signature.Kind() != reflect.Func || tc.signature.NumIn() != inputs || tc.signature.IsVariadic() != tc.variadic { + t.Fatalf("Go signature = %v, C fixed parameters = %d, variadic = %v", tc.signature, len(tc.inputs), tc.variadic) + } + for i, slot := range tc.inputs { + check(tc.name+" parameter", tc.signature.In(i), slot) + } + outputs := 0 + if tc.output != nil { + outputs = 1 + } + if tc.signature.NumOut() != outputs { + t.Fatalf("Go result count = %d, C = %d", tc.signature.NumOut(), outputs) + } + if tc.output != nil { + check(tc.name+" result", tc.signature.Out(0), *tc.output) + } + }) + } + for _, tc := range signalStaticFunctionPrototypes { + t.Run(tc.name, func(t *testing.T) { + for _, slot := range tc.slots { + if slot.goType != nil { + check(tc.name+" "+slot.label, slot.goType, slot.want) + } else if slot.got != slot.want { + t.Errorf("%s %s ABI = %+v, C = %+v", tc.name, slot.label, slot.got, slot.want) + } + } + }) + } + + }) + t.Run("native types and globals", func(t *testing.T) { + for _, tc := range signalTypeLayouts { + t.Run(tc.symbol+"/"+tc.property, func(t *testing.T) { + if tc.got != tc.want { + t.Fatalf("Go layout = %d, C headers = %d", tc.got, tc.want) + } + }) + } + for _, symbol := range signalVariableSymbols { + if symbol.address == nil { + t.Errorf("%s C variable address is nil", symbol.name) + } + t.Logf("%s C variable address: %p", symbol.name, symbol.address) + } + }) + t.Run("native constants", func(t *testing.T) { + for _, tc := range signalIntegerConstants { + t.Run(tc.name, func(t *testing.T) { + if tc.got != tc.want { + t.Fatalf("Go constant = %d, C headers = %d", tc.got, tc.want) + } + }) + } + }) + t.Run("union accessors", func(t *testing.T) { + for _, tc := range signalAccessorChecks { + t.Run(tc.name, func(t *testing.T) { + offset, size, align := tc.check() + if offset != tc.offset || size != tc.size || align != tc.align { + t.Fatalf("Go field offset/size/alignment = %d/%d/%d, C = %d/%d/%d", offset, size, align, tc.offset, tc.size, tc.align) + } + }) + } + }) + t.Run("symbol inventory", func(t *testing.T) { + functions, prototypes, types, constants, variables := map[string]bool{}, map[string]bool{}, map[string]bool{}, map[string]bool{}, map[string]bool{} + for _, tc := range signalFunctionPrototypes { + prototypes[tc.name] = true + } + for _, tc := range signalStaticFunctionPrototypes { + prototypes[tc.name] = true + } + + for _, symbol := range signalFunctionSymbols { + functions[symbol.name] = true + if !prototypes[symbol.name] { + t.Errorf("%s has no native prototype test", symbol.name) + } + } + for _, tc := range signalAccessorChecks { + functions[tc.name] = true + } + for _, tc := range signalTypeLayouts { + types[tc.symbol] = true + } + for _, tc := range signalIntegerConstants { + constants[tc.name] = true + } + for _, symbol := range signalVariableSymbols { + variables[symbol.name] = true + } + constants["LLGoPackage"] = true + functions["Signal"] = true + if LLGoPackage != "link" { + t.Errorf("LLGoPackage = %q, want link", LLGoPackage) + } + files := []string{"libc_" + runtime.GOOS + "_" + runtime.GOARCH + ".go"} + + for _, filename := range files { + source, err := parser.ParseFile(token.NewFileSet(), filename, nil, parser.ParseComments) + if err != nil { + t.Fatal(err) + } + for _, declaration := range source.Decls { + switch decl := declaration.(type) { + case *ast.FuncDecl: + name := decl.Name.Name + if !ast.IsExported(name) { + continue + } + if decl.Recv != nil { + receiver, prefix := decl.Recv.List[0].Type, "" + if pointer, ok := receiver.(*ast.StarExpr); ok { + receiver, prefix = pointer.X, "*" + } + name = prefix + receiver.(*ast.Ident).Name + "." + name + } + if !functions[name] { + t.Errorf("%s: function %s has no test", filename, name) + } + if strings.HasPrefix(decl.Name.Name, "Native") && decl.Name.Name != "NativeSignal" { + t.Errorf("%s retains duplicate %s", filename, name) + } + if decl.Doc != nil { + for _, comment := range decl.Doc.List { + for _, private := range []string{"C._llcppg_", "C.__sig", "C.__sysv_signal", "C.__libc_current_sigrt"} { + if strings.Contains(comment.Text, private) { + t.Errorf("%s still exposes private C entry point %s", filename, private) + } + } + } + } + case *ast.GenDecl: + for _, specification := range decl.Specs { + switch spec := specification.(type) { + case *ast.TypeSpec: + if ast.IsExported(spec.Name.Name) && !types[spec.Name.Name] { + t.Errorf("%s: type %s has no ABI test", filename, spec.Name.Name) + } + case *ast.ValueSpec: + for _, name := range spec.Names { + if !ast.IsExported(name.Name) { + continue + } + if decl.Tok == token.CONST && !constants[name.Name] { + t.Errorf("%s: constant %s has no test", filename, name.Name) + } + if decl.Tok == token.VAR && !variables[name.Name] { + t.Errorf("%s: variable %s has no test", filename, name.Name) + } + } + } + } + } + } + } + t.Logf("coverage: %d C functions, %d Go union accessors, %d types/global layouts, %d constants, %d globals", len(signalFunctionSymbols), len(signalAccessorChecks), len(signalTypeLayouts), len(constants), len(signalVariableSymbols)) + }) + + var set SigsetT + var info SiginfoT + var value Sigval + if unsafe.Sizeof(set) != nativeSigsetSize || unsafe.Alignof(set) != nativeSigsetAlign { + t.Fatalf("sigset_t = %d/%d, want %d/%d", unsafe.Sizeof(set), unsafe.Alignof(set), nativeSigsetSize, nativeSigsetAlign) + } + if unsafe.Sizeof(info) != nativeSiginfoSize || unsafe.Alignof(info) != 8 { + t.Fatalf("siginfo_t = %d/%d, want %d/8", unsafe.Sizeof(info), unsafe.Alignof(info), nativeSiginfoSize) + } + if unsafe.Offsetof(info.SiSigno) != 0 || unsafe.Offsetof(info.SiErrno) != 4 || unsafe.Offsetof(info.SiCode) != 8 { + t.Fatalf("siginfo_t header offsets = %d/%d/%d", unsafe.Offsetof(info.SiSigno), unsafe.Offsetof(info.SiErrno), unsafe.Offsetof(info.SiCode)) + } + if unsafe.Sizeof(value) != 8 || unsafe.Alignof(value) != 8 { + t.Fatalf("sigval = %d/%d, want 8/8", unsafe.Sizeof(value), unsafe.Alignof(value)) + } + *value.XGof_ref_sival_int() = -7 + if got := *(*c.Int)(unsafe.Pointer(&value)); got != -7 { + t.Fatalf("sigval integer storage = %d, want -7", got) + } + var marker uintptr + *value.XGof_ref_sival_ptr() = unsafe.Pointer(&marker) + if got := *(*unsafe.Pointer)(unsafe.Pointer(&value)); got != unsafe.Pointer(&marker) { + t.Fatalf("sigval pointer storage = %p, want %p", got, &marker) + } + +}