1package runtime
2
3// Constants
4const (
5	_EINTR  = 0x4
6	_ENOMEM = 0xc
7	_EAGAIN = 0xb
8	_ENOSYS = 0x26
9
10	_PROT_NONE  = 0
11	_PROT_READ  = 0x1
12	_PROT_WRITE = 0x2
13	_PROT_EXEC  = 0x4
14
15	_MAP_ANON    = 0x20
16	_MAP_PRIVATE = 0x2
17	_MAP_FIXED   = 0x10
18
19	_MADV_DONTNEED   = 0x4
20	_MADV_FREE       = 0x8
21	_MADV_HUGEPAGE   = 0xe
22	_MADV_NOHUGEPAGE = 0xf
23
24	_SA_RESTART     = 0x10000000
25	_SA_ONSTACK     = 0x8000000
26	_SA_RESTORER    = 0 // unused on ARM
27	_SA_SIGINFO     = 0x4
28	_SIGHUP         = 0x1
29	_SIGINT         = 0x2
30	_SIGQUIT        = 0x3
31	_SIGILL         = 0x4
32	_SIGTRAP        = 0x5
33	_SIGABRT        = 0x6
34	_SIGBUS         = 0x7
35	_SIGFPE         = 0x8
36	_SIGKILL        = 0x9
37	_SIGUSR1        = 0xa
38	_SIGSEGV        = 0xb
39	_SIGUSR2        = 0xc
40	_SIGPIPE        = 0xd
41	_SIGALRM        = 0xe
42	_SIGSTKFLT      = 0x10
43	_SIGCHLD        = 0x11
44	_SIGCONT        = 0x12
45	_SIGSTOP        = 0x13
46	_SIGTSTP        = 0x14
47	_SIGTTIN        = 0x15
48	_SIGTTOU        = 0x16
49	_SIGURG         = 0x17
50	_SIGXCPU        = 0x18
51	_SIGXFSZ        = 0x19
52	_SIGVTALRM      = 0x1a
53	_SIGPROF        = 0x1b
54	_SIGWINCH       = 0x1c
55	_SIGIO          = 0x1d
56	_SIGPWR         = 0x1e
57	_SIGSYS         = 0x1f
58	_FPE_INTDIV     = 0x1
59	_FPE_INTOVF     = 0x2
60	_FPE_FLTDIV     = 0x3
61	_FPE_FLTOVF     = 0x4
62	_FPE_FLTUND     = 0x5
63	_FPE_FLTRES     = 0x6
64	_FPE_FLTINV     = 0x7
65	_FPE_FLTSUB     = 0x8
66	_BUS_ADRALN     = 0x1
67	_BUS_ADRERR     = 0x2
68	_BUS_OBJERR     = 0x3
69	_SEGV_MAPERR    = 0x1
70	_SEGV_ACCERR    = 0x2
71	_ITIMER_REAL    = 0
72	_ITIMER_PROF    = 0x2
73	_ITIMER_VIRTUAL = 0x1
74	_O_RDONLY       = 0
75	_O_NONBLOCK     = 0x800
76	_O_CLOEXEC      = 0x80000
77
78	_EPOLLIN       = 0x1
79	_EPOLLOUT      = 0x4
80	_EPOLLERR      = 0x8
81	_EPOLLHUP      = 0x10
82	_EPOLLRDHUP    = 0x2000
83	_EPOLLET       = 0x80000000
84	_EPOLL_CLOEXEC = 0x80000
85	_EPOLL_CTL_ADD = 0x1
86	_EPOLL_CTL_DEL = 0x2
87	_EPOLL_CTL_MOD = 0x3
88
89	_AF_UNIX    = 0x1
90	_F_SETFL    = 0x4
91	_SOCK_DGRAM = 0x2
92)
93
94type timespec struct {
95	tv_sec  int32
96	tv_nsec int32
97}
98
99//go:nosplit
100func (ts *timespec) setNsec(ns int64) {
101	ts.tv_sec = timediv(ns, 1e9, &ts.tv_nsec)
102}
103
104type stackt struct {
105	ss_sp    *byte
106	ss_flags int32
107	ss_size  uintptr
108}
109
110type sigcontext struct {
111	trap_no       uint32
112	error_code    uint32
113	oldmask       uint32
114	r0            uint32
115	r1            uint32
116	r2            uint32
117	r3            uint32
118	r4            uint32
119	r5            uint32
120	r6            uint32
121	r7            uint32
122	r8            uint32
123	r9            uint32
124	r10           uint32
125	fp            uint32
126	ip            uint32
127	sp            uint32
128	lr            uint32
129	pc            uint32
130	cpsr          uint32
131	fault_address uint32
132}
133
134type ucontext struct {
135	uc_flags    uint32
136	uc_link     *ucontext
137	uc_stack    stackt
138	uc_mcontext sigcontext
139	uc_sigmask  uint32
140	__unused    [31]int32
141	uc_regspace [128]uint32
142}
143
144type timeval struct {
145	tv_sec  int32
146	tv_usec int32
147}
148
149func (tv *timeval) set_usec(x int32) {
150	tv.tv_usec = x
151}
152
153type itimerval struct {
154	it_interval timeval
155	it_value    timeval
156}
157
158type siginfo struct {
159	si_signo int32
160	si_errno int32
161	si_code  int32
162	// below here is a union; si_addr is the only field we use
163	si_addr uint32
164}
165
166type sigactiont struct {
167	sa_handler  uintptr
168	sa_flags    uint32
169	sa_restorer uintptr
170	sa_mask     uint64
171}
172
173type epollevent struct {
174	events uint32
175	_pad   uint32
176	data   [8]byte // to match amd64
177}
178
179type sockaddr_un struct {
180	family uint16
181	path   [108]byte
182}
183