Skip to content

Define types and functions in the proposal's template #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions proposal-template.abi.md

This file was deleted.

32 changes: 0 additions & 32 deletions proposal-template.wit.md

This file was deleted.

31 changes: 31 additions & 0 deletions wasi-threads.abi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Types

## <a href="#thread_spawn_result" name="thread_spawn_result"></a> `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

## <a href="#start_arg" name="start_arg"></a> `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

----

#### <a href="#thread_spawn" name="thread_spawn"></a> `thread-spawn`

Creates a new thread.
##### Params

- <a href="#thread_spawn.start_arg" name="thread_spawn.start_arg"></a> `start-arg`: [`start-arg`](#start_arg)
##### Results

- [`thread-spawn-result`](#thread_spawn_result)

33 changes: 33 additions & 0 deletions wasi-threads.wit.md
Original file line number Diff line number Diff line change
@@ -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
```