From eff57e8d7036b2c76cb62a2f32a174b4fefd55be Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 12 Feb 2024 12:25:27 -0700 Subject: [PATCH] move descriptor_table.h to headers/private We're not yet ready to commit to making this API public, so we'll make it private for now. I've also expanded a comment in descriptor_table.c to explain the current ABI for resource handles. Signed-off-by: Joel Dice --- expected/wasm32-wasi-preview2/include-all.c | 1 - expected/wasm32-wasi-preview2/predefined-macros.txt | 1 - .../{public => private}/wasi/descriptor_table.h | 0 libc-bottom-half/sources/descriptor_table.c | 11 ++++++----- 4 files changed, 6 insertions(+), 7 deletions(-) rename libc-bottom-half/headers/{public => private}/wasi/descriptor_table.h (100%) diff --git a/expected/wasm32-wasi-preview2/include-all.c b/expected/wasm32-wasi-preview2/include-all.c index 316824a8c..3de5cf010 100644 --- a/expected/wasm32-wasi-preview2/include-all.c +++ b/expected/wasm32-wasi-preview2/include-all.c @@ -164,7 +164,6 @@ #include #include #include -#include #include #include #include diff --git a/expected/wasm32-wasi-preview2/predefined-macros.txt b/expected/wasm32-wasi-preview2/predefined-macros.txt index 3c6113c04..77b1db05b 100644 --- a/expected/wasm32-wasi-preview2/predefined-macros.txt +++ b/expected/wasm32-wasi-preview2/predefined-macros.txt @@ -166,7 +166,6 @@ #define DECIMAL_DIG 36 #define DELAYTIMER_MAX 0x7fffffff #define DELETE ns_uop_delete -#define DESCRIPTOR_TABLE_H #define DEV_BSIZE 512 #define DIRTYPE '5' #define DM 242 diff --git a/libc-bottom-half/headers/public/wasi/descriptor_table.h b/libc-bottom-half/headers/private/wasi/descriptor_table.h similarity index 100% rename from libc-bottom-half/headers/public/wasi/descriptor_table.h rename to libc-bottom-half/headers/private/wasi/descriptor_table.h diff --git a/libc-bottom-half/sources/descriptor_table.c b/libc-bottom-half/sources/descriptor_table.c index 2310245fa..166bb84df 100644 --- a/libc-bottom-half/sources/descriptor_table.c +++ b/libc-bottom-half/sources/descriptor_table.c @@ -3,11 +3,12 @@ * descriptors. * * WASI Preview 2 has no notion of file descriptors and instead uses unforgeable - * resource handles. Moreover, there's not necessarily a one-to-one - * correspondence between POSIX file descriptors and resource handles (e.g. a - * TCP connection may require separate handles for reading, writing, and polling - * the same connection). We use this table to map each POSIX descriptor to a - * set of one or more handles. + * resource handles (which are currently represented as integers at the ABI + * level, used as indices into per-component tables managed by the host). + * Moreover, there's not necessarily a one-to-one correspondence between POSIX + * file descriptors and resource handles (e.g. a TCP connection may require + * separate handles for reading, writing, and polling the same connection). We + * use this table to map each POSIX descriptor to a set of one or more handles. * * As of this writing, we still rely on the WASI Preview 1 adapter * (https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi-preview1-component-adapter)