Skip to content
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

migrate from size_t to uvwasi_size_t #121

Merged
merged 1 commit into from
May 10, 2020
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
100 changes: 50 additions & 50 deletions README.md

Large diffs are not rendered by default.

90 changes: 46 additions & 44 deletions include/uvwasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ typedef struct uvwasi_mem_s {

typedef struct uvwasi_s {
struct uvwasi_fd_table_t fds;
size_t argc;
uvwasi_size_t argc;
char** argv;
char* argv_buf;
size_t argv_buf_size;
size_t envc;
uvwasi_size_t argv_buf_size;
uvwasi_size_t envc;
char** env;
char* env_buf;
size_t env_buf_size;
uvwasi_size_t env_buf_size;
const uvwasi_mem_t* allocator;
} uvwasi_t;

Expand All @@ -54,10 +54,10 @@ typedef struct uvwasi_preopen_s {
} uvwasi_preopen_t;

typedef struct uvwasi_options_s {
size_t fd_table_size;
size_t preopenc;
uvwasi_size_t fd_table_size;
uvwasi_size_t preopenc;
uvwasi_preopen_t* preopens;
size_t argc;
uvwasi_size_t argc;
char** argv;
char** envp;
uvwasi_fd_t in;
Expand All @@ -78,8 +78,8 @@ const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code);
/* WASI system call API. */
uvwasi_errno_t uvwasi_args_get(uvwasi_t* uvwasi, char** argv, char* argv_buf);
uvwasi_errno_t uvwasi_args_sizes_get(uvwasi_t* uvwasi,
size_t* argc,
size_t* argv_buf_size);
uvwasi_size_t* argc,
uvwasi_size_t* argv_buf_size);
uvwasi_errno_t uvwasi_clock_res_get(uvwasi_t* uvwasi,
uvwasi_clockid_t clock_id,
uvwasi_timestamp_t* resolution);
Expand All @@ -91,8 +91,8 @@ uvwasi_errno_t uvwasi_environ_get(uvwasi_t* uvwasi,
char** environment,
char* environ_buf);
uvwasi_errno_t uvwasi_environ_sizes_get(uvwasi_t* uvwasi,
size_t* environ_count,
size_t* environ_buf_size);
uvwasi_size_t* environ_count,
uvwasi_size_t* environ_buf_size);
uvwasi_errno_t uvwasi_fd_advise(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
uvwasi_filesize_t offset,
Expand Down Expand Up @@ -129,33 +129,33 @@ uvwasi_errno_t uvwasi_fd_filestat_set_times(uvwasi_t* uvwasi,
uvwasi_errno_t uvwasi_fd_pread(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const uvwasi_iovec_t* iovs,
size_t iovs_len,
uvwasi_size_t iovs_len,
uvwasi_filesize_t offset,
size_t* nread);
uvwasi_size_t* nread);
uvwasi_errno_t uvwasi_fd_prestat_get(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
uvwasi_prestat_t* buf);
uvwasi_errno_t uvwasi_fd_prestat_dir_name(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
char* path,
size_t path_len);
uvwasi_size_t path_len);
uvwasi_errno_t uvwasi_fd_pwrite(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const uvwasi_ciovec_t* iovs,
size_t iovs_len,
uvwasi_size_t iovs_len,
uvwasi_filesize_t offset,
size_t* nwritten);
uvwasi_size_t* nwritten);
uvwasi_errno_t uvwasi_fd_read(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const uvwasi_iovec_t* iovs,
size_t iovs_len,
size_t* nread);
uvwasi_size_t iovs_len,
uvwasi_size_t* nread);
uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
void* buf,
size_t buf_len,
uvwasi_size_t buf_len,
uvwasi_dircookie_t cookie,
size_t* bufused);
uvwasi_size_t* bufused);
uvwasi_errno_t uvwasi_fd_renumber(uvwasi_t* uvwasi,
uvwasi_fd_t from,
uvwasi_fd_t to);
Expand All @@ -171,39 +171,39 @@ uvwasi_errno_t uvwasi_fd_tell(uvwasi_t* uvwasi,
uvwasi_errno_t uvwasi_fd_write(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const uvwasi_ciovec_t* iovs,
size_t iovs_len,
size_t* nwritten);
uvwasi_size_t iovs_len,
uvwasi_size_t* nwritten);
uvwasi_errno_t uvwasi_path_create_directory(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const char* path,
size_t path_len);
uvwasi_size_t path_len);
uvwasi_errno_t uvwasi_path_filestat_get(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
uvwasi_lookupflags_t flags,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
uvwasi_filestat_t* buf);
uvwasi_errno_t uvwasi_path_filestat_set_times(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
uvwasi_lookupflags_t flags,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
uvwasi_timestamp_t st_atim,
uvwasi_timestamp_t st_mtim,
uvwasi_fstflags_t fst_flags);
uvwasi_errno_t uvwasi_path_link(uvwasi_t* uvwasi,
uvwasi_fd_t old_fd,
uvwasi_lookupflags_t old_flags,
const char* old_path,
size_t old_path_len,
uvwasi_size_t old_path_len,
uvwasi_fd_t new_fd,
const char* new_path,
size_t new_path_len);
uvwasi_size_t new_path_len);
uvwasi_errno_t uvwasi_path_open(uvwasi_t* uvwasi,
uvwasi_fd_t dirfd,
uvwasi_lookupflags_t dirflags,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
uvwasi_oflags_t o_flags,
uvwasi_rights_t fs_rights_base,
uvwasi_rights_t fs_rights_inheriting,
Expand All @@ -212,53 +212,55 @@ uvwasi_errno_t uvwasi_path_open(uvwasi_t* uvwasi,
uvwasi_errno_t uvwasi_path_readlink(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
char* buf,
size_t buf_len,
size_t* bufused);
uvwasi_size_t buf_len,
uvwasi_size_t* bufused);
uvwasi_errno_t uvwasi_path_remove_directory(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const char* path,
size_t path_len);
uvwasi_size_t path_len);
uvwasi_errno_t uvwasi_path_rename(uvwasi_t* uvwasi,
uvwasi_fd_t old_fd,
const char* old_path,
size_t old_path_len,
uvwasi_size_t old_path_len,
uvwasi_fd_t new_fd,
const char* new_path,
size_t new_path_len);
uvwasi_size_t new_path_len);
uvwasi_errno_t uvwasi_path_symlink(uvwasi_t* uvwasi,
const char* old_path,
size_t old_path_len,
uvwasi_size_t old_path_len,
uvwasi_fd_t fd,
const char* new_path,
size_t new_path_len);
uvwasi_size_t new_path_len);
uvwasi_errno_t uvwasi_path_unlink_file(uvwasi_t* uvwasi,
uvwasi_fd_t fd,
const char* path,
size_t path_len);
uvwasi_size_t path_len);
uvwasi_errno_t uvwasi_poll_oneoff(uvwasi_t* uvwasi,
const uvwasi_subscription_t* in,
uvwasi_event_t* out,
size_t nsubscriptions,
size_t* nevents);
uvwasi_size_t nsubscriptions,
uvwasi_size_t* nevents);
uvwasi_errno_t uvwasi_proc_exit(uvwasi_t* uvwasi, uvwasi_exitcode_t rval);
uvwasi_errno_t uvwasi_proc_raise(uvwasi_t* uvwasi, uvwasi_signal_t sig);
uvwasi_errno_t uvwasi_random_get(uvwasi_t* uvwasi, void* buf, size_t buf_len);
uvwasi_errno_t uvwasi_random_get(uvwasi_t* uvwasi,
void* buf,
uvwasi_size_t buf_len);
uvwasi_errno_t uvwasi_sched_yield(uvwasi_t* uvwasi);
uvwasi_errno_t uvwasi_sock_recv(uvwasi_t* uvwasi,
uvwasi_fd_t sock,
const uvwasi_iovec_t* ri_data,
size_t ri_data_len,
uvwasi_size_t ri_data_len,
uvwasi_riflags_t ri_flags,
size_t* ro_datalen,
uvwasi_size_t* ro_datalen,
uvwasi_roflags_t* ro_flags);
uvwasi_errno_t uvwasi_sock_send(uvwasi_t* uvwasi,
uvwasi_fd_t sock,
const uvwasi_ciovec_t* si_data,
size_t si_data_len,
uvwasi_size_t si_data_len,
uvwasi_siflags_t si_flags,
size_t* so_datalen);
uvwasi_size_t* so_datalen);
uvwasi_errno_t uvwasi_sock_shutdown(uvwasi_t* uvwasi,
uvwasi_fd_t sock,
uvwasi_sdflags_t how);
Expand Down
8 changes: 5 additions & 3 deletions include/wasi_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/* API: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md */

typedef uint32_t uvwasi_size_t;

typedef uint8_t uvwasi_advice_t;
#define UVWASI_ADVICE_NORMAL 0
#define UVWASI_ADVICE_SEQUENTIAL 1
Expand All @@ -16,7 +18,7 @@ typedef uint8_t uvwasi_advice_t;

typedef struct uvwasi_ciovec_s {
const void* buf;
size_t buf_len;
uvwasi_size_t buf_len;
} uvwasi_ciovec_t;

typedef uint32_t uvwasi_clockid_t;
Expand Down Expand Up @@ -152,7 +154,7 @@ typedef uint64_t uvwasi_inode_t;

typedef struct uvwasi_iovec_s {
void* buf;
size_t buf_len;
uvwasi_size_t buf_len;
} uvwasi_iovec_t;

typedef uint64_t uvwasi_linkcount_t;
Expand All @@ -173,7 +175,7 @@ typedef struct uvwasi_prestat_s {
uvwasi_preopentype_t pr_type;
union uvwasi_prestat_u {
struct uvwasi_prestat_dir_t {
size_t pr_name_len;
uvwasi_size_t pr_name_len;
} dir;
} u;
} uvwasi_prestat_t;
Expand Down
32 changes: 16 additions & 16 deletions src/path_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#endif /* _WIN32 */


static int uvwasi__is_absolute_path(const char* path, size_t path_len) {
static int uvwasi__is_absolute_path(const char* path, uvwasi_size_t path_len) {
/* It's expected that only Unix style paths will be generated by WASI. */
return path != NULL && path_len > 0 && path[0] == '/';
}
Expand All @@ -33,9 +33,9 @@ static char* uvwasi__strchr_slash(const char* s) {


uvwasi_errno_t uvwasi__normalize_path(const char* path,
size_t path_len,
uvwasi_size_t path_len,
char* normalized_path,
size_t normalized_len) {
uvwasi_size_t normalized_len) {
const char* cur;
char* ptr;
char* next;
Expand Down Expand Up @@ -125,9 +125,9 @@ uvwasi_errno_t uvwasi__normalize_path(const char* path,


static int uvwasi__is_path_sandboxed(const char* path,
size_t path_len,
uvwasi_size_t path_len,
const char* fd_path,
size_t fd_path_len) {
uvwasi_size_t fd_path_len) {
char* ptr;
int remaining_len;

Expand Down Expand Up @@ -173,9 +173,9 @@ static uvwasi_errno_t uvwasi__normalize_absolute_path(
const uvwasi_t* uvwasi,
const struct uvwasi_fd_wrap_t* fd,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
char** normalized_path,
size_t* normalized_len
uvwasi_size_t* normalized_len
) {
/* This function resolves an absolute path to the provided file descriptor.
If the file descriptor's path is relative, then this operation will fail
Expand Down Expand Up @@ -224,9 +224,9 @@ static uvwasi_errno_t uvwasi__normalize_relative_path(
const uvwasi_t* uvwasi,
const struct uvwasi_fd_wrap_t* fd,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
char** normalized_path,
size_t* normalized_len
uvwasi_size_t* normalized_len
) {
/* This function resolves a relative path to the provided file descriptor.
The relative path is concatenated to the file descriptor's path, and then
Expand Down Expand Up @@ -298,9 +298,9 @@ static uvwasi_errno_t uvwasi__resolve_path_to_host(
const uvwasi_t* uvwasi,
const struct uvwasi_fd_wrap_t* fd,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
char** resolved_path,
size_t* resolved_len
uvwasi_size_t* resolved_len
) {
/* Return the normalized path, but resolved to the host's real path. */
char* res_path;
Expand All @@ -309,7 +309,7 @@ static uvwasi_errno_t uvwasi__resolve_path_to_host(
int fake_path_len;
int stripped_len;
#ifdef _WIN32
size_t i;
uvwasi_size_t i;
#endif /* _WIN32 */

real_path_len = strlen(fd->real_path);
Expand Down Expand Up @@ -364,7 +364,7 @@ static uvwasi_errno_t uvwasi__resolve_path_to_host(
uvwasi_errno_t uvwasi__resolve_path(const uvwasi_t* uvwasi,
const struct uvwasi_fd_wrap_t* fd,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
char** resolved_path,
uvwasi_lookupflags_t flags) {
uv_fs_t req;
Expand All @@ -373,9 +373,9 @@ uvwasi_errno_t uvwasi__resolve_path(const uvwasi_t* uvwasi,
char* host_path;
char* normalized_path;
char* link_target;
size_t input_len;
size_t host_path_len;
size_t normalized_len;
uvwasi_size_t input_len;
uvwasi_size_t host_path_len;
uvwasi_size_t normalized_len;
int follow_count;
int r;

Expand Down
6 changes: 3 additions & 3 deletions src/path_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "uvwasi.h"

uvwasi_errno_t uvwasi__normalize_path(const char* path,
size_t path_len,
uvwasi_size_t path_len,
char* normalized_path,
size_t normalized_len);
uvwasi_size_t normalized_len);

uvwasi_errno_t uvwasi__resolve_path(const uvwasi_t* uvwasi,
const struct uvwasi_fd_wrap_t* fd,
const char* path,
size_t path_len,
uvwasi_size_t path_len,
char** resolved_path,
uvwasi_lookupflags_t flags);

Expand Down
Loading