package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint32
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type stackt struct {
ss_sp *byte
ss_flags int32
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
data [8]byte // to match amd64
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
data [8]byte // unaligned uintptr
package runtime
+import "unsafe"
+
// Constants
const (
_EINTR = 0x4
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
-type siginfo struct {
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint32
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type sigactiont struct {
sa_handler uintptr
sa_flags uint32
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
_pad uint32
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_restorer uintptr
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_code int32
si_errno int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
pad_cgo_0 [4]byte
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_restorer uintptr
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_code int32
si_errno int32
si_addr uint32
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
pad_cgo_0 [4]byte
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
pad_cgo_0 [4]byte
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
pad_cgo_0 [4]byte
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
pad_cgo_0 [4]byte
package runtime
+import "unsafe"
+
const (
_EINTR = 0x4
_EAGAIN = 0xb
sa_mask uint64
}
-type siginfo struct {
+type siginfoFields struct {
si_signo int32
si_errno int32
si_code int32
si_addr uint64
}
+type siginfo struct {
+ siginfoFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
+}
+
type itimerspec struct {
it_interval timespec
it_value timespec
it_value timeval
}
-type sigevent struct {
+type sigeventFields struct {
value uintptr
signo int32
notify int32
sigev_notify_thread_id int32
}
+type sigevent struct {
+ sigeventFields
+
+ // Pad struct to the max size in the kernel.
+ _ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
+}
+
type epollevent struct {
events uint32
pad_cgo_0 [4]byte
import "unsafe"
+const SiginfoMaxSize = _si_max_size
+const SigeventMaxSize = _sigev_max_size
+
var NewOSProc0 = newosproc0
var Mincore = mincore
var Add = add
type EpollEvent epollevent
+type Siginfo siginfo
+type Sigevent sigevent
func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 {
return epollctl(epfd, op, fd, (*epollevent)(ev))
func pipe2(flags int32) (r, w int32, errno int32)
func setNonblock(fd int32)
+const (
+ _si_max_size = 128
+ _sigev_max_size = 64
+)
+
//go:nosplit
//go:nowritebarrierrec
func setsig(i uint32, fn uintptr) {
spec.it_interval.setNsec(1e9 / int64(hz))
var timerid int32
- sevp := &sigevent{
- notify: _SIGEV_THREAD_ID,
- signo: _SIGPROF,
- sigev_notify_thread_id: int32(mp.procid),
- }
- ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, sevp, &timerid)
+ var sevp sigevent
+ sevp.notify = _SIGEV_THREAD_ID
+ sevp.signo = _SIGPROF
+ sevp.sigev_notify_thread_id = int32(mp.procid)
+ ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, &sevp, &timerid)
if ret != 0 {
// If we cannot create a timer for this M, leave profileTimerValid false
// to fall back to the process-wide setitimer profiler.
t.Errorf("epollctl = %v, want %v", v, -EBADF)
}
}
+
+func TestKernelStructSize(t *testing.T) {
+ // Check that the Go definitions of structures exchanged with the kernel are
+ // the same size as what the kernel defines.
+ if have, want := unsafe.Sizeof(Siginfo{}), uintptr(SiginfoMaxSize); have != want {
+ t.Errorf("Go's siginfo struct is %d bytes long; kernel expects %d", have, want)
+ }
+ if have, want := unsafe.Sizeof(Sigevent{}), uintptr(SigeventMaxSize); have != want {
+ t.Errorf("Go's sigevent struct is %d bytes long; kernel expects %d", have, want)
+ }
+}