Skip to content

Commit 70cab1a

Browse files
authored
Merge pull request #6 from johnlanni/support-go-1.24
Support go 1.24
2 parents ecf42a2 + f2438ad commit 70cab1a

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

Diff for: include/proxy-wasm/exports.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,19 @@ Word wasi_unstable_fd_read(Word, Word, Word, Word);
143143
Word wasi_unstable_fd_seek(Word, int64_t, Word, Word);
144144
Word wasi_unstable_fd_close(Word);
145145
Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut);
146+
Word wasi_unstable_fd_fdstat_set_flags(Word fd, Word flags);
146147
Word wasi_unstable_environ_get(Word, Word);
147148
Word wasi_unstable_environ_sizes_get(Word count_ptr, Word buf_size_ptr);
148149
Word wasi_unstable_args_get(Word argc_ptr, Word argv_buf_size_ptr);
149150
Word wasi_unstable_args_sizes_get(Word argc_ptr, Word argv_buf_size_ptr);
151+
Word wasi_unstable_sched_yield();
152+
Word wasi_unstable_poll_oneoff(Word in, Word out, Word nsubscriptions, Word nevents);
150153
void wasi_unstable_proc_exit(Word);
151154
Word wasi_unstable_clock_time_get(Word, uint64_t, Word);
152155
Word wasi_unstable_random_get(Word, Word);
153156
Word pthread_equal(Word left, Word right);
154157
void emscripten_notify_memory_growth(Word);
158+
Word wasi_unstable_path_filestat_get(Word fd, Word flags, Word path, Word path_len, Word buf);
155159

156160
// Support for embedders, not exported to Wasm.
157161

@@ -175,9 +179,10 @@ void emscripten_notify_memory_growth(Word);
175179
_f(continue_stream) _f(close_stream) _f(get_log_level)
176180

177181
#define FOR_ALL_WASI_FUNCTIONS(_f) \
178-
_f(fd_write) _f(fd_read) _f(fd_seek) _f(fd_close) _f(fd_fdstat_get) _f(environ_get) \
179-
_f(environ_sizes_get) _f(args_get) _f(args_sizes_get) _f(clock_time_get) _f(random_get) \
180-
_f(proc_exit) _f(path_open) _f(fd_prestat_get) _f(fd_prestat_dir_name)
182+
_f(fd_write) _f(fd_read) _f(fd_seek) _f(fd_close) _f(fd_fdstat_get) _f(fd_fdstat_set_flags) \
183+
_f(environ_get) _f(environ_sizes_get) _f(args_get) _f(args_sizes_get) _f(clock_time_get) \
184+
_f(random_get) _f(sched_yield) _f(poll_oneoff) _f(proc_exit) _f(path_open) \
185+
_f(fd_prestat_get) _f(fd_prestat_dir_name) _f(path_filestat_get)
181186

182187
// Helpers to generate a stub to pass to VM, in place of a restricted proxy-wasm capability.
183188
#define _CREATE_PROXY_WASM_STUB(_fn) \

Diff for: src/exports.cc

+33
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,9 @@ Word grpc_send(Word token, Word message_ptr, Word message_size, Word end_stream)
671671
return context->grpcSend(token, message.value(), end_stream != 0U);
672672
}
673673

674+
// WASIp1 typings in comments sourced from
675+
// https://github.com/WebAssembly/wasi-libc/blob/446cb3f1aa21f9b1a1eab372f82d65d19003e924/libc-bottom-half/headers/public/wasi/api.h
676+
674677
// __wasi_errno_t path_open(__wasi_fd_t fd, __wasi_lookupflags_t dirflags, const char *path,
675678
// size_t path_len, __wasi_oflags_t oflags, __wasi_rights_t fs_rights_base, __wasi_rights_t
676679
// fs_rights_inheriting, __wasi_fdflags_t fdflags, __wasi_fd_t *retptr0)
@@ -781,6 +784,14 @@ Word wasi_unstable_fd_close(Word /*fd*/) {
781784
return 0;
782785
}
783786

787+
// __wasi_errno_t __wasi_path_filestat_get(__wasi_fd_t fd,__wasi_lookupflags_t flags,const char
788+
// *path,size_t path_len,__wasi_filestat_t *buf);
789+
790+
Word wasi_unstable_path_filestat_get(Word /*fd*/, Word /*flags*/, Word /*path*/, Word /*path_len*/,
791+
Word /*buf*/) {
792+
return 58; // __WASI_ENOTSUP
793+
}
794+
784795
// __wasi_errno_t __wasi_fd_fdstat_get(__wasi_fd_t fd, __wasi_fdstat_t *stat)
785796
Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut) {
786797
// We will only support this interface on stdout and stderr
@@ -801,6 +812,13 @@ Word wasi_unstable_fd_fdstat_get(Word fd, Word statOut) {
801812
return 0; // __WASI_ESUCCESS
802813
}
803814

815+
// __wasi_errno_t __wasi_fd_fdstat_set_flags(__wasi_fd_t fd, __wasi_fdflags_t flags)
816+
Word wasi_unstable_fd_fdstat_set_flags(Word /*fd*/, Word /*flags*/) {
817+
// Flags that can be specified: append, dsync, nonblock, rsync, and sync. Proxy-wasm only supports
818+
// STDOUT and STDERR, but none of these flags have any effect in Proxy-Wasm.
819+
return 52; // __WASI_ERRNO_ENOSYS
820+
}
821+
804822
// __wasi_errno_t __wasi_environ_get(char **environ, char *environ_buf);
805823
Word wasi_unstable_environ_get(Word environ_array_ptr, Word environ_buf) {
806824
auto *context = contextOrEffectiveContext();
@@ -904,6 +922,21 @@ Word wasi_unstable_random_get(Word result_buf_ptr, Word buf_len) {
904922
return 0; // __WASI_ESUCCESS
905923
}
906924

925+
// __wasi_errno_t __wasi_sched_yield()
926+
Word wasi_unstable_sched_yield() {
927+
// Per POSIX man pages, it is valid to return success if the calling thread is the only thread in
928+
// the highest priority list. This is vacuously true for wasm without threads. There are no valid
929+
// error cases defined.
930+
return 0; // __WASI_ESUCCESS
931+
}
932+
933+
// __wasi_errno_t __wasi_poll_oneoff(const __wasi_subscription_t *in, __wasi_event_t *out,
934+
// __wasi_size_t nsubscriptions, __wasi_size_t *nevents)
935+
Word wasi_unstable_poll_oneoff(Word /*in*/, Word /*out*/, Word /*nsubscriptions*/,
936+
Word /*nevents_ptr*/) {
937+
return 52; // __WASI_ERRNO_ENOSYS
938+
}
939+
907940
// void __wasi_proc_exit(__wasi_exitcode_t rval);
908941
void wasi_unstable_proc_exit(Word /*exit_code*/) {
909942
auto *context = contextOrEffectiveContext();

Diff for: src/wasm.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ void WasmBase::startVm(ContextBase *root_context) {
413413
// time
414414
"wasi_unstable.clock_time_get", "wasi_snapshot_preview1.clock_time_get",
415415
// random
416-
"wasi_unstable.random_get", "wasi_snapshot_preview1.random_get"});
416+
"wasi_unstable.random_get", "wasi_snapshot_preview1.random_get",
417+
// Go runtime initialization
418+
"wasi_unstable.fd_fdstat_get", "wasi_snapshot_preview1.fd_fdstat_get",
419+
"wasi_unstable.fd_fdstat_set_flags", "wasi_snapshot_preview1.fd_fdstat_set_flags",
420+
"wasi_unstable.path_filestat_get"});
417421
if (_initialize_) {
418422
// WASI reactor.
419423
_initialize_(root_context);

0 commit comments

Comments
 (0)