Abstract POSIX filesystem functions (#2585)
To allow non-POSIX platforms such as Windows to support WASI libc filesystem functionality, create a set of wrapper functions which provide a platform-agnostic interface to interact with the host filesystem. For now, the Windows implementation is stubbed but this will be implemented properly in a future PR. There are no functional changes in this change, just a reorganization of code to move any direct POSIX references out of posix.c in the libc implementation into posix_file.c under the shared POSIX sources. See https://github.com/bytecodealliance/wasm-micro-runtime/issues/2495 for a more detailed overview of the plan to port the WASI libc filesystem to Windows.
This commit is contained in:
@ -69,6 +69,10 @@ strcpy(char *dest, const char *src);
|
||||
#define os_memory_order_seq_cst __ATOMIC_SEQ_CST
|
||||
#define os_atomic_thread_fence __atomic_thread_fence
|
||||
|
||||
typedef int os_file_handle;
|
||||
typedef DIR *os_dir_stream;
|
||||
typedef int os_raw_file_handle;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#define _LIBC_WASI_SGX_PFS_H
|
||||
|
||||
#include "bh_hashmap.h"
|
||||
#include "wasmtime_ssp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@ -20,16 +20,20 @@ if (NOT BUILD_UNTRUST_PART EQUAL 1)
|
||||
${SGX_SDK_DIR}/include/libcxx)
|
||||
endif ()
|
||||
|
||||
if (NOT WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||
add_definitions(-DSGX_DISABLE_WASI)
|
||||
endif ()
|
||||
|
||||
if (NOT WAMR_BUILD_THREAD_MGR EQUAL 1)
|
||||
add_definitions(-DSGX_DISABLE_PTHREAD)
|
||||
endif ()
|
||||
|
||||
file (GLOB source_all ${PLATFORM_SHARED_DIR}/*.c)
|
||||
|
||||
if (NOT WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||
add_definitions(-DSGX_DISABLE_WASI)
|
||||
else()
|
||||
list(APPEND source_all ${PLATFORM_SHARED_DIR}/../common/posix/posix_file.c)
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/../common/libc-util/platform_common_libc_util.cmake)
|
||||
set(source_all ${source_all} ${PLATFORM_COMMON_LIBC_UTIL_SOURCE})
|
||||
endif()
|
||||
|
||||
file (GLOB source_all_untrusted ${PLATFORM_SHARED_DIR}/untrusted/*.c)
|
||||
|
||||
set (PLATFORM_SHARED_SOURCE ${source_all})
|
||||
|
||||
Reference in New Issue
Block a user