summaryrefslogtreecommitdiff
path: root/support/syscall-gen/types+linux-x64.frag
blob: 9e90a5ac3719e4c4fbaddc39f050ddbbc7796e98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
type size	= int64		/* spans entire address space */
type usize	= uint64	/* unsigned size */
type off	= int64         /* file offsets */
type intptr	= uint64	/* can hold any pointer losslessly */
type time	= int64		/* milliseconds since epoch */
type scno	= int64		/* syscall */

/* processes/threads */
type pid	= int	/* process id */
type tid	= int	/* thread id */
type cloneopt	= int64	/* options for clone(2) */

/* file descriptor manipulation */
type fdopt	= int64	/* fd options */
type fd		= int32	/* fd */
type whence	= uint64	/* seek from whence */
type filemode	= uint32	/* file open mode */

type mprot	= int64	/* memory protection */
type mopt	= int64	/* memory mapping options */
type socktype	= int64	/* socket type */
type sockproto	= int32	/* socket protocol */
type sockfam	= uint16	/* socket family */
type sockopt	= int64
type msgflags	= uint32
type cmsgtype	= uint32

type epollflags	= uint32
type epollop	= uint32
type epollevttype	= uint32

type pollevt	= uint16

type futexop	= uint32
type signo	= int32
type sigflags	= int64
type fallocmode	= uint32
type mfdflags	= uint32
type aiocontext	= uint64
type msg	= void#


type clock = union
	`Clockrealtime
	`Clockmonotonic
	`Clockproccpu
	`Clockthreadcpu
	`Clockmonotonicraw
	`Clockrealtimecoarse
	`Clockmonotoniccoarse
	`Clockboottime
	`Clockrealtimealarm
	`Clockboottimealarm
;;

type waitstatus = union
	`Waitexit int32
	`Waitsig  int32
	`Waitstop int32
	`Waitfail int32
;;

type sigset = struct
	bits	: uint32[2]
;;

type sigaction = struct
	handler	: byte#	/* code pointer */
	flags	: sigflags
	restore	: byte#	/* code pointer */
	mask	: sigset
;;

const Sipadsz = 128
type siginfo = struct
	signo	: int
	errno	: int
	code	: int

	_pad	: int[Sipadsz]
;;

/* union { int, void* } */
type sigval = struct
	_pad	: void#
;;

const Sigevmaxsz = 64
const Sigevpadsz = Sigevmaxsz / sizeof(int) - 4
type sigevent = struct
	value	: sigval
	signo	: int
	notify	: int
	_pad	: int[Sigevpadsz]
;;

type timespec = struct
	sec	: int64
	nsec	: int64
;;

type timeval = struct
	sec	: int64
	usec	: int64
;;

type timex = struct
        modes		: uint     	/* mode selector */
        offset		: int64 	/* time offset (usec) */
        freq		: int64		/* frequency offset (scaled ppm) */
        maxerror	: int64		/* maximum error (usec) */
        esterror	: int64		/* estimated error (usec) */
        status		: int             /* clock command/status */
        constant	: int64		/* pll time constant */
        precision	: int64		/* clock precision (usec) (read only) */
        tolerance	: int64		/* clock frequency tolerance (ppm) */
        time		: timeval	/* (read only, except for ADJ_SETOFFSET) */
        tick		: int64		/* (modified) usecs between clock ticks */

        ppsfreq		: int64		/* pps frequency (scaled ppm) (ro) */
        jitter		: int64		/* pps jitter (us) (ro) */
        shift		: int		/* interval duration (s) (shift) (ro) */
        stabil		: int64		/* pps stability (scaled ppm) (ro) */
        jitcnt		: int64		/* jitter limit exceeded (ro) */
        calcnt		: int64		/* calibration intervals (ro) */
        errcnt		: int64		/* calibration errors (ro) */
        stbcnt		: int64		/* stability limit exceeded (ro) */

        tai		: int		/* TAI offset (ro) */

	__pad		: int[11]
;;


type rusage = struct
	utime	: timeval	/* user time */
	stime	: timeval	/* system time */
	_opaque	: uint64[14]	/* padding (darwin-specific data) */
;;

type sched_param = struct
	priority	: int
;;

type sched_attr = struct
        size	: uint32
        sched_policy	: uint32
        sched_flags	: uint64

        /* SCHED_NORMAL, SCHED_BATCH */
        sched_nice	: int32

        /* SCHED_FIFO, SCHED_RR */
        sched_priority	: uint32

        /* SCHED_DEADLINE */
        sched_runtime	: uint64
        sched_deadline	: uint64
        sched_period	: uint64

;;

type statbuf = struct
	dev	: uint64
	ino	: uint64
	nlink	: uint64
	mode	: filemode
	uid	: uint32
	gid	: uint32
	__pad0	: uint32
	rdev	: uint64
	size	: uint64
	blksz	: uint32
	blocks	: uint64
	atime	: timespec
	mtime	: timespec
	ctime	: timespec
	__pad1	: uint64[3]
;;

type statfs = struct
	kind	: uint64
	bsize	: uint64
	blocks	: uint64
	bfree	: uint64
	bavail	: uint64
	files	: uint64
	ffree	: uint64
	fsid	: int[2]
	namelen	: uint64
	frsize	: uint64
	flags	: uint64
	spare	: uint64[4]
;;

type ustat = struct
 	tfree	: uint32;		/* Number of free blocks.  */
    	tinode	: uint64;		/* Number of free inodes.  */
	fname	: byte[6]
	fpack	: byte[6]
;;

type dirent64 = struct
	ino	: uint64
	off	: uint64
	reclen	: uint16
	etype	: byte
	name	: byte[...]	/* special case; zero length => unchecked indexing */
;;

type utsname = struct
	system	: byte[65]
	node	: byte[65]
	release	: byte[65]
	version	: byte[65]
	machine	: byte[65]
	domain	: byte[65]
;;

type sockaddr = struct
	fam	: sockfam
	data	: byte[14]
;;

type sockaddr_in = struct
	fam	: sockfam
	port	: uint16
	addr	: byte[4]
	zero	: byte[8]
;;

type sockaddr_in6 = struct
	fam	: sockfam
	port	: uint16
	addr	: byte[16]
	scope	: uint32
;;

type sockaddr_un = struct
	fam	: sockfam
	path	: byte[108]
;;

type sockaddr_storage = struct
	fam	: sockfam
	__align	: uint32
	__pad	: byte[112]
;;

type bpfgattr = void#
type bpfmapattr = struct
	maptype	: uint32
	keysz	: uint32
	valsz	: uint32
	mapents	: uint32
	mapflg	: uint32
;;

type bpfeltattr = struct
	fd	: uint32
	key	: uint64
	val	: uint64
	flg	: uint64
;;

type bpfprogattr = struct
	kind	: uint32
	insncnt	: uint32
	insns	: uint64
	license	: uint64
	loglev	: uint32
	logsz	: uint32
	logbuf	: uint64
	kvers	: uint32
;;

type bpfobjattr = struct
	path	: uint64
	fd	: uint32
;;

type bfpattachattr = struct
	targfd	: uint32
	fd	: uint32
	kind	: uint32
	flags	: uint32
;;

type epollevt = struct
	events	: epollevttype
	data	: byte[8]
;;

type pollfd = struct
	fd	: fd
	events	: pollevt
	revents	: pollevt
;;

type file_handle = struct
	bytes	: uint
	kind	: int
	handle	: byte[...]
;;

type iovec = struct
	base	: byte#
	len	: uint64
;;

type semun = struct
	__pad	: void#
;;

type msgbuf = struct
	mtype	: int64
	buf	: byte[...]
;;

type msghdr = struct
	name		: sockaddr#
	namelen		: int32
	iov		: iovec#
	iovlen		: uint64
	control		: byte#
	controllen	: uint64
	flags		: msgflags
;;

type getcpu_cache = struct
	__opaque	: byte[128]
;;

type perf_event_attr = struct
	kind		: uint32
	size		: uint32
	config		: uint64
	timing		: uint64	/* frequency or period */
	samplekind	: uint64
	readformat	: uint64
	flags		: uint64
	wakeups		: uint32	/* events or watermarks */
	addr		: uint32	/* can also be extension of config */
	len		: uint32	/* can also be extension of config1 */
	brsamplekind	: uint64
	uregs		: uint64
	ustack		: uint32
	clockid		: int32
	intrregs	: uint64
	auxwatermark	: uint32
	samplestack	: uint16
	reserved	: uint16
;;

type mmsghdr = struct
	hdr	: msghdr
	len	: uint32
;;

type cmsghdr = struct
	len	: uint64
	level	: sockproto
	cmtype	: cmsgtype
	data	: byte[...]
;;

type capuserheader = struct
	version	: uint32
	pid	: int
;;

type capuserdata = struct
	effective	: uint32
	permitted	: uint32
	inheritable	: uint32
;;

type kexec_segment = struct
	buf	: void#
	bufsz	: size
	mem	: void#
	memsz	: size
;;

/* clone options */
const Clonesignal	: cloneopt = 0xff
const Clonevm		: cloneopt = 0x100
const Clonefs		: cloneopt = 0x200
const Clonefiles	: cloneopt = 0x400
const Clonesighand	: cloneopt = 0x800
const Cloneptrace	: cloneopt = 0x2000
const Clonevfork	: cloneopt = 0x4000
const Cloneparent	: cloneopt = 0x8000
const Clonethread	: cloneopt = 0x10000
const Clonenewns	: cloneopt = 0x20000
const Clonesysvsem	: cloneopt = 0x40000
const Clonesettls	: cloneopt = 0x80000
const Cloneparentsettid	: cloneopt = 0x100000
const Clonechildcleartid: cloneopt = 0x200000
const Clonedetached	: cloneopt = 0x400000
const Cloneuntraced	: cloneopt = 0x800000
const Clonechildsettid	: cloneopt = 0x1000000
const Clonenewuts	: cloneopt = 0x4000000
const Clonenewipc	: cloneopt = 0x8000000
const Clonenewuser	: cloneopt = 0x10000000
const Clonenewpid	: cloneopt = 0x20000000
const Clonenewnet	: cloneopt = 0x40000000
const Cloneio		: cloneopt = 0x80000000

type ptregs = struct
;;

/* open options */
const Ordonly  	: fdopt = 0x0
const Owronly  	: fdopt = 0x1
const Ordwr    	: fdopt = 0x2
const Ocreat   	: fdopt = 0x40
const Oexcl  	: fdopt = 0x80
const Otrunc   	: fdopt = 0x200
const Oappend  	: fdopt = 0x400
const Ondelay  	: fdopt = 0x800
const Odirect	: fdopt = 0x4000
const Olarge	: fdopt = 0x8000
const Odir	: fdopt = 0x10000
const Onofollow	: fdopt = 0x20000
const Onoatime	: fdopt = 0x40000
const Ocloexec	: fdopt = 0x80000

/* stat modes */
const Sifmt	: filemode = 0xf000
const Sififo	: filemode = 0x1000
const Sifchr	: filemode = 0x2000
const Sifdir	: filemode = 0x4000
const Sifblk	: filemode = 0x6000
const Sifreg	: filemode = 0x8000
const Siflnk	: filemode = 0xa000
const Sifsock	: filemode = 0xc000

/* mmap protection */
const Mprotnone	: mprot = 0x0
const Mprotrd	: mprot = 0x1
const Mprotwr	: mprot = 0x2
const Mprotexec	: mprot = 0x4
const Mprotrw	: mprot = 0x3 /* convenience */

/* mmap options */
const Mshared	: mopt = 0x1
const Mpriv	: mopt = 0x2
const Mfixed	: mopt = 0x10
const Mfile	: mopt = 0x0
const Manon	: mopt = 0x20
const M32bit	: mopt = 0x40

/* socket families. INCOMPLETE. */
const Afunspec	: sockfam = 0
const Afunix	: sockfam = 1
const Afinet	: sockfam = 2
const Afinet6	: sockfam = 10

/* socket types. */
const Sockstream	: socktype = 1	/* sequenced, reliable byte stream */
const Sockdgram		: socktype = 2	/* datagrams */
const Sockraw		: socktype = 3	/* raw proto */
const Sockrdm		: socktype = 4	/* reliably delivered messages */
const Sockseqpacket	: socktype = 5	/* sequenced, reliable packets */
const Sockdccp		: socktype = 6	/* data congestion control protocol */
const Sockpack		: socktype = 10	/* linux specific packet */

/* socket options */
const Sodebug		: sockopt = 1
const Soreuseaddr	: sockopt = 2
const Sotype		: sockopt = 3
const Soerror		: sockopt = 4
const Sodontroute	: sockopt = 5
const Sobroadcast	: sockopt = 6
const Sosndbuf		: sockopt = 7
const Sorcvbuf		: sockopt = 8
const Sosndbufforce	: sockopt = 32
const Sorcvbufforce	: sockopt = 33
const Sokeepalive	: sockopt = 9
const Sooobinline	: sockopt = 10
const Sono_check	: sockopt = 11
const Sopriority	: sockopt = 12
const Solinger		: sockopt = 13
const Sobsdcompat	: sockopt = 14
const Soreuseport	: sockopt = 15
const Sopasscred	: sockopt = 16
const Sopeercred	: sockopt = 17
const Sorcvlowat	: sockopt = 18
const Sosndlowat	: sockopt = 19
const Sorcvtimeo	: sockopt = 20
const Sosndtimeo	: sockopt = 21

/* socket option levels */
const Solsocket		: sockproto = 1

/* network protocols */
const Ipproto_ip	: sockproto = 0
const Ipproto_icmp	: sockproto = 1
const Ipproto_tcp	: sockproto = 6
const Ipproto_udp	: sockproto = 17
const Ipproto_raw	: sockproto = 255

/* message flags */
const Msgoob		: msgflags = 0x0001
const Msgpeek		: msgflags = 0x0002
const Msgdontroute	: msgflags = 0x0004
const Msgctrunc		: msgflags = 0x0008
const Msgtrunc		: msgflags = 0x0020
const Msgeor		: msgflags = 0x0080
const Msgwaitall	: msgflags = 0x0100
const Msgnosignal	: msgflags = 0x4000

/* ancillary data */
const Scmrights		: cmsgtype = 1

/* epoll flags */
const Epollcloexec	: epollflags	= 0o2000000

/* epoll ops */
const Epollctladd	: epollop	= 1
const Epollctlmod	: epollop	= 2
const Epollctldel	: epollop	= 3

/* epoll events */
const Epollin	: epollevttype = 0x001
const Epollpri	: epollevttype = 0x002
const Epollout	: epollevttype = 0x004
const Epollerr	: epollevttype = 0x008
const Epollhup	: epollevttype = 0x010
const Epollrdnorm	: epollevttype = 0x040
const Epollrdband	: epollevttype = 0x080
const Epollwrnorm	: epollevttype = 0x100
const Epollwrband	: epollevttype = 0x200
const Epollmsg		: epollevttype = 0x400
const Epollrdhup	: epollevttype = 0x2000
const Epollwakeup	: epollevttype = 1 << 29
const Epolloneshot	: epollevttype = 1 << 30
const Epolledge	: epollevttype = 1 << 31

/* futex ops */
const Futexwait	: futexop = 0
const Futexwake	: futexop = 1
/* Futexfd: removed */
const Futexrequeue	: futexop = 3
const Futexcmprequeue	: futexop = 4
const Futexwakeop	: futexop = 5
const Futexlockpi	: futexop = 6
const Futexunlockpi	: futexop = 7
const Futextrylockpi	: futexop = 8
const Futexwaitbitset	: futexop = 9
const Futexwakebitset	: futexop = 10
const Futexwaitrequeuepi	: futexop = 11
const Futexcmprequeuepi	: futexop = 12

const Futexpriv	: futexop = 128
const Futexclockrt	: futexop = 256

const Futexbitsetmatchany : int32 = -1

/* poll events : posix */
const Pollin	: pollevt = 0x001	/* There is data to read.  */
const Pollpri	: pollevt = 0x002	/* There is urgent data to read.  */
const Pollout	: pollevt = 0x004	/* Writing now will not block.  */
const Pollerr	: pollevt = 0x008           /* Error condition.  */
const Pollhup	: pollevt = 0x010           /* Hung up.  */
const Pollnval	: pollevt = 0x020           /* Invalid polling request.  */

/* poll events: xopen */
const Pollrdnorm	: pollevt = 0x040	/* Normal data may be read.  */
const Pollrdband	: pollevt = 0x080	/* Priority data may be read.  */
const Pollwrnorm	: pollevt = 0x100	/* Writing now will not block.  */
const Pollwrband	: pollevt = 0x200	/* Priority data may be written.  */

/* poll events: linux */
const Pollmsg		: pollevt = 0x400
const Pollremove	: pollevt = 0x1000
const Pollrdhup		: pollevt = 0x2000

const Seekset	: whence = 0
const Seekcur	: whence = 1
const Seekend	: whence = 2

/* return value for a failed mapping */
const Mapbad	: byte# = (-1 : byte#)

/* signal flags */
const Sanocldstop	: sigflags = 0x00000001
const Sanocldwait	: sigflags = 0x00000002
const Sasiginfo		: sigflags = 0x00000004
const Sarestorer	: sigflags = 0x04000000
const Saonstack		: sigflags = 0x08000000
const Sarestart		: sigflags = 0x10000000
const Sanodefer		: sigflags = 0x40000000
const Saresethand	: sigflags = 0x80000000
const Sanomask		: sigflags = Sanodefer
const Saoneshot		: sigflags = Saresethand

/* signal numbers */
const Sighup	: signo = 1
const Sigint	: signo = 2
const Sigquit	: signo = 3
const Sigill	: signo = 4
const Sigtrap	: signo = 5
const Sigabrt	: signo = 6
const Sigiot	: signo = 6
const Sigbus	: signo = 7
const Sigfpe	: signo = 8
const Sigkill	: signo = 9
const Sigusr1	: signo = 10
const Sigsegv	: signo = 11
const Sigusr2	: signo = 12
const Sigpipe	: signo = 13
const Sigalrm	: signo = 14
const Sigterm	: signo = 15
const Sigstkflt	: signo = 16
const Sigchld	: signo = 17
const Sigcont	: signo = 18
const Sigstop	: signo = 19
const Sigtstp	: signo = 20
const Sigttin	: signo = 21
const Sigttou	: signo = 22
const Sigurg	: signo = 23
const Sigxcpu	: signo = 24
const Sigxfsz	: signo = 25
const Sigvtalrm	: signo = 26
const Sigprof	: signo = 27
const Sigwinch	: signo = 28
const Sigio	: signo = 29
const Sigpoll	: signo = Sigio

/* fallocate mode */
const Fallockeepsize		: fallocmode = 0x01
const Fallocpunchhole		: fallocmode = 0x02
const Fallocnohidestale		: fallocmode = 0x04
const Falloccollapserange	: fallocmode = 0x08
const Falloczerorange		: fallocmode = 0x10
const Fallocinsertrange		: fallocmode = 0x20

/* memfd flags */
const Mfdcloexec	: mfdflags = 0x01
const Mfdallowsealing	: mfdflags = 0x02

/* exported values: initialized by start code */
extern var __cenvp : byte##