From 12c643e21c1c6e9b560e57d9d1e5cc6c66aaac74 Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Mon, 9 Jan 2023 13:31:22 +0000 Subject: [PATCH] Define types and functions in the proposal's template --- proposal-template.abi.md | 31 ------------------------------- proposal-template.wit.md | 32 -------------------------------- wasi-threads.abi.md | 31 +++++++++++++++++++++++++++++++ wasi-threads.wit.md | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 63 deletions(-) delete mode 100644 proposal-template.abi.md delete mode 100644 proposal-template.wit.md create mode 100644 wasi-threads.abi.md create mode 100644 wasi-threads.wit.md diff --git a/proposal-template.abi.md b/proposal-template.abi.md deleted file mode 100644 index 7a1c372..0000000 --- a/proposal-template.abi.md +++ /dev/null @@ -1,31 +0,0 @@ -# Types - -## `api-type-one`: record - - Short description - - Explanation for developers using the API. - -Size: 16, Alignment: 8 - -### Record Fields - -- [`property1`](#api_type_one.property1): `u64` - - -- [`property2`](#api_type_one.property2): `string` - - -# Functions - ----- - -#### `api-function-one` - - Short description - - Explanation for developers using the API. -##### Results - -- [`api-type-one`](#api_type_one) - diff --git a/proposal-template.wit.md b/proposal-template.wit.md deleted file mode 100644 index 3c7e8ef..0000000 --- a/proposal-template.wit.md +++ /dev/null @@ -1,32 +0,0 @@ -# [Proposal Template] API - -[This document contains the actual specification. It should be written in the WIT interface definition format. You can find more documentation on the WIT syntax (coming soon!).] - -[Note that all comments inside of WIT code blocks will be included in the developer facing documentation for language bindings generated using this WIT file. If there is additional information that needs to be communicated to implementers of the API, then these should be captured in text directly below the code block.] - -[If you want to include examples of the API in use, these should be in the README and linked to from this file.] - -## api_type_one - -```wit -/// Short description -/// -/// Explanation for developers using the API. -record api-type-one { - property1: u64, - property2: string, -} -``` - -More rigorous specification details for the implementer go here, if needed. - -## api_function_one - -```wit -/// Short description -/// -/// Explanation for developers using the API. -api-function-one: func() -> api-type-one -``` - -If needed, this would explain what a compliant implementation MUST do, such as never returning an earlier result from a later call. diff --git a/wasi-threads.abi.md b/wasi-threads.abi.md new file mode 100644 index 0000000..053c14a --- /dev/null +++ b/wasi-threads.abi.md @@ -0,0 +1,31 @@ +# Types + +## `thread-spawn-result`: `s32` + + The result of the `thread-spawn()` function. + If spawning the thread was successful, the value is positive + and represents a unique thread identifier. Otherwise, the + value is negative and it represents error code. + +Size: 4, Alignment: 4 + +## `start-arg`: `u32` + + A reference to data passed to the start function (`wasi_thread_start()`) called by the newly spawned thread. + +Size: 4, Alignment: 4 + +# Functions + +---- + +#### `thread-spawn` + + Creates a new thread. +##### Params + +- `start-arg`: [`start-arg`](#start_arg) +##### Results + +- [`thread-spawn-result`](#thread_spawn_result) + diff --git a/wasi-threads.wit.md b/wasi-threads.wit.md new file mode 100644 index 0000000..00b054c --- /dev/null +++ b/wasi-threads.wit.md @@ -0,0 +1,33 @@ +# WASI threads API + +WASI threads is an API for thread creation. + +Its goal is to provide functions that allow implementation of a subset of `pthreads` API, but it doesn't aim to be 100% compatible with POSIX threads standard. + + +## thread-id + +```wit +/// The result of the `thread-spawn()` function. +/// If spawning the thread was successful, the value is positive +/// and represents a unique thread identifier. Otherwise, the +/// value is negative and it represents error code. +type thread-spawn-result = s32 +``` + +## start-arg + +```wit +/// A reference to data passed to the start function (`wasi_thread_start()`) called by the newly spawned thread. +type start-arg = u32 +``` + +## thread_spawn + +```wit +/// Creates a new thread. +thread-spawn: func( + /// A value being passed to a start function (`wasi_thread_start()`). + start-arg: start-arg, +) -> thread-spawn-result +```