Files
wasmtime/wasmtime-wasi-c/sandboxed-system-primitives/src/posix.h
Dan Gohman 06b6ec42b9 Provide the C WASI implementation as an option.
This adds the C WASI implementation as a new crate, wasmtime-wasi-c,
and adds a command-line flag to the wasmtime command-line driver to
select which WASI implementation to use.
2019-06-03 13:23:07 -07:00

60 lines
1.6 KiB
C

// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/CraneStation/wasmtime/blob/master/LICENSE for license information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/CraneStation/wasmtime/blob/master/lib/wasi/sandboxed-system-primitives/src/LICENSE
// for license information.
//
// The upstream file contains the following copyright notice:
//
// Copyright (c) 2016-2018 Nuxi, https://nuxi.nl/
#ifndef POSIX_H
#define POSIX_H
#include <stdbool.h>
#include <stddef.h>
#include "locking.h"
struct fd_entry;
struct fd_prestat;
struct syscalls;
struct fd_table {
struct rwlock lock;
struct fd_entry *entries;
size_t size;
size_t used;
};
struct fd_prestats {
struct rwlock lock;
struct fd_prestat *prestats;
size_t size;
size_t used;
};
struct argv_environ_values {
size_t argc;
size_t argv_buf_size;
char **argv;
char *argv_buf;
size_t environ_count;
size_t environ_buf_size;
char **environ;
char *environ_buf;
};
void fd_table_init(struct fd_table *);
bool fd_table_insert_existing(struct fd_table *, __wasi_fd_t, int);
void fd_prestats_init(struct fd_prestats *);
bool fd_prestats_insert(struct fd_prestats *, const char *, __wasi_fd_t);
void argv_environ_init(struct argv_environ_values *,
const size_t *argv_offsets, size_t argv_offsets_len,
const char *argv_buf, size_t argv_buf_len,
const size_t *environ_offsets, size_t environ_offsets_len,
const char *environ_buf, size_t environ_buf_len);
#endif