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

[wasm] Define _WASI_EMULATED_MMAN to replace imports #4913

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h
Expand Up @@ -66,6 +66,11 @@
#include <termios.h>
#elif TARGET_OS_WASI
#include <fcntl.h>
// Define _WASI_EMULATED_MMAN here to use the emulated mman functions in
// Foundation-side without requiring transitive clients to define it.
#undef _WASI_EMULATED_MMAN
#define _WASI_EMULATED_MMAN
#include <sys/mman.h>
#elif TARGET_OS_LINUX
#include <errno.h>
#include <features.h>
Expand Down
5 changes: 0 additions & 5 deletions Sources/Foundation/Data.swift
Expand Up @@ -36,11 +36,6 @@
@usableFromInline let memcpy = Musl.memcpy
@usableFromInline let memcmp = Musl.memcmp
#elseif canImport(WASILibc)
#if swift(>=6.0)
private import wasi_emulated_mman
#else
import wasi_emulated_mman
#endif
@usableFromInline let calloc = WASILibc.calloc
@usableFromInline let malloc = WASILibc.malloc
@usableFromInline let free = WASILibc.free
Expand Down
1 change: 0 additions & 1 deletion Sources/Foundation/FileHandle.swift
Expand Up @@ -29,7 +29,6 @@ fileprivate let _write = Musl.write(_:_:_:)
fileprivate let _close = Musl.close(_:)
#elseif canImport(WASILibc)
import WASILibc
@_implementationOnly import wasi_emulated_mman
fileprivate let _read = WASILibc.read(_:_:_:)
fileprivate let _write = WASILibc.write(_:_:_:)
fileprivate let _close = WASILibc.close(_:)
Expand Down