44#include <wasi/api.h>
55
66#ifndef __wasip1__
7- #include <wasi/poll.h>
8- #include <sys/stat.h>
97#include <netinet/in.h>
8+ #include <sys/stat.h>
9+ #include <wasi/poll.h>
1010
1111// Metadata for WASI reads which is used to delegate to `__wasilibc_read(...)`
1212// to perform the actual read of a stream.
@@ -30,7 +30,7 @@ typedef struct wasi_read_t {
3030
3131 // A callback/ptr pair to invoke when EOF is reached to set errno and return
3232 // an error code.
33- int (* eof )(void * );
33+ int (* eof )(void * );
3434 void * eof_data ;
3535#endif
3636} wasi_read_t ;
@@ -51,7 +51,7 @@ typedef struct wasi_write_t {
5151 bool * done ;
5252 // A callback/ptr pair to invoke when EOF is reached to set errno and return
5353 // an error code.
54- int (* eof )(void * );
54+ int (* eof )(void * );
5555 void * eof_data ;
5656#endif
5757} wasi_write_t ;
@@ -75,73 +75,73 @@ typedef uint32_t waitable_t;
7575 */
7676typedef struct descriptor_vtable_t {
7777 /// Deallocates the parameter provided, closing all resources as well.
78- void (* free )(void * );
78+ void (* free )(void * );
7979
8080 // =====================================================================
8181 // Generic I/O
8282
83- /// Looks up metadata to perform a read operation for this stream. This is used
84- /// to implement the `read` syscall, for example, and is also used with `poll`
85- /// when waiting for readability.
86- int (* get_read_stream )(void * , wasi_read_t * );
83+ /// Looks up metadata to perform a read operation for this stream. This is
84+ /// used to implement the `read` syscall, for example, and is also used with
85+ /// `poll` when waiting for readability.
86+ int (* get_read_stream )(void * , wasi_read_t * );
8787 /// Same as `get_read_stream`, but for output streams.
88- int (* get_write_stream )(void * , wasi_write_t * );
88+ int (* get_write_stream )(void * , wasi_write_t * );
8989
9090 /// Sets the nonblocking flag for this object to the specified value.
91- int (* set_blocking )(void * , bool );
91+ int (* set_blocking )(void * , bool );
9292
9393 /// Implementation of `fstat` the function call, used to learn about file
9494 /// descriptors.
95- int (* fstat )(void * , struct stat * );
95+ int (* fstat )(void * , struct stat * );
9696
9797 // =====================================================================
9898 // File-related APIs
9999
100100 /// Looks up a `wasi:filesystem/types.descriptor`, if present, from this
101101 /// object.
102- int (* get_file )(void * , filesystem_borrow_descriptor_t * );
102+ int (* get_file )(void * , filesystem_borrow_descriptor_t * );
103103 /// Implementation of `lseek`-the-function.
104- off_t (* seek )(void * , off_t , int );
104+ off_t (* seek )(void * , off_t , int );
105105 /// Used during `unlinkat` to ensure that all internal stremas are
106106 /// closed before deleting the file to ensure there are no open references to
107107 /// it.
108- void (* close_streams )(void * );
108+ void (* close_streams )(void * );
109109 /// Implementation of `fnctl(fd, F_GETFL)`.
110- int (* fcntl_getfl )(void * );
110+ int (* fcntl_getfl )(void * );
111111 /// Implementation of `fnctl(fd, F_SETFL)`.
112- int (* fcntl_setfl )(void * , int );
112+ int (* fcntl_setfl )(void * , int );
113113 /// Implementation of `isatty`-the-function.
114- int (* isatty )(void * );
114+ int (* isatty )(void * );
115115
116116 // =====================================================================
117117 // Sockets-related APIs
118118
119119 /// Implementation of `accept4`-the-function.
120- int (* accept4 )(void * , struct sockaddr * addr , socklen_t * addrlen , int flags );
120+ int (* accept4 )(void * , struct sockaddr * addr , socklen_t * addrlen , int flags );
121121 /// Implementation of `bind`-the-function.
122- int (* bind )(void * , const struct sockaddr * addr , socklen_t addrlen );
122+ int (* bind )(void * , const struct sockaddr * addr , socklen_t addrlen );
123123 /// Implementation of `connect`-the-function.
124- int (* connect )(void * , const struct sockaddr * addr , socklen_t addrlen );
124+ int (* connect )(void * , const struct sockaddr * addr , socklen_t addrlen );
125125 /// Implementation of `getsockname`-the-function.
126- int (* getsockname )(void * , struct sockaddr * addr , socklen_t * addrlen );
126+ int (* getsockname )(void * , struct sockaddr * addr , socklen_t * addrlen );
127127 /// Implementation of `getpeername`-the-function.
128- int (* getpeername )(void * , struct sockaddr * addr , socklen_t * addrlen );
128+ int (* getpeername )(void * , struct sockaddr * addr , socklen_t * addrlen );
129129 /// Implementation of `listen`-the-function.
130- int (* listen )(void * , int backlog );
130+ int (* listen )(void * , int backlog );
131131 /// Implementation of `recvfrom`-the-function.
132- ssize_t (* recvfrom )(void * , void * buffer , size_t length , int flags ,
132+ ssize_t (* recvfrom )(void * , void * buffer , size_t length , int flags ,
133133 struct sockaddr * addr , socklen_t * addrlen );
134134 /// Implementation of `sendto`-the-function.
135- ssize_t (* sendto )(void * , const void * buffer , size_t length , int flags ,
135+ ssize_t (* sendto )(void * , const void * buffer , size_t length , int flags ,
136136 const struct sockaddr * addr , socklen_t addrlen );
137137 /// Implementation of `shutdown`-the-function.
138- int (* shutdown )(void * , int how );
138+ int (* shutdown )(void * , int how );
139139 /// Implementation of `getsockopt`-the-function.
140- int (* getsockopt )(void * , int level , int optname ,
141- void * optval , socklen_t * optlen );
140+ int (* getsockopt )(void * , int level , int optname , void * optval ,
141+ socklen_t * optlen );
142142 /// Implementation of `setsockopt`-the-function.
143- int (* setsockopt )(void * , int level , int optname ,
144- const void * optval , socklen_t optlen );
143+ int (* setsockopt )(void * , int level , int optname , const void * optval ,
144+ socklen_t optlen );
145145
146146 // =====================================================================
147147 // `poll`-related APIs
@@ -154,7 +154,7 @@ typedef struct descriptor_vtable_t {
154154 ///
155155 /// If this function is not provided then `poll` will use `get_read_stream`
156156 /// and `get_write_stream`, if present, to handle `POLL{RD,WR}NORM` events.
157- int (* poll_register )(void * , poll_state_t * state , short events );
157+ int (* poll_register )(void * , poll_state_t * state , short events );
158158
159159 /// Invoked when `poll` has already run and detected that this object was
160160 /// ready. The `events` provided are the same as those provided to
@@ -164,7 +164,7 @@ typedef struct descriptor_vtable_t {
164164 ///
165165 /// If this function is not provided then `events` will automatically
166166 /// be placed into the `revents` field of `pollfd`.
167- int (* poll_finish )(void * , poll_state_t * state , short events );
167+ int (* poll_finish )(void * , poll_state_t * state , short events );
168168} descriptor_vtable_t ;
169169
170170/// A "fat pointer" which is placed inside of the descriptor table.
0 commit comments