Move WASI types into separate header (#2724)
To allow anything to depend on WASI types, including platform-specific data structures, move the WASI libc filesystem/clock interface into `platform_api_extension.h`, which leaves just WASI types in `platform_wasi.h`. And `platform_wasi.h` has been renamed to `platform_wasi_types.h` to reflect that it only defines types now and no function declarations. Finally, these changes allow us to remove the `windows_fdflags` type which was essentially a duplicate of `__wasi_fdflags_t`.
This commit is contained in:
@ -32,6 +32,8 @@
|
||||
#include <basetsd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "platform_wasi_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -146,19 +148,9 @@ typedef enum windows_access_mode {
|
||||
windows_access_mode_write = 1 << 1
|
||||
} windows_access_mode;
|
||||
|
||||
// These enum values are defined to be the same as the corresponding WASI
|
||||
// fdflags so they can be used interchangeably.
|
||||
typedef enum windows_fdflags {
|
||||
windows_fdflags_append = 1 << 0,
|
||||
windows_fdflags_dsync = 1 << 1,
|
||||
windows_fdflags_nonblock = 1 << 2,
|
||||
windows_fdflags_rsync = 1 << 3,
|
||||
windows_fdflags_sync = 1 << 4
|
||||
} windows_fdflags;
|
||||
|
||||
typedef struct windows_handle {
|
||||
windows_handle_type type;
|
||||
windows_fdflags fdflags;
|
||||
__wasi_fdflags_t fdflags;
|
||||
windows_access_mode access_mode;
|
||||
union {
|
||||
HANDLE handle;
|
||||
|
||||
@ -1046,7 +1046,7 @@ os_writev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt,
|
||||
{
|
||||
CHECK_VALID_HANDLE(handle);
|
||||
|
||||
bool append = (handle->fdflags & windows_fdflags_append) != 0;
|
||||
bool append = (handle->fdflags & __WASI_FDFLAG_APPEND) != 0;
|
||||
LARGE_INTEGER write_offset = { .QuadPart = 0 };
|
||||
DWORD move_method = append ? FILE_END : FILE_CURRENT;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#ifndef _WIN_UTIL_H
|
||||
#define _WIN_UTIL_H
|
||||
|
||||
#include "platform_wasi.h"
|
||||
#include "platform_wasi_types.h"
|
||||
#include "windows.h"
|
||||
|
||||
__wasi_timestamp_t
|
||||
|
||||
Reference in New Issue
Block a user