Skip to content

Commit

Permalink
Define types and functions in the proposal's template (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
loganek authored Jan 20, 2023
1 parent 4a9776c commit e2feef4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 63 deletions.
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
```

0 comments on commit e2feef4

Please sign in to comment.