From fc4eeae8961c56d2307e4f9ed895f06d3ff43887 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 12 Dec 2020 06:38:55 +0000 Subject: [PATCH] Alias `yanix::file::OFlags::RSYNC` to `SYNC` on Android. Android defines O_RSYNC to be the same as O_SYNC: https://github.com/aosp-mirror/platform_bionic/blob/35bb46188ce8dbbb8bde0702e6cc6bf1d0795980/libc/include/fcntl.h#L57 --- crates/wasi-common/yanix/src/file.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/wasi-common/yanix/src/file.rs b/crates/wasi-common/yanix/src/file.rs index 1764d29120..62af1c9d77 100644 --- a/crates/wasi-common/yanix/src/file.rs +++ b/crates/wasi-common/yanix/src/file.rs @@ -90,11 +90,26 @@ bitflags! { const WRONLY = libc::O_WRONLY; const RDWR = libc::O_RDWR; #[cfg(any(target_os = "linux", + target_os = "android", target_os = "netbsd", target_os = "openbsd", target_os = "wasi", target_os = "emscripten"))] - const RSYNC = libc::O_RSYNC; + const RSYNC = { + // Have to use cfg_if: https://github.com/bitflags/bitflags/issues/137 + cfg_if! { + if #[cfg(any(target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "wasi", + target_os = "emscripten"))] { + libc::O_RSYNC + } else if #[cfg(target_os = "android")] { + // Android defines O_RSYNC as O_SYNC + libc::O_SYNC + } + } + }; const SYNC = libc::O_SYNC; const TRUNC = libc::O_TRUNC; #[cfg(any(target_os = "linux",