diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c09dd6df..d35c4d82 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,8 +85,9 @@ jobs: - name: Build libc shell: bash run: | - make -j4 - WASI_SNAPSHOT=preview2 make -j4 + make -j4 TARGET_TRIPLE=wasm32-wasi + make -j4 TARGET_TRIPLE=wasm32-wasip1 + make -j4 TARGET_TRIPLE=wasm32-wasip2 WASI_SNAPSHOT=p2 - name: Build libc + threads # Only build the thread-capable wasi-libc in the latest supported Clang @@ -94,7 +95,9 @@ jobs: # (e.g., `__builtin_wasm_memory_atomic_notify`). if: matrix.clang_version != '10.0.0' shell: bash - run: make -j4 THREAD_MODEL=posix + run: | + make -j4 THREAD_MODEL=posix TARGET_TRIPLE=wasm32-wasi-threads + make -j4 THREAD_MODEL=posix TARGET_TRIPLE=wasm32-wasip1-threads - name: Test shell: bash @@ -105,13 +108,21 @@ jobs: cd test make download export WASI_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasi/) - mkdir -p $WASI_DIR + export WASIP1_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasip1/) + export WASIP2_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasip2/) + mkdir -p $WASI_DIR $WASIP1_DIR $WASIP2_DIR cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASI_DIR + cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASIP1_DIR + cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASIP2_DIR TARGET_TRIPLE=wasm32-wasi make test rm -r build - TARGET_TRIPLE=wasm32-wasi-preview2 make test + TARGET_TRIPLE=wasm32-wasip1 make test + rm -r build + TARGET_TRIPLE=wasm32-wasip2 make test rm -r build TARGET_TRIPLE=wasm32-wasi-threads make test + rm -r build + TARGET_TRIPLE=wasm32-wasip1-threads make test # The older version of Clang does not provide the expected symbol for the # test entrypoints: `undefined symbol: __main_argc_argv`. # The older (<15.0.7) version of wasm-ld does not provide `__heap_end`, diff --git a/Makefile b/Makefile index c6752a79..c1a1ad27 100644 --- a/Makefile +++ b/Makefile @@ -15,20 +15,20 @@ SYSROOT ?= $(CURDIR)/sysroot INSTALL_DIR ?= /usr/local # single or posix; note that pthread support is still a work-in-progress. THREAD_MODEL ?= single -# preview1 or preview2; the latter is not (yet) compatible with multithreading -WASI_SNAPSHOT ?= preview1 +# p1 or p2; the latter is not (yet) compatible with multithreading +WASI_SNAPSHOT ?= p1 # dlmalloc or none MALLOC_IMPL ?= dlmalloc # yes or no BUILD_LIBC_TOP_HALF ?= yes # The directory where we will store intermediate artifacts. OBJDIR ?= build/$(TARGET_TRIPLE) -# The directory where we store files and tools for generating WASI Preview 2 bindings +# The directory where we store files and tools for generating WASIp2 bindings BINDING_WORK_DIR ?= build/bindings -# URL from which to retrieve the WIT files used to generate the WASI Preview 2 bindings +# URL from which to retrieve the WIT files used to generate the WASIp2 bindings WASI_CLI_URL ?= https://github.com/WebAssembly/wasi-cli/archive/refs/tags/v0.2.0.tar.gz -# URL from which to retrieve the `wit-bindgen` command used to generate the WASI -# Preview 2 bindings. +# URL from which to retrieve the `wit-bindgen` command used to generate the +# WASIp2 bindings. WIT_BINDGEN_URL ?= https://github.com/bytecodealliance/wit-bindgen/releases/download/wit-bindgen-cli-0.17.0/wit-bindgen-v0.17.0-x86_64-linux.tar.gz # When the length is no larger than this threshold, we consider the @@ -50,8 +50,8 @@ ifeq ($(THREAD_MODEL), posix) TARGET_TRIPLE = wasm32-wasi-threads endif -ifeq ($(WASI_SNAPSHOT), preview2) -TARGET_TRIPLE = wasm32-wasi-preview2 +ifeq ($(WASI_SNAPSHOT), p2) +TARGET_TRIPLE = wasm32-wasip2 endif BUILTINS_LIB ?= $(shell ${CC} --print-libgcc-file-name) @@ -75,16 +75,16 @@ LIBC_BOTTOM_HALF_ALL_SOURCES = \ $(shell find $(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC) -name \*.c) \ $(shell find $(LIBC_BOTTOM_HALF_SOURCES) -name \*.c)) -ifeq ($(WASI_SNAPSHOT), preview1) -# Omit source files not relevant to WASI Preview 1. As we introduce files -# supporting `wasi-sockets` for `wasm32-wasi-preview2`, we'll add those files to +ifeq ($(WASI_SNAPSHOT), p1) +# Omit source files not relevant to WASIp1. As we introduce files +# supporting `wasi-sockets` for `wasm32-wasip2`, we'll add those files to # this list. LIBC_BOTTOM_HALF_OMIT_SOURCES := \ - $(LIBC_BOTTOM_HALF_SOURCES)/preview2.c \ + $(LIBC_BOTTOM_HALF_SOURCES)/wasip2.c \ $(LIBC_BOTTOM_HALF_SOURCES)/descriptor_table.c LIBC_BOTTOM_HALF_ALL_SOURCES := $(filter-out $(LIBC_BOTTOM_HALF_OMIT_SOURCES),$(LIBC_BOTTOM_HALF_ALL_SOURCES)) -# Omit preview2-specific headers from include-all.c test. -INCLUDE_ALL_CLAUSES := -not -name preview2.h -not -name descriptor_table.h +# Omit p2-specific headers from include-all.c test. +INCLUDE_ALL_CLAUSES := -not -name wasip2.h -not -name descriptor_table.h endif # FIXME(https://reviews.llvm.org/D85567) - due to a bug in LLD the weak @@ -382,8 +382,8 @@ DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES)) EMMALLOC_OBJS = $(call objs,$(EMMALLOC_SOURCES)) LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES)) LIBC_TOP_HALF_ALL_OBJS = $(call asmobjs,$(call objs,$(LIBC_TOP_HALF_ALL_SOURCES))) -ifeq ($(WASI_SNAPSHOT), preview2) -LIBC_OBJS += $(OBJDIR)/preview2_component_type.o +ifeq ($(WASI_SNAPSHOT), p2) +LIBC_OBJS += $(OBJDIR)/wasip2_component_type.o endif ifeq ($(MALLOC_IMPL),dlmalloc) LIBC_OBJS += $(DLMALLOC_OBJS) @@ -606,7 +606,7 @@ $(OBJDIR)/%.long-double.pic.o: %.c include_dirs @mkdir -p "$(@D)" $(CC) $(CFLAGS) -MD -MP -o $@ -c $< -$(OBJDIR)/preview2_component_type.pic.o $(OBJDIR)/preview2_component_type.o: $(LIBC_BOTTOM_HALF_SOURCES)/preview2_component_type.o +$(OBJDIR)/wasip2_component_type.pic.o $(OBJDIR)/wasip2_component_type.o: $(LIBC_BOTTOM_HALF_SOURCES)/wasip2_component_type.o @mkdir -p "$(@D)" cp $< $@ @@ -741,6 +741,17 @@ endif DEFINED_SYMBOLS = $(SYSROOT_SHARE)/defined-symbols.txt UNDEFINED_SYMBOLS = $(SYSROOT_SHARE)/undefined-symbols.txt +ifeq ($(WASI_SNAPSHOT),p2) +EXPECTED_TARGET_DIR = expected/wasm32-wasip2 +else +ifeq ($(THREAD_MODEL),posix) +EXPECTED_TARGET_DIR = expected/wasm32-wasip1-threads +else +EXPECTED_TARGET_DIR = expected/wasm32-wasip1 +endif +endif + + check-symbols: startup_files libc # # Collect metadata on the sysroot and perform sanity checks. @@ -836,7 +847,7 @@ check-symbols: startup_files libc # Check that the computed metadata matches the expected metadata. # This ignores whitespace because on Windows the output has CRLF line endings. - diff -wur "expected/$(TARGET_TRIPLE)" "$(SYSROOT_SHARE)" + diff -wur "$(EXPECTED_TARGET_DIR)" "$(SYSROOT_SHARE)" install: finish mkdir -p "$(INSTALL_DIR)" @@ -860,7 +871,7 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen cd "$(BINDING_WORK_DIR)" && \ ./wit-bindgen/wit-bindgen c \ --autodrop-borrows yes \ - --rename-world preview2 \ + --rename-world wasip2 \ --type-section-suffix __wasi_libc \ --world wasi:cli/imports@0.2.0 \ --rename wasi:clocks/monotonic-clock@0.2.0=monotonic_clock \ @@ -891,12 +902,12 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen --rename wasi:cli/terminal-stdout@0.2.0=terminal_stdout \ --rename wasi:cli/terminal-stderr@0.2.0=terminal_stderr \ ./wasi-cli/wit && \ - mv preview2.h ../../libc-bottom-half/headers/public/wasi/ && \ - mv preview2_component_type.o ../../libc-bottom-half/sources && \ - sed 's_#include "preview2\.h"_#include "wasi/preview2.h"_' \ - < preview2.c \ - > ../../libc-bottom-half/sources/preview2.c && \ - rm preview2.c + mv wasip2.h ../../libc-bottom-half/headers/public/wasi/ && \ + mv wasip2_component_type.o ../../libc-bottom-half/sources && \ + sed 's_#include "wasip2\.h"_#include "wasi/wasip2.h"_' \ + < wasip2.c \ + > ../../libc-bottom-half/sources/wasip2.c && \ + rm wasip2.c clean: diff --git a/expected/wasm32-wasi-threads/defined-symbols.txt b/expected/wasm32-wasip1-threads/defined-symbols.txt similarity index 100% rename from expected/wasm32-wasi-threads/defined-symbols.txt rename to expected/wasm32-wasip1-threads/defined-symbols.txt diff --git a/expected/wasm32-wasi-threads/include-all.c b/expected/wasm32-wasip1-threads/include-all.c similarity index 100% rename from expected/wasm32-wasi-threads/include-all.c rename to expected/wasm32-wasip1-threads/include-all.c diff --git a/expected/wasm32-wasi-threads/predefined-macros.txt b/expected/wasm32-wasip1-threads/predefined-macros.txt similarity index 100% rename from expected/wasm32-wasi-threads/predefined-macros.txt rename to expected/wasm32-wasip1-threads/predefined-macros.txt diff --git a/expected/wasm32-wasi-threads/undefined-symbols.txt b/expected/wasm32-wasip1-threads/undefined-symbols.txt similarity index 100% rename from expected/wasm32-wasi-threads/undefined-symbols.txt rename to expected/wasm32-wasip1-threads/undefined-symbols.txt diff --git a/expected/wasm32-wasi/defined-symbols.txt b/expected/wasm32-wasip1/defined-symbols.txt similarity index 100% rename from expected/wasm32-wasi/defined-symbols.txt rename to expected/wasm32-wasip1/defined-symbols.txt diff --git a/expected/wasm32-wasi/include-all.c b/expected/wasm32-wasip1/include-all.c similarity index 100% rename from expected/wasm32-wasi/include-all.c rename to expected/wasm32-wasip1/include-all.c diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasip1/predefined-macros.txt similarity index 100% rename from expected/wasm32-wasi/predefined-macros.txt rename to expected/wasm32-wasip1/predefined-macros.txt diff --git a/expected/wasm32-wasi/undefined-symbols.txt b/expected/wasm32-wasip1/undefined-symbols.txt similarity index 100% rename from expected/wasm32-wasi/undefined-symbols.txt rename to expected/wasm32-wasip1/undefined-symbols.txt diff --git a/expected/wasm32-wasi-preview2/defined-symbols.txt b/expected/wasm32-wasip2/defined-symbols.txt similarity index 98% rename from expected/wasm32-wasi-preview2/defined-symbols.txt rename to expected/wasm32-wasip2/defined-symbols.txt index 9c4408c5..bf4b07a6 100644 --- a/expected/wasm32-wasi-preview2/defined-symbols.txt +++ b/expected/wasm32-wasip2/defined-symbols.txt @@ -19,8 +19,8 @@ __c_locale __clock __clock_gettime __clock_nanosleep -__component_type_object_force_link_preview2 -__component_type_object_force_link_preview2_public_use_in_this_compilation_unit +__component_type_object_force_link_wasip2 +__component_type_object_force_link_wasip2_public_use_in_this_compilation_unit __cos __cosdf __cosl @@ -1008,15 +1008,6 @@ powf powl pread preadv -preview2_list_string_free -preview2_list_tuple2_string_string_free -preview2_list_u32_free -preview2_list_u8_free -preview2_option_string_free -preview2_string_dup -preview2_string_free -preview2_string_set -preview2_tuple2_string_string_free printf program_invocation_name program_invocation_short_name @@ -1384,6 +1375,15 @@ vwprintf vwscanf wall_clock_now wall_clock_resolution +wasip2_list_string_free +wasip2_list_tuple2_string_string_free +wasip2_list_u32_free +wasip2_list_u8_free +wasip2_option_string_free +wasip2_string_dup +wasip2_string_free +wasip2_string_set +wasip2_tuple2_string_string_free wcpcpy wcpncpy wcrtomb diff --git a/expected/wasm32-wasi-preview2/include-all.c b/expected/wasm32-wasip2/include-all.c similarity index 99% rename from expected/wasm32-wasi-preview2/include-all.c rename to expected/wasm32-wasip2/include-all.c index 3de5cf01..db324a96 100644 --- a/expected/wasm32-wasi-preview2/include-all.c +++ b/expected/wasm32-wasip2/include-all.c @@ -168,6 +168,6 @@ #include #include #include -#include +#include #include #include diff --git a/expected/wasm32-wasi-preview2/predefined-macros.txt b/expected/wasm32-wasip2/predefined-macros.txt similarity index 99% rename from expected/wasm32-wasi-preview2/predefined-macros.txt rename to expected/wasm32-wasip2/predefined-macros.txt index 77b1db05..961a38a3 100644 --- a/expected/wasm32-wasi-preview2/predefined-macros.txt +++ b/expected/wasm32-wasip2/predefined-macros.txt @@ -2474,7 +2474,7 @@ #define __BIGGEST_ALIGNMENT__ 16 #define __BIG_ENDIAN 4321 #define __BIND 19950621 -#define __BINDINGS_PREVIEW2_H +#define __BINDINGS_WASIP2_H #define __BYTE_ORDER __BYTE_ORDER__ #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __CHAR16_TYPE__ unsigned short diff --git a/expected/wasm32-wasi-preview2/undefined-symbols.txt b/expected/wasm32-wasip2/undefined-symbols.txt similarity index 100% rename from expected/wasm32-wasi-preview2/undefined-symbols.txt rename to expected/wasm32-wasip2/undefined-symbols.txt diff --git a/libc-bottom-half/headers/private/wasi/descriptor_table.h b/libc-bottom-half/headers/private/wasi/descriptor_table.h index aeec5bdd..8e9a90d9 100644 --- a/libc-bottom-half/headers/private/wasi/descriptor_table.h +++ b/libc-bottom-half/headers/private/wasi/descriptor_table.h @@ -1,7 +1,7 @@ #ifndef DESCRIPTOR_TABLE_H #define DESCRIPTOR_TABLE_H -#include +#include typedef struct { int dummy; diff --git a/libc-bottom-half/headers/public/wasi/preview2.h b/libc-bottom-half/headers/public/wasi/wasip2.h similarity index 96% rename from libc-bottom-half/headers/public/wasi/preview2.h rename to libc-bottom-half/headers/public/wasi/wasip2.h index 821eb897..49bb9b87 100644 --- a/libc-bottom-half/headers/public/wasi/preview2.h +++ b/libc-bottom-half/headers/public/wasi/wasip2.h @@ -1,6 +1,6 @@ // Generated by `wit-bindgen` 0.17.0. DO NOT EDIT! -#ifndef __BINDINGS_PREVIEW2_H -#define __BINDINGS_PREVIEW2_H +#ifndef __BINDINGS_WASIP2_H +#define __BINDINGS_WASIP2_H #ifdef __cplusplus extern "C" { #endif @@ -13,27 +13,27 @@ extern "C" { typedef struct { uint8_t*ptr; size_t len; -} preview2_string_t; +} wasip2_string_t; typedef struct { - preview2_string_t f0; - preview2_string_t f1; -} preview2_tuple2_string_string_t; + wasip2_string_t f0; + wasip2_string_t f1; +} wasip2_tuple2_string_string_t; typedef struct { - preview2_tuple2_string_string_t *ptr; + wasip2_tuple2_string_string_t *ptr; size_t len; -} preview2_list_tuple2_string_string_t; +} wasip2_list_tuple2_string_string_t; typedef struct { - preview2_string_t *ptr; + wasip2_string_t *ptr; size_t len; -} preview2_list_string_t; +} wasip2_list_string_t; typedef struct { bool is_some; - preview2_string_t val; -} preview2_option_string_t; + wasip2_string_t val; +} wasip2_option_string_t; typedef struct { bool is_err; @@ -63,7 +63,7 @@ typedef struct { typedef struct { uint32_t *ptr; size_t len; -} preview2_list_u32_t; +} wasip2_list_u32_t; typedef io_error_own_error_t streams_own_error_t; @@ -103,12 +103,12 @@ typedef struct streams_borrow_output_stream_t { typedef struct { uint8_t *ptr; size_t len; -} preview2_list_u8_t; +} wasip2_list_u8_t; typedef struct { bool is_err; union { - preview2_list_u8_t ok; + wasip2_list_u8_t ok; streams_stream_error_t err; } val; } streams_result_list_u8_stream_error_t; @@ -336,7 +336,7 @@ typedef struct { // The type of the file referred to by this directory entry. filesystem_descriptor_type_t type; // The name of the object. - preview2_string_t name; + wasip2_string_t name; } filesystem_directory_entry_t; // Error codes returned by functions, similar to `errno` in POSIX. @@ -511,14 +511,14 @@ typedef struct { } filesystem_result_descriptor_type_error_code_t; typedef struct { - preview2_list_u8_t f0; + wasip2_list_u8_t f0; bool f1; -} preview2_tuple2_list_u8_bool_t; +} wasip2_tuple2_list_u8_bool_t; typedef struct { bool is_err; union { - preview2_tuple2_list_u8_bool_t ok; + wasip2_tuple2_list_u8_bool_t ok; filesystem_error_code_t err; } val; } filesystem_result_tuple2_list_u8_bool_error_code_t; @@ -558,7 +558,7 @@ typedef struct { typedef struct { bool is_err; union { - preview2_string_t ok; + wasip2_string_t ok; filesystem_error_code_t err; } val; } filesystem_result_string_error_code_t; @@ -595,7 +595,7 @@ typedef filesystem_own_descriptor_t filesystem_preopens_own_descriptor_t; typedef struct { filesystem_preopens_own_descriptor_t f0; - preview2_string_t f1; + wasip2_string_t f1; } filesystem_preopens_tuple2_own_descriptor_string_t; typedef struct { @@ -763,7 +763,7 @@ typedef struct { // The payload. // // Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes. - preview2_list_u8_t data; + wasip2_list_u8_t data; // The source address. // // This field is guaranteed to match the remote address the stream was initialized with, if any. @@ -780,7 +780,7 @@ typedef struct { // A datagram to be sent out. typedef struct { // The payload. - preview2_list_u8_t data; + wasip2_list_u8_t data; // The destination address. // // The requirements on this field depend on how the stream was initialized: @@ -1064,7 +1064,7 @@ typedef poll_own_pollable_t ip_name_lookup_own_pollable_t; typedef struct { uint64_t f0; uint64_t f1; -} preview2_tuple2_u64_u64_t; +} wasip2_tuple2_u64_u64_t; // Imported Functions from `wasi:cli/environment@0.2.0` // Get the POSIX-style environment variables. @@ -1075,12 +1075,12 @@ typedef struct { // Morally, these are a value import, but until value imports are available // in the component model, this import function should return the same // values each time it is called. -extern void environment_get_environment(preview2_list_tuple2_string_string_t *ret); +extern void environment_get_environment(wasip2_list_tuple2_string_string_t *ret); // Get the POSIX-style arguments to the program. -extern void environment_get_arguments(preview2_list_string_t *ret); +extern void environment_get_arguments(wasip2_list_string_t *ret); // Return a path that programs should use as their initial current working // directory, interpreting `.` as shorthand for this. -extern bool environment_initial_cwd(preview2_string_t *ret); +extern bool environment_initial_cwd(wasip2_string_t *ret); // Imported Functions from `wasi:cli/exit@0.2.0` // Exit the current instance and any linked instances. @@ -1094,7 +1094,7 @@ extern void exit_exit(exit_result_void_void_t *status); // It may change across platforms, hosts, or other implementation // details. Parsing this string is a major platform-compatibility // hazard. -extern void io_error_method_error_to_debug_string(io_error_borrow_error_t self, preview2_string_t *ret); +extern void io_error_method_error_to_debug_string(io_error_borrow_error_t self, wasip2_string_t *ret); // Imported Functions from `wasi:io/poll@0.2.0` // Return the readiness of a pollable. This function never blocks. @@ -1125,7 +1125,7 @@ extern void poll_method_pollable_block(poll_borrow_pollable_t self); // do any I/O so it doesn't fail. If any of the I/O sources identified by // the pollables has an error, it is indicated by marking the source as // being reaedy for I/O. -extern void poll_poll(poll_list_borrow_pollable_t *in, preview2_list_u32_t *ret); +extern void poll_poll(poll_list_borrow_pollable_t *in, wasip2_list_u32_t *ret); // Imported Functions from `wasi:io/streams@0.2.0` // Perform a non-blocking read from the stream. @@ -1154,10 +1154,10 @@ extern void poll_poll(poll_list_borrow_pollable_t *in, preview2_list_u32_t *ret) // is not possible to allocate in wasm32, or not desirable to allocate as // as a return value by the callee. The callee may return a list of bytes // less than `len` in size while more bytes are available for reading. -extern bool streams_method_input_stream_read(streams_borrow_input_stream_t self, uint64_t len, preview2_list_u8_t *ret, streams_stream_error_t *err); +extern bool streams_method_input_stream_read(streams_borrow_input_stream_t self, uint64_t len, wasip2_list_u8_t *ret, streams_stream_error_t *err); // Read bytes from a stream, after blocking until at least one byte can // be read. Except for blocking, behavior is identical to `read`. -extern bool streams_method_input_stream_blocking_read(streams_borrow_input_stream_t self, uint64_t len, preview2_list_u8_t *ret, streams_stream_error_t *err); +extern bool streams_method_input_stream_blocking_read(streams_borrow_input_stream_t self, uint64_t len, wasip2_list_u8_t *ret, streams_stream_error_t *err); // Skip bytes from a stream. Returns number of bytes skipped. // // Behaves identical to `read`, except instead of returning a list @@ -1196,7 +1196,7 @@ extern bool streams_method_output_stream_check_write(streams_borrow_output_strea // // returns Err(closed) without writing if the stream has closed since // the last call to check-write provided a permit. -extern bool streams_method_output_stream_write(streams_borrow_output_stream_t self, preview2_list_u8_t *contents, streams_stream_error_t *err); +extern bool streams_method_output_stream_write(streams_borrow_output_stream_t self, wasip2_list_u8_t *contents, streams_stream_error_t *err); // Perform a write of up to 4096 bytes, and then flush the stream. Block // until all of these operations are complete, or an error occurs. // @@ -1221,7 +1221,7 @@ extern bool streams_method_output_stream_write(streams_borrow_output_stream_t se // // Check for any errors that arose during `flush` // let _ = this.check-write(); // eliding error handling // ``` -extern bool streams_method_output_stream_blocking_write_and_flush(streams_borrow_output_stream_t self, preview2_list_u8_t *contents, streams_stream_error_t *err); +extern bool streams_method_output_stream_blocking_write_and_flush(streams_borrow_output_stream_t self, wasip2_list_u8_t *contents, streams_stream_error_t *err); // Request to flush buffered output. This function never blocks. // // This tells the output-stream that the caller intends any buffered @@ -1436,7 +1436,7 @@ extern bool filesystem_method_descriptor_set_times(filesystem_borrow_descriptor_ // In the future, this may change to return a `stream`. // // Note: This is similar to `pread` in POSIX. -extern bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t self, filesystem_filesize_t length, filesystem_filesize_t offset, preview2_tuple2_list_u8_bool_t *ret, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t self, filesystem_filesize_t length, filesystem_filesize_t offset, wasip2_tuple2_list_u8_bool_t *ret, filesystem_error_code_t *err); // Write to a descriptor, without using and updating the descriptor's offset. // // It is valid to write past the end of a file; the file is extended to the @@ -1446,7 +1446,7 @@ extern bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t sel // In the future, this may change to take a `stream`. // // Note: This is similar to `pwrite` in POSIX. -extern bool filesystem_method_descriptor_write(filesystem_borrow_descriptor_t self, preview2_list_u8_t *buffer, filesystem_filesize_t offset, filesystem_filesize_t *ret, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_write(filesystem_borrow_descriptor_t self, wasip2_list_u8_t *buffer, filesystem_filesize_t offset, filesystem_filesize_t *ret, filesystem_error_code_t *err); // Read directory entries from a directory. // // On filesystems where directories contain entries referring to themselves @@ -1467,7 +1467,7 @@ extern bool filesystem_method_descriptor_sync(filesystem_borrow_descriptor_t sel // Create a directory. // // Note: This is similar to `mkdirat` in POSIX. -extern bool filesystem_method_descriptor_create_directory_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_create_directory_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, filesystem_error_code_t *err); // Return the attributes of an open file or directory. // // Note: This is similar to `fstat` in POSIX, except that it does not return @@ -1485,18 +1485,18 @@ extern bool filesystem_method_descriptor_stat(filesystem_borrow_descriptor_t sel // discussion of alternatives. // // Note: This was called `path_filestat_get` in earlier versions of WASI. -extern bool filesystem_method_descriptor_stat_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_descriptor_stat_t *ret, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_stat_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_descriptor_stat_t *ret, filesystem_error_code_t *err); // Adjust the timestamps of a file or directory. // // Note: This is similar to `utimensat` in POSIX. // // Note: This was called `path_filestat_set_times` in earlier versions of // WASI. -extern bool filesystem_method_descriptor_set_times_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_new_timestamp_t *data_access_timestamp, filesystem_new_timestamp_t *data_modification_timestamp, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_set_times_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_new_timestamp_t *data_access_timestamp, filesystem_new_timestamp_t *data_modification_timestamp, filesystem_error_code_t *err); // Create a hard link. // // Note: This is similar to `linkat` in POSIX. -extern bool filesystem_method_descriptor_link_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t old_path_flags, preview2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, preview2_string_t *new_path, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_link_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t old_path_flags, wasip2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, wasip2_string_t *new_path, filesystem_error_code_t *err); // Open a file or directory. // // The returned descriptor is not guaranteed to be the lowest-numbered @@ -1515,36 +1515,36 @@ extern bool filesystem_method_descriptor_link_at(filesystem_borrow_descriptor_t // `error-code::read-only`. // // Note: This is similar to `openat` in POSIX. -extern bool filesystem_method_descriptor_open_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_open_flags_t open_flags, filesystem_descriptor_flags_t flags, filesystem_own_descriptor_t *ret, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_open_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_open_flags_t open_flags, filesystem_descriptor_flags_t flags, filesystem_own_descriptor_t *ret, filesystem_error_code_t *err); // Read the contents of a symbolic link. // // If the contents contain an absolute or rooted path in the underlying // filesystem, this function fails with `error-code::not-permitted`. // // Note: This is similar to `readlinkat` in POSIX. -extern bool filesystem_method_descriptor_readlink_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, preview2_string_t *ret, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_readlink_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, wasip2_string_t *ret, filesystem_error_code_t *err); // Remove a directory. // // Return `error-code::not-empty` if the directory is not empty. // // Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. -extern bool filesystem_method_descriptor_remove_directory_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_remove_directory_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, filesystem_error_code_t *err); // Rename a filesystem object. // // Note: This is similar to `renameat` in POSIX. -extern bool filesystem_method_descriptor_rename_at(filesystem_borrow_descriptor_t self, preview2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, preview2_string_t *new_path, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_rename_at(filesystem_borrow_descriptor_t self, wasip2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, wasip2_string_t *new_path, filesystem_error_code_t *err); // Create a symbolic link (also known as a "symlink"). // // If `old-path` starts with `/`, the function fails with // `error-code::not-permitted`. // // Note: This is similar to `symlinkat` in POSIX. -extern bool filesystem_method_descriptor_symlink_at(filesystem_borrow_descriptor_t self, preview2_string_t *old_path, preview2_string_t *new_path, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_symlink_at(filesystem_borrow_descriptor_t self, wasip2_string_t *old_path, wasip2_string_t *new_path, filesystem_error_code_t *err); // Unlink a filesystem object that is not a directory. // // Return `error-code::is-directory` if the path refers to a directory. // Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. -extern bool filesystem_method_descriptor_unlink_file_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_unlink_file_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, filesystem_error_code_t *err); // Test whether two descriptors refer to the same filesystem object. // // In POSIX, this corresponds to testing whether the two descriptors have the @@ -1576,7 +1576,7 @@ extern bool filesystem_method_descriptor_metadata_hash(filesystem_borrow_descrip // to by a directory descriptor and a relative path. // // This performs the same hash computation as `metadata-hash`. -extern bool filesystem_method_descriptor_metadata_hash_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_metadata_hash_value_t *ret, filesystem_error_code_t *err); +extern bool filesystem_method_descriptor_metadata_hash_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_metadata_hash_value_t *ret, filesystem_error_code_t *err); // Read a single directory entry from a `directory-entry-stream`. extern bool filesystem_method_directory_entry_stream_read_directory_entry(filesystem_borrow_directory_entry_stream_t self, filesystem_option_directory_entry_t *ret, filesystem_error_code_t *err); // Attempts to extract a filesystem-related `error-code` from the stream @@ -2174,7 +2174,7 @@ extern bool tcp_create_socket_create_tcp_socket(tcp_create_socket_ip_address_fam // - // - // - -extern bool ip_name_lookup_resolve_addresses(ip_name_lookup_borrow_network_t network, preview2_string_t *name, ip_name_lookup_own_resolve_address_stream_t *ret, ip_name_lookup_error_code_t *err); +extern bool ip_name_lookup_resolve_addresses(ip_name_lookup_borrow_network_t network, wasip2_string_t *name, ip_name_lookup_own_resolve_address_stream_t *ret, ip_name_lookup_error_code_t *err); // Returns the next address from the resolver. // // This function should be called multiple times. On each call, it will @@ -2208,7 +2208,7 @@ extern ip_name_lookup_own_pollable_t ip_name_lookup_method_resolve_address_strea // This function must always return fresh data. Deterministic environments // must omit this function, rather than implementing it with deterministic // data. -extern void random_get_random_bytes(uint64_t len, preview2_list_u8_t *ret); +extern void random_get_random_bytes(uint64_t len, wasip2_list_u8_t *ret); // Return a cryptographically-secure random or pseudo-random `u64` value. // // This function returns the same type of data as `get-random-bytes`, @@ -2224,7 +2224,7 @@ extern uint64_t random_get_random_u64(void); // There are no requirements on the values of the returned bytes, however // implementations are encouraged to return evenly distributed values with // a long period. -extern void random_insecure_get_insecure_random_bytes(uint64_t len, preview2_list_u8_t *ret); +extern void random_insecure_get_insecure_random_bytes(uint64_t len, wasip2_list_u8_t *ret); // Return an insecure pseudo-random `u64` value. // // This function returns the same type of pseudo-random data as @@ -2249,17 +2249,17 @@ extern uint64_t random_insecure_get_insecure_random_u64(void); // This will likely be changed to a value import, to prevent it from being // called multiple times and potentially used for purposes other than DoS // protection. -extern void random_insecure_seed_insecure_seed(preview2_tuple2_u64_u64_t *ret); +extern void random_insecure_seed_insecure_seed(wasip2_tuple2_u64_u64_t *ret); // Helper Functions -void preview2_tuple2_string_string_free(preview2_tuple2_string_string_t *ptr); +void wasip2_tuple2_string_string_free(wasip2_tuple2_string_string_t *ptr); -void preview2_list_tuple2_string_string_free(preview2_list_tuple2_string_string_t *ptr); +void wasip2_list_tuple2_string_string_free(wasip2_list_tuple2_string_string_t *ptr); -void preview2_list_string_free(preview2_list_string_t *ptr); +void wasip2_list_string_free(wasip2_list_string_t *ptr); -void preview2_option_string_free(preview2_option_string_t *ptr); +void wasip2_option_string_free(wasip2_option_string_t *ptr); void exit_result_void_void_free(exit_result_void_void_t *ptr); @@ -2277,7 +2277,7 @@ extern poll_borrow_pollable_t poll_borrow_pollable(poll_own_pollable_t handle); void poll_list_borrow_pollable_free(poll_list_borrow_pollable_t *ptr); -void preview2_list_u32_free(preview2_list_u32_t *ptr); +void wasip2_list_u32_free(wasip2_list_u32_t *ptr); void streams_stream_error_free(streams_stream_error_t *ptr); @@ -2293,7 +2293,7 @@ extern void streams_output_stream_drop_borrow(streams_borrow_output_stream_t han extern streams_borrow_output_stream_t streams_borrow_output_stream(streams_own_output_stream_t handle); -void preview2_list_u8_free(preview2_list_u8_t *ptr); +void wasip2_list_u8_free(wasip2_list_u8_t *ptr); void streams_result_list_u8_stream_error_free(streams_result_list_u8_stream_error_t *ptr); @@ -2470,15 +2470,15 @@ void ip_name_lookup_option_ip_address_free(ip_name_lookup_option_ip_address_t *p void ip_name_lookup_result_option_ip_address_error_code_free(ip_name_lookup_result_option_ip_address_error_code_t *ptr); // Transfers ownership of `s` into the string `ret` -void preview2_string_set(preview2_string_t *ret, char*s); +void wasip2_string_set(wasip2_string_t *ret, char*s); // Creates a copy of the input nul-terminate string `s` and // stores it into the component model string `ret`. -void preview2_string_dup(preview2_string_t *ret, const char*s); +void wasip2_string_dup(wasip2_string_t *ret, const char*s); // Deallocates the string pointed to by `ret`, deallocating // the memory behind the string. -void preview2_string_free(preview2_string_t *ret); +void wasip2_string_free(wasip2_string_t *ret); #ifdef __cplusplus } diff --git a/libc-bottom-half/sources/preview2.c b/libc-bottom-half/sources/wasip2.c similarity index 96% rename from libc-bottom-half/sources/preview2.c rename to libc-bottom-half/sources/wasip2.c index 4d4c1bfd..c55c3b06 100644 --- a/libc-bottom-half/sources/preview2.c +++ b/libc-bottom-half/sources/wasip2.c @@ -1,5 +1,5 @@ // Generated by `wit-bindgen` 0.17.0. DO NOT EDIT! -#include "wasi/preview2.h" +#include "wasi/wasip2.h" __attribute__((__import_module__("wasi:cli/environment@0.2.0"), __import_name__("get-environment"))) @@ -379,32 +379,32 @@ void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { // Helper Functions -void preview2_tuple2_string_string_free(preview2_tuple2_string_string_t *ptr) { - preview2_string_free(&ptr->f0); - preview2_string_free(&ptr->f1); +void wasip2_tuple2_string_string_free(wasip2_tuple2_string_string_t *ptr) { + wasip2_string_free(&ptr->f0); + wasip2_string_free(&ptr->f1); } -void preview2_list_tuple2_string_string_free(preview2_list_tuple2_string_string_t *ptr) { +void wasip2_list_tuple2_string_string_free(wasip2_list_tuple2_string_string_t *ptr) { for (size_t i = 0; i < ptr->len; i++) { - preview2_tuple2_string_string_free(&ptr->ptr[i]); + wasip2_tuple2_string_string_free(&ptr->ptr[i]); } if (ptr->len > 0) { free(ptr->ptr); } } -void preview2_list_string_free(preview2_list_string_t *ptr) { +void wasip2_list_string_free(wasip2_list_string_t *ptr) { for (size_t i = 0; i < ptr->len; i++) { - preview2_string_free(&ptr->ptr[i]); + wasip2_string_free(&ptr->ptr[i]); } if (ptr->len > 0) { free(ptr->ptr); } } -void preview2_option_string_free(preview2_option_string_t *ptr) { +void wasip2_option_string_free(wasip2_option_string_t *ptr) { if (ptr->is_some) { - preview2_string_free(&ptr->val); + wasip2_string_free(&ptr->val); } } @@ -451,7 +451,7 @@ void poll_list_borrow_pollable_free(poll_list_borrow_pollable_t *ptr) { } } -void preview2_list_u32_free(preview2_list_u32_t *ptr) { +void wasip2_list_u32_free(wasip2_list_u32_t *ptr) { for (size_t i = 0; i < ptr->len; i++) { } if (ptr->len > 0) { @@ -497,7 +497,7 @@ streams_borrow_output_stream_t streams_borrow_output_stream(streams_own_output_s return (streams_borrow_output_stream_t) { arg.__handle }; } -void preview2_list_u8_free(preview2_list_u8_t *ptr) { +void wasip2_list_u8_free(wasip2_list_u8_t *ptr) { for (size_t i = 0; i < ptr->len; i++) { } if (ptr->len > 0) { @@ -507,7 +507,7 @@ void preview2_list_u8_free(preview2_list_u8_t *ptr) { void streams_result_list_u8_stream_error_free(streams_result_list_u8_stream_error_t *ptr) { if (!ptr->is_err) { - preview2_list_u8_free(&ptr->val.ok); + wasip2_list_u8_free(&ptr->val.ok); } else { streams_stream_error_free(&ptr->val.err); } @@ -592,7 +592,7 @@ void filesystem_new_timestamp_free(filesystem_new_timestamp_t *ptr) { } void filesystem_directory_entry_free(filesystem_directory_entry_t *ptr) { - preview2_string_free(&ptr->name); + wasip2_string_free(&ptr->name); } __attribute__((__import_module__("wasi:filesystem/types@0.2.0"), __import_name__("[resource-drop]descriptor"))) @@ -688,7 +688,7 @@ void filesystem_result_own_descriptor_error_code_free(filesystem_result_own_desc void filesystem_result_string_error_code_free(filesystem_result_string_error_code_t *ptr) { if (!ptr->is_err) { - preview2_string_free(&ptr->val.ok); + wasip2_string_free(&ptr->val.ok); } else { } } @@ -718,7 +718,7 @@ void filesystem_option_error_code_free(filesystem_option_error_code_t *ptr) { } void filesystem_preopens_tuple2_own_descriptor_string_free(filesystem_preopens_tuple2_own_descriptor_string_t *ptr) { - preview2_string_free(&ptr->f1); + wasip2_string_free(&ptr->f1); } void filesystem_preopens_list_tuple2_own_descriptor_string_free(filesystem_preopens_list_tuple2_own_descriptor_string_t *ptr) { @@ -1010,18 +1010,18 @@ void ip_name_lookup_result_option_ip_address_error_code_free(ip_name_lookup_resu } } -void preview2_string_set(preview2_string_t *ret, char*s) { +void wasip2_string_set(wasip2_string_t *ret, char*s) { ret->ptr = (uint8_t*) s; ret->len = strlen(s); } -void preview2_string_dup(preview2_string_t *ret, const char*s) { +void wasip2_string_dup(wasip2_string_t *ret, const char*s) { ret->len = strlen(s); ret->ptr = cabi_realloc(NULL, 0, 1, ret->len * 1); memcpy(ret->ptr, s, ret->len * 1); } -void preview2_string_free(preview2_string_t *ret) { +void wasip2_string_free(wasip2_string_t *ret) { if (ret->len > 0) { free(ret->ptr); } @@ -1031,28 +1031,28 @@ void preview2_string_free(preview2_string_t *ret) { // Component Adapters -void environment_get_environment(preview2_list_tuple2_string_string_t *ret) { +void environment_get_environment(wasip2_list_tuple2_string_string_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; __wasm_import_environment_get_environment(ptr); - *ret = (preview2_list_tuple2_string_string_t) { (preview2_tuple2_string_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; + *ret = (wasip2_list_tuple2_string_string_t) { (wasip2_tuple2_string_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; } -void environment_get_arguments(preview2_list_string_t *ret) { +void environment_get_arguments(wasip2_list_string_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; __wasm_import_environment_get_arguments(ptr); - *ret = (preview2_list_string_t) { (preview2_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; + *ret = (wasip2_list_string_t) { (wasip2_string_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; } -bool environment_initial_cwd(preview2_string_t *ret) { +bool environment_initial_cwd(wasip2_string_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[12]; int32_t ptr = (int32_t) &ret_area; __wasm_import_environment_initial_cwd(ptr); - preview2_option_string_t option; + wasip2_option_string_t option; switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { case 0: { option.is_some = false; @@ -1060,7 +1060,7 @@ bool environment_initial_cwd(preview2_string_t *ret) { } case 1: { option.is_some = true; - option.val = (preview2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; + option.val = (wasip2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; break; } } @@ -1078,12 +1078,12 @@ void exit_exit(exit_result_void_void_t *status) { __wasm_import_exit_exit(result); } -void io_error_method_error_to_debug_string(io_error_borrow_error_t self, preview2_string_t *ret) { +void io_error_method_error_to_debug_string(io_error_borrow_error_t self, wasip2_string_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; __wasm_import_io_error_method_error_to_debug_string((self).__handle, ptr); - *ret = (preview2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; + *ret = (wasip2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; } bool poll_method_pollable_ready(poll_borrow_pollable_t self) { @@ -1095,15 +1095,15 @@ void poll_method_pollable_block(poll_borrow_pollable_t self) { __wasm_import_poll_method_pollable_block((self).__handle); } -void poll_poll(poll_list_borrow_pollable_t *in, preview2_list_u32_t *ret) { +void poll_poll(poll_list_borrow_pollable_t *in, wasip2_list_u32_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; __wasm_import_poll_poll((int32_t) (*in).ptr, (int32_t) (*in).len, ptr); - *ret = (preview2_list_u32_t) { (uint32_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; + *ret = (wasip2_list_u32_t) { (uint32_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; } -bool streams_method_input_stream_read(streams_borrow_input_stream_t self, uint64_t len, preview2_list_u8_t *ret, streams_stream_error_t *err) { +bool streams_method_input_stream_read(streams_borrow_input_stream_t self, uint64_t len, wasip2_list_u8_t *ret, streams_stream_error_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[12]; int32_t ptr = (int32_t) &ret_area; @@ -1112,7 +1112,7 @@ bool streams_method_input_stream_read(streams_borrow_input_stream_t self, uint64 switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { case 0: { result.is_err = false; - result.val.ok = (preview2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; + result.val.ok = (wasip2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; break; } case 1: { @@ -1142,7 +1142,7 @@ bool streams_method_input_stream_read(streams_borrow_input_stream_t self, uint64 } } -bool streams_method_input_stream_blocking_read(streams_borrow_input_stream_t self, uint64_t len, preview2_list_u8_t *ret, streams_stream_error_t *err) { +bool streams_method_input_stream_blocking_read(streams_borrow_input_stream_t self, uint64_t len, wasip2_list_u8_t *ret, streams_stream_error_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[12]; int32_t ptr = (int32_t) &ret_area; @@ -1151,7 +1151,7 @@ bool streams_method_input_stream_blocking_read(streams_borrow_input_stream_t sel switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { case 0: { result.is_err = false; - result.val.ok = (preview2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; + result.val.ok = (wasip2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; break; } case 1: { @@ -1303,7 +1303,7 @@ bool streams_method_output_stream_check_write(streams_borrow_output_stream_t sel } } -bool streams_method_output_stream_write(streams_borrow_output_stream_t self, preview2_list_u8_t *contents, streams_stream_error_t *err) { +bool streams_method_output_stream_write(streams_borrow_output_stream_t self, wasip2_list_u8_t *contents, streams_stream_error_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[12]; int32_t ptr = (int32_t) &ret_area; @@ -1340,7 +1340,7 @@ bool streams_method_output_stream_write(streams_borrow_output_stream_t self, pre } } -bool streams_method_output_stream_blocking_write_and_flush(streams_borrow_output_stream_t self, preview2_list_u8_t *contents, streams_stream_error_t *err) { +bool streams_method_output_stream_blocking_write_and_flush(streams_borrow_output_stream_t self, wasip2_list_u8_t *contents, streams_stream_error_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[12]; int32_t ptr = (int32_t) &ret_area; @@ -2011,7 +2011,7 @@ bool filesystem_method_descriptor_set_times(filesystem_borrow_descriptor_t self, } } -bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t self, filesystem_filesize_t length, filesystem_filesize_t offset, preview2_tuple2_list_u8_bool_t *ret, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t self, filesystem_filesize_t length, filesystem_filesize_t offset, wasip2_tuple2_list_u8_bool_t *ret, filesystem_error_code_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[16]; int32_t ptr = (int32_t) &ret_area; @@ -2020,8 +2020,8 @@ bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t self, file switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { case 0: { result.is_err = false; - result.val.ok = (preview2_tuple2_list_u8_bool_t) { - (preview2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }, + result.val.ok = (wasip2_tuple2_list_u8_bool_t) { + (wasip2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }, (int32_t) (*((uint8_t*) (ptr + 12))), }; break; @@ -2041,7 +2041,7 @@ bool filesystem_method_descriptor_read(filesystem_borrow_descriptor_t self, file } } -bool filesystem_method_descriptor_write(filesystem_borrow_descriptor_t self, preview2_list_u8_t *buffer, filesystem_filesize_t offset, filesystem_filesize_t *ret, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_write(filesystem_borrow_descriptor_t self, wasip2_list_u8_t *buffer, filesystem_filesize_t offset, filesystem_filesize_t *ret, filesystem_error_code_t *err) { __attribute__((__aligned__(8))) uint8_t ret_area[16]; int32_t ptr = (int32_t) &ret_area; @@ -2120,7 +2120,7 @@ bool filesystem_method_descriptor_sync(filesystem_borrow_descriptor_t self, file } } -bool filesystem_method_descriptor_create_directory_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_create_directory_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t ptr = (int32_t) &ret_area; @@ -2225,7 +2225,7 @@ bool filesystem_method_descriptor_stat(filesystem_borrow_descriptor_t self, file } } -bool filesystem_method_descriptor_stat_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_descriptor_stat_t *ret, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_stat_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_descriptor_stat_t *ret, filesystem_error_code_t *err) { __attribute__((__aligned__(8))) uint8_t ret_area[104]; int32_t ptr = (int32_t) &ret_area; @@ -2305,7 +2305,7 @@ bool filesystem_method_descriptor_stat_at(filesystem_borrow_descriptor_t self, f } } -bool filesystem_method_descriptor_set_times_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_new_timestamp_t *data_access_timestamp, filesystem_new_timestamp_t *data_modification_timestamp, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_set_times_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_new_timestamp_t *data_access_timestamp, filesystem_new_timestamp_t *data_modification_timestamp, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t variant; @@ -2378,7 +2378,7 @@ bool filesystem_method_descriptor_set_times_at(filesystem_borrow_descriptor_t se } } -bool filesystem_method_descriptor_link_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t old_path_flags, preview2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, preview2_string_t *new_path, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_link_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t old_path_flags, wasip2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, wasip2_string_t *new_path, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t ptr = (int32_t) &ret_area; @@ -2403,7 +2403,7 @@ bool filesystem_method_descriptor_link_at(filesystem_borrow_descriptor_t self, f } } -bool filesystem_method_descriptor_open_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_open_flags_t open_flags, filesystem_descriptor_flags_t flags, filesystem_own_descriptor_t *ret, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_open_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_open_flags_t open_flags, filesystem_descriptor_flags_t flags, filesystem_own_descriptor_t *ret, filesystem_error_code_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; @@ -2430,7 +2430,7 @@ bool filesystem_method_descriptor_open_at(filesystem_borrow_descriptor_t self, f } } -bool filesystem_method_descriptor_readlink_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, preview2_string_t *ret, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_readlink_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, wasip2_string_t *ret, filesystem_error_code_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[12]; int32_t ptr = (int32_t) &ret_area; @@ -2439,7 +2439,7 @@ bool filesystem_method_descriptor_readlink_at(filesystem_borrow_descriptor_t sel switch ((int32_t) (*((uint8_t*) (ptr + 0)))) { case 0: { result.is_err = false; - result.val.ok = (preview2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; + result.val.ok = (wasip2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 4))), (size_t)(*((int32_t*) (ptr + 8))) }; break; } case 1: { @@ -2457,7 +2457,7 @@ bool filesystem_method_descriptor_readlink_at(filesystem_borrow_descriptor_t sel } } -bool filesystem_method_descriptor_remove_directory_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_remove_directory_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t ptr = (int32_t) &ret_area; @@ -2482,7 +2482,7 @@ bool filesystem_method_descriptor_remove_directory_at(filesystem_borrow_descript } } -bool filesystem_method_descriptor_rename_at(filesystem_borrow_descriptor_t self, preview2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, preview2_string_t *new_path, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_rename_at(filesystem_borrow_descriptor_t self, wasip2_string_t *old_path, filesystem_borrow_descriptor_t new_descriptor, wasip2_string_t *new_path, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t ptr = (int32_t) &ret_area; @@ -2507,7 +2507,7 @@ bool filesystem_method_descriptor_rename_at(filesystem_borrow_descriptor_t self, } } -bool filesystem_method_descriptor_symlink_at(filesystem_borrow_descriptor_t self, preview2_string_t *old_path, preview2_string_t *new_path, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_symlink_at(filesystem_borrow_descriptor_t self, wasip2_string_t *old_path, wasip2_string_t *new_path, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t ptr = (int32_t) &ret_area; @@ -2532,7 +2532,7 @@ bool filesystem_method_descriptor_symlink_at(filesystem_borrow_descriptor_t self } } -bool filesystem_method_descriptor_unlink_file_at(filesystem_borrow_descriptor_t self, preview2_string_t *path, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_unlink_file_at(filesystem_borrow_descriptor_t self, wasip2_string_t *path, filesystem_error_code_t *err) { __attribute__((__aligned__(1))) uint8_t ret_area[2]; int32_t ptr = (int32_t) &ret_area; @@ -2592,7 +2592,7 @@ bool filesystem_method_descriptor_metadata_hash(filesystem_borrow_descriptor_t s } } -bool filesystem_method_descriptor_metadata_hash_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, preview2_string_t *path, filesystem_metadata_hash_value_t *ret, filesystem_error_code_t *err) { +bool filesystem_method_descriptor_metadata_hash_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip2_string_t *path, filesystem_metadata_hash_value_t *ret, filesystem_error_code_t *err) { __attribute__((__aligned__(8))) uint8_t ret_area[24]; int32_t ptr = (int32_t) &ret_area; @@ -2641,7 +2641,7 @@ bool filesystem_method_directory_entry_stream_read_directory_entry(filesystem_bo option.is_some = true; option.val = (filesystem_directory_entry_t) { (int32_t) (*((uint8_t*) (ptr + 8))), - (preview2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }, + (wasip2_string_t) { (uint8_t*)(*((int32_t*) (ptr + 12))), (size_t)(*((int32_t*) (ptr + 16))) }, }; break; } @@ -4184,7 +4184,7 @@ bool tcp_create_socket_create_tcp_socket(tcp_create_socket_ip_address_family_t a } } -bool ip_name_lookup_resolve_addresses(ip_name_lookup_borrow_network_t network, preview2_string_t *name, ip_name_lookup_own_resolve_address_stream_t *ret, ip_name_lookup_error_code_t *err) { +bool ip_name_lookup_resolve_addresses(ip_name_lookup_borrow_network_t network, wasip2_string_t *name, ip_name_lookup_own_resolve_address_stream_t *ret, ip_name_lookup_error_code_t *err) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; @@ -4283,12 +4283,12 @@ ip_name_lookup_own_pollable_t ip_name_lookup_method_resolve_address_stream_subsc return (ip_name_lookup_own_pollable_t) { ret }; } -void random_get_random_bytes(uint64_t len, preview2_list_u8_t *ret) { +void random_get_random_bytes(uint64_t len, wasip2_list_u8_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; __wasm_import_random_get_random_bytes((int64_t) (len), ptr); - *ret = (preview2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; + *ret = (wasip2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; } uint64_t random_get_random_u64(void) { @@ -4296,12 +4296,12 @@ uint64_t random_get_random_u64(void) { return (uint64_t) (ret); } -void random_insecure_get_insecure_random_bytes(uint64_t len, preview2_list_u8_t *ret) { +void random_insecure_get_insecure_random_bytes(uint64_t len, wasip2_list_u8_t *ret) { __attribute__((__aligned__(4))) uint8_t ret_area[8]; int32_t ptr = (int32_t) &ret_area; __wasm_import_random_insecure_get_insecure_random_bytes((int64_t) (len), ptr); - *ret = (preview2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; + *ret = (wasip2_list_u8_t) { (uint8_t*)(*((int32_t*) (ptr + 0))), (size_t)(*((int32_t*) (ptr + 4))) }; } uint64_t random_insecure_get_insecure_random_u64(void) { @@ -4309,18 +4309,18 @@ uint64_t random_insecure_get_insecure_random_u64(void) { return (uint64_t) (ret); } -void random_insecure_seed_insecure_seed(preview2_tuple2_u64_u64_t *ret) { +void random_insecure_seed_insecure_seed(wasip2_tuple2_u64_u64_t *ret) { __attribute__((__aligned__(8))) uint8_t ret_area[16]; int32_t ptr = (int32_t) &ret_area; __wasm_import_random_insecure_seed_insecure_seed(ptr); - *ret = (preview2_tuple2_u64_u64_t) { + *ret = (wasip2_tuple2_u64_u64_t) { (uint64_t) (*((int64_t*) (ptr + 0))), (uint64_t) (*((int64_t*) (ptr + 8))), }; } -extern void __component_type_object_force_link_preview2(void); -void __component_type_object_force_link_preview2_public_use_in_this_compilation_unit(void) { - __component_type_object_force_link_preview2(); +extern void __component_type_object_force_link_wasip2(void); +void __component_type_object_force_link_wasip2_public_use_in_this_compilation_unit(void) { + __component_type_object_force_link_wasip2(); } diff --git a/libc-bottom-half/sources/preview2_component_type.o b/libc-bottom-half/sources/wasip2_component_type.o similarity index 98% rename from libc-bottom-half/sources/preview2_component_type.o rename to libc-bottom-half/sources/wasip2_component_type.o index eef1630d..0548e3e9 100644 Binary files a/libc-bottom-half/sources/preview2_component_type.o and b/libc-bottom-half/sources/wasip2_component_type.o differ diff --git a/test/Makefile b/test/Makefile index da0c968b..ff0799e8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -47,7 +47,7 @@ $(LIBC_TEST): | $(DOWNDIR) # TODO install target to place into... $(LIBRT): | $(DOWNDIR) wget --no-clobber --directory-prefix=$(DOWNDIR) $(LIBRT_URL) - tar --extract --file=$(DOWNDIR)/$(shell basename $(LIBRT_URL)) --directory=$(DOWNDIR)/ + tar --extract --file=$(DOWNDIR)/$(shell basename $(LIBRT_URL)) --directory=$(DOWNDIR)/ $(WASMTIME): | $(DOWNDIR) wget --no-clobber --directory-prefix=$(DOWNDIR) $(WASMTIME_URL) @@ -137,7 +137,7 @@ LDFLAGS ?= CFLAGS ?= --target=$(TARGET_TRIPLE) --sysroot=../sysroot # Always include the `libc-test` infrastructure headers. CFLAGS += -I$(LIBC_TEST)/src/common -ifeq ($(TARGET_TRIPLE), wasm32-wasi-threads) +ifneq ($(findstring -threads,$(TARGET_TRIPLE)),) CFLAGS += -pthread endif @@ -159,7 +159,7 @@ endif $(WASM_OBJS): $(LIBC_TEST)/src/common/test.h | $(OBJDIRS) $(OBJDIR)/%.wasm.o: $(LIBC_TEST)/src/%.c - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< $(OBJDIRS): mkdir -p $@