forked from WebAssembly/WASI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wasix_v1.witx
741 lines (669 loc) · 26 KB
/
wasix_v1.witx
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
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
;; WASIX Preview. This is an extension of the API that WASI initially
;; launched with.
;;
;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi).
;;
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
;; for an explanation of what that means.
(use "typenames.witx")
(module $wasix_module_name
;;; Linear memory to be accessed by WASI(X) functions that need it.
(import "memory" (memory))
;;; Sets the time value of a clock.
;;; Note: This is similar to `clock_settime` in POSIX.
(@interface func (export "clock_time_set")
;;; The clock for which to set the time.
(param $id $clockid)
;;; The value of the time to be set.
(param $timestamp $timestamp)
;;; The time value of the clock.
(result $error (expected (error $errno)))
)
;;; Atomically duplicate a file handle.
;;
(@interface func (export "fd_dup")
(param $fd $fd)
(result $error (expected $fd (error $errno)))
)
;;; Creates a file handle for event notifications
;;;
(@interface func (export "fd_event")
(param $initial_val u64)
(param $flags $eventfdflags)
(result $error (expected $fd (error $errno)))
)
;;; Opens a pipe with two file handles
;;;
;;; Pipes are bidirectional
(@interface func (export "fd_pipe")
(result $error (expected (tuple $fd $fd) (error $errno)))
)
;;; Retrieves the current state of the TTY
(@interface func (export "tty_get")
(param $state (@witx pointer $tty))
(result $error (expected (error $errno)))
)
;;; Updates the properties of the the TTY
(@interface func (export "tty_set")
(param $state (@witx pointer $tty))
(result $error (expected (error $errno)))
)
;;; Returns the current working directory
;;;
;;; If the path exceeds the size of the buffer then this function
;;; will fill the path_len with the needed size and return EOVERFLOW
(@interface func (export "getcwd")
;;; The buffer where current directory is stored
(param $path (@witx pointer u8))
(param $path_len (@witx pointer $pointersize))
(result $error (expected (error $errno)))
)
;;; Sets the current working directory
(@interface func (export "chdir")
;;; Path to change the current working directory to
(param $path string)
(result $error (expected (error $errno)))
)
;;; Registers a callback function for signals
(@interface func (export "callback_signal")
;;; Exported function that will be called back when the signal triggers
;;; (must match the callback signature that takes the signal value)
;;; (if this is not specified the default will be "_signal")
(param $callback string)
)
;;; Creates a new thread by spawning that shares the same
;;; memory address space, file handles and main event loops.
;;; The web assembly process must export function named 'wasi_thread_start'
(@interface func (export "thread_spawn_v2")
;;; Pointer to the structure the describes the thread
;;; that is being spawened
(param $args (@witx pointer $thread_start))
;;; Returns the thread index of the newly created thread
;;; (indices always start from zero)
(result $error (expected $tid (error $errno)))
)
;;; Sends the current thread to sleep for a period of time
(@interface func (export "thread_sleep")
;;; Amount of time that the thread should sleep
(param $duration $timestamp)
(result $error (expected (error $errno)))
)
;;; Returns the index of the current thread
;;; (threads indices are sequential from zero while the
;;; main thread ID equals the process ID)
(@interface func (export "thread_id")
(result $error (expected $tid (error $errno)))
)
;;; Joins this thread with another thread, blocking this
;;; one until the other finishes
(@interface func (export "thread_join")
;;; Handle of the thread to wait on
(param $tid $tid)
(result $error (expected (error $errno)))
)
;;; Returns the available parallelism which is normally the
;;; number of available cores that can run concurrently
(@interface func (export "thread_parallelism")
(result $error (expected $size (error $errno)))
)
;;; Sends a signal to a specific thread
(@interface func (export "thread_signal")
;;; Handle of the thread to send a signal
(param $tid $tid)
;;; Signal to send to the thread
(param $signal $signal)
(result $error (expected (error $errno)))
)
;;; Wait for a futex_wake operation to wake us.
;;;
;;; Returns with EINVAL if the futex doesn't hold the expected value.
;;; Returns false on timeout, and true in all other cases.
(@interface func (export "futex_wait")
;;; Memory location that holds the value that will be checked
(param $futex (@witx pointer u32))
;;; Expected value that should be currently held at the memory location
(param $expected u32)
;;; Timeout should the futex not be triggered in the allocated time
(param $timeout (@witx const_pointer $option_timestamp))
(result $error (expected $bool (error $errno)))
)
;;; Wake up one thread that's blocked on futex_wait on this futex.
;;;
;;; Returns true if this actually woke up such a thread,
;;; or false if no thread was waiting on this futex.
(@interface func (export "futex_wake")
;;; Memory location that holds a futex that others may be waiting on
(param $futex (@witx pointer u32))
(result $error (expected $bool (error $errno)))
)
;;; Wake up all threads that are waiting on futex_wait on this futex.
(@interface func (export "futex_wake_all")
;;; Memory location that holds a futex that others may be waiting on
(param $futex (@witx pointer u32))
(result $error (expected $bool (error $errno)))
)
;;; Terminates the current running thread, if this is the last thread then
;;; the process will also exit with the specified exit code. An exit code
;;; of 0 indicates successful termination of the thread. The meanings of
;;; other values is dependent on the environment.
(@interface func (export "thread_exit")
;;; The exit code returned by the process.
(param $rval $exitcode)
(@witx noreturn)
)
;;; Creates a checkpoint of the current stack which allows it to be restored
;;; later using its stack hash. The value supplied will be returned upon
;;; restoration (and hence must be none zero) - zero will be returned when
;;; the stack is first recorded.
;;;
;;; This is used by `longjmp` and `setjmp`
;;;
;;; This function will read the __stack_pointer global
(@interface func (export "stack_checkpoint")
;;; Reference to the stack snapshot that will be filled
(param $snapshot (@witx pointer $stack_snapshot))
;;; Returns zero upon registration and the value when restored
(result $error (expected $longsize (error $errno)))
)
;;; Restores the current stack to a previous stack described by supplying
;;; stack snapshot.
;;;
;;; This function will manipulate the __stack_pointer global
(@interface func (export "stack_restore")
;;; Reference to the stack snapshot that will be restored
(param $snapshot (@witx const_pointer $stack_snapshot))
;;; Value to be returned when the stack is restored
;;; (if zero this will change to one)
(param $val $longsize)
;;; This function never returns
(@witx noreturn)
)
;;; Send a signal to the process of the calling thread on a regular basis
;;; Note: This is similar to `setitimer` in POSIX.
(@interface func (export "proc_raise_interval")
;;; The signal condition to trigger.
(param $sig $signal)
;;; Time to wait before raising the signal
;;; (zero here indicates the signal interval is cancelled)
(param $interval $timestamp)
;;; Flag that indicates if the signal will trigger indefinately
(param $repeat $bool)
(result $error (expected (error $errno)))
)
;;; Forks the current process into a new subprocess. If the function
;;; returns a zero then its the new subprocess. If it returns a positive
;;; number then its the current process and the $pid represents the child.
(@interface func (export "proc_fork")
;;; Indicates if the memory will be copied into the new process
;;; (if it is not copied this then becomes similar to `vfork` in
;;; that the current process pauses until `proc_exec` is called)
(param $copy_memory $bool)
(result $error (expected $pid (error $errno)))
)
;;; execve() executes the program referred to by pathname. This causes the
;;; program that is currently being run by the calling process to be replaced
;;; with a new program, with newly initialized stack, heap, and (initialized
;;; and uninitialized) data segments
;;;
;;; If the named process does not exist then the process will fail and terminate
(@interface func (export "proc_exec")
;;; Name of the process to be spawned
(param $name string)
;;; List of the arguments to pass the process
;;; (entries are separated by line feeds)
(param $args string)
;;; This function never returns
(@witx noreturn)
)
;;; Spawns a new process within the context of the parent process
;;; (i.e. this process). It inherits the filesystem and sandbox
;;; permissions but runs standalone.
(@interface func (export "proc_spawn")
;;; Name of the process to be spawned
(param $name string)
;;; Indicates if the process will chroot or not
(param $chroot $bool)
;;; List of the arguments to pass the process
;;; (entries are separated by line feeds)
(param $args string)
;;; List of the preopens for this process
;;; (entries are separated by line feeds)
(param $preopen string)
;;; How will stdin be handled
(param $stdin $stdio_mode)
;;; How will stdout be handled
(param $stdout $stdio_mode)
;;; How will stderr be handled
(param $stderr $stdio_mode)
;;; Working directory where this process should run
;;; (passing '.' will use the current directory)
(param $working_dir string)
;;; Returns a bus process id that can be used to invoke calls
(result $error (expected $process_handles (error $errno)))
)
;;; Returns the handle of the current process
(@interface func (export "proc_id")
(result $error (expected $pid (error $errno)))
)
;;; Returns the parent handle of a particular process
(@interface func (export "proc_parent")
;;; Handle of the process to get the parent handle for
(param $pid $pid)
(result $error (expected $pid (error $errno)))
)
;;; Wait for process to exit
;;;
;;; Passing none to PID will mean that the call will wait
;;; for any subprocess to exit. PID will be populated with
;;; the process that exited.
(@interface func (export "proc_join")
;;; ID of the process to wait on
(param $pid (@witx pointer $option_pid))
;;; Flags that determine how the join behaves
(param $flags $join_flags)
;;; Returns the status of the process
(result $error (expected $join_status (error $errno)))
)
;;; Sends a signal to another process
(@interface func (export "proc_signal")
;;; ID of the process to send a singal
(param $pid $pid)
;;; Signal to send to the thread
(param $signal $signal)
(result $error (expected (error $errno)))
)
;;; Connects to a websocket at a particular network URL
(@interface func (export "ws_connect")
;;; URL of the web socket destination to connect to
(param $url string)
;;; Returns a socket handle which is used to send and receive data
(result $error (expected $fd (error $errno)))
)
;;; Makes a HTTP request to a remote web resource and
;;; returns a socket handles that are used to send and receive data
(@interface func (export "http_request")
;;; URL of the HTTP resource to connect to
(param $url string)
;;; HTTP method to be invoked
(param $method string)
;;; HTTP headers to attach to the request
;;; (headers seperated by lines)
(param $headers string)
;;; Should the request body be compressed
(param $gzip $bool)
;;; The body of the response can be streamed from the returned
;;; file handle
(result $error (expected $http_handles (error $errno)))
)
;;; Retrieves the status of a HTTP request
(@interface func (export "http_status")
;;; Handle of the HTTP request
(param $fd $fd)
;;; Pointer to a buffer that will be filled with the current
;;; status of this HTTP request
(param $status (@witx pointer $http_status))
(result $error (expected (error $errno)))
)
;;; Securely connects to a particular remote network
(@interface func (export "port_bridge")
;;; Fully qualified identifier for the network
(param $network string)
;;; Access token used to authenticate with the network
(param $token string)
;;; Level of encryption to encapsulate the network connection with
(param $security $stream_security)
(result $error (expected (error $errno)))
)
;;; Disconnects from a remote network
(@interface func (export "port_unbridge")
(result $error (expected (error $errno)))
)
;;; Acquires a set of addresses using DHCP
(@interface func (export "port_dhcp_acquire")
(result $error (expected (error $errno)))
)
;;; Adds another static address to the local port
(@interface func (export "port_addr_add")
;;; Address to be added
(param $addr (@witx const_pointer $addr_cidr))
(result $error (expected (error $errno)))
)
;;; Removes an address from the local port
(@interface func (export "port_addr_remove")
;;; Address to be removed
(param $addr (@witx const_pointer $addr))
(result $error (expected (error $errno)))
)
;;; Clears all the addresses on the local port
(@interface func (export "port_addr_clear")
(result $error (expected (error $errno)))
)
;;; Returns the MAC address of the local port
(@interface func (export "port_mac")
(result $error (expected $hardware_address (error $errno)))
)
;;; Returns a list of all the addresses owned by the local port
;;;
;;; This function fills the output buffer as much as possible.
;;; If the buffer is not big enough then the naddrs address will be
;;; filled with the buffer size needed and the EOVERFLOW will be returned
(@interface func (export "port_addr_list")
;;; The buffer where addresses will be stored
(param $addrs (@witx pointer $addr_cidr))
(param $naddrs (@witx pointer $size))
;;; The number of addresses returned.
(result $error (expected (error $errno)))
)
;;; Adds a default gateway to the local port
(@interface func (export "port_gateway_set")
;;; Address of the default gateway
(param $addr (@witx const_pointer $addr))
(result $error (expected (error $errno)))
)
;;; Adds a new route to the local port
(@interface func (export "port_route_add")
(param $cidr (@witx const_pointer $addr_cidr))
(param $via_router (@witx const_pointer $addr))
(param $preferred_until (@witx const_pointer $option_timestamp))
(param $expires_at (@witx const_pointer $option_timestamp))
(result $error (expected (error $errno)))
)
;;; Removes an existing route from the local port
(@interface func (export "port_route_remove")
(param $cidr (@witx const_pointer $addr))
(result $error (expected (error $errno)))
)
;;; Clears all the routes in the local port
(@interface func (export "port_route_clear")
(result $error (expected (error $errno)))
)
;;; Returns a list of all the routes owned by the local port
;;; This function fills the output buffer as much as possible.
;;; If the buffer is too small this will return EOVERFLOW and
;;; fill nroutes with the size of the buffer needed.
(@interface func (export "port_route_list")
;;; The buffer where routes will be stored
(param $routes (@witx pointer $route))
(param $nroutes (@witx pointer $size))
(result $error (expected (error $errno)))
)
;;; Returns the current status of a socket
(@interface func (export "sock_status")
(param $fd $fd)
(result $error (expected $sock_status (error $errno)))
)
;;; Returns the local address to which the socket is bound.
;;;
;;; Note: This is similar to `getsockname` in POSIX
;;;
;;; When successful, the contents of the output buffer consist of an IP address,
;;; either IP4 or IP6.
(@interface func (export "sock_addr_local")
;;; Socket that the address is bound to
(param $fd $fd)
(result $error (expected $addr_port (error $errno)))
)
;;; Returns the remote address to which the socket is connected to.
;;;
;;; Note: This is similar to `getpeername` in POSIX
;;;
;;; When successful, the contents of the output buffer consist of an IP address,
;;; either IP4 or IP6.
(@interface func (export "sock_addr_peer")
;;; Socket that the address is bound to
(param $fd $fd)
(result $error (expected $addr_port (error $errno)))
)
;;; Create an endpoint for communication.
;;;
;;; creates an endpoint for communication and returns a file descriptor
;;; tor that refers to that endpoint. The file descriptor returned by a successful
;;; call will be the lowest-numbered file descriptor not currently open
;;; for the process.
;;;
;;; Note: This is similar to `socket` in POSIX using PF_INET
(@interface func (export "sock_open")
;;; Address family
(param $af $address_family)
;;; Socket type, either datagram or stream
(param $socktype $sock_type)
;;; Socket protocol
(param $sock_proto $sock_proto)
;;; The file descriptor of the socket that has been opened.
(result $error (expected $fd (error $errno)))
)
;;; Sets a particular socket setting
;;; Note: This is similar to `setsockopt` in POSIX for SO_REUSEADDR
(@interface func (export "sock_set_opt_flag")
;;; Socket descriptor
(param $fd $fd)
;;; Socket option to be set
(param $sockopt $sock_option)
;;; Value to set the option to
(param $flag $bool)
(result $error (expected (error $errno)))
)
;;; Retrieve status of particular socket seting
;;; Note: This is similar to `getsockopt` in POSIX for SO_REUSEADDR
(@interface func (export "sock_get_opt_flag")
;;; Socket descriptor
(param $fd $fd)
;;; Socket option to be retrieved
(param $sockopt $sock_option)
(result $error (expected $bool (error $errno)))
)
;;; Sets one of the times the socket
(@interface func (export "sock_set_opt_time")
;;; Socket descriptor
(param $fd $fd)
;;; Socket option to be set
(param $sockopt $sock_option)
;;; Value to set the time to
(param $timeout (@witx const_pointer $option_timestamp))
(result $error (expected (error $errno)))
)
;;; Retrieve one of the times on the socket
(@interface func (export "sock_get_opt_time")
;;; Socket descriptor
(param $fd $fd)
;;; Socket option to be retrieved
(param $sockopt $sock_option)
(result $error (expected $option_timestamp (error $errno)))
)
;;; Set size of particular option for this socket
;;; Note: This is similar to `setsockopt` in POSIX for SO_RCVBUF
(@interface func (export "sock_set_opt_size")
;;; Socket descriptor
(param $fd $fd)
;;; Socket option to be set
(param $sockopt $sock_option)
;;; Buffer size
(param $size $filesize)
(result $error (expected (error $errno)))
)
;;; Retrieve the size of particular option for this socket
;;; Note: This is similar to `getsockopt` in POSIX for SO_RCVBUF
(@interface func (export "sock_get_opt_size")
;;; Socket descriptor
(param $fd $fd)
;;; Socket option to be retrieved
(param $sockopt $sock_option)
(result $error (expected $filesize (error $errno)))
)
;;; Joins a particular multicast IPv4 group
(@interface func (export "sock_join_multicast_v4")
;;; Socket descriptor
(param $fd $fd)
;;; Multicast group to joined
(param $multiaddr (@witx const_pointer $addr_ip4))
;;; Interface that will join
(param $interface (@witx const_pointer $addr_ip4))
(result $error (expected (error $errno)))
)
;;; Leaves a particular multicast IPv4 group
(@interface func (export "sock_leave_multicast_v4")
;;; Socket descriptor
(param $fd $fd)
;;; Multicast group to leave
(param $multiaddr (@witx const_pointer $addr_ip4))
;;; Interface that will left
(param $interface (@witx const_pointer $addr_ip4))
(result $error (expected (error $errno)))
)
;;; Joins a particular multicast IPv6 group
(@interface func (export "sock_join_multicast_v6")
;;; Socket descriptor
(param $fd $fd)
;;; Multicast group to joined
(param $multiaddr (@witx const_pointer $addr_ip6))
;;; Interface that will join
(param $interface u32)
(result $error (expected (error $errno)))
)
;;; Leaves a particular multicast IPv6 group
(@interface func (export "sock_leave_multicast_v6")
;;; Socket descriptor
(param $fd $fd)
;;; Multicast group to leave
(param $multiaddr (@witx const_pointer $addr_ip6))
;;; Interface that will left
(param $interface u32)
(result $error (expected (error $errno)))
)
;;; Bind a socket
;;; Note: This is similar to `bind` in POSIX using PF_INET
(@interface func (export "sock_bind")
;;; File descriptor of the socket to be bind
(param $fd $fd)
;;; Address to bind the socket to
(param $addr (@witx const_pointer $addr_port))
(result $error (expected (error $errno)))
)
;;; Listen for connections on a socket
;;;
;;; Polling the socket handle will wait until a connection
;;; attempt is made
;;;
;;; Note: This is similar to `listen`
(@interface func (export "sock_listen")
;;; File descriptor of the socket to be bind
(param $fd $fd)
;;; Maximum size of the queue for pending connections
(param $backlog $size)
(result $error (expected (error $errno)))
)
;;; Accept a new incoming connection.
;;; Note: This is similar to `accept` in POSIX.
(@interface func (export "sock_accept_v2")
;;; The listening socket.
(param $fd $fd)
;;; The desired values of the file descriptor flags.
(param $flags $fdflags)
;;; New socket connection
(result $error (expected (tuple $fd $addr_port) (error $errno)))
)
;;; Initiate a connection on a socket to the specified address
;;;
;;; Polling the socket handle will wait for data to arrive or for
;;; the socket status to change which can be queried via 'sock_status'
;;;
;;; Note: This is similar to `connect` in POSIX
(@interface func (export "sock_connect")
;;; Socket descriptor
(param $fd $fd)
;;; Address of the socket to connect to
(param $addr (@witx const_pointer $addr_port))
(result $error (expected (error $errno)))
)
;;; Receive a message and its peer address from a socket.
;;; Note: This is similar to `recvfrom` in POSIX, though it also supports reading
;;; the data into multiple buffers in the manner of `readv`.
(@interface func (export "sock_recv_from")
(param $fd $fd)
;;; List of scatter/gather vectors to which to store data.
(param $ri_data $iovec_array)
;;; Message flags.
(param $ri_flags $riflags)
;;; Number of bytes stored in ri_data and message flags.
(result $error (expected (tuple $size $roflags $addr_port) (error $errno)))
)
;;; Send a message on a socket to a specific address.
;;; Note: This is similar to `sendto` in POSIX, though it also supports writing
;;; the data from multiple buffers in the manner of `writev`.
(@interface func (export "sock_send_to")
(param $fd $fd)
;;; List of scatter/gather vectors to which to retrieve data
(param $si_data $ciovec_array)
;;; Message flags.
(param $si_flags $siflags)
;;; Address of the socket to send message to
(param $addr (@witx const_pointer $addr_port))
;;; Number of bytes transmitted.
(result $error (expected $size (error $errno)))
)
;;; Sends the entire contents of a file down a socket
(@interface func (export "sock_send_file")
(param $out_fd $fd)
;;; Open file that has the data to be transmitted
(param $in_fd $fd)
;;; Offset into the file to start reading at
(param $offset $filesize)
;;; Number of bytes to be sent
(param $count $filesize)
;;; Number of bytes transmitted.
(result $error (expected $filesize (error $errno)))
)
;;; Resolves a hostname and a port to one or more IP addresses.
;;;
;;; Note: This is similar to `getaddrinfo` in POSIX
;;;
;;; When successful, the contents of the output buffer consist of a sequence of
;;; IPv4 and/or IPv6 addresses. Each address entry consists of a addr_t object.
;;
;;; This function fills the output buffer as much as possible.
(@interface func (export "resolve")
;;; Host to resolve
(param $host string)
;;; Port hint (zero if no hint is supplied)
(param $port u16)
;;; The buffer where addresses will be stored
(param $addrs (@witx pointer $addr))
(param $naddrs $size)
;;; The number of IP addresses returned during the DNS resolution.
(result $error (expected $size (error $errno)))
)
;;; Create an epoll interest list
;;;
(@interface func (export "epoll_create")
;;; The file descriptor for this epoll interest list
(result $error (expected $fd (error $errno)))
)
;;; Modifies an epoll interest list
;;;
(@interface func (export "epoll_ctl")
;;; File descriptor of the epoll interest list
(param $epfd $fd)
;;; Operation to be made on the list
(param $op $epoll_ctl)
;;; File descriptor to be added, deleted or modified
(param $fd $fd)
;;; Reference to the event to be added, deleted or modified
(param $event (@witx const_pointer $epoll_event))
;;; The number of bytes written.
(result $error (expected (error $errno)))
)
;;; wait for an I/O event on an epoll file descriptor
;;;
(@interface func (export "epoll_wait")
;;; File descriptor of the epoll interest list
(param $epfd $fd)
;;; Reference to the array of events
(param $event (@witx pointer $epoll_event))
;;; Maximum number of events that will be returned in the array
(param $maxevents $size)
;;; Timeout for the wait event
(param $timeout $timestamp)
;;; The number of events returned.
(result $error (expected $size (error $errno)))
)
)