summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/emscripten/system/include/wasi/wasi-helpers.h
blob: 43dfe58fff41ca8647db4534bea640639a2c8631 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Copyright 2019 The Emscripten Authors.  All rights reserved.
 * Emscripten is available under two separate licenses, the MIT license and the
 * University of Illinois/NCSA Open Source License.  Both these licenses can be
 * found in the LICENSE file.
 */

#ifndef __wasi_emscripten_helpers_h
#define __wasi_emscripten_helpers_h

#include <wasi/api.h>

#ifdef __cplusplus
extern "C" {
#endif

// Converts a wasi return code to a musl syscall return code (-1 if
// error, 0 otherwise), and sets errno accordingly.
int __wasi_syscall_ret(__wasi_errno_t code);

// Check if a wasi file descriptor is valid, returning 1 if valid and 0 if
// not. If not, also sets errno to EBADF.
int __wasi_fd_is_valid(__wasi_fd_t fd);

struct timespec __wasi_timestamp_to_timespec(__wasi_timestamp_t timestamp);

#ifdef __cplusplus
}
#endif

#endif // __wasi_emscripten_helpers_h