1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 16:19:12 -05:00
denoland-deno/std/wasi
Casper Beyer b9dc2c3521
test(std/wasi): re-enable clock_time_get tests (#8098)
This brings in revised tests for clock_time_get from upstream and
re-enables them.

This revision of these tests allow for lower precision clocks (we only
provide millisecond precision, and that is conformant but previous
tests for this in the upstream test suite were a bit more aggressive).
2020-10-26 16:57:09 +01:00
..
testdata@8f49014513 test(std/wasi): re-enable clock_time_get tests (#8098) 2020-10-26 16:57:09 +01:00
README.md docs(std/wasi): mark sched_yield as implemented (#8055) 2020-10-24 16:05:30 +02:00
snapshot_preview1.ts fix(std/wasi): disallow path_open outside of pre-opened dirfd (#8078) 2020-10-24 16:04:59 +02:00
snapshot_preview1_test.ts test(std/wasi): re-enable clock_time_get tests (#8098) 2020-10-26 16:57:09 +01:00
snapshot_preview1_test_runner.ts chore(std/wasi): enable and fix lint errors in snapshot_preview1 (#7360) 2020-09-29 11:41:22 +02:00

wasi

This module provides an implementation of the WebAssembly System Interface.

Supported Syscalls

wasi_snapshot_preview1

  • args_get
  • args_sizes_get
  • environ_get
  • environ_sizes_get
  • clock_res_get
  • clock_time_get
  • fd_advise
  • fd_allocate
  • fd_close
  • fd_datasync
  • fd_fdstat_get
  • fd_fdstat_set_flags
  • fd_fdstat_set_rights
  • fd_filestat_get
  • fd_filestat_set_size
  • fd_filestat_set_times
  • fd_pread
  • fd_prestat_get
  • fd_prestat_dir_name
  • fd_pwrite
  • fd_read
  • fd_readdir
  • fd_renumber
  • fd_seek
  • fd_sync
  • fd_tell
  • fd_write
  • path_create_directory
  • path_filestat_get
  • path_filestat_set_times
  • path_link
  • path_open
  • path_readlink
  • path_remove_directory
  • path_rename
  • path_symlink
  • path_unlink_file
  • poll_oneoff
  • proc_exit
  • proc_raise
  • sched_yield
  • random_get
  • sock_recv
  • sock_send
  • sock_shutdown

Usage

import Context from "https://deno.land/std@$STD_VERSION/wasi/snapshot_preview1.ts";

const context = new Context({
  args: Deno.args,
  env: Deno.env.toObject(),
});

const binary = await Deno.readFile("path/to/your/module.wasm");
const module = await WebAssembly.compile(binary);
const instance = await WebAssembly.instantiate(module, {
  "wasi_snapshot_preview1": context.exports,
});

const {
  _start: start,
  _initialize: initialize,
  memory,
} = instance.exports;

context.memory = memory as WebAssembly.Memory;

if (start instanceof Function) {
  start();
} else if (initialize instanceof Function) {
  initialize();
} else {
  throw new Error(
    "No '_start' or '_initialize' entry point found in WebAssembly module, make sure to compile with wasm32-wasi as the target.",
  );
}